tpm/st33zp24: Switch to devm_acpi_dev_add_driver_gpios()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 12 Jun 2017 15:44:16 +0000 (18:44 +0300)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 19 Jun 2017 00:33:22 +0000 (02:33 +0200)
Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify
error path and fix potentially wrong assignment if ->probe() fails.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com> (compilation)
Signed-off-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
drivers/char/tpm/st33zp24/i2c.c
drivers/char/tpm/st33zp24/spi.c

index 1b10e38f214ef48acffdd41de4c49bb6c5599a45..be5d1abd3e8ef05d9ce66ba8d61d120750303c9e 100644 (file)
@@ -127,7 +127,7 @@ static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client)
        struct device *dev = &client->dev;
        int ret;
 
-       ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios);
+       ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st33zp24_gpios);
        if (ret)
                return ret;
 
@@ -285,7 +285,6 @@ static int st33zp24_i2c_remove(struct i2c_client *client)
        if (ret)
                return ret;
 
-       acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
        return 0;
 }
 
index c69d15198f84c7de79303e732037f588404d0537..0fc4f20b5f83160974717bf07d2dd8cf5a9e2623 100644 (file)
@@ -246,7 +246,7 @@ static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
        struct device *dev = &spi_dev->dev;
        int ret;
 
-       ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios);
+       ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st33zp24_gpios);
        if (ret)
                return ret;
 
@@ -402,7 +402,6 @@ static int st33zp24_spi_remove(struct spi_device *dev)
        if (ret)
                return ret;
 
-       acpi_dev_remove_driver_gpios(ACPI_COMPANION(&dev->dev));
        return 0;
 }