tpm: chip struct update
Subsystems (2)
PATCH 3/7 tpm: chip struct update
To assist with chip management and better support the possibility of having multiple TPMs in the system of the same kind, the struct tpm_vendor_specific member of the tpm_chip was changed from a pointer to an instance. This patch changes that declaration and fixes up all accesses to the structure member except in tpm_infineon which is coming in a patch from Marcel Selhorst.
---
drivers/char/tpm/tpm.c | 48 +++++++++++++++------------------ drivers/char/tpm/tpm.h | 2 - drivers/char/tpm/tpm_atmel.c | 26 ++++++++--------- drivers/char/tpm/tpm_nsc.c | 32 +++++++++++----------- 4 files changed, 53 insertions(+), 55 deletions(-)
drivers/char/tpm/tpm.c +1 -1
@@ -78,21 +385,20 @@ static ssize_t tpm_transmit(struct tpm_cdown (&chip->tpm_mutex); -if ((rc = chip->vendor->send (chip, (u8 *) buf, count)) <0 ) { +if ((rc = chip->vendor.send (chip, (u8 *) buf, count)) <0 ) {dev_err (chip->dev,"tpm_transmit: tpm_send: error %zd\n" , rc); goto out; }
stop = jiffies + 2 * 60 * HZ;
do {
- u8 status = chip->vendor->status(chip);
- if ((status & chip->vendor->req_complete_mask) ==
- chip->vendor->req_complete_val) {
+ u8 status = chip->vendor.status(chip);
+ if ((status & chip->vendor.req_complete_mask) ==
+ chip->vendor.req_complete_val)
goto out_recv;
- }
- if ((status == chip->vendor->req_canceled)) {
+ if ((status == chip->vendor.req_canceled)) {
dev_err(chip->dev, "Operation Canceled\n"); rc = -ECANCELED;
goto out;
@@ -102,14 +411,13 @@ static ssize_t tpm_transmit(struct tpm_c
rmb();
} while (time_before(jiffies, stop));
-
- chip->vendor->cancel(chip);
+ chip->vendor.cancel(chip);
dev_err(chip->dev, "Operation Timed out\n"); rc = -ETIME;
goto out;
out_recv:
- rc = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
+ rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz);
if (rc < 0)
dev_err(chip->dev,
"tpm_transmit: tpm_recv: error %zd\n", rc);
@@ -344,7 +832,7 @@ ssize_t tpm_store_cancel(struct device *dev
if (chip == NULL)
return 0;
- chip->vendor->cancel(chip);
+ chip->vendor.cancel(chip);
return count;
}
EXPORT_SYMBOL_GPL(tpm_store_cancel);
@@ -369,7 +913,7 @@ int tpm_open(struct inode *inode, struct
spin_lock(&driver_lock);
list_for_each_entry(pos, &tpm_chip_list, list) {
- if (pos->vendor->miscdev.minor == minor) {
+ if (pos->vendor.miscdev.minor == minor) {
chip = pos;
break;
}
@@ -502,14 +1049,14 @@ void tpm_remove_hardware(struct device *
spin_unlock(&driver_lock);
dev_set_drvdata(dev, NULL);
- misc_deregister(&chip->vendor->miscdev);
- kfree(chip->vendor->miscdev.name);
+ misc_deregister(&chip->vendor.miscdev);
+ kfree(chip->vendor.miscdev.name);
- sysfs_remove_group(&dev->kobj, chip->vendor->attr_group);
+ sysfs_remove_group(&dev->kobj, chip->vendor.attr_group);
tpm_bios_log_teardown(chip->bios_dir);
- dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &=
- ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
+ dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &=
+ ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
kfree(chip);
@@ -583,7 +1134,7 @@ int tpm_register_hardware(struct device
chip->user_read_timer.function = user_reader_timeout; chip->user_read_timer.data = (unsigned long) chip;
- chip->vendor = entry;
+ memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));
chip->dev_num = -1;
@@ -602,22 +1153,22 @@ dev_num_search_complete:
kfree(chip);
return -ENODEV;
} else if (chip->dev_num == 0)
- chip->vendor->miscdev.minor = TPM_MINOR;
+ chip->vendor.miscdev.minor = TPM_MINOR;
else
- chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR;
+ chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;
devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
- chip->vendor->miscdev.name = devname;
+ chip->vendor.miscdev.name = devname;
- chip->vendor->miscdev.dev = dev;
+ chip->vendor.miscdev.dev = dev;
chip->dev = get_device(dev);
- if (misc_register(&chip->vendor->miscdev)) {
+ if (misc_register(&chip->vendor.miscdev)) {
dev_err(chip->dev,
"unable to misc_register %s, minor %d\n",
- chip->vendor->miscdev.name,
- chip->vendor->miscdev.minor);
+ chip->vendor.miscdev.name,
+ chip->vendor.miscdev.minor);
put_device(dev);
kfree(chip);
dev_mask[i] &= !(1 << j);
@@ -632,7 +1183,7 @@ dev_num_search_complete:
spin_unlock(&driver_lock);
- sysfs_create_group(&dev->kobj, chip->vendor->attr_group);
+ sysfs_create_group(&dev->kobj, chip->vendor.attr_group);
chip->bios_dir = tpm_bios_log_setup(devname);
drivers/char/tpm/tpm_atmel.c +13 -13
@@ -47,12 +47,12 @@ static int tpm_atml_recv(struct tpm_chipreturn -EIO ;for (i =0 ; i <6 ; i++) { - status =ioread8 (chip->vendor->iobase +1 ); + status =ioread8 (chip->vendor.iobase +1 );if ((status &ATML_STATUS_DATA_AVAIL ) ==0 ) {dev_err (chip->dev,"error reading header\n" );return -EIO ; } - *buf++ =ioread8 (chip->vendor->iobase); + *buf++ =ioread8 (chip->vendor.iobase); }/* size of the data received */
@@ -63,7 +63,7 @@ static int tpm_atml_recv(struct tpm_chipdev_err (chip->dev,"Recv size(%d) less than available space\n" , size);for (; i < size; i++) {/* clear the waiting data anyway */ - status =ioread8 (chip->vendor->iobase +1 ); + status =ioread8 (chip->vendor.iobase +1 );if ((status &ATML_STATUS_DATA_AVAIL ) ==0 ) {dev_err (chip->dev,"error reading data\n" );return -EIO ;
@@ -74,16 +74,16 @@ static int tpm_atml_recv(struct tpm_chip/* read all the data available */ for (; i < size; i++) { - status =ioread8 (chip->vendor->iobase +1 ); + status =ioread8 (chip->vendor.iobase +1 );if ((status &ATML_STATUS_DATA_AVAIL ) ==0 ) {dev_err (chip->dev,"error reading data\n" );return -EIO ; } - *buf++ =ioread8 (chip->vendor->iobase); + *buf++ =ioread8 (chip->vendor.iobase); }/* make sure data available is gone */ - status =ioread8 (chip->vendor->iobase +1 ); + status =ioread8 (chip->vendor.iobase +1 );if (status &ATML_STATUS_DATA_AVAIL ) {dev_err (chip->dev,"data available is stuck\n" );
@@ -100,7 +100,7 @@ static int tpm_atml_send(struct tpm_chipdev_dbg (chip->dev,"tpm_atml_send:\n" );for (i =0 ; i < count; i++) {dev_dbg (chip->dev,"%d 0x%x(%d)\n" , i, buf[i], buf[i]); -iowrite8 (buf[i], chip->vendor->iobase); +iowrite8 (buf[i], chip->vendor.iobase); }return count;
@@ -108,12 +108,12 @@ static int tpm_atml_send(struct tpm_chipstatic void tpm_atml_cancel (struct tpm_chip *chip) { -iowrite8 (ATML_STATUS_ABORT , chip->vendor->iobase +1 ); +iowrite8 (ATML_STATUS_ABORT , chip->vendor.iobase +1 ); }static u8 tpm_atml_status (struct tpm_chip *chip) { -return ioread8 (chip->vendor->iobase +1 ); +return ioread8 (chip->vendor.iobase +1 ); }static struct file_operations atmel_ops = {
@@ -159,10 +159,10 @@ static void atml_plat_remove(void)struct tpm_chip *chip =dev_get_drvdata (&pdev->dev);if (chip) { -if (chip->vendor->have_region) -atmel_release_region (chip->vendor->base, - chip->vendor->region_size); -atmel_put_base_addr (chip->vendor); +if (chip->vendor.have_region) +atmel_release_region (chip->vendor.base, + chip->vendor.region_size); +atmel_put_base_addr (chip->vendor.iobase);tpm_remove_hardware (chip->dev);platform_device_unregister (pdev); }
drivers/char/tpm/tpm_nsc.c +16 -16
@@ -71,7 +71,7 @@ static int wait_for_stat(struct tpm_chipunsigned long stop;/* status immediately available check */ - *data =inb (chip->vendor->base +NSC_STATUS ); + *data =inb (chip->vendor.base +NSC_STATUS );if ((*data & mask) == val)return 0 ;
@@ -79,7 +79,7 @@ static int wait_for_stat(struct tpm_chip stop = jiffies +10 *HZ ; do { msleep(TPM_TIMEOUT); - *data = inb(chip->vendor->base + 1); + *data = inb(chip->vendor.base + 1); if ((*data & mask) == val) return 0; }
@@ -94,9 +94,9 @@ static int nsc_wait_for_ready(struct tpmunsigned long stop;/* status immediately available check */ - status =inb (chip->vendor->base +NSC_STATUS ); + status =inb (chip->vendor.base +NSC_STATUS );if (status &NSC_STATUS_OBF ) - status =inb (chip->vendor->base +NSC_DATA ); + status =inb (chip->vendor.base +NSC_DATA );if (status &NSC_STATUS_RDY )return 0 ;
@@ -104,9 +104,9 @@ static int nsc_wait_for_ready(struct tpm stop = jiffies +100 ; do { msleep(TPM_TIMEOUT); - status = inb(chip->vendor->base + NSC_STATUS); + status = inb(chip->vendor.base + NSC_STATUS); if (status & NSC_STATUS_OBF) - status = inb(chip->vendor->base + NSC_DATA); + status = inb(chip->vendor.base + NSC_DATA); if (status & NSC_STATUS_RDY) return 0; }
@@ -132,7 +132,7 @@ static int tpm_nsc_recv(struct tpm_chipreturn -EIO ; }if ((data = -inb (chip->vendor->base +NSC_DATA )) !=NSC_COMMAND_NORMAL ) { +inb (chip->vendor.base +NSC_DATA )) !=NSC_COMMAND_NORMAL ) {dev_err (chip->dev,"not in normal mode (0x%x)\n" , data);return -EIO ;
@@ -148,7 +148,7 @@ static int tpm_nsc_recv(struct tpm_chip }if (data &NSC_STATUS_F0 )break ; - *p =inb (chip->vendor->base +NSC_DATA ); + *p =inb (chip->vendor.base +NSC_DATA ); } if ((data & NSC_STATUS_F0) == 0 &&
@@ -156,7 +156,7 @@ static int tpm_nsc_recv(struct tpm_chipdev_err (chip->dev,"F0 not set\n" );return -EIO ; } -if ((data =inb (chip->vendor->base +NSC_DATA )) !=NSC_COMMAND_EOC ) { +if ((data =inb (chip->vendor.base +NSC_DATA )) !=NSC_COMMAND_EOC ) {dev_err (chip->dev,"expected end of command(0x%x)\n" , data);return -EIO ;
@@ -182,7 +182,7 @@ static int tpm_nsc_send(struct tpm_chip* fix it. Not sure why this is needed, we followed the flow * chart in the manual to the letter. */ -outb (NSC_COMMAND_CANCEL , chip->vendor->base +NSC_COMMAND ); +outb (NSC_COMMAND_CANCEL , chip->vendor.base +NSC_COMMAND );if (nsc_wait_for_ready (chip) !=0 )return -EIO ;
@@ -192,7 +192,7 @@ static int tpm_nsc_send(struct tpm_chipreturn -EIO ; } -outb (NSC_COMMAND_NORMAL , chip->vendor->base +NSC_COMMAND ); +outb (NSC_COMMAND_NORMAL , chip->vendor.base +NSC_COMMAND );if (wait_for_stat (chip,NSC_STATUS_IBR ,NSC_STATUS_IBR , &data) <0 ) {dev_err (chip->dev,"IBR timeout\n" );return -EIO ;
@@ -204,26 +204,26 @@ static int tpm_nsc_send(struct tpm_chip "IBF timeout (while writing data)\n");return -EIO ; } -outb (buf[i], chip->vendor->base +NSC_DATA ); +outb (buf[i], chip->vendor.base +NSC_DATA ); }if (wait_for_stat (chip,NSC_STATUS_IBF ,0 , &data) <0 ) {dev_err (chip->dev,"IBF timeout\n" );return -EIO ; } -outb (NSC_COMMAND_EOC , chip->vendor->base +NSC_COMMAND ); +outb (NSC_COMMAND_EOC , chip->vendor.base +NSC_COMMAND );return count; }static void tpm_nsc_cancel (struct tpm_chip *chip) { -outb (NSC_COMMAND_CANCEL , chip->vendor->base +NSC_COMMAND ); +outb (NSC_COMMAND_CANCEL , chip->vendor.base +NSC_COMMAND ); }static u8 tpm_nsc_status (struct tpm_chip *chip) { -return inb (chip->vendor->base +NSC_STATUS ); +return inb (chip->vendor.base +NSC_STATUS ); }static struct file_operations nsc_ops = {
@@ -268,7 +268,7 @@ static void __devexit tpm_nsc_remove(str {struct tpm_chip *chip =dev_get_drvdata (dev);if ( chip ) { -release_region (chip->vendor->base,2 ); +release_region (chip->vendor.base,2 );tpm_remove_hardware (chip->dev); } }
drivers/char/tpm/tpm.h +1 -1
@@ -80,7 +93,7 @@ struct tpm_chip {struct work_struct work;struct semaphore tpm_mutex;/* tpm is processing */ -struct tpm_vendor_specific *vendor; +struct tpm_vendor_specific vendor;struct dentry **bios_dir;
Review
Quoted 3 lines · Kylene Jo Hall
(quoted diff) +1
-0+ dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &= + ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
If you were to make dev_mask[] an array of longs, this could perhaps become
clear_bit(dev_mask, chip->dev_num);
PATCH 1/1 tpm: use clear_bit
Quoted 9 lines · Andrew Morton
Review
Quoted 3 lines · Kylene Jo Hall
(quoted diff) +1
-0+ dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &= + ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));If you were to make dev_mask[] an array of longs, this could perhaps become
clear_bit(dev_mask, chip->dev_num);
Use set_bit and clear_bit for dev_mask manipulation.
--- drivers/char/tpm/tpm.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm.c +4 -5
@@ -32,7 +32,7 @@ enum tpm_const {TPM_MINOR =224 ,/* officially assigned */ TPM_BUFSIZE =2048 ,TPM_NUM_DEVICES =256 , -TPM_NUM_MASK_ENTRIES =TPM_NUM_DEVICES / (8 *sizeof (int )) +TPM_NUM_MASK_ENTRIES =TPM_NUM_DEVICES / (8 *sizeof (unsigned long )) }; enum tpm_duration {
@@ -48,7 +48,7 @@ enum tpm_duration {static LIST_HEAD (tpm_chip_list);static DEFINE_SPINLOCK (driver_lock); -static int dev_mask[TPM_NUM_MASK_ENTRIES ]; +static unsigned long dev_mask[TPM_NUM_MASK_ENTRIES ];/* * Array with one entry per ordinal defining the maximum amount
@@ -1033,8 +1033,7 @@ void tpm_remove_hardware(struct device *sysfs_remove_group (&dev->kobj, chip->vendor.attr_group);tpm_bios_log_teardown (chip->bios_dir); - dev_mask[chip->dev_num /TPM_NUM_MASK_ENTRIES ] &= - ~(1 << (chip->dev_num %TPM_NUM_MASK_ENTRIES )); +clear_bit (chip->dev_num , dev_mask);kfree (chip);
@@ -1118,7 +1117,7 @@ struct tpm_chip *tpm_register_hardware(sif ((dev_mask[i] & (1 << j)) ==0 ) { chip->dev_num = i *TPM_NUM_MASK_ENTRIES + j; - dev_mask[i] |=1 << j; +set_bit (chip->dev_num, dev_mask); goto dev_num_search_complete; }
Re: [PATCH] tpm: use clear_bit
Quoted 50 lines · Kylene Jo Hall
Quoted 9 lines · Andrew Morton
Review
Quoted 3 lines · Kylene Jo Hall
(quoted diff) +1
-0+ dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &= + ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));If you were to make dev_mask[] an array of longs, this could perhaps become
clear_bit(dev_mask, chip->dev_num);Use
set_bitandclear_bitfordev_maskmanipulation.Signed-off-by Kylie Hall <[email protected]>--- drivers/char/tpm/tpm.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)drivers/char/tpm/tpm.c +3
-4@@ -32,7 +32,7 @@ enum tpm_const {TPM_MINOR =224 ,/* officially assigned */ TPM_BUFSIZE =2048 ,TPM_NUM_DEVICES =256 , -TPM_NUM_MASK_ENTRIES =TPM_NUM_DEVICES / (8 *sizeof (int )) +TPM_NUM_MASK_ENTRIES =TPM_NUM_DEVICES / (8 *sizeof (unsigned long )) }; enum tpm_duration {@@ -48,7 +48,7 @@ enum tpm_duration {static LIST_HEAD (tpm_chip_list);static DEFINE_SPINLOCK (driver_lock); -static int dev_mask[TPM_NUM_MASK_ENTRIES ]; +static unsigned long dev_mask[TPM_NUM_MASK_ENTRIES ];/* * Array with one entry per ordinal defining the maximum amount @@ -1033,8 +1033,7 @@ void tpm_remove_hardware(struct device *sysfs_remove_group (&dev->kobj, chip->vendor.attr_group);tpm_bios_log_teardown (chip->bios_dir); - dev_mask[chip->dev_num /TPM_NUM_MASK_ENTRIES ] &= - ~(1 << (chip->dev_num %TPM_NUM_MASK_ENTRIES )); +clear_bit (chip->dev_num , dev_mask);kfree (chip);
drivers/char/tpm/tpm.c struct tpm_chip *tpm_register_hardware(s · line 1123
Quoted 8 lines
drivers/char/tpm/tpm.c +1
-1@@ -1118,7 +1117,7 @@ struct tpm_chip *tpm_register_hardware(sif ((dev_mask[i] & (1 << j)) ==0 ) { chip->dev_num = i *TPM_NUM_MASK_ENTRIES + j; - dev_mask[i] |=1 << j; +set_bit (chip->dev_num, dev_mask); goto dev_num_search_complete; }
It should use test_bit() as well. How's this?
drivers/char/tpm/tpm.c renamed from drivers/char/tpm/tpm.c~tpm-use-clear_bit-fix +13 -14
@@ -32,7 +32,6 @@ enum tpm_const {TPM_MINOR =224 ,/* officially assigned */ TPM_BUFSIZE =2048 , TPM_NUM_DEVICES = 256, -TPM_NUM_MASK_ENTRIES =TPM_NUM_DEVICES / (8 *sizeof (unsigned long )) }; enum tpm_duration {
@@ -48,7 +47,8 @@ enum tpm_duration {static LIST_HEAD (tpm_chip_list);static DEFINE_SPINLOCK (driver_lock); -static unsigned long dev_mask[TPM_NUM_MASK_ENTRIES ]; +static unsigned long dev_mask[(TPM_NUM_DEVICES +BITS_PER_LONG -1 ) / +BITS_PER_LONG ];/* * Array with one entry per ordinal defining the maximum amount
@@ -1032,7 +1032,7 @@ void tpm_remove_hardware(struct device *sysfs_remove_group (&dev->kobj, chip->vendor.attr_group);tpm_bios_log_teardown (chip->bios_dir); -clear_bit (chip->dev_num , dev_mask); +clear_bit (chip->dev_num, dev_mask);kfree (chip);
@@ -1090,7 +1090,7 @@ struct tpm_chip *tpm_register_hardware(schar *devname;struct tpm_chip *chip; -int i, j; +int dev_num;/* Driver specific per-device data */ chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1111,16 +1111,15 @@ struct tpm_chip *tpm_register_hardware(s chip->dev_num =-1 ; -for (i =0 ; i <TPM_NUM_MASK_ENTRIES ; i++) -for (j =0 ; j <8 *sizeof (int ); j++) -if ((dev_mask[i] & (1 << j)) ==0 ) { - chip->dev_num = - i *TPM_NUM_MASK_ENTRIES + j; -set_bit (chip->dev_num, dev_mask); - goto dev_num_search_complete; - } +/* This should use find_first_zero_bit() */ +for (dev_num =0 ; dev_num <TPM_NUM_DEVICES ; dev_num++) { +if (!test_bit (dev_num, dev_mask)) { + chip->dev_num = dev_num; +set_bit (dev_num, dev_mask); +break ; + } + } -dev_num_search_complete:if (chip->dev_num <0 ) {dev_err (dev,"No available tpm device numbers\n" );kfree (chip);
@@ -1144,7 +1143,7 @@ dev_num_search_complete: chip->vendor.miscdev.minor);put_device (dev);kfree (chip); - dev_mask[i] &= !(1 << j); +clear_bit (dev_num, dev_mask);return NULL ; }
_
Re: [PATCH] tpm: use clear_bit
drivers/char/tpm/tpm.c dev_num_search_complete: · line 1146
Quoted 3 lines · Andrew Morton
drivers/char/tpm/tpm.c renamed from drivers/char/tpm/tpm.c~tpm-use-clear_bit-fix +1
-1- dev_mask[i] &= !(1 << j); +clear_bit (dev_num, dev_mask);
Note that this fixes a bug. We wanted a ~ in there.
PATCH 1/1 tpm: use find_first_zero_bit
In reply to Andrew MortonReview
Quoted 3 lines · Andrew Morton
(quoted diff) +2
-1- } + /* This should use find_first_zero_bit() */ + for (dev_num = 0; dev_num < TPM_NUM_DEVICES; dev_num++) {
Given the suggestion in the code of your use-clear_bit-fix. This patch uses find_first_zero_bit to find a bit instead of the roll my own for loop solution.
--- drivers/char/tpm/tpm.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-)
drivers/char/tpm/tpm.c +6 -14
@@ -1090,7 +1090,6 @@ struct tpm_chip *tpm_register_hardware(schar *devname;struct tpm_chip *chip; -int dev_num;/* Driver specific per-device data */ chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1109,18 +1108,9 @@ struct tpm_chip *tpm_register_hardware(smemcpy (&chip->vendor, entry,sizeof (struct tpm_vendor_specific )); - chip->dev_num =-1 ; - -/* This should use find_first_zero_bit() */ -for (dev_num =0 ; dev_num <TPM_NUM_DEVICES ; dev_num++) { -if (!test_bit (dev_num, dev_mask)) { - chip->dev_num = dev_num; -set_bit (dev_num, dev_mask); -break ; - } - } - -if (chip->dev_num <0 ) { + chip->dev_num =find_first_zero_bit (dev_mask,TPM_NUM_DEVICES ); + +if (chip->dev_num <0 || chip->dev_num >TPM_NUM_DEVICES ) {dev_err (dev,"No available tpm device numbers\n" );kfree (chip);return NULL ;
@@ -1129,6 +1119,8 @@ struct tpm_chip *tpm_register_hardware(selse chip->vendor.miscdev.minor =MISC_DYNAMIC_MINOR ; +set_bit (chip->dev_num, dev_mask); + devname =kmalloc (DEVNAME_SIZE ,GFP_KERNEL );scnprintf (devname,DEVNAME_SIZE ,"%s%d" ,"tpm" , chip->dev_num); chip->vendor.miscdev.name = devname;
@@ -1143,7 +1135,7 @@ struct tpm_chip *tpm_register_hardware(s chip->vendor.miscdev.minor);put_device (dev);kfree (chip); -clear_bit (dev_num, dev_mask); +clear_bit (chip->dev_num, dev_mask);return NULL ; }