From patchwork Tue Nov 15 22:11:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2967407wru; Tue, 15 Nov 2022 14:17:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5haAQV1RLNYXlfi65AvgvQrTdMZ1B2xSAUtKvCJeqRRLdahO8iHIkkDCJazuLw/8WBqkhD X-Received: by 2002:a63:f658:0:b0:474:bbb:6523 with SMTP id u24-20020a63f658000000b004740bbb6523mr17877159pgj.476.1668550671226; Tue, 15 Nov 2022 14:17:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550671; cv=none; d=google.com; s=arc-20160816; b=q8FMSg0t+jTM6RNeFBFDM1cz7ip4k7zT01u8QXDlXOcs03DNYXpgFZwczuEuMQ/4l9 +eGrDXHWfM6inU8W5VG32AcTcL0RdDU7d95vhUTDhP21jWynpR1IswIoPZq3xWaNAzFo 98zex71DNnJyEcyuJ9ascij3te5S3fAXE3buFmyIjflm/HXnE0c8zhH6it0u1KKDbFjx XfE4jF8Mo/S3cYrDGUnPBMKhrV+gogoCylpMcgQHNbpH8u9S9k1ho0vEeRd8HysjpsMd MI9VAP41luCJsGUGEEsng+Eyeb0p4PpppGicMeuvl8lnI4XMdJdFbtj4+1ic3bbF6eOw tv7g== 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=Xt37wQQQ2UBMRQ+NV2HhjZPCcpOsAKHeXNbqwrzrV88=; b=EVdkH3JdAlagZBDGKqNgFeYFo/1bb6Voue9q+pdEx630CjwQKweF08hWkbh2nGHlX/ wmOfyWAv315ZrTkDUV4QMkh2aDKG5Gddk+Zyaa3HmJugT4VFmmTROaejRvQ3Db+GetoC q4Sy2VEP95EPhSGHJgPdYmlPW8FPYtlAPLfofEq4cuemYcRgt5vvNo6o7ZC0eSr9F5/p 4fRYcpoKn71Y11N1E21Bp2JppMWNr0V6SHRDJJ1I2clL379OD/VVHJryVMF2k1+5+oRW rANJuGsGHPedxOwgaaLR/bP6CVrNGAe3SrYvpyUsmYDzhiYw0Kcr8l+3G+3vEelpVrFM /b+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YkwZAzWU; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a63ab48000000b0044034f2c3b8si13173000pgp.310.2022.11.15.14.17.35; Tue, 15 Nov 2022 14:17:51 -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=YkwZAzWU; 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 S231203AbiKOWLx (ORCPT + 99 others); Tue, 15 Nov 2022 17:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbiKOWLw (ORCPT ); Tue, 15 Nov 2022 17:11:52 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7FF2715F; Tue, 15 Nov 2022 14:11:51 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id k5so14744579pjo.5; Tue, 15 Nov 2022 14:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xt37wQQQ2UBMRQ+NV2HhjZPCcpOsAKHeXNbqwrzrV88=; b=YkwZAzWUea0ahhsPHFNd25jYxc/z63BYkatRQ2FtDZ20WztyLg2G9ADtwKOcdLXmwg 9GNnJtuIvKz77+f4PyHZ624jBlXJQhAJ4uz/6wDD5BbCsreuX2INetEb5LAqctlCFtd5 4FuEmhURypmHAR54y1pDv71WKqnsTAcMsJupcgldgICRtd79jfURpN321025tLvFTUBy 2e8upnFgnSnFhU8UuFc+2fZow7m5WyIDtq3LwA4rEDwVyRRhih2aYL1FOoPlJo6Doz5u n7+M7x6b6//TwfoQWFFChE64fUnsuVXnwFmJsm0GYMuGvvbVBszpfrq6RJNlAzltfkGd iGjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xt37wQQQ2UBMRQ+NV2HhjZPCcpOsAKHeXNbqwrzrV88=; b=cqpWU9L3YHpT0VmpJlpG0NH0IoyMpE5Da7notjmYcWN5JsORnXAkzfyi7YX4Yvd1m6 jqO0GKLMbdf5MDcfx8kKjorBu6fFjiSqrFj01/4jI+WRV4Updjpz4WKKdPaG8KvATFED 3zTuisV1JZmGCx/4LiQSPcahXmCo5qUvZowonqA6eytyWkktbRPuKNLRYQmHdv2AjvPm TOKleL+1yCBNglR/h6ONUaOCFiBR/lM5KTfit+DYbs2Uo0RlQKtBFduOAFIF7orMCu6O OgX986irDExbwf6upvH2EQFTg5DjOoOKtQfKLBYY3VdqaAJ5SXlfKSd3N2ZPniVUUc0T 8inA== X-Gm-Message-State: ANoB5pkStksMn1HUkldFC22DnmzzFxUYTXOf9Ez9UUxXA8vLnJ8LVmFO b6JJCQaDFIPjbXJ2VUQoItp91TlPwBA= X-Received: by 2002:a17:90a:ca96:b0:212:d404:5513 with SMTP id y22-20020a17090aca9600b00212d4045513mr505081pjt.27.1668550310433; Tue, 15 Nov 2022 14:11:50 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 14:11:49 -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 1/4] media: i2c: s5k6a3: switch to using gpiod API Date: Tue, 15 Nov 2022 14:11:42 -0800 Message-Id: <20221115221145.2550572-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749602188251568580?= X-GMAIL-MSGID: =?utf-8?q?1749602188251568580?= This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes one of the last uses of of_get_gpio_flags(). Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij Reviewed-by: Tommaso Merciai --- drivers/media/i2c/s5k6a3.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index a4efd6d10b43..ef6673b10580 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -9,12 +9,12 @@ #include #include #include +#include #include -#include +#include #include #include #include -#include #include #include #include @@ -59,7 +59,7 @@ struct s5k6a3 { struct v4l2_subdev subdev; struct media_pad pad; struct regulator_bulk_data supplies[S5K6A3_NUM_SUPPLIES]; - int gpio_reset; + struct gpio_desc *gpio_reset; struct mutex lock; struct v4l2_mbus_framefmt format; struct clk *clock; @@ -216,11 +216,11 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor) goto error_clk; } - gpio_set_value(sensor->gpio_reset, 1); + gpiod_set_value_cansleep(sensor->gpio_reset, 0); usleep_range(600, 800); - gpio_set_value(sensor->gpio_reset, 0); + gpiod_set_value_cansleep(sensor->gpio_reset, 1); usleep_range(600, 800); - gpio_set_value(sensor->gpio_reset, 1); + gpiod_set_value_cansleep(sensor->gpio_reset, 0); /* Delay needed for the sensor initialization */ msleep(20); @@ -240,7 +240,7 @@ static int __s5k6a3_power_off(struct s5k6a3 *sensor) { int i; - gpio_set_value(sensor->gpio_reset, 0); + gpiod_set_value_cansleep(sensor->gpio_reset, 1); for (i = S5K6A3_NUM_SUPPLIES - 1; i >= 0; i--) regulator_disable(sensor->supplies[i].consumer); @@ -285,32 +285,24 @@ static int s5k6a3_probe(struct i2c_client *client) struct device *dev = &client->dev; struct s5k6a3 *sensor; struct v4l2_subdev *sd; - int gpio, i, ret; + int i, ret; sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); if (!sensor) return -ENOMEM; mutex_init(&sensor->lock); - sensor->gpio_reset = -EINVAL; - sensor->clock = ERR_PTR(-EINVAL); sensor->dev = dev; sensor->clock = devm_clk_get(sensor->dev, S5K6A3_CLK_NAME); if (IS_ERR(sensor->clock)) return PTR_ERR(sensor->clock); - gpio = of_get_gpio_flags(dev->of_node, 0, NULL); - if (!gpio_is_valid(gpio)) - return gpio; - - ret = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_LOW, - S5K6A3_DRV_NAME); - if (ret < 0) + sensor->gpio_reset = devm_gpiod_get(dev, NULL, GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(sensor->gpio_reset); + if (ret) return ret; - sensor->gpio_reset = gpio; - if (of_property_read_u32(dev->of_node, "clock-frequency", &sensor->clock_frequency)) { sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ;