From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Christoph Rudorff <chris@rudorff.com>
Cc: "Linus Walleij" <linusw@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: light: gp2ap002: add led power supply
Date: Wed, 21 Oct 2026 11:29:14 +0300 [thread overview]
Message-ID: <ath32oZkOYl2UwqX@ashevche-desk.local> (raw)
In-Reply-To: <20261020-iio-light-gp2ap002-v3-2-b7e0946c9e79@rudorff.com>
On Tue, Oct 20, 2026 at 01:35:39PM +0200, Christoph Rudorff wrote:
> tested on samsung-j5
>
> v2: Use regulator bulk api.
> v3: pretty up, rename vled to leda
The comment and changelog area is...
> Signed-off-by: Christoph Rudorff <chris@rudorff.com>
> ---
...here, but the commit message is effectively missing. We may not accept such
a change, so please provide a commit message and move unnecessary bits to the
comment and changelog area.
...
> +enum {
> + SUPPLY_VIO,
> + SUPPLY_VDD,
> + SUPPLY_LEDA,
> + NUM_SUPPLIES
Not critical, but the naming is too broad, better to have namespaced variants
GP2AP002_SUPPLY_VIO,
et cetera.
> +};
> struct regmap *regmap;
> int num_chan;
> const char *compat;
> + static const char *const gp2ap002_supply_names[NUM_SUPPLIES] = {
> + [SUPPLY_VIO] = "vio",
> + [SUPPLY_VDD] = "vdd",
> + [SUPPLY_LEDA] = "leda",
> + };
Can be moved out of the function to see the static data (that's effectively
global anyway).
> u8 val;
> int ret;
...
> + ret = devm_regulator_bulk_get(dev, NUM_SUPPLIES, gp2ap002->supplies);
> +
Redundant blank line.
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to get regulators\n");
...
> + ret = regulator_set_voltage(gp2ap002->supplies[SUPPLY_VDD].consumer, 2400000, 3600000);
> - ret = regulator_get_voltage(gp2ap002->vdd);
> + ret = regulator_get_voltage(gp2ap002->supplies[SUPPLY_VDD].consumer);
> - ret = regulator_set_voltage(gp2ap002->vio, 1650000, ret);
> + ret = regulator_set_voltage(gp2ap002->supplies[SUPPLY_VIO].consumer, 1650000, ret);
To make these lines shorter you can introduce a temporary variable (or reuse
"compat" if it's feasible, might require to rename the variable, though)
rname = gp2ap002->supplies[SUPPLY_VDD].consumer;
ret = regulator_set_voltage(rname, 2400000, 3600000);
...
rname = gp2ap002->supplies[SUPPLY_VIO].consumer;
ret = regulator_set_voltage(rname, 1650000, ret);
(Side note: This ret = foo(ret) doesn't sound good, the rule of thumb to have a separate
variable for the 'ret', so you will have ret = foo($VAR) in the code.)
...
> ret = gp2ap002_init(gp2ap002);
> if (ret) {
> dev_err(dev, "initialization failed\n");
> - goto out_disable_vio;
> + goto out_disable_power;
> }
> pm_runtime_get_noresume(dev);
> pm_runtime_set_active(dev);
> @@ -616,10 +619,8 @@ static int gp2ap002_probe(struct i2c_client *client)
> pm_runtime_put_noidle(dev);
> out_disable_pm:
> pm_runtime_disable(dev);
> -out_disable_vio:
> - regulator_disable(gp2ap002->vio);
> -out_disable_vdd:
> - regulator_disable(gp2ap002->vdd);
> +out_disable_power:
> + regulator_bulk_disable(NUM_SUPPLIES, gp2ap002->supplies);
> return ret;
Wondering if we can use managed resources to disable regulators.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-10-21 8:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 11:35 [PATCH v3 0/3] MSM8916: improve gp2ap002 proximity sensor v3 Christoph Rudorff
2026-10-20 11:35 ` [PATCH v3 1/3] dt-bindings: iio: light: gp2ap002: add leda power supply Christoph Rudorff
2026-10-20 17:14 ` Linus Walleij
2026-10-20 11:35 ` [PATCH v3 2/3] iio: light: gp2ap002: add led " Christoph Rudorff
2026-10-20 17:15 ` Linus Walleij
2026-10-21 8:29 ` Andy Shevchenko [this message]
2026-10-20 11:35 ` [PATCH v3 3/3] arm64: dts: qcom: msm8916-samsung-j5: Add proximity sensor Christoph Rudorff
2026-10-20 17:16 ` Linus Walleij
2026-10-21 7:58 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ath32oZkOYl2UwqX@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andersson@kernel.org \
--cc=andy@kernel.org \
--cc=chris@rudorff.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®