From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-input@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Michael Srba <Michael.Srba@seznam.cz>,
phone-devel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] Input: zinitix - Handle proper supply names
Date: Fri, 23 Jul 2021 18:13:02 -0700 [thread overview]
Message-ID: <YPtpHg2aoGlULuQQ@google.com> (raw)
In-Reply-To: <20210625113435.2539282-2-linus.walleij@linaro.org>
Hi Linus,
On Fri, Jun 25, 2021 at 01:34:35PM +0200, Linus Walleij wrote:
> The supply names of the Zinitix touchscreen were a bit confused, the new
> bindings rectifies this.
>
> To deal with old and new devicetrees, first check if we have "vddo" and in
> case that exists assume the old supply names. Else go and look for the new
> ones.
>
> We cannot just get the regulators since we would get an OK and a dummy
> regulator: we need to check explicitly for the old supply name.
>
> Use struct device *dev as a local variable instead of the I2C client since
> the device is what we are actually obtaining the resources from.
>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Michael Srba <Michael.Srba@seznam.cz>
> Cc: phone-devel@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Mark: please check that I'm doing this check the right way, I assume
> that since we get regulator dummies this is the way I need to check
> for the old regulator name but maybe there are better ways.
> ---
> drivers/input/touchscreen/zinitix.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
> index b8d901099378..7001307382f0 100644
> --- a/drivers/input/touchscreen/zinitix.c
> +++ b/drivers/input/touchscreen/zinitix.c
> @@ -252,16 +252,28 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541)
>
> static int zinitix_init_regulators(struct bt541_ts_data *bt541)
> {
> - struct i2c_client *client = bt541->client;
> + struct device *dev = &bt541->client->dev;
> int error;
>
> - bt541->supplies[0].supply = "vdd";
> - bt541->supplies[1].supply = "vddo";
> - error = devm_regulator_bulk_get(&client->dev,
> + /*
> + * Some older device trees have erroneous names for the regulators,
> + * so check if "vddo" is present and in that case use these names
> + * and warn. Else use the proper supply names on the component.
> + */
> + if (IS_ENABLED(CONFIG_OF) &&
Why is this check needed? The of_property_*() are stubbed out properly I
believe. We might need to check that dev->of_node is not NULL, although
I think of_* API handles this properly.
> + of_property_read_bool(dev->of_node, "vddo-supply")) {
If we go with this I do not like using of_property_read_bool() as this
is not a boolean property, but rather of_find_property().
However maybe we should use regulator_get_optional() which will not give
a dummy regulator? Still quite awkward, a dedicated API to see if a
regulator is defined would be nice.
> + bt541->supplies[0].supply = "vdd";
> + bt541->supplies[1].supply = "vddo";
> + } else {
> + /* Else use the proper supply names */
> + bt541->supplies[0].supply = "vcca";
> + bt541->supplies[1].supply = "vdd";
> + }
> + error = devm_regulator_bulk_get(dev,
> ARRAY_SIZE(bt541->supplies),
> bt541->supplies);
> if (error < 0) {
> - dev_err(&client->dev, "Failed to get regulators: %d\n", error);
> + dev_err(dev, "Failed to get regulators: %d\n", error);
> return error;
> }
>
> --
> 2.31.1
>
Thanks.
--
Dmitry
next prev parent reply other threads:[~2021-07-24 1:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 11:34 [PATCH 1/2] dt-bindings: input/ts/zinitix: Convert to YAML, fix and extend Linus Walleij
2021-06-25 11:34 ` [PATCH 2/2] Input: zinitix - Handle proper supply names Linus Walleij
2021-07-24 1:13 ` Dmitry Torokhov [this message]
2021-11-18 22:47 ` Linus Walleij
2021-07-14 19:51 ` [PATCH 1/2] dt-bindings: input/ts/zinitix: Convert to YAML, fix and extend Rob Herring
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=YPtpHg2aoGlULuQQ@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=Michael.Srba@seznam.cz \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=phone-devel@vger.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;
as well as URLs for NNTP newsgroup(s).