xen-tpmfront.c (0c49cd295d42d0032af11d55e2140dbec11dc8d0) | xen-tpmfront.c (afb5abc262e962089ef2d7c2bbf71bb6f53a2a78) |
---|---|
1/* 2 * Implementation of the Xen vTPM device frontend 3 * 4 * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2, 8 * as published by the Free Software Foundation. --- 161 unchanged lines hidden (view full) --- 170 } 171 return IRQ_HANDLED; 172} 173 174static int setup_chip(struct device *dev, struct tpm_private *priv) 175{ 176 struct tpm_chip *chip; 177 | 1/* 2 * Implementation of the Xen vTPM device frontend 3 * 4 * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2, 8 * as published by the Free Software Foundation. --- 161 unchanged lines hidden (view full) --- 170 } 171 return IRQ_HANDLED; 172} 173 174static int setup_chip(struct device *dev, struct tpm_private *priv) 175{ 176 struct tpm_chip *chip; 177 |
178 chip = tpm_register_hardware(dev, &tpm_vtpm); 179 if (!chip) 180 return -ENODEV; | 178 chip = tpmm_chip_alloc(dev, &tpm_vtpm); 179 if (IS_ERR(chip)) 180 return PTR_ERR(chip); |
181 182 init_waitqueue_head(&chip->vendor.read_queue); 183 184 priv->chip = chip; 185 TPM_VPRIV(chip) = priv; 186 187 return 0; 188} --- 92 unchanged lines hidden (view full) --- 281 282 kfree(priv); 283} 284 285static int tpmfront_probe(struct xenbus_device *dev, 286 const struct xenbus_device_id *id) 287{ 288 struct tpm_private *priv; | 181 182 init_waitqueue_head(&chip->vendor.read_queue); 183 184 priv->chip = chip; 185 TPM_VPRIV(chip) = priv; 186 187 return 0; 188} --- 92 unchanged lines hidden (view full) --- 281 282 kfree(priv); 283} 284 285static int tpmfront_probe(struct xenbus_device *dev, 286 const struct xenbus_device_id *id) 287{ 288 struct tpm_private *priv; |
289 struct tpm_chip *chip; |
|
289 int rv; 290 291 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 292 if (!priv) { 293 xenbus_dev_fatal(dev, -ENOMEM, "allocating priv structure"); 294 return -ENOMEM; 295 } 296 297 rv = setup_chip(&dev->dev, priv); 298 if (rv) { 299 kfree(priv); 300 return rv; 301 } 302 303 rv = setup_ring(dev, priv); 304 if (rv) { | 290 int rv; 291 292 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 293 if (!priv) { 294 xenbus_dev_fatal(dev, -ENOMEM, "allocating priv structure"); 295 return -ENOMEM; 296 } 297 298 rv = setup_chip(&dev->dev, priv); 299 if (rv) { 300 kfree(priv); 301 return rv; 302 } 303 304 rv = setup_ring(dev, priv); 305 if (rv) { |
305 tpm_remove_hardware(&dev->dev); | 306 chip = dev_get_drvdata(&dev->dev); 307 tpm_chip_unregister(chip); |
306 ring_free(priv); 307 return rv; 308 } 309 310 tpm_get_timeouts(priv->chip); 311 | 308 ring_free(priv); 309 return rv; 310 } 311 312 tpm_get_timeouts(priv->chip); 313 |
312 return rv; | 314 return tpm_chip_register(priv->chip); |
313} 314 315static int tpmfront_remove(struct xenbus_device *dev) 316{ 317 struct tpm_chip *chip = dev_get_drvdata(&dev->dev); 318 struct tpm_private *priv = TPM_VPRIV(chip); | 315} 316 317static int tpmfront_remove(struct xenbus_device *dev) 318{ 319 struct tpm_chip *chip = dev_get_drvdata(&dev->dev); 320 struct tpm_private *priv = TPM_VPRIV(chip); |
319 tpm_remove_hardware(&dev->dev); | 321 tpm_chip_unregister(chip); |
320 ring_free(priv); 321 TPM_VPRIV(chip) = NULL; 322 return 0; 323} 324 325static int tpmfront_resume(struct xenbus_device *dev) 326{ 327 /* A suspend/resume/migrate will interrupt a vTPM anyway */ --- 71 unchanged lines hidden --- | 322 ring_free(priv); 323 TPM_VPRIV(chip) = NULL; 324 return 0; 325} 326 327static int tpmfront_resume(struct xenbus_device *dev) 328{ 329 /* A suspend/resume/migrate will interrupt a vTPM anyway */ --- 71 unchanged lines hidden --- |