Message ID | 20180618074556.6944-3-linus.walleij@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | RFC: Mezzanine handling for 96boards | expand |
On Mon, Jun 18, 2018 at 10:45 AM, Linus Walleij <linus.walleij@linaro.org> wrote: > This makes it possible to pass an initialized GPIO descriptor > to the driver through platform data. > > This is useful when we are dealing with EEPROMs on expansion > boards where the GPIO has to be looked up indirectly using a > connector abstraction (several systems using the same > connector) so the machine descriptor tables cannot be used > to associate the descriptor with the device and we then want > to pass this descriptor on to the EEPROM driver this way > instead. How this descriptor is supposed to be created? Whenever we probe the device we might add properties to it (consider how MFD does instansiate them), I guess same way GPIO lookup tables work. No? P.S. I really would like to hear a _strong_ argument why it can't be done using other means like built-in device properties or GPIO lookup tables (which on my opinion have to work in the similar way at run time). -- With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index f5cc517d1131..d577cdbe221e 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -662,7 +662,11 @@ static int at24_probe(struct i2c_client *client) at24->client[0].client = client; at24->client[0].regmap = regmap; - at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); + if (pdata.wp_gpiod) + at24->wp_gpio = pdata.wp_gpiod; + else + at24->wp_gpio = + devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); if (IS_ERR(at24->wp_gpio)) return PTR_ERR(at24->wp_gpio); diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h index 63507ff464ee..5606fb2ef76c 100644 --- a/include/linux/platform_data/at24.h +++ b/include/linux/platform_data/at24.h @@ -11,6 +11,7 @@ #include <linux/types.h> #include <linux/nvmem-consumer.h> #include <linux/bitops.h> +#include <linux/gpio/consumer.h> /** * struct at24_platform_data - data to set up at24 (generic eeprom) driver @@ -55,6 +56,7 @@ struct at24_platform_data { void (*setup)(struct nvmem_device *nvmem, void *context); void *context; + struct gpio_desc *wp_gpiod; }; #endif /* _LINUX_AT24_H */
This makes it possible to pass an initialized GPIO descriptor to the driver through platform data. This is useful when we are dealing with EEPROMs on expansion boards where the GPIO has to be looked up indirectly using a connector abstraction (several systems using the same connector) so the machine descriptor tables cannot be used to associate the descriptor with the device and we then want to pass this descriptor on to the EEPROM driver this way instead. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/misc/eeprom/at24.c | 6 +++++- include/linux/platform_data/at24.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html