Merge tag 'nfs-for-3.12-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[firefly-linux-kernel-4.4.55.git] / drivers / gpio / gpio-pcf857x.c
index a19b7457a726e4c4f6a2c48a9c8c9a52e370dcff..9e61bb0719d0cac80f176b941adf51aa52cd9b01 100644 (file)
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pcf857x.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
@@ -45,6 +45,7 @@ static const struct i2c_device_id pcf857x_id[] = {
        { "pca9675", 16 },
        { "max7328", 8 },
        { "max7329", 8 },
+       { "tca9554", 8 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, pcf857x_id);
@@ -222,7 +223,6 @@ static void pcf857x_irq_domain_cleanup(struct pcf857x *gpio)
 }
 
 static int pcf857x_irq_domain_init(struct pcf857x *gpio,
-                                  struct pcf857x_platform_data *pdata,
                                   struct i2c_client *client)
 {
        int status;
@@ -261,13 +261,13 @@ static int pcf857x_probe(struct i2c_client *client,
        struct pcf857x                  *gpio;
        int                             status;
 
-       pdata = client->dev.platform_data;
+       pdata = dev_get_platdata(&client->dev);
        if (!pdata) {
                dev_dbg(&client->dev, "no platform data\n");
        }
 
        /* Allocate, initialize, and register this gpio_chip. */
-       gpio = kzalloc(sizeof *gpio, GFP_KERNEL);
+       gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
        if (!gpio)
                return -ENOMEM;
 
@@ -285,8 +285,8 @@ static int pcf857x_probe(struct i2c_client *client,
        gpio->chip.ngpio                = id->driver_data;
 
        /* enable gpio_to_irq() if platform has settings */
-       if (pdata && client->irq) {
-               status = pcf857x_irq_domain_init(gpio, pdata, client);
+       if (client->irq) {
+               status = pcf857x_irq_domain_init(gpio, client);
                if (status < 0) {
                        dev_err(&client->dev, "irq_domain init failed\n");
                        goto fail;
@@ -387,16 +387,15 @@ fail:
        dev_dbg(&client->dev, "probe error %d for '%s'\n",
                        status, client->name);
 
-       if (pdata && client->irq)
+       if (client->irq)
                pcf857x_irq_domain_cleanup(gpio);
 
-       kfree(gpio);
        return status;
 }
 
 static int pcf857x_remove(struct i2c_client *client)
 {
-       struct pcf857x_platform_data    *pdata = client->dev.platform_data;
+       struct pcf857x_platform_data    *pdata = dev_get_platdata(&client->dev);
        struct pcf857x                  *gpio = i2c_get_clientdata(client);
        int                             status = 0;
 
@@ -411,13 +410,11 @@ static int pcf857x_remove(struct i2c_client *client)
                }
        }
 
-       if (pdata && client->irq)
+       if (client->irq)
                pcf857x_irq_domain_cleanup(gpio);
 
        status = gpiochip_remove(&gpio->chip);
-       if (status == 0)
-               kfree(gpio);
-       else
+       if (status)
                dev_err(&client->dev, "%s --> %d\n", "remove", status);
        return status;
 }