Skip to content

Commit 3635e2e

Browse files
jgunthorpeJarkko Sakkinen
authored andcommitted
tpm: Get rid of devname
Now that we have a proper struct device just use dev_name() to access this value instead of keeping two copies. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent 8cfffc9 commit 3635e2e

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎drivers/char/tpm/tpm-chip.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
111111

112112
set_bit(chip->dev_num, dev_mask);
113113

114-
scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
114+
device_initialize(&chip->dev);
115115

116116
dev_set_drvdata(dev, chip);
117117

@@ -127,9 +127,9 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
127127
else
128128
chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num);
129129

130-
dev_set_name(&chip->dev, "%s", chip->devname);
131-
132-
device_initialize(&chip->dev);
130+
rc = dev_set_name(&chip->dev, "tpm%d", chip->dev_num);
131+
if (rc)
132+
goto out;
133133

134134
cdev_init(&chip->cdev, &tpm_fops);
135135
chip->cdev.owner = dev->driver->owner;
@@ -142,6 +142,10 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
142142
}
143143

144144
return chip;
145+
146+
out:
147+
put_device(&chip->dev);
148+
return ERR_PTR(rc);
145149
}
146150
EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
147151

@@ -153,7 +157,7 @@ static int tpm_add_char_device(struct tpm_chip *chip)
153157
if (rc) {
154158
dev_err(&chip->dev,
155159
"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
156-
chip->devname, MAJOR(chip->dev.devt),
160+
dev_name(&chip->dev), MAJOR(chip->dev.devt),
157161
MINOR(chip->dev.devt), rc);
158162

159163
return rc;
@@ -163,7 +167,7 @@ static int tpm_add_char_device(struct tpm_chip *chip)
163167
if (rc) {
164168
dev_err(&chip->dev,
165169
"unable to device_register() %s, major %d, minor %d, err=%d\n",
166-
chip->devname, MAJOR(chip->dev.devt),
170+
dev_name(&chip->dev), MAJOR(chip->dev.devt),
167171
MINOR(chip->dev.devt), rc);
168172

169173
cdev_del(&chip->cdev);
@@ -190,7 +194,7 @@ static int tpm1_chip_register(struct tpm_chip *chip)
190194
if (rc)
191195
return rc;
192196

193-
chip->bios_dir = tpm_bios_log_setup(chip->devname);
197+
chip->bios_dir = tpm_bios_log_setup(dev_name(&chip->dev));
194198

195199
return 0;
196200
}

‎drivers/char/tpm/tpm.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ struct tpm_chip {
174174
unsigned int flags;
175175

176176
int dev_num; /* /dev/tpm# */
177-
char devname[7];
178177
unsigned long is_open; /* only one allowed */
179178
int time_expired;
180179

‎drivers/char/tpm/tpm_eventlog.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int is_bad(void *p)
403403
return 0;
404404
}
405405

406-
struct dentry **tpm_bios_log_setup(char *name)
406+
struct dentry **tpm_bios_log_setup(const char *name)
407407
{
408408
struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
409409

‎drivers/char/tpm/tpm_eventlog.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int read_log(struct tpm_bios_log *log);
7777

7878
#if defined(CONFIG_TCG_IBMVTPM) || defined(CONFIG_TCG_IBMVTPM_MODULE) || \
7979
defined(CONFIG_ACPI)
80-
extern struct dentry **tpm_bios_log_setup(char *);
80+
extern struct dentry **tpm_bios_log_setup(const char *);
8181
extern void tpm_bios_log_teardown(struct dentry **);
8282
#else
8383
static inline struct dentry **tpm_bios_log_setup(char *name)

‎drivers/char/tpm/tpm_i2c_nuvoton.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
560560
rc = devm_request_irq(dev, chip->vendor.irq,
561561
i2c_nuvoton_int_handler,
562562
IRQF_TRIGGER_LOW,
563-
chip->devname,
563+
dev_name(&chip->dev),
564564
chip);
565565
if (rc) {
566566
dev_err(dev, "%s() Unable to request irq: %d for use\n",

‎drivers/char/tpm/tpm_tis.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
577577
u8 original_int_vec;
578578

579579
if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
580-
chip->devname, chip) != 0) {
580+
dev_name(&chip->dev), chip) != 0) {
581581
dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
582582
irq);
583583
return -1;

0 commit comments

Comments
 (0)