Message ID | 20230130131003.668888-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2173820wrn; Mon, 30 Jan 2023 05:19:12 -0800 (PST) X-Google-Smtp-Source: AK7set8hdm04nAl67hXO4mBUrUnvGoakEHgJVtEf5l9Toykr4m5mVcaxElvHJvMzdPIFnslSpoo6 X-Received: by 2002:a17:902:e547:b0:196:47f0:50b6 with SMTP id n7-20020a170902e54700b0019647f050b6mr17371563plf.47.1675084752210; Mon, 30 Jan 2023 05:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675084752; cv=none; d=google.com; s=arc-20160816; b=iEyE40EZaMKnuB6TBIxndcchcEIThfYJAqSq7jD4I8taLWmQNWmsSD+TNvymcHlPd+ ZzTUIMYJpY4Ned4AxEwekifmKwCYOO8EXBFSi/s2v9N708V1PDD6etPAsRjh1uSWmuvJ z/2gjVihUVI6ptME/yDlkdMqEv7eycKPkfD4iQTNM31ppjORsEE/VzMfBFOEmXUgQidG GnMwoJoysuR4/m24vldEzhvZrV0tpfU0GcgZDB+k3oRfdxbkpK1PsqiS4Mb1s+8KUzVz /m1Go6EiUc2sGjQPiH+gJMXhx4DnRMBvnTJXcHpTeLhuHfOSCsNKcbqRd58gknBUIJlx oLwQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=9HPebHdwAkY/yEvpr+VD8ZugebL5X0C6ifrGPyWfKx4=; b=XjSWfY3OpTAmD34HInXJtlAmz6i93GghUiAGnB9iRSaczX0ZKStlSNagbibFGoLTNu lm5PTYD0aUCkBL2KTa7gBa3vrNXx/S/oBmW3bLGpviwPhPF5M8sQZ/CoA9KQojpuNTBz /h+5jaAlb8HYG9UpTOJDHqC3iJrSQ7WR13X6txsAm8smn7RB1RADqg0T6tmzrigOQoT7 a4t6OTEmTLw/ZEZ8+yEb2uKMh1kmLAa/IaUea5w2/DVF/31JPzze8fVuVEQ4owSKzLPH ALKzWt5u3muUKQXNHcnViGjIEFD8whENrJBBVElYnOVc9ABwReyDL9iXIOf20i045ZrH PJww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=soqa2bDo; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a17090301c300b00181dc40f516si512498plh.146.2023.01.30.05.18.57; Mon, 30 Jan 2023 05:19:12 -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=@kernel.org header.s=k20201202 header.b=soqa2bDo; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235662AbjA3NKU (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Mon, 30 Jan 2023 08:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjA3NKO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 30 Jan 2023 08:10:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B327D11671; Mon, 30 Jan 2023 05:10:09 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C272B810B3; Mon, 30 Jan 2023 13:10:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15CECC433EF; Mon, 30 Jan 2023 13:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675084207; bh=bZA+wZr8NdCCPrh2rvo5BbcTdhiDb0tNcViWpZHHSXQ=; h=From:To:Cc:Subject:Date:From; b=soqa2bDobZh0j+klshJUgTokPs/tiAaXd7xgN/pvhIgN1i63K+wcslJsMvSHsf0Cx s0gKXrHchYiZgOWOMQRsnEeQGe/JX5GA9fESpmdsgVMzpRfK/tFWg85YeRSq7LXUB3 U4u1swXhRK1sAP/KSO/zhaA4iHlBSy0hy1m1cN0/pOKY0UK+mB6CQu8UCGB8u9oxVe u8OfoAk1MdhSsQBK1yrbPBcBwSKjAY1leK/5gxJMr4p4bzWAy6lzAK1sTs8iIMQjm4 id7tHX34c5wMtDgBH+SpzqjbtbBE3O1vcQOn8zE3n0VGwo5sXwcA2bLniZPQKGBKoI Mla4/YvUqwuyg== From: Arnd Bergmann <arnd@kernel.org> To: Patrice Chotard <patrice.chotard@foss.st.com>, Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Hugues Fruchet <hugues.fruchet@st.com>, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: c8sectpfe: convert to gpio descriptors Date: Mon, 30 Jan 2023 14:09:47 +0100 Message-Id: <20230130131003.668888-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756453668945950186?= X-GMAIL-MSGID: =?utf-8?q?1756453668945950186?= |
Series |
media: c8sectpfe: convert to gpio descriptors
|
|
Commit Message
Arnd Bergmann
Jan. 30, 2023, 1:09 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> The gpio usage in the function is fairly straightforward, but the normal gpiod_get() interface cannot be used here since the gpio is referenced by a child node of the device. Using devm_fwnode_gpiod_get_index() is the best alternative here. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- .../st/sti/c8sectpfe/c8sectpfe-core.c | 30 ++++++++----------- .../st/sti/c8sectpfe/c8sectpfe-core.h | 2 +- 2 files changed, 13 insertions(+), 19 deletions(-)
Comments
On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The gpio usage in the function is fairly straightforward, > but the normal gpiod_get() interface cannot be used here > since the gpio is referenced by a child node of the device. > > Using devm_fwnode_gpiod_get_index() is the best alternative > here. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> One topic to discuss below (but I'm fine with this version). > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > .../st/sti/c8sectpfe/c8sectpfe-core.c | 30 ++++++++----------- > .../st/sti/c8sectpfe/c8sectpfe-core.h | 2 +- > 2 files changed, 13 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > index c38b62d4f1ae..86a2c77c5471 100644 > --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > @@ -22,7 +22,7 @@ > #include <linux/interrupt.h> > #include <linux/io.h> > #include <linux/module.h> > -#include <linux/of_gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/of_platform.h> > #include <linux/pinctrl/consumer.h> > #include <linux/pinctrl/pinctrl.h> > @@ -812,30 +812,24 @@ static int c8sectpfe_probe(struct platform_device *pdev) > } > of_node_put(i2c_bus); > > - tsin->rst_gpio = of_get_named_gpio(child, "reset-gpios", 0); > - > - ret = gpio_is_valid(tsin->rst_gpio); > - if (!ret) { > - dev_err(dev, > - "reset gpio for tsin%d not valid (gpio=%d)\n", > - tsin->tsin_id, tsin->rst_gpio); > - ret = -EINVAL; > - goto err_node_put; > - } > - > - ret = devm_gpio_request_one(dev, tsin->rst_gpio, > - GPIOF_OUT_INIT_LOW, "NIM reset"); > + tsin->rst_gpio = devm_fwnode_gpiod_get_index(dev, > + of_node_to_fwnode(child), > + "reset-gpios", > + 0, GPIOD_OUT_LOW, > + "NIM reset"); > + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); > if (ret && ret != -EBUSY) { > - dev_err(dev, "Can't request tsin%d reset gpio\n" > - , fei->channel_data[index]->tsin_id); > + dev_err_probe(dev, ret, > + "reset gpio for tsin%d not valid\n", > + tsin->tsin_id); > goto err_node_put; > } > > if (!ret) { Can be if (IS_ERR() && PTR_ERR() != -EBUSY) { ret = dev_err_probe(dev, PTR_ERR(), ...); ... } if (!IS_ERR()) (Up to you) But -EBUSY check seems strange to me. What was the motivation behind? (As far as I can read the code the possibility to get this if and only if we have requested GPIO too early at initcall level. Would it be ever a possibility to get it in real life?) > /* toggle reset lines */ > - gpio_direction_output(tsin->rst_gpio, 0); > + gpiod_direction_output(tsin->rst_gpio, 0); > usleep_range(3500, 5000); > - gpio_direction_output(tsin->rst_gpio, 1); > + gpiod_direction_output(tsin->rst_gpio, 1); > usleep_range(3000, 5000); > } > > diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h > index c9d6021904cd..f2a6991e064e 100644 > --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h > +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h > @@ -25,7 +25,7 @@ struct channel_info { > int i2c; > int dvb_card; > > - int rst_gpio; > + struct gpio_desc *rst_gpio; > > struct i2c_adapter *i2c_adapter; > struct i2c_adapter *tuner_i2c; > -- > 2.39.0 >
On Mon, Jan 30, 2023, at 18:18, Andy Shevchenko wrote: > On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: >> + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); >> if (ret && ret != -EBUSY) { >> - dev_err(dev, "Can't request tsin%d reset gpio\n" >> - , fei->channel_data[index]->tsin_id); >> + dev_err_probe(dev, ret, >> + "reset gpio for tsin%d not valid\n", >> + tsin->tsin_id); >> goto err_node_put; >> } >> >> if (!ret) { > > Can be > > if (IS_ERR() && PTR_ERR() != -EBUSY) { > ret = dev_err_probe(dev, PTR_ERR(), ...); > ... > } > > if (!IS_ERR()) > > (Up to you) I prefer the version that only has one PTR_ERR(), but either way is fine with me. > But -EBUSY check seems strange to me. What was the motivation behind? > (As far as I can read the code the possibility to get this if and only > if we have requested GPIO too early at initcall level. Would it be > ever a possibility to get it in real life?) I noticed this part as being odd as well, no idea why the code is like this. I just left the logic unchanged here. Arnd
On Mon, Jan 30, 2023 at 5:31 AM Arnd Bergmann <arnd@kernel.org> wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > The gpio usage in the function is fairly straightforward, > but the normal gpiod_get() interface cannot be used here > since the gpio is referenced by a child node of the device. > > Using devm_fwnode_gpiod_get_index() is the best alternative > here. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > .../st/sti/c8sectpfe/c8sectpfe-core.c | 30 ++++++++----------- > .../st/sti/c8sectpfe/c8sectpfe-core.h | 2 +- > 2 files changed, 13 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > index c38b62d4f1ae..86a2c77c5471 100644 > --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c > @@ -22,7 +22,7 @@ > #include <linux/interrupt.h> > #include <linux/io.h> > #include <linux/module.h> > -#include <linux/of_gpio.h> > +#include <linux/gpio/consumer.h> > #include <linux/of_platform.h> > #include <linux/pinctrl/consumer.h> > #include <linux/pinctrl/pinctrl.h> > @@ -812,30 +812,24 @@ static int c8sectpfe_probe(struct platform_device *pdev) > } > of_node_put(i2c_bus); > > - tsin->rst_gpio = of_get_named_gpio(child, "reset-gpios", 0); > - > - ret = gpio_is_valid(tsin->rst_gpio); > - if (!ret) { > - dev_err(dev, > - "reset gpio for tsin%d not valid (gpio=%d)\n", > - tsin->tsin_id, tsin->rst_gpio); > - ret = -EINVAL; > - goto err_node_put; > - } > - > - ret = devm_gpio_request_one(dev, tsin->rst_gpio, > - GPIOF_OUT_INIT_LOW, "NIM reset"); > + tsin->rst_gpio = devm_fwnode_gpiod_get_index(dev, > + of_node_to_fwnode(child), > + "reset-gpios", Wrong name. > + 0, GPIOD_OUT_LOW, > + "NIM reset"); > + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); > if (ret && ret != -EBUSY) { > - dev_err(dev, "Can't request tsin%d reset gpio\n" > - , fei->channel_data[index]->tsin_id); > + dev_err_probe(dev, ret, > + "reset gpio for tsin%d not valid\n", > + tsin->tsin_id); > goto err_node_put; > } > > if (!ret) { > /* toggle reset lines */ > - gpio_direction_output(tsin->rst_gpio, 0); > + gpiod_direction_output(tsin->rst_gpio, 0); It is already set up as output, and you either need to use "raw" or fix polarity. > usleep_range(3500, 5000); > - gpio_direction_output(tsin->rst_gpio, 1); > + gpiod_direction_output(tsin->rst_gpio, 1); > usleep_range(3000, 5000); > } Thanks.
On Tue, Jan 31, 2023 at 07:29:37PM -0800, Dmitry Torokhov wrote: > On Mon, Jan 30, 2023 at 5:31 AM Arnd Bergmann <arnd@kernel.org> wrote: ... > > + tsin->rst_gpio = devm_fwnode_gpiod_get_index(dev, > > + of_node_to_fwnode(child), Actually, please use of_fwnode_handle() and not IRQ framework custom grown duplicate. > > + "reset-gpios", > > Wrong name. > > > + 0, GPIOD_OUT_LOW, > > + "NIM reset");
On Mon, Jan 30, 2023 at 10:19 AM Arnd Bergmann <arnd@arndb.de> wrote: > > On Mon, Jan 30, 2023, at 18:18, Andy Shevchenko wrote: > > On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > > >> + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); > >> if (ret && ret != -EBUSY) { > >> - dev_err(dev, "Can't request tsin%d reset gpio\n" > >> - , fei->channel_data[index]->tsin_id); > >> + dev_err_probe(dev, ret, > >> + "reset gpio for tsin%d not valid\n", > >> + tsin->tsin_id); > >> goto err_node_put; > >> } > >> > >> if (!ret) { > > > > Can be > > > > if (IS_ERR() && PTR_ERR() != -EBUSY) { > > ret = dev_err_probe(dev, PTR_ERR(), ...); > > ... > > } > > > > if (!IS_ERR()) > > > > (Up to you) > > I prefer the version that only has one PTR_ERR(), but > either way is fine with me. > > > But -EBUSY check seems strange to me. What was the motivation behind? > > (As far as I can read the code the possibility to get this if and only > > if we have requested GPIO too early at initcall level. Would it be > > ever a possibility to get it in real life?) > > I noticed this part as being odd as well, no idea why the > code is like this. I just left the logic unchanged here. It could be they were trying to account for the possibility of the reset line being shared between several blocks, and so the first one to initialize would grab it and reset all chips, and the followers would be skipping the reset logic.
Hi Arnd, On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The gpio usage in the function is fairly straightforward, > but the normal gpiod_get() interface cannot be used here > since the gpio is referenced by a child node of the device. > > Using devm_fwnode_gpiod_get_index() is the best alternative > here. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> I've picked <URL:https://patchwork.linuxtv.org/project/linux-media/patch/20230130131003.668888-1-arnd@kernel.org/> instead. I hope that's fine. Also cc Dmitry.
On Wed, May 17, 2023 at 09:21:00PM +0300, Sakari Ailus wrote: > Hi Arnd, > > On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > > > The gpio usage in the function is fairly straightforward, > > but the normal gpiod_get() interface cannot be used here > > since the gpio is referenced by a child node of the device. > > > > Using devm_fwnode_gpiod_get_index() is the best alternative > > here. > > > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > I've picked > <URL:https://patchwork.linuxtv.org/project/linux-media/patch/20230130131003.668888-1-arnd@kernel.org/> > instead. I hope that's fine. Also cc Dmitry. What do you mean "instead"? This is the exact patch that started this thread, and it is broken (uses wrong name of the GPIO and wrong polarity). I'd much rather you picked up https://lore.kernel.org/all/Y92VLGLQJZ%2FUDRx1@google.com/ Thanks.
Hi Dmitry, On Wed, May 17, 2023 at 12:12:05PM -0700, Dmitry Torokhov wrote: > On Wed, May 17, 2023 at 09:21:00PM +0300, Sakari Ailus wrote: > > Hi Arnd, > > > > On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > > > From: Arnd Bergmann <arnd@arndb.de> > > > > > > The gpio usage in the function is fairly straightforward, > > > but the normal gpiod_get() interface cannot be used here > > > since the gpio is referenced by a child node of the device. > > > > > > Using devm_fwnode_gpiod_get_index() is the best alternative > > > here. > > > > > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > > > I've picked > > <URL:https://patchwork.linuxtv.org/project/linux-media/patch/20230130131003.668888-1-arnd@kernel.org/> > > instead. I hope that's fine. Also cc Dmitry. > > What do you mean "instead"? This is the exact patch that started this > thread, and it is broken (uses wrong name of the GPIO and wrong polarity). > > I'd much rather you picked up > https://lore.kernel.org/all/Y92VLGLQJZ%2FUDRx1@google.com/ > > Thanks. Ah, the URL in my e-mail was wrong. I have <URL:https://patchwork.linuxtv.org/project/linux-media/patch/Y92VLGLQJZ/UDRx1@google.com/>, i.e. the same patch.
On Wed, May 17, 2023 at 10:26:17PM +0300, Sakari Ailus wrote: > Hi Dmitry, > > On Wed, May 17, 2023 at 12:12:05PM -0700, Dmitry Torokhov wrote: > > On Wed, May 17, 2023 at 09:21:00PM +0300, Sakari Ailus wrote: > > > Hi Arnd, > > > > > > On Mon, Jan 30, 2023 at 02:09:47PM +0100, Arnd Bergmann wrote: > > > > From: Arnd Bergmann <arnd@arndb.de> > > > > > > > > The gpio usage in the function is fairly straightforward, > > > > but the normal gpiod_get() interface cannot be used here > > > > since the gpio is referenced by a child node of the device. > > > > > > > > Using devm_fwnode_gpiod_get_index() is the best alternative > > > > here. > > > > > > > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > > > > > I've picked > > > <URL:https://patchwork.linuxtv.org/project/linux-media/patch/20230130131003.668888-1-arnd@kernel.org/> > > > instead. I hope that's fine. Also cc Dmitry. > > > > What do you mean "instead"? This is the exact patch that started this > > thread, and it is broken (uses wrong name of the GPIO and wrong polarity). > > > > I'd much rather you picked up > > https://lore.kernel.org/all/Y92VLGLQJZ%2FUDRx1@google.com/ > > > > Thanks. > > Ah, the URL in my e-mail was wrong. I have > <URL:https://patchwork.linuxtv.org/project/linux-media/patch/Y92VLGLQJZ/UDRx1@google.com/>, > i.e. the same patch. Ah, I see, thank you.
diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c index c38b62d4f1ae..86a2c77c5471 100644 --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c @@ -22,7 +22,7 @@ #include <linux/interrupt.h> #include <linux/io.h> #include <linux/module.h> -#include <linux/of_gpio.h> +#include <linux/gpio/consumer.h> #include <linux/of_platform.h> #include <linux/pinctrl/consumer.h> #include <linux/pinctrl/pinctrl.h> @@ -812,30 +812,24 @@ static int c8sectpfe_probe(struct platform_device *pdev) } of_node_put(i2c_bus); - tsin->rst_gpio = of_get_named_gpio(child, "reset-gpios", 0); - - ret = gpio_is_valid(tsin->rst_gpio); - if (!ret) { - dev_err(dev, - "reset gpio for tsin%d not valid (gpio=%d)\n", - tsin->tsin_id, tsin->rst_gpio); - ret = -EINVAL; - goto err_node_put; - } - - ret = devm_gpio_request_one(dev, tsin->rst_gpio, - GPIOF_OUT_INIT_LOW, "NIM reset"); + tsin->rst_gpio = devm_fwnode_gpiod_get_index(dev, + of_node_to_fwnode(child), + "reset-gpios", + 0, GPIOD_OUT_LOW, + "NIM reset"); + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); if (ret && ret != -EBUSY) { - dev_err(dev, "Can't request tsin%d reset gpio\n" - , fei->channel_data[index]->tsin_id); + dev_err_probe(dev, ret, + "reset gpio for tsin%d not valid\n", + tsin->tsin_id); goto err_node_put; } if (!ret) { /* toggle reset lines */ - gpio_direction_output(tsin->rst_gpio, 0); + gpiod_direction_output(tsin->rst_gpio, 0); usleep_range(3500, 5000); - gpio_direction_output(tsin->rst_gpio, 1); + gpiod_direction_output(tsin->rst_gpio, 1); usleep_range(3000, 5000); } diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h index c9d6021904cd..f2a6991e064e 100644 --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h @@ -25,7 +25,7 @@ struct channel_info { int i2c; int dvb_card; - int rst_gpio; + struct gpio_desc *rst_gpio; struct i2c_adapter *i2c_adapter; struct i2c_adapter *tuner_i2c;