Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp889623pxb; Wed, 27 Oct 2021 14:32:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdc4UvyGBwoaPQNzRmn7820iY7jM2dJOXnoo29YzTWYvKaZFY5gH43GExOL+TACD/YLQzD X-Received: by 2002:a17:902:9a97:b0:13e:2da4:8132 with SMTP id w23-20020a1709029a9700b0013e2da48132mr103181plp.34.1635370348730; Wed, 27 Oct 2021 14:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370348; cv=none; d=google.com; s=arc-20160816; b=Phog5JhPOXHg1DsMjb/BGdCgXkttofm6ed6O/WQCzEYJSl7XQ+gsqXlPC1bEDVNUl1 +2BVik5KatBGMkWMyhi9Wv0iOhiSUBSj5Mt9nzYcuPQ+4e4x58ju5DC0sF6AdU5eHCar WRXSnmH1oso4pFDQ2NC5hFHd2vzD185uizORO71hLlmK55lfhXSJhwCQDw3YE3gy7/FT 5PpMJ+ww/stfcKCoXMO8EPi5iWutlzHQQIddxRjPC1wr9JLX+QmJ4dd56UrzjIZCQOpR GsmsIxmzSFe6T2NtJ692yPN5XQZbmYG3Vac7zj2wDmiN6XRK1DW5KdzjX2KDZ//6Kcjz YUcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pgIai/IyiJjs4Q3YM/oVPh7XdDkuRKGMg1f2gQB6oAQ=; b=any0Apga4Da2UHQ47HgQzJPvjbc6GzyH67fV3HnK9YJi10AonWGxPbjPuUh0oDqPAj 6kwGq9GfQ7pZAkYJxrF9gTvJvFI/ctVXsH1iZOL4q07p9ubs8y24OMxpvKlxVxIVxGuX qSwBsaE6kVzQJ0+ZNjrqruO9dDXloM2CA0DGJCPxq9b7JWdE+zolCH4jDBQv9RaWHZC9 UEn2IdGEoLQGWKoBhz/ZkTZhEdZeVSHpO/5k3Rrr2lpGTSM2sSdmznAl6ZYXWpuMdqAg Actj1HYEPvAchoZjB2rNOVkrbPhxYCnscdNuKtn/OQDKl72Pn5eICOyV4Nn3l7CkcaYb Ah8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=0S1XCdVe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d35si1452095pgl.78.2021.10.27.14.32.16; Wed, 27 Oct 2021 14:32:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=0S1XCdVe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243421AbhJ0SSQ (ORCPT + 97 others); Wed, 27 Oct 2021 14:18:16 -0400 Received: from box.trvn.ru ([194.87.146.52]:38717 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240200AbhJ0SSL (ORCPT ); Wed, 27 Oct 2021 14:18:11 -0400 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 1239440519; Wed, 27 Oct 2021 23:15:27 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1635358527; bh=ar/AyF5GUE1L2gpjDkjuwKzVAeg5SZPXsABa6hsTHcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0S1XCdVeGxOHY+WyN5YS5cxkwDHPZVjvBOIf+zO7aGh+uBJqvS1F3u7/V34XwAdZ8 yGJaGjgftDXNHqj5OTbOeexmnjLTKKIVD6ulnRQUgbtGvg2CWbbxp00I32Po5oBFyx FJBiuH4XgHf08y2wV2++pPuAl9utWYHVbp71JULEigZiL150QLSt/zLI3DkNYgb4IE nFyygfmW/HiiT/0WZ5vXyPAuPG5xkyBf7WJf5yQs02upcdXE4NewIcgK+0uBrbyhlc UOMOfearjy4asHZr7Y9YzTsVfRJhD0+xflFq3zeIUbeHA+IVjoRyIoRfhjPo4wt4dN TIrhDA6vRm4zQ== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, 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 Subject: [PATCH 3/6] Input: zinitix - Handle proper supply names Date: Wed, 27 Oct 2021 23:13:47 +0500 Message-Id: <20211027181350.91630-4-nikita@trvn.ru> In-Reply-To: <20211027181350.91630-1-nikita@trvn.ru> References: <20211027181350.91630-1-nikita@trvn.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij 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 Cc: Michael Srba Cc: phone-devel@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij [Slightly changed the legacy regulator detection] Signed-off-by: Nikita Travkin --- This patch was previously submitted here: https://lore.kernel.org/linux-input/20210625113435.2539282-2-linus.walleij@linaro.org/ Changes since the original patch: - Adress the review comments by Dmitry: Drop explict OF check and use of_find_property() --- 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..d4e06a88a883 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 + * and warn. 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