tpm: Store devname in the tpm_chip
Just put the memory directly in the chip structure, rather than in a 2nd dedicated kmalloc. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com> Reviewed-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Acked-by: Ashley Lai <adlai@linux.vnet.ibm.com>
This commit is contained in:
committed by
Peter Huewe
parent
1e6e0974b5
commit
6aff1fdc5d
@@ -1463,7 +1463,6 @@ void tpm_dev_vendor_release(struct tpm_chip *chip)
|
|||||||
chip->vendor.release(chip->dev);
|
chip->vendor.release(chip->dev);
|
||||||
|
|
||||||
clear_bit(chip->dev_num, dev_mask);
|
clear_bit(chip->dev_num, dev_mask);
|
||||||
kfree(chip->vendor.miscdev.name);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);
|
EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);
|
||||||
|
|
||||||
@@ -1496,17 +1495,13 @@ EXPORT_SYMBOL_GPL(tpm_dev_release);
|
|||||||
struct tpm_chip *tpm_register_hardware(struct device *dev,
|
struct tpm_chip *tpm_register_hardware(struct device *dev,
|
||||||
const struct tpm_vendor_specific *entry)
|
const struct tpm_vendor_specific *entry)
|
||||||
{
|
{
|
||||||
#define DEVNAME_SIZE 7
|
|
||||||
|
|
||||||
char *devname;
|
|
||||||
struct tpm_chip *chip;
|
struct tpm_chip *chip;
|
||||||
|
|
||||||
/* Driver specific per-device data */
|
/* Driver specific per-device data */
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||||
devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
|
|
||||||
|
|
||||||
if (chip == NULL || devname == NULL)
|
if (chip == NULL)
|
||||||
goto out_free;
|
return NULL;
|
||||||
|
|
||||||
mutex_init(&chip->buffer_mutex);
|
mutex_init(&chip->buffer_mutex);
|
||||||
mutex_init(&chip->tpm_mutex);
|
mutex_init(&chip->tpm_mutex);
|
||||||
@@ -1531,8 +1526,9 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
|
|||||||
|
|
||||||
set_bit(chip->dev_num, dev_mask);
|
set_bit(chip->dev_num, dev_mask);
|
||||||
|
|
||||||
scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
|
scnprintf(chip->devname, sizeof(chip->devname), "%s%d", "tpm",
|
||||||
chip->vendor.miscdev.name = devname;
|
chip->dev_num);
|
||||||
|
chip->vendor.miscdev.name = chip->devname;
|
||||||
|
|
||||||
chip->vendor.miscdev.parent = dev;
|
chip->vendor.miscdev.parent = dev;
|
||||||
chip->dev = get_device(dev);
|
chip->dev = get_device(dev);
|
||||||
@@ -1558,7 +1554,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
|
|||||||
goto put_device;
|
goto put_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
chip->bios_dir = tpm_bios_log_setup(devname);
|
chip->bios_dir = tpm_bios_log_setup(chip->devname);
|
||||||
|
|
||||||
/* Make chip available */
|
/* Make chip available */
|
||||||
spin_lock(&driver_lock);
|
spin_lock(&driver_lock);
|
||||||
@@ -1571,7 +1567,6 @@ put_device:
|
|||||||
put_device(chip->dev);
|
put_device(chip->dev);
|
||||||
out_free:
|
out_free:
|
||||||
kfree(chip);
|
kfree(chip);
|
||||||
kfree(devname);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(tpm_register_hardware);
|
EXPORT_SYMBOL_GPL(tpm_register_hardware);
|
||||||
|
@@ -122,6 +122,7 @@ struct tpm_chip {
|
|||||||
struct device *dev; /* Device stuff */
|
struct device *dev; /* Device stuff */
|
||||||
|
|
||||||
int dev_num; /* /dev/tpm# */
|
int dev_num; /* /dev/tpm# */
|
||||||
|
char devname[7];
|
||||||
unsigned long is_open; /* only one allowed */
|
unsigned long is_open; /* only one allowed */
|
||||||
int time_expired;
|
int time_expired;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user