From nobody Sun May 10 16:25:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40B88C433EF for ; Fri, 29 Apr 2022 12:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359411AbiD2MmQ (ORCPT ); Fri, 29 Apr 2022 08:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359360AbiD2MmF (ORCPT ); Fri, 29 Apr 2022 08:42:05 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437D8C9B65 for ; Fri, 29 Apr 2022 05:38:46 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-e93bbb54f9so7964514fac.12 for ; Fri, 29 Apr 2022 05:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uAcN2Jau5uY/pToJWSrqvm2t7QVf6G7bhywOw1/QJeM=; b=DVv+VK0f7UTJDgepW/qW0a0E0p4SOunM126nr37ZeZpS1zUVxdfudJqeU/ShOi+luK sJMLkkBjtJCrfuThKSp2yC/1yBmPrQJgHxZQZKj4vqAS1thYlJMBksftfAn0KdwsN3MP 0PUG+QDijPhdKRvJPxgDVDAMOmmJQQ5j9IhX+tr78z+/Fsjkbqbe7RLbYIEJJ3VbEAL/ EbSGRkSqOatrG2ml6uQVp6aHpfgRWvrcSZOec+VzWGZ4oCZ1gflM6uYjJnsmZeWU9EkF btLk0+dRTKtC2oosaOTVGz4QAQUZy9Zuwjx1yEtldWb+C/hDotBS/AoqWiWluIH8m1WS Qviw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uAcN2Jau5uY/pToJWSrqvm2t7QVf6G7bhywOw1/QJeM=; b=pyDsrleR65yI6ZQLLLNXV700Ykk/ZI+8wTOVwmHMJJxezU4SPl6snqNtMB2jmmqEZI gWYdbhvrx7wK52yXAPyYii+Qsd2P15oslMumkPybRGRYAkVwgYDfuvC4u/kMK+cdikj9 pXYVGf2zks6Ec+f0mUqZzuZXBhtXttBxmty4uYfIt10PaovU0uaXFiEvAJ9aoK3pgaGQ dqAin5CmBmdu8aiFT94uF3P5JtUeQq5uFUBGwLAZunVtewNuUOzjdYzOBY5vFbpUHsPi 6o+gssA9WMPNh9ualVEvqF0/2cXQgXX0KCGaF9BJvBU0fzsdD3pshp1Qllzh8cVJ78If SSSg== X-Gm-Message-State: AOAM530k8deZyt/B1mJTb3S51Nr1HE+yrtdJPpccOLJegLJwIIWzceS/ +ybzq9jSEKsyBEpxlrjf7xP3Uw== X-Google-Smtp-Source: ABdhPJzHY64EG++nd35N4o4leJdZPgr4ww+GAtCkyM121JrTHzu2ZpD3eBZZIPQdYWLN/AIvWB/BkA== X-Received: by 2002:a05:6870:b408:b0:dd:ed4f:b1c7 with SMTP id x8-20020a056870b40800b000dded4fb1c7mr1258439oap.41.1651235925603; Fri, 29 Apr 2022 05:38:45 -0700 (PDT) Received: from fedora.sc.usp.br (gwsc.sc.usp.br. [143.107.225.16]) by smtp.gmail.com with ESMTPSA id e12-20020a4ae0cc000000b0035eb4e5a6d9sm705158oot.47.2022.04.29.05.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 05:38:45 -0700 (PDT) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Sylwester Nawrocki , Andrzej Hajda Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 1/2] media: s5c73m3: Replace legacy gpio interface for gpiod Date: Fri, 29 Apr 2022 09:37:39 -0300 Message-Id: <20220429123740.147703-2-maira.canal@usp.br> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429123740.147703-1-maira.canal@usp.br> References: <20220429123740.147703-1-maira.canal@usp.br> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Considering the current transition of the GPIO subsystem, remove all dependencies of the legacy GPIO interface (linux/gpio.h and linux /of_gpio.h) and replace it with the descriptor-based GPIO approach. Signed-off-by: Ma=C3=ADra Canal --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 95 ++++++++++-------------- drivers/media/i2c/s5c73m3/s5c73m3.h | 9 +-- include/media/i2c/s5c73m3.h | 15 +--- 3 files changed, 44 insertions(+), 75 deletions(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s= 5c73m3/s5c73m3-core.c index e2b88c5e4f98..8af785fbf25b 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -10,12 +10,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include #include @@ -1347,22 +1346,26 @@ static int s5c73m3_oif_open(struct v4l2_subdev *sd,= struct v4l2_subdev_fh *fh) return 0; } =20 -static int s5c73m3_gpio_set_value(struct s5c73m3 *priv, int id, u32 val) +static int s5c73m3_gpio_set_value(struct gpio_desc *gpio, int val) { - if (!gpio_is_valid(priv->gpio[id].gpio)) + if (!gpio) return 0; - gpio_set_value(priv->gpio[id].gpio, !!val); + gpiod_set_value(gpio, !!val); return 1; } =20 -static int s5c73m3_gpio_assert(struct s5c73m3 *priv, int id) +static int s5c73m3_gpio_assert(struct gpio_desc *gpio) { - return s5c73m3_gpio_set_value(priv, id, priv->gpio[id].level); + int val =3D gpiod_get_value(gpio); + + return s5c73m3_gpio_set_value(gpio, val); } =20 -static int s5c73m3_gpio_deassert(struct s5c73m3 *priv, int id) +static int s5c73m3_gpio_deassert(struct gpio_desc *gpio) { - return s5c73m3_gpio_set_value(priv, id, !priv->gpio[id].level); + int val =3D gpiod_get_value(gpio); + + return s5c73m3_gpio_set_value(gpio, !val); } =20 static int __s5c73m3_power_on(struct s5c73m3 *state) @@ -1386,10 +1389,10 @@ static int __s5c73m3_power_on(struct s5c73m3 *state) v4l2_dbg(1, s5c73m3_dbg, &state->oif_sd, "clock frequency: %ld\n", clk_get_rate(state->clock)); =20 - s5c73m3_gpio_deassert(state, STBY); + s5c73m3_gpio_deassert(state->gpio_stby); usleep_range(100, 200); =20 - s5c73m3_gpio_deassert(state, RSET); + s5c73m3_gpio_deassert(state->gpio_reset); usleep_range(50, 100); =20 return 0; @@ -1404,10 +1407,10 @@ static int __s5c73m3_power_off(struct s5c73m3 *stat= e) { int i, ret; =20 - if (s5c73m3_gpio_assert(state, RSET)) + if (s5c73m3_gpio_assert(state->gpio_reset)) usleep_range(10, 50); =20 - if (s5c73m3_gpio_assert(state, STBY)) + if (s5c73m3_gpio_assert(state->gpio_stby)) usleep_range(100, 200); =20 clk_disable_unprepare(state->clock); @@ -1545,50 +1548,34 @@ static const struct v4l2_subdev_ops oif_subdev_ops = =3D { =20 static int s5c73m3_configure_gpios(struct s5c73m3 *state) { - static const char * const gpio_names[] =3D { - "S5C73M3_STBY", "S5C73M3_RST" - }; struct i2c_client *c =3D state->i2c_client; - struct s5c73m3_gpio *g =3D state->gpio; - int ret, i; + struct device *dev =3D &c->dev; + struct device_node *np =3D dev->of_node; =20 - for (i =3D 0; i < GPIO_NUM; ++i) { - unsigned int flags =3D GPIOF_DIR_OUT; - if (g[i].level) - flags |=3D GPIOF_INIT_HIGH; - ret =3D devm_gpio_request_one(&c->dev, g[i].gpio, flags, - gpio_names[i]); - if (ret) { - v4l2_err(c, "failed to request gpio %s\n", - gpio_names[i]); - return ret; - } + state->gpio_stby =3D gpiod_get_from_of_node(np, "standby-gpios", 0, GPIOD= _ASIS, + "S5C73M3_STBY"); + + if (IS_ERR(state->gpio_stby)) { + v4l2_err(c, "failed to request gpio S5C73M3_STBY"); + return PTR_ERR(state->gpio_stby); } - return 0; -} =20 -static int s5c73m3_parse_gpios(struct s5c73m3 *state) -{ - static const char * const prop_names[] =3D { - "standby-gpios", "xshutdown-gpios", - }; - struct device *dev =3D &state->i2c_client->dev; - struct device_node *node =3D dev->of_node; - int ret, i; + if (state->gpio_stby) + gpiod_direction_output(state->gpio_stby, + !gpiod_is_active_low(state->gpio_stby)); =20 - for (i =3D 0; i < GPIO_NUM; ++i) { - enum of_gpio_flags of_flags; + state->gpio_reset =3D gpiod_get_from_of_node(np, "xshutdown-gpios", 0, GP= IOD_ASIS, + "S5C73M3_RST"); =20 - ret =3D of_get_named_gpio_flags(node, prop_names[i], - 0, &of_flags); - if (ret < 0) { - dev_err(dev, "failed to parse %s DT property\n", - prop_names[i]); - return -EINVAL; - } - state->gpio[i].gpio =3D ret; - state->gpio[i].level =3D !(of_flags & OF_GPIO_ACTIVE_LOW); + if (IS_ERR(state->gpio_reset)) { + v4l2_err(c, "failed to request gpio S5C73M3_RST"); + return PTR_ERR(state->gpio_reset); } + + if (state->gpio_reset) + gpiod_direction_output(state->gpio_reset, + !gpiod_is_active_low(state->gpio_reset)); + return 0; } =20 @@ -1608,8 +1595,8 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *= state) } =20 state->mclk_frequency =3D pdata->mclk_frequency; - state->gpio[STBY] =3D pdata->gpio_stby; - state->gpio[RSET] =3D pdata->gpio_reset; + state->gpio_stby =3D pdata->gpio_stby; + state->gpio_reset =3D pdata->gpio_reset; return 0; } =20 @@ -1624,10 +1611,6 @@ static int s5c73m3_get_platform_data(struct s5c73m3 = *state) state->mclk_frequency); } =20 - ret =3D s5c73m3_parse_gpios(state); - if (ret < 0) - return -EINVAL; - node_ep =3D of_graph_get_next_endpoint(node, NULL); if (!node_ep) { dev_warn(dev, "no endpoint defined for node: %pOF\n", node); diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m= 3/s5c73m3.h index c3fcfdd3ea66..f0056ae6e51a 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3.h +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h @@ -351,12 +351,6 @@ struct s5c73m3_ctrls { struct v4l2_ctrl *scene_mode; }; =20 -enum s5c73m3_gpio_id { - STBY, - RSET, - GPIO_NUM, -}; - enum s5c73m3_resolution_types { RES_ISP, RES_JPEG, @@ -383,7 +377,8 @@ struct s5c73m3 { u32 i2c_read_address; =20 struct regulator_bulk_data supplies[S5C73M3_MAX_SUPPLIES]; - struct s5c73m3_gpio gpio[GPIO_NUM]; + struct gpio_desc *gpio_stby; + struct gpio_desc *gpio_reset; =20 struct clk *clock; =20 diff --git a/include/media/i2c/s5c73m3.h b/include/media/i2c/s5c73m3.h index a51f1025ba1c..caad855a8394 100644 --- a/include/media/i2c/s5c73m3.h +++ b/include/media/i2c/s5c73m3.h @@ -17,19 +17,10 @@ #ifndef MEDIA_S5C73M3__ #define MEDIA_S5C73M3__ =20 +#include #include #include =20 -/** - * struct s5c73m3_gpio - data structure describing a GPIO - * @gpio: GPIO number - * @level: indicates active state of the @gpio - */ -struct s5c73m3_gpio { - int gpio; - int level; -}; - /** * struct s5c73m3_platform_data - s5c73m3 driver platform data * @mclk_frequency: sensor's master clock frequency in Hz @@ -44,8 +35,8 @@ struct s5c73m3_gpio { struct s5c73m3_platform_data { unsigned long mclk_frequency; =20 - struct s5c73m3_gpio gpio_reset; - struct s5c73m3_gpio gpio_stby; + struct gpio_desc *gpio_reset; + struct gpio_desc *gpio_stby; =20 enum v4l2_mbus_type bus_type; u8 nlanes; --=20 2.35.1 From nobody Sun May 10 16:25:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA89C433EF for ; Fri, 29 Apr 2022 12:39:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359424AbiD2Mmc (ORCPT ); Fri, 29 Apr 2022 08:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359431AbiD2MmX (ORCPT ); Fri, 29 Apr 2022 08:42:23 -0400 Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812F8C9B77 for ; Fri, 29 Apr 2022 05:38:50 -0700 (PDT) Received: by mail-oo1-xc2a.google.com with SMTP id c19-20020a4a3813000000b0035ea4a3b97eso1079069ooa.12 for ; Fri, 29 Apr 2022 05:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hv1PCf+XzDO3hkXoIiVts/K8+qjbqCrBljwvRZWyJFs=; b=BR070dtAgCfrI7G/Ipt+6yT2fuGmT1ftvPiR812mjsWIhGYXC5eOytF+eH/vWWk14L gKrMvm0AiNNOKRqGuI3nQoYgDOTGqDWIuu4+nR92hZ5DMpbWovxnTEi4A99adcIYozD6 u3B0fQyc/S1z1G7r24nnzhd7T5tXhbDI8xEgd4Ek+e9w5hAv82ru5v0ImZT9YVPkBEP8 Ijmp6UNQwKOcsNvcBS7DG/3qu3L1q/3dbb8rvV/eKS6Tb86mOxCDdowiFIKjnLhzWZX1 QWO8Wq6IWERCperKVegssFJ4JB4N7UlC8ktEP/RIiDk4Vt29gP2ZCUbowhKxyi3eX/p4 8fjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hv1PCf+XzDO3hkXoIiVts/K8+qjbqCrBljwvRZWyJFs=; b=NtEQY967GOuU8QUB6JO/pFCeALgOyfG2OZoxAn+G/80vTiFs2yBNOw22KvFlj3SJdQ VKpqJoYy3Q20bEmxFpDHAAtdYJWiDkHCS7YBZCpRl7p6+4BP2ijnUnCCaU2zxcUQdBt6 WsrNluj1UMD/TJFydmq5NeBKr35GFUgM/vzFg02/FS7nh/x4i3J/+R1uncbiDCnEzesk nE+hIT/AdDuA4mDrX37q+wooUBZGMdBjw/iR0keE2t+MmT6ncwj7au4RUgUnULnY+DBh 1Rowp2MQ616gKOSLOEGYugl4y6oex65lYlZfCxYPZbgW7M0ieKveWZ2mztvMeLiqTuqx Ov+w== X-Gm-Message-State: AOAM531h/w7fbnqbETpatiZi5JdnxsW8+Nek5+Vj86NhxOoyM0jXHpMA LOloGUBE/1BG5m3xO3lppng+Yg== X-Google-Smtp-Source: ABdhPJylvYNJ7ENkrIf452qlc0xbGCPtKL3CAi+0CPZL+kKiJVoTr8IkphGljZN4d8qxJTQws5YgyQ== X-Received: by 2002:a4a:e2ca:0:b0:35e:b623:8799 with SMTP id l10-20020a4ae2ca000000b0035eb6238799mr1211599oot.68.1651235929759; Fri, 29 Apr 2022 05:38:49 -0700 (PDT) Received: from fedora.sc.usp.br (gwsc.sc.usp.br. [143.107.225.16]) by smtp.gmail.com with ESMTPSA id e12-20020a4ae0cc000000b0035eb4e5a6d9sm705158oot.47.2022.04.29.05.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 05:38:49 -0700 (PDT) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Sylwester Nawrocki , Andrzej Hajda Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 2/2] dt-bindings: media: s5c73m3: Fix reset-gpio descriptor Date: Fri, 29 Apr 2022 09:37:40 -0300 Message-Id: <20220429123740.147703-3-maira.canal@usp.br> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429123740.147703-1-maira.canal@usp.br> References: <20220429123740.147703-1-maira.canal@usp.br> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The reset-gpios is described as xshutdown-gpios on the required properties, as it is on the driver. Despite that, the device tree example set the property 'reset-gpios' instead of the property 'xshutdown-gpios'. Therefore, this patch updates the example to match the property specified on the driver. Signed-off-by: Ma=C3=ADra Canal Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/media/samsung-s5c73m3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/samsung-s5c73m3.txt b/= Documentation/devicetree/bindings/media/samsung-s5c73m3.txt index 21f31fdf5543..f0ea9adad442 100644 --- a/Documentation/devicetree/bindings/media/samsung-s5c73m3.txt +++ b/Documentation/devicetree/bindings/media/samsung-s5c73m3.txt @@ -76,7 +76,7 @@ i2c@138a000000 { clock-frequency =3D <24000000>; clocks =3D <&clk 0>; clock-names =3D "cis_extclk"; - reset-gpios =3D <&gpf1 3 1>; + xshutdown-gpios =3D <&gpf1 3 1>; standby-gpios =3D <&gpm0 1 1>; port { s5c73m3_ep: endpoint { --=20 2.35.1