All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikita Travkin <nikita@trvn.ru>
To: dmitry.torokhov@gmail.com
Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz,
	linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	Nikita Travkin <nikita@trvn.ru>
Subject: [PATCH v2 3/6] Input: zinitix - Handle proper supply names
Date: Wed,  5 Jan 2022 11:03:20 +0500	[thread overview]
Message-ID: <20220105060323.7928-4-nikita@trvn.ru> (raw)
In-Reply-To: <20220105060323.7928-1-nikita@trvn.ru>

From: Linus Walleij <linus.walleij@linaro.org>

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>
[Slightly changed the legacy regulator detection]
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
---
This patch was previously submitted here:
https://lore.kernel.org/linux-input/20210625113435.2539282-2-linus.walleij@linaro.org/

Changes since the original patch:
 - Address the review comments by Dmitry:
   Drop explicit OF check and use of_find_property()
Changes in v2:
 - Reword the legacy regulator comment to drop "... and warn" as no
   warning is done. (I think adding a warning is not very useful here)
---
 drivers/input/touchscreen/zinitix.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index 1e70b8d2a8d7..e84e4c3b1b3a 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -252,16 +252,27 @@ 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.
+	 * Else use the proper supply names on the component.
+	 */
+	if (of_find_property(dev->of_node, "vddo-supply", NULL)) {
+		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.30.2


  parent reply	other threads:[~2022-01-05  6:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  6:03 [PATCH v2 0/6] Add touch-keys support to the Zinitix touch driver Nikita Travkin
2022-01-05  6:03 ` [PATCH v2 1/6] input: zinitix: Make sure the IRQ is allocated before it gets enabled Nikita Travkin
2022-01-05  6:03 ` [PATCH v2 2/6] dt-bindings: input/ts/zinitix: Convert to YAML, fix and extend Nikita Travkin
2022-01-05  6:03 ` Nikita Travkin [this message]
2022-01-05  6:03 ` [PATCH v2 4/6] input: zinitix: Add compatible for bt532 Nikita Travkin
2022-01-05  6:03 ` [PATCH v2 5/6] dt-bindings: input: zinitix: Document touch-keys support Nikita Travkin
2022-01-05  6:03 ` [PATCH v2 6/6] input: zinitix: Add touchkey support Nikita Travkin
2022-01-05 15:38   ` kernel test robot
2022-01-05 15:38     ` kernel test robot

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=20220105060323.7928-4-nikita@trvn.ru \
    --to=nikita@trvn.ru \
    --cc=Michael.Srba@seznam.cz \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.