Commit 253115b7 authored by Rajiv Andrade's avatar Rajiv Andrade Committed by James Morris

The tpm_dev_release function is only called for platform devices, not pnp

devices, so we implemented the .remove function for pnp ones.  Since it's
code is very similar to the one inside tpm_dev_release, we've created a
helper function tpm_dev_vendor_release, which is called by both.
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent f02a9364
...@@ -1133,23 +1133,33 @@ int tpm_pm_resume(struct device *dev) ...@@ -1133,23 +1133,33 @@ int tpm_pm_resume(struct device *dev)
} }
EXPORT_SYMBOL_GPL(tpm_pm_resume); EXPORT_SYMBOL_GPL(tpm_pm_resume);
/* In case vendor provided release function, call it too.*/
void tpm_dev_vendor_release(struct tpm_chip *chip)
{
if (chip->vendor.release)
chip->vendor.release(chip->dev);
clear_bit(chip->dev_num, dev_mask);
kfree(chip->vendor.miscdev.name);
}
EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);
/* /*
* Once all references to platform device are down to 0, * Once all references to platform device are down to 0,
* release all allocated structures. * release all allocated structures.
* In case vendor provided release function, call it too.
*/ */
static void tpm_dev_release(struct device *dev) static void tpm_dev_release(struct device *dev)
{ {
struct tpm_chip *chip = dev_get_drvdata(dev); struct tpm_chip *chip = dev_get_drvdata(dev);
if (chip->vendor.release) tpm_dev_vendor_release(chip);
chip->vendor.release(dev);
chip->release(dev);
clear_bit(chip->dev_num, dev_mask); chip->release(dev);
kfree(chip->vendor.miscdev.name);
kfree(chip); kfree(chip);
} }
EXPORT_SYMBOL_GPL(tpm_dev_release);
/* /*
* Called from tpm_<specific>.c probe function only for devices * Called from tpm_<specific>.c probe function only for devices
......
...@@ -132,6 +132,7 @@ extern struct tpm_chip* tpm_register_hardware(struct device *, ...@@ -132,6 +132,7 @@ extern struct tpm_chip* tpm_register_hardware(struct device *,
const struct tpm_vendor_specific *); const struct tpm_vendor_specific *);
extern int tpm_open(struct inode *, struct file *); extern int tpm_open(struct inode *, struct file *);
extern int tpm_release(struct inode *, struct file *); extern int tpm_release(struct inode *, struct file *);
extern void tpm_dev_vendor_release(struct tpm_chip *);
extern ssize_t tpm_write(struct file *, const char __user *, size_t, extern ssize_t tpm_write(struct file *, const char __user *, size_t,
loff_t *); loff_t *);
extern ssize_t tpm_read(struct file *, char __user *, size_t, loff_t *); extern ssize_t tpm_read(struct file *, char __user *, size_t, loff_t *);
......
...@@ -630,12 +630,23 @@ static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = { ...@@ -630,12 +630,23 @@ static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = {
{"", 0} /* Terminator */ {"", 0} /* Terminator */
}; };
static __devexit void tpm_tis_pnp_remove(struct pnp_dev *dev)
{
struct tpm_chip *chip = pnp_get_drvdata(dev);
tpm_dev_vendor_release(chip);
kfree(chip);
}
static struct pnp_driver tis_pnp_driver = { static struct pnp_driver tis_pnp_driver = {
.name = "tpm_tis", .name = "tpm_tis",
.id_table = tpm_pnp_tbl, .id_table = tpm_pnp_tbl,
.probe = tpm_tis_pnp_init, .probe = tpm_tis_pnp_init,
.suspend = tpm_tis_pnp_suspend, .suspend = tpm_tis_pnp_suspend,
.resume = tpm_tis_pnp_resume, .resume = tpm_tis_pnp_resume,
.remove = tpm_tis_pnp_remove,
}; };
#define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2 #define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2
...@@ -683,6 +694,7 @@ static void __exit cleanup_tis(void) ...@@ -683,6 +694,7 @@ static void __exit cleanup_tis(void)
spin_lock(&tis_lock); spin_lock(&tis_lock);
list_for_each_entry_safe(i, j, &tis_chips, list) { list_for_each_entry_safe(i, j, &tis_chips, list) {
chip = to_tpm_chip(i); chip = to_tpm_chip(i);
tpm_remove_hardware(chip->dev);
iowrite32(~TPM_GLOBAL_INT_ENABLE & iowrite32(~TPM_GLOBAL_INT_ENABLE &
ioread32(chip->vendor.iobase + ioread32(chip->vendor.iobase +
TPM_INT_ENABLE(chip->vendor. TPM_INT_ENABLE(chip->vendor.
...@@ -694,9 +706,9 @@ static void __exit cleanup_tis(void) ...@@ -694,9 +706,9 @@ static void __exit cleanup_tis(void)
free_irq(chip->vendor.irq, chip); free_irq(chip->vendor.irq, chip);
iounmap(i->iobase); iounmap(i->iobase);
list_del(&i->list); list_del(&i->list);
tpm_remove_hardware(chip->dev);
} }
spin_unlock(&tis_lock); spin_unlock(&tis_lock);
if (force) { if (force) {
platform_device_unregister(pdev); platform_device_unregister(pdev);
driver_unregister(&tis_drv); driver_unregister(&tis_drv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment