[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdZavToGYqLYnkKYt53HXoQxXnRER5Cn5b2==gWTvkAWQ@mail.gmail.com>
Date: Mon, 15 Apr 2024 17:04:53 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Aren Moynihan <aren@...cevolution.org>
Cc: Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>, Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, Ondrej Jirman <megi@....cz>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
linux-iio@...r.kernel.org, phone-devel@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
Willow Barraco <contact@...lowbarraco.fr>
Subject: Re: [PATCH 2/4] iio: light: stk3310: Implement vdd supply and power
it off during suspend
On Sun, Apr 14, 2024 at 8:57 PM Aren Moynihan <aren@...cevolution.org> wrote:
>
> From: Ondrej Jirman <megi@....cz>
>
> VDD power input can be used to completely power off the chip during
> system suspend. Do so if available.
..
> #include <linux/iio/events.h>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> +#include <linux/regulator/consumer.h>
Move it to be ordered and add a blank line to separate iio/*.h group.
..
> + data->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd");
> + if (IS_ERR(data->vdd_reg)) {
> + ret = PTR_ERR(data->vdd_reg);
> + if (ret == -ENODEV)
> + data->vdd_reg = NULL;
> + else
Redundant 'else' when you follow the pattern "check for error condition first".
> + return dev_err_probe(&client->dev, ret,
> + "get regulator vdd failed\n");
> + }
..
> + if (data->vdd_reg) {
> + ret = regulator_enable(data->vdd_reg);
> + if (ret)
> + return dev_err_probe(&client->dev, ret,
> + "regulator vdd enable failed\n");
> +
> + usleep_range(1000, 2000);
fsleep()
> + }
..
> stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY);
> + if (data->vdd_reg)
> + regulator_disable(data->vdd_reg);
I forgot to check the order of freeing resources, be sure you have no
devm_*() releases happening before this call.
..
> + usleep_range(1000, 2000);
fsleep()
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists