Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7560746rwb; Tue, 15 Nov 2022 14:20:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf7OS4ewlFwJasRhhYaoYo9gIUyvGM91FHA9tlsBX9j1VNASbuiR3m53nYjv0OyaVKijRMWN X-Received: by 2002:a17:90a:b304:b0:213:f398:ed51 with SMTP id d4-20020a17090ab30400b00213f398ed51mr425305pjr.216.1668550829263; Tue, 15 Nov 2022 14:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550829; cv=none; d=google.com; s=arc-20160816; b=gAxI7xQLx0DrHQJBnlqWvXe3zV0pIj5UUxuB+Xs+7afb8Bq3od8RgfpnhjzykD9g93 brkVQROJXbVKrVXLv8rPjwRA0qNQVhVp0VWl1yx8FGc4M/C8XkMUW859c0GnnZ+o6KqM Uv0tDyTNa8ZHK/TwHFTnavzn7zAc03DBKb8m3eHr7fzMz9doXks418ol0oSGrFrL9cF8 9T4AKKgQBhqc5DWn2Zt5elog3xgQ+t/c85Zj4c/PYHr6iGkTnby0YxaAeDiE06liB17q w1i/+jXk/wE8zQGr7+S9vgkYZ3I4wndiXpYoc5iwQ5ZMU3BUL/iKb9AZl2E/6JZCwkYg Ew0A== 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=OrZfenAnf9sYON4n47hNey76ONHNUDUWnON3//izvEc=; b=egMODqrlM+1kntoU94V35JdqqNn2dG0auY/aU+U0+jSQVI12yigF4x2AJPG6pTzOp7 Hki5wpq1AfK60RdHzldMi+EeH0RjgR7sKsb50sJkxeGmJvjOTRL4/QfiKFR86vPn/fIJ 3mp1+wCA4f4XWAiHxu1LlVo3odGoQWvDez+YL1dDBACClOevPWKyXyu5GSG9q3LEshaO qLRojEuLCfCpdzgTwgZ7D26BjD1VANYUl6ljS1pMDRACBjZ9Rn/YYzOeb3spCeh5C0Lk w+Tla5K/JA7N3FHGibvjIqhTIV2CE0DGcn1mYQlo3VTVCoNF17mw/3UMm/ej7SKB4ucP XKHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kiQkSeD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a1709027c1100b0018863e1bc39si12095921pll.248.2022.11.15.14.20.16; Tue, 15 Nov 2022 14:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kiQkSeD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238381AbiKOWMI (ORCPT + 90 others); Tue, 15 Nov 2022 17:12:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbiKOWL6 (ORCPT ); Tue, 15 Nov 2022 17:11:58 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D183120C; Tue, 15 Nov 2022 14:11:56 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso427645pjc.2; Tue, 15 Nov 2022 14:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OrZfenAnf9sYON4n47hNey76ONHNUDUWnON3//izvEc=; b=kiQkSeD9f7oaGu/M9BkH6RjD6Au08SNhthZGu5aQbxMFaUJ5W7YNSXB7Y5t4fx2EN5 FD/kK2AToQ6cOJeISWZ+H/U9ixFbaJbdlp+noFxYE3AbnaXIGFBYBo3fEaAMxqaz+fjs GEb3zHIQSlXeJpslI8BBRyoRnwYfuGSKzB9sXlwcMxku7qGoby//GhXV4pJ7dgney+WQ yGS/VNqUR91DmxqRz1g+JK/kRclX9jcE/hl6rVn6DvjcqKXjvMPf9yilCwl+s7U1Wpji rBkPsmYXV/7zTu56lTk+r+M372/7FaP7VlGwTPtpAxv1hyOOKMa6arR10oY8KxkudKyE Mf2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OrZfenAnf9sYON4n47hNey76ONHNUDUWnON3//izvEc=; b=MP3X3CZ2bV5tpHJvYdBknV4AqZSH80tIWQS7KcCroazXn3m9KosnBet4vTf3eaCEeG UK12klM3Y2RCcuUUgS9LZ4AHPjC29SzPm3giG/lvVwX+K82ldNDu+LJCzRRXo9dA9sDf zLZpzlX+V1E3XcXRCsQvgooQiMa60oOoWKQg1wD2JwTAL7gKkEGrWSVrSXjSF4xPV9dm yUJGwYfA0rNitpKkCV8T3CZjJbGlkXW2sS1z/VAnCPABvDVVM0fr4K4WarpQ7N5aMwfk JDKFB/Hb6w68H/T43wJ58Pqa244aJU14qCweYs+EY9AteAmv95Hj+lqE05WDKr5vkklx HgLw== X-Gm-Message-State: ANoB5pnihnFt658EVT5N4OsPNK6TyMz9UrgRedrcJ9kp0fNLeEwfugUP ijsTbxnzhG6mDLxCS40QJ4M= X-Received: by 2002:a17:902:76c5:b0:187:282c:9b95 with SMTP id j5-20020a17090276c500b00187282c9b95mr6140760plt.41.1668550316213; Tue, 15 Nov 2022 14:11:56 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:2d36:e9a0:170b:669f]) by smtp.gmail.com with ESMTPSA id y1-20020a17090264c100b00178b6ccc8a0sm10400038pli.51.2022.11.15.14.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 14:11:55 -0800 (PST) From: Dmitry Torokhov To: Mauro Carvalho Chehab Cc: Sylwester Nawrocki , Andrzej Hajda , Linus Walleij , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 4/4] media: i2c: s5c73m3: switch to using gpiod API Date: Tue, 15 Nov 2022 14:11:45 -0800 Message-Id: <20221115221145.2550572-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221115221145.2550572-1-dmitry.torokhov@gmail.com> References: <20221115221145.2550572-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. Signed-off-by: Dmitry Torokhov --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 63 +++++++----------------- drivers/media/i2c/s5c73m3/s5c73m3.h | 7 +-- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 561c1a1583ac..f1e073ed5f99 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 @@ -1348,20 +1347,20 @@ static int s5c73m3_oif_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) static int s5c73m3_gpio_set_value(struct s5c73m3 *priv, int id, u32 val) { - if (!gpio_is_valid(priv->gpio[id].gpio)) + if (!priv->gpio[id]) return 0; - gpio_set_value(priv->gpio[id].gpio, !!val); + gpiod_set_value_cansleep(priv->gpio[id], val); return 1; } static int s5c73m3_gpio_assert(struct s5c73m3 *priv, int id) { - return s5c73m3_gpio_set_value(priv, id, priv->gpio[id].level); + return s5c73m3_gpio_set_value(priv, id, 1); } static int s5c73m3_gpio_deassert(struct s5c73m3 *priv, int id) { - return s5c73m3_gpio_set_value(priv, id, !priv->gpio[id].level); + return s5c73m3_gpio_set_value(priv, id, 0); } static int __s5c73m3_power_on(struct s5c73m3 *state) @@ -1544,49 +1543,29 @@ static const struct v4l2_subdev_ops oif_subdev_ops = { static int s5c73m3_configure_gpios(struct s5c73m3 *state) { - static const char * const gpio_names[] = { - "S5C73M3_STBY", "S5C73M3_RST" - }; + static const char * const name[] = { "standby", "xshutdown" }; + static const char * const label[] = { "S5C73M3_STBY", "S5C73M3_RST" }; struct i2c_client *c = state->i2c_client; - struct s5c73m3_gpio *g = state->gpio; + struct gpio_desc *gpio; int ret, i; for (i = 0; i < GPIO_NUM; ++i) { - unsigned int flags = GPIOF_DIR_OUT; - if (g[i].level) - flags |= GPIOF_INIT_HIGH; - ret = devm_gpio_request_one(&c->dev, g[i].gpio, flags, - gpio_names[i]); + gpio = devm_gpiod_get(&c->dev, name[i], GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(gpio); if (ret) { - v4l2_err(c, "failed to request gpio %s\n", - gpio_names[i]); + v4l2_err(c, "failed to request gpio %s: %d\n", + name[i], ret); return ret; } - } - return 0; -} - -static int s5c73m3_parse_gpios(struct s5c73m3 *state) -{ - static const char * const prop_names[] = { - "standby-gpios", "xshutdown-gpios", - }; - struct device *dev = &state->i2c_client->dev; - struct device_node *node = dev->of_node; - int ret, i; - for (i = 0; i < GPIO_NUM; ++i) { - enum of_gpio_flags of_flags; - - ret = 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; + ret = gpiod_set_consumer_name(gpio, label[i]); + if (ret) { + v4l2_err(c, "failed to set up name for gpio %s: %d\n", + name[i], ret); + return ret; } - state->gpio[i].gpio = ret; - state->gpio[i].level = !(of_flags & OF_GPIO_ACTIVE_LOW); + + state->gpio[i] = gpio; } return 0; } @@ -1613,10 +1592,6 @@ static int s5c73m3_get_dt_data(struct s5c73m3 *state) state->mclk_frequency); } - ret = s5c73m3_parse_gpios(state); - if (ret < 0) - return -EINVAL; - node_ep = 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/s5c73m3/s5c73m3.h index d68528898249..9887d03fcdeb 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3.h +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h @@ -356,11 +356,6 @@ enum s5c73m3_gpio_id { GPIO_NUM, }; -struct s5c73m3_gpio { - int gpio; - int level; -}; - enum s5c73m3_resolution_types { RES_ISP, RES_JPEG, @@ -387,7 +382,7 @@ struct s5c73m3 { u32 i2c_read_address; struct regulator_bulk_data supplies[S5C73M3_MAX_SUPPLIES]; - struct s5c73m3_gpio gpio[GPIO_NUM]; + struct gpio_desc *gpio[GPIO_NUM]; struct clk *clock; -- 2.38.1.431.g37b22c650d-goog