Skip to content

Commit c54be0e

Browse files
Linus Walleijdtor
authored andcommitted
Input: zinitix - handle proper supply names
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. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> [Slightly changed the legacy regulator detection] Signed-off-by: Nikita Travkin <nikita@trvn.ru> Link: https://lore.kernel.org/r/20220106072840.36851-4-nikita@trvn.ru Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent fdbb802 commit c54be0e

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

drivers/input/touchscreen/zinitix.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,27 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541)
252252

253253
static int zinitix_init_regulators(struct bt541_ts_data *bt541)
254254
{
255-
struct i2c_client *client = bt541->client;
255+
struct device *dev = &bt541->client->dev;
256256
int error;
257257

258-
bt541->supplies[0].supply = "vdd";
259-
bt541->supplies[1].supply = "vddo";
260-
error = devm_regulator_bulk_get(&client->dev,
258+
/*
259+
* Some older device trees have erroneous names for the regulators,
260+
* so check if "vddo" is present and in that case use these names.
261+
* Else use the proper supply names on the component.
262+
*/
263+
if (of_find_property(dev->of_node, "vddo-supply", NULL)) {
264+
bt541->supplies[0].supply = "vdd";
265+
bt541->supplies[1].supply = "vddo";
266+
} else {
267+
/* Else use the proper supply names */
268+
bt541->supplies[0].supply = "vcca";
269+
bt541->supplies[1].supply = "vdd";
270+
}
271+
error = devm_regulator_bulk_get(dev,
261272
ARRAY_SIZE(bt541->supplies),
262273
bt541->supplies);
263274
if (error < 0) {
264-
dev_err(&client->dev, "Failed to get regulators: %d\n", error);
275+
dev_err(dev, "Failed to get regulators: %d\n", error);
265276
return error;
266277
}
267278

0 commit comments

Comments
 (0)