mfd: stmpe: Move platform data into MFD driver
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 25 May 2016 12:22:02 +0000 (14:22 +0200)
committerLee Jones <lee.jones@linaro.org>
Wed, 29 Jun 2016 09:15:51 +0000 (10:15 +0100)
The STMPE platform data is only populated from the device tree
in all existing users, so push the struct and make the OF case
the norm.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/stmpe.c
include/linux/mfd/stmpe.h

index fb8f9e8..94c7cc0 100644 (file)
 #include <linux/regulator/consumer.h>
 #include "stmpe.h"
 
+/**
+ * struct stmpe_platform_data - STMPE platform data
+ * @id: device id to distinguish between multiple STMPEs on the same board
+ * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*)
+ * @irq_trigger: IRQ trigger to use for the interrupt to the host
+ * @autosleep: bool to enable/disable stmpe autosleep
+ * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
+ * @irq_over_gpio: true if gpio is used to get irq
+ * @irq_gpio: gpio number over which irq will be requested (significant only if
+ *           irq_over_gpio is true)
+ */
+struct stmpe_platform_data {
+       int id;
+       unsigned int blocks;
+       unsigned int irq_trigger;
+       bool autosleep;
+       bool irq_over_gpio;
+       int irq_gpio;
+       int autosleep_timeout;
+};
+
 static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)
 {
        return stmpe->variant->enable(stmpe, blocks, true);
@@ -1187,24 +1208,19 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
 /* Called from client specific probe routines */
 int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
 {
-       struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev);
+       struct stmpe_platform_data *pdata;
        struct device_node *np = ci->dev->of_node;
        struct stmpe *stmpe;
        int ret;
 
-       if (!pdata) {
-               if (!np)
-                       return -EINVAL;
-
-               pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL);
-               if (!pdata)
-                       return -ENOMEM;
+       pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL);
+       if (!pdata)
+               return -ENOMEM;
 
-               stmpe_of_probe(pdata, np);
+       stmpe_of_probe(pdata, np);
 
-               if (of_find_property(np, "interrupts", NULL) == NULL)
-                       ci->irq = -1;
-       }
+       if (of_find_property(np, "interrupts", NULL) == NULL)
+               ci->irq = -1;
 
        stmpe = devm_kzalloc(ci->dev, sizeof(struct stmpe), GFP_KERNEL);
        if (!stmpe)
index cb83883..de748bc 100644 (file)
@@ -62,6 +62,7 @@ enum {
 
 struct stmpe_variant_info;
 struct stmpe_client_info;
+struct stmpe_platform_data;
 
 /**
  * struct stmpe - STMPE MFD structure
@@ -117,25 +118,4 @@ extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
 
 #define STMPE_GPIO_NOREQ_811_TOUCH     (0xf0)
 
-/**
- * struct stmpe_platform_data - STMPE platform data
- * @id: device id to distinguish between multiple STMPEs on the same board
- * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*)
- * @irq_trigger: IRQ trigger to use for the interrupt to the host
- * @autosleep: bool to enable/disable stmpe autosleep
- * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
- * @irq_over_gpio: true if gpio is used to get irq
- * @irq_gpio: gpio number over which irq will be requested (significant only if
- *           irq_over_gpio is true)
- */
-struct stmpe_platform_data {
-       int id;
-       unsigned int blocks;
-       unsigned int irq_trigger;
-       bool autosleep;
-       bool irq_over_gpio;
-       int irq_gpio;
-       int autosleep_timeout;
-};
-
 #endif