From: Stefan Berger <[email protected]> Introduce tpmm_chip_alloc_pattern that takes an additional parameter of the device's name pattern. All existing devices use "tpm%d".
Signed-off-by: Stefan Berger <[email protected]> --- drivers/char/tpm/tpm-chip.c | 28 ++++++++++++++++++++++++---- drivers/char/tpm/tpm.h | 6 +++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index f2da376..d98fcd9 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -76,17 +76,20 @@ static void tpm_dev_release(struct device *dev) } /** - * tpmm_chip_alloc() - allocate a new struct tpm_chip instance + * tpmm_chip_alloc_pattern() - allocate a new struct tpm_chip instance + * and use the given pattern for naming the device * @dev: device to which the chip is associated * @ops: struct tpm_class_ops instance + * @pattern: name pattern of the device * * Allocates a new struct tpm_chip instance and assigns a free * device number for it. Caller does not have to worry about * freeing the allocated resources. When the devices is removed * devres calls tpmm_chip_remove() to do the job. */ -struct tpm_chip *tpmm_chip_alloc(struct device *dev, - const struct tpm_class_ops *ops) +struct tpm_chip *tpmm_chip_alloc_pattern(struct device *dev, + const struct tpm_class_ops *ops, + const char *pattern) { struct tpm_chip *chip; @@ -111,7 +114,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, set_bit(chip->dev_num, dev_mask); - scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num); + scnprintf(chip->devname, sizeof(chip->devname), pattern, chip->dev_num); chip->pdev = dev; @@ -139,6 +142,23 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, return chip; } +EXPORT_SYMBOL_GPL(tpmm_chip_alloc_pattern); + +/** + * tpmm_chip_alloc() - allocate a new struct tpm_chip instance + * @dev: device to which the chip is associated + * @ops: struct tpm_class_ops instance + * + * Allocates a new struct tpm_chip instance and assigns a free + * device number for it. Caller does not have to worry about + * freeing the allocated resources. When the devices is removed + * devres calls tpmm_chip_remove() to do the job. + */ +struct tpm_chip *tpmm_chip_alloc(struct device *dev, + const struct tpm_class_ops *ops) +{ + return tpmm_chip_alloc_pattern(dev, ops, "tpm%d"); +} EXPORT_SYMBOL_GPL(tpmm_chip_alloc); static int tpm_dev_add_device(struct tpm_chip *chip) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index dfa755b..c95b26e 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -181,7 +181,7 @@ struct tpm_chip { unsigned int flags; int dev_num; /* /dev/tpm# */ - char devname[7]; + char devname[10]; unsigned long is_open; /* only one allowed */ int time_expired; @@ -517,6 +517,10 @@ 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 struct tpm_chip *tpmm_chip_alloc_pattern( + struct device *dev, + const struct tpm_class_ops *ops, + const char *pattern); extern int tpm_chip_register(struct tpm_chip *chip); extern void tpm_chip_unregister(struct tpm_chip *chip); -- 2.4.3 ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ tpmdd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
