@@ -59,6 +59,15 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
}
EXPORT_SYMBOL_GPL(tpm_chip_find_get);
+void tpm_chip_free(struct tpm_chip *chip)
+{
+ spin_lock(&driver_lock);
+ clear_bit(chip->dev_num, dev_mask);
+ spin_unlock(&driver_lock);
+ kfree(chip);
+}
+EXPORT_SYMBOL_GPL(tpm_chip_free);
+
/**
* tpm_dev_release() - free chip memory and the device number
* @dev: the character device for the TPM chip
@@ -69,10 +78,7 @@ static void tpm_dev_release(struct device *dev)
{
struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
- spin_lock(&driver_lock);
- clear_bit(chip->dev_num, dev_mask);
- spin_unlock(&driver_lock);
- kfree(chip);
+ tpm_chip_free(chip);
}
/**
@@ -515,6 +515,7 @@ extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
struct tpm_chip *tpm_chip_find_get(int chip_num);
extern struct tpm_chip *tpmm_chip_alloc(struct device *dev,
const struct tpm_class_ops *ops);
+extern void tpm_chip_free(struct tpm_chip *chip);
extern int tpm_chip_register(struct tpm_chip *chip);
extern void tpm_chip_unregister(struct tpm_chip *chip);
Implement the public function tpm_chip_free to undo tpmm_chip_alloc. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- drivers/char/tpm/tpm-chip.c | 14 ++++++++++---- drivers/char/tpm/tpm.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-)