Message ID | 20220708093448.42617-10-nuno.sa@analog.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | adp5588-keys refactor and fw properties support | expand |
On Fri, Jul 8, 2022 at 11:37 AM Nuno Sá <nuno.sa@analog.com> wrote: > > Support feeding VCC through a regulator. ... > + ret = devm_add_action_or_reset(&client->dev, adp5588_disable_regulator, > + vcc); One line? > + if (ret) > + return ret;
> -----Original Message----- > From: Andy Shevchenko <andy.shevchenko@gmail.com> > Sent: Friday, July 8, 2022 4:47 PM > To: Sa, Nuno <Nuno.Sa@analog.com> > Cc: devicetree <devicetree@vger.kernel.org>; open list:GPIO > SUBSYSTEM <linux-gpio@vger.kernel.org>; linux-input <linux- > input@vger.kernel.org>; Dmitry Torokhov > <dmitry.torokhov@gmail.com>; Bartosz Golaszewski > <brgl@bgdev.pl>; Hennerich, Michael > <Michael.Hennerich@analog.com>; Rob Herring > <robh+dt@kernel.org>; Krzysztof Kozlowski > <krzysztof.kozlowski+dt@linaro.org>; Linus Walleij > <linus.walleij@linaro.org> > Subject: Re: [PATCH 09/10] input: keyboard: adp5588-keys: add > regulator support > > [External] > > On Fri, Jul 8, 2022 at 11:37 AM Nuno Sá <nuno.sa@analog.com> wrote: > > > > Support feeding VCC through a regulator. > > ... > > > + ret = devm_add_action_or_reset(&client->dev, > adp5588_disable_regulator, > > + vcc); > > One line? > Happy to do it but I guess it depends on the maintainer... If no one complains, I will change it on v2 - Nuno Sá
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c index 57bc4e52ec21..b4414f5f3cfb 100644 --- a/drivers/input/keyboard/adp5588-keys.c +++ b/drivers/input/keyboard/adp5588-keys.c @@ -23,6 +23,7 @@ #include <linux/pinctrl/pinconf-generic.h> #include <linux/platform_device.h> #include <linux/pm.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/timekeeping.h> @@ -698,12 +699,18 @@ static int adp5588_fw_parse(struct adp5588_kpad *kpad) return 0; } +static void adp5588_disable_regulator(void *reg) +{ + regulator_disable(reg); +} + static int adp5588_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adp5588_kpad *kpad; struct input_dev *input; struct gpio_desc *gpio; + struct regulator *vcc; unsigned int revid; int ret; int error; @@ -729,6 +736,19 @@ static int adp5588_probe(struct i2c_client *client, if (error) return error; + vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(vcc)) + return PTR_ERR(vcc); + + ret = regulator_enable(vcc); + if (ret) + return ret; + + ret = devm_add_action_or_reset(&client->dev, adp5588_disable_regulator, + vcc); + if (ret) + return ret; + gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpio)) return PTR_ERR(gpio);
Support feeding VCC through a regulator. Signed-off-by: Nuno Sá <nuno.sa@analog.com> --- drivers/input/keyboard/adp5588-keys.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)