tpm: Get rid of devname
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Mon, 29 Feb 2016 17:29:48 +0000 (12:29 -0500)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 25 Jun 2016 14:26:35 +0000 (17:26 +0300)
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>
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm_eventlog.c
drivers/char/tpm/tpm_eventlog.h
drivers/char/tpm/tpm_i2c_nuvoton.c
drivers/char/tpm/tpm_tis.c

index 12829dd84e56720203d58d683c1faf291aa7211f..c21d81c055f391c6b90d5a4fe9a023c7e538b2e5 100644 (file)
@@ -111,7 +111,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);
+       device_initialize(&chip->dev);
 
        dev_set_drvdata(dev, chip);
 
@@ -127,9 +127,9 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
        else
                chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num);
 
-       dev_set_name(&chip->dev, "%s", chip->devname);
-
-       device_initialize(&chip->dev);
+       rc = dev_set_name(&chip->dev, "tpm%d", chip->dev_num);
+       if (rc)
+               goto out;
 
        cdev_init(&chip->cdev, &tpm_fops);
        chip->cdev.owner = dev->driver->owner;
@@ -142,6 +142,10 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
        }
 
        return chip;
+
+out:
+       put_device(&chip->dev);
+       return ERR_PTR(rc);
 }
 EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
 
@@ -153,7 +157,7 @@ static int tpm_add_char_device(struct tpm_chip *chip)
        if (rc) {
                dev_err(&chip->dev,
                        "unable to cdev_add() %s, major %d, minor %d, err=%d\n",
-                       chip->devname, MAJOR(chip->dev.devt),
+                       dev_name(&chip->dev), MAJOR(chip->dev.devt),
                        MINOR(chip->dev.devt), rc);
 
                return rc;
@@ -163,7 +167,7 @@ static int tpm_add_char_device(struct tpm_chip *chip)
        if (rc) {
                dev_err(&chip->dev,
                        "unable to device_register() %s, major %d, minor %d, err=%d\n",
-                       chip->devname, MAJOR(chip->dev.devt),
+                       dev_name(&chip->dev), MAJOR(chip->dev.devt),
                        MINOR(chip->dev.devt), rc);
 
                cdev_del(&chip->cdev);
@@ -190,7 +194,7 @@ static int tpm1_chip_register(struct tpm_chip *chip)
        if (rc)
                return rc;
 
-       chip->bios_dir = tpm_bios_log_setup(chip->devname);
+       chip->bios_dir = tpm_bios_log_setup(dev_name(&chip->dev));
 
        return 0;
 }
index 9c9be6c9be6d81a06f44213729b1337cf5a793e7..5d33ba595929bd38367edee2c0b1bd5cc98ca3aa 100644 (file)
@@ -174,7 +174,6 @@ struct tpm_chip {
        unsigned int flags;
 
        int dev_num;            /* /dev/tpm# */
-       char devname[7];
        unsigned long is_open;  /* only one allowed */
        int time_expired;
 
index 4e6940acf639b00333baed9660567d81e4b75bf0..e7228863290edea53508fd597ff6855b98c1440c 100644 (file)
@@ -403,7 +403,7 @@ static int is_bad(void *p)
        return 0;
 }
 
-struct dentry **tpm_bios_log_setup(char *name)
+struct dentry **tpm_bios_log_setup(const char *name)
 {
        struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
 
index 267bfbd1b7bbe7addf4dcd029e8c21df3a731859..cc9672f64e8f36ddf7856dd31daf284133d96fb1 100644 (file)
@@ -77,7 +77,7 @@ int read_log(struct tpm_bios_log *log);
 
 #if defined(CONFIG_TCG_IBMVTPM) || defined(CONFIG_TCG_IBMVTPM_MODULE) || \
        defined(CONFIG_ACPI)
-extern struct dentry **tpm_bios_log_setup(char *);
+extern struct dentry **tpm_bios_log_setup(const char *);
 extern void tpm_bios_log_teardown(struct dentry **);
 #else
 static inline struct dentry **tpm_bios_log_setup(char *name)
index a1e1474dda306bb57485b6da61cf34226e13e00a..d61d43feda25d40bce8e56b7524202408e43771f 100644 (file)
@@ -560,7 +560,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
                rc = devm_request_irq(dev, chip->vendor.irq,
                                      i2c_nuvoton_int_handler,
                                      IRQF_TRIGGER_LOW,
-                                     chip->devname,
+                                     dev_name(&chip->dev),
                                      chip);
                if (rc) {
                        dev_err(dev, "%s() Unable to request irq: %d for use\n",
index 0a9aee980c41680192fe429db1642adcd037ea2f..eed3bf510682550076b8bd301286e49776dfb83c 100644 (file)
@@ -577,7 +577,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
        u8 original_int_vec;
 
        if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
-                            chip->devname, chip) != 0) {
+                            dev_name(&chip->dev), chip) != 0) {
                dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
                         irq);
                return -1;