From patchwork Mon Jan 30 13:09:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13121372 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7987DC54EAA for ; Mon, 30 Jan 2023 15:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=U0NjRENgEboZAnn1fOLCwxct1kQrWsVCWFlzRAAe84I=; b=F6YGDPhK/6fosc RdhW9RmFimZy2OaydyjUtt7W5011eQY0+7xR4n4C4DIq3K2j11LU2iuIocTfIZH9dpV3Bc95mpvNi L4PAJCEB1WTvwfI4y+3Eu6oL5LLjANhnhsnfc2N9l64689lf110srRjVDHRD4rzSbS6++KOzowQWH wCdAer7ul5QE6wa0qXQeZrtRFcnvNqXaF4CqYAnbuNfPKgrkeO2MPdEKBhiEFAT9hkYHcwhjBy3Id NqrBI5s4M+dxO+brrHX7IsZ/3DLTIPAl6vJ76AJOZNVcE0CyOKAdo2PB5C2QAvnrHzk/Faw8XmYJM 3wLM2rRyudBHa/wDLFrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMWFX-00441G-O3; Mon, 30 Jan 2023 15:39:15 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMWEw-0043zC-Jb for linux-arm-kernel@lists.infradead.org; Mon, 30 Jan 2023 15:38:40 +0000 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 668A1B810B2; 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 To: Patrice Chotard , Mauro Carvalho Chehab Cc: Arnd Bergmann , Andy Shevchenko , Hans Verkuil , Hugues Fruchet , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230130_073838_937939_B335657D X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann 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 Reviewed-by: Andy Shevchenko --- .../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 #include #include -#include +#include #include #include #include @@ -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;