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; From patchwork Tue Nov 15 22:11:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2967481wru; Tue, 15 Nov 2022 14:18:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf506TRvzT1DZm+lSWChddl8nIqJlD/yOQuhSLk4db98JMEByXyFsjGYaqtRiBnR7fQ7MAie X-Received: by 2002:a17:906:488a:b0:7ad:9893:fba9 with SMTP id v10-20020a170906488a00b007ad9893fba9mr15129973ejq.62.1668550685101; Tue, 15 Nov 2022 14:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550685; cv=none; d=google.com; s=arc-20160816; b=QxTQUfM15iJE81AcO0aO7/rG5TvRDnCSyp3UPfCpG+B5qthuEyS2ZaGb3dZKpQ5TJH xGpxY76AnE6kL4EC/+JgIzWs5u/T+OY07XjcTj+vsDJ4IxTekUUEMkbYg6E5aPq+/Gz0 /eDk/jeJbNwRRCDMoMZU2q4ttrHxiu12VK0weMewuV2WYKKje/CKhly4vOJJcokjnWRe QS4lx98PMFRxZUshr4XPuIXrx310zLMFVnetmVBiCvUzdJO+g8VG1PF+rsAicmqGMuFV fOsrXwrtMBYqwyTVsVOJSw4LFJlHBfVLsMcII/9D8nZALKP+fA1LPOLPn9jaSFk95PbW UyOA== 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=0FfC6mdt0ik5bfv6PbUvOpPqpC/h2diKZQ8Yf0+D53Q=; b=OGew6OH+GkKUNQhQPl8NBSRZtjBsIQh9Pby7CJDcK4tS+SRTZdUF2fgt8A/DZkiixc eykdpLOlzim8zNqTjCvTiOIgJPq7ZX6FfOd5IYTa1/+cJwYK2uQnM4wEuxyS1g88Xk7R HOoJxIvBaUOLb8tlaK/rE//tE/8Nf8RnGTA+5JSUpG09VINo1VYHxGN3g0yaDH2kX/LP /5lF3LqWyHabE5DYW2UFKZ5gaIjNRLkLZYF8kG9hPIIq1AuKRu34OBdKF5wbNMUmuBbZ dKN2WczvtShMYorx8wUtTt7s46D4FUQTrMsrsczvHwqqIlQ4rDQ9uWF1yzrwKo6z6NQI gtdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BYQ5tQkv; 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 sb2-20020a1709076d8200b007adca6532d5si11049201ejc.708.2022.11.15.14.17.40; Tue, 15 Nov 2022 14:18:05 -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=BYQ5tQkv; 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 S231495AbiKOWL4 (ORCPT + 99 others); Tue, 15 Nov 2022 17:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbiKOWLx (ORCPT ); Tue, 15 Nov 2022 17:11:53 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1072E2715F; Tue, 15 Nov 2022 14:11:53 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so363795pjs.4; Tue, 15 Nov 2022 14:11:53 -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=0FfC6mdt0ik5bfv6PbUvOpPqpC/h2diKZQ8Yf0+D53Q=; b=BYQ5tQkvzOLFVsy7z4h5LEwu9ZW9K3e6AOtPecFt7taLzV5rHyTn55Xg1uaaIl7Hpi WP4K6+bDQQqn0FkTGhhy4WAmRds6ZRqSq/KC8JC6lGMFGOlc5boAPvv0/+eYwQtyaROz rj4FozwDwZ362ntq7GFkrhABvPa104WIOmGAYUt/39HtPuJ6eyIy5i0hpc21MYv3s420 rvbzUkzqiJ6X48LjcA2GpqTTa43S4iJWWVD//Vkv1HTvx+E0WKiVE+Ka2Bx6SWsyyJ88 1UE+UgzlliyqgyrtgFfyIRgAF2i8EAOUEJu+mPl2HwfbJF/z0eFqItO5LBkDdKapoYc0 8f0Q== 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=0FfC6mdt0ik5bfv6PbUvOpPqpC/h2diKZQ8Yf0+D53Q=; b=vLrzsxvFK8pwNAJGVo+WKHTETRhluSneTLFdaTPhbcfbORuzdugxEDxdtTAGWFMlCb VF+32rR4TH31T39izeUT+wyjq1nDIOPvpNBn3KKtk09xfxPAohBETOzkefqT7KHXJPI1 iw5h5EWnlfZ2/snL4SzhQGhkqKtcTYm6fWGKwJ8nk7/YpxKqTcXTWdUW6Hl84CYyC3UJ QYQu62itWA13QjxKIZ/meybkIbLObibs9yWoYLFp1S3zvoooDw40r2Yvdba/OXkNZBHn hbYFA4i0fVhhKPE+Ng5ud2GiN1AVn7Kdejo2okUsvIkq0dJWv3Ctq1P8wZewn+gIggvF o7SQ== X-Gm-Message-State: ANoB5pn4uzSXUNT6yy6GxjBPlf0w0vD1a2txfnsgq/ViwSDlU2xC83QT DiLma4NU84PEQ5YHquycRQE= X-Received: by 2002:a17:902:8d90:b0:187:3bc8:fc56 with SMTP id v16-20020a1709028d9000b001873bc8fc56mr5989374plo.83.1668550312337; Tue, 15 Nov 2022 14:11:52 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 14:11:51 -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 2/4] media: i2c: s5k5baf: switch to using gpiod API Date: Tue, 15 Nov 2022 14:11:43 -0800 Message-Id: <20221115221145.2550572-2-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 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?1749602202793548713?= X-GMAIL-MSGID: =?utf-8?q?1749602202793548713?= 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. Reviewed-by: Linus Walleij Signed-off-by: Dmitry Torokhov Reviewed-by: Tommaso Merciai --- drivers/media/i2c/s5k5baf.c | 64 +++++++++++-------------------------- 1 file changed, 18 insertions(+), 46 deletions(-) diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 5c2253ab3b6f..960fbf6428ea 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -13,11 +13,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include #include @@ -228,11 +227,6 @@ static const char * const s5k5baf_supply_names[] = { }; #define S5K5BAF_NUM_SUPPLIES ARRAY_SIZE(s5k5baf_supply_names) -struct s5k5baf_gpio { - int gpio; - int level; -}; - enum s5k5baf_gpio_id { STBY, RSET, @@ -284,7 +278,7 @@ struct s5k5baf_fw { }; struct s5k5baf { - struct s5k5baf_gpio gpios[NUM_GPIOS]; + struct gpio_desc *gpios[NUM_GPIOS]; enum v4l2_mbus_type bus_type; u8 nlanes; struct regulator_bulk_data supplies[S5K5BAF_NUM_SUPPLIES]; @@ -936,16 +930,12 @@ static void s5k5baf_hw_set_test_pattern(struct s5k5baf *state, int id) static void s5k5baf_gpio_assert(struct s5k5baf *state, int id) { - struct s5k5baf_gpio *gpio = &state->gpios[id]; - - gpio_set_value(gpio->gpio, gpio->level); + gpiod_set_value_cansleep(state->gpios[id], 1); } static void s5k5baf_gpio_deassert(struct s5k5baf *state, int id) { - struct s5k5baf_gpio *gpio = &state->gpios[id]; - - gpio_set_value(gpio->gpio, !gpio->level); + gpiod_set_value_cansleep(state->gpios[id], 0); } static int s5k5baf_power_on(struct s5k5baf *state) @@ -1799,44 +1789,30 @@ static const struct v4l2_subdev_ops s5k5baf_subdev_ops = { static int s5k5baf_configure_gpios(struct s5k5baf *state) { - static const char * const name[] = { "S5K5BAF_STBY", "S5K5BAF_RST" }; + static const char * const name[] = { "stbyn", "rstn" }; + static const char * const label[] = { "S5K5BAF_STBY", "S5K5BAF_RST" }; struct i2c_client *c = v4l2_get_subdevdata(&state->sd); - struct s5k5baf_gpio *g = state->gpios; + struct gpio_desc *gpio; int ret, i; for (i = 0; i < NUM_GPIOS; ++i) { - int flags = GPIOF_DIR_OUT; - if (g[i].level) - flags |= GPIOF_INIT_HIGH; - ret = devm_gpio_request_one(&c->dev, g[i].gpio, flags, name[i]); - if (ret < 0) { - v4l2_err(c, "failed to request gpio %s\n", name[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: %d\n", + name[i], ret); return ret; } - } - return 0; -} - -static int s5k5baf_parse_gpios(struct s5k5baf_gpio *gpios, struct device *dev) -{ - static const char * const names[] = { - "stbyn-gpios", - "rstn-gpios", - }; - struct device_node *node = dev->of_node; - enum of_gpio_flags flags; - int ret, i; - for (i = 0; i < NUM_GPIOS; ++i) { - ret = of_get_named_gpio_flags(node, names[i], 0, &flags); - if (ret < 0) { - dev_err(dev, "no %s GPIO pin provided\n", names[i]); + 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; } - gpios[i].gpio = ret; - gpios[i].level = !(flags & OF_GPIO_ACTIVE_LOW); - } + state->gpios[i] = gpio; + } return 0; } @@ -1860,10 +1836,6 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev) state->mclk_frequency); } - ret = s5k5baf_parse_gpios(state->gpios, dev); - if (ret < 0) - return ret; - node_ep = of_graph_get_next_endpoint(node, NULL); if (!node_ep) { dev_err(dev, "no endpoint defined at node %pOF\n", node); From patchwork Tue Nov 15 22:11:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2968161wru; Tue, 15 Nov 2022 14:20:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7InxTT4I3CCnhfok6DUSxrKm+SN5/VPUZtHrcCTMI4++Ovf9+OrCSY4adLVDrhl3SmN3h1 X-Received: by 2002:a17:90a:19cb:b0:205:fa0b:798c with SMTP id 11-20020a17090a19cb00b00205fa0b798cmr448721pjj.179.1668550801529; Tue, 15 Nov 2022 14:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550801; cv=none; d=google.com; s=arc-20160816; b=M2OamFvltwt3aFY0UssxF4BHZiz6cid3UKE4kd8Zc4D9sPV+FnVxaivNRMeU2yMc3O Gepg69erF7YEUyCVGExegaGOMjMRRQX3mr4mJK7nlhlwwkA3KggAi7kvYGQPUDByD/HP +auiKkylIu6o088d6VJAasAMdYCyyiaq2Sc3PcpAMNqZpXWzOrOxzqaIxBR4fdmOtghU Qk7Pd+YFcGsYytGkwZaNCnvSdVUo8jru3W7UH9HBQRtS1/YgP1rkr1jCsL3DWgNNrcuB mrWTvB4vppkFRNmGuEH31rytuP2MPy/oEqHuZoL7S5k/Q99O/vS0+VK/DpEt/eSrl/DZ fI5g== 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=WMGCOoya80Yh9qZLv453WUxet4tv4AcyXFF/KHbcD0s=; b=vqFooagoV68DxaFCq9SILGO9/OWOBXPE/y7mFjGBForOUV8vFSBKviBloZ0kS83tqV NQu0Ht+y80zMal890R93CbFNgxxpXQjW8SiubifOBSfQbfoFxxzjiEDMCf5xvlcVT3aS GQL7M5OY4dL+YdwJ+beTz5j6Wkz4D0pODL67E+zdpXvVE67nrihq+fZuREq8FMvTvtP2 6XIS2YoydeXJaqDmDmebH84cXPtS/opB+ZLEyncfX1zCdkQVxipMykgC4F0Py/lsrFpx h/42ZlTf7KrWiBXD6JOF7toW21hlh/rvYGPQ/84XbsDHV10UCuXMqTvgXeUhV1n25rJF 7Jxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VrAItYOO; 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 k7-20020a056a00134700b0056301324a24si14874965pfu.133.2022.11.15.14.19.48; Tue, 15 Nov 2022 14:20:01 -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=VrAItYOO; 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 S232040AbiKOWMF (ORCPT + 99 others); Tue, 15 Nov 2022 17:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbiKOWLz (ORCPT ); Tue, 15 Nov 2022 17:11:55 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3AB1303F8; Tue, 15 Nov 2022 14:11:54 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id gw22so14757890pjb.3; Tue, 15 Nov 2022 14:11:54 -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=WMGCOoya80Yh9qZLv453WUxet4tv4AcyXFF/KHbcD0s=; b=VrAItYOOcUcnfIpE0RT5T8tL0J0dqo2B7Lv2zbYjRBB9Lp2rIr1gBiM1pvxGJXfr7m uZGO9agr4dNhf0wDT+REyzcNKZvxa7QHCmQ7AVM4yjedgQyes7LhCuAb6d9n9893Iqh9 oxgDnepdLbqaNUapW38UiqBxUxPVRv71V/YhvlI1i14PrEEPeWvpG6ng2czmvzcz+XmQ BuiU0h/wrrhqP8j0yLICy+5MdAEIJw6i4NcVUZ7vpJSEUUAoMBZDN1FuqAHFLuCPxbRi XmsFnQNHlrgruk9BBr0mW0L6ORbqkJBbREYdjTub/TGApQ6N617zuGoge5LzKh7oi0kO PyPw== 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=WMGCOoya80Yh9qZLv453WUxet4tv4AcyXFF/KHbcD0s=; b=waL4AohePqMYDmJRySDsHJWHHT9Zs0/9trK8qXsu8wi6Eigyx/2sKv/GGvjKHdV0v5 79bonWTIgSrW5/nUultdpsws47bw1R30jSPGK2nnZXJNPARGj+CX1NZSBYK8TO3VqW3W SrbPtSIhdH3TLAjN2kzyv1rN9hQCWbq336h38qMw54H94s8Y4tjuRbdlToeQkp/oZkxh s9HnbRIAhOGEpSeFqsZV9bEyLdr5zo3CbfeJk0vW9TvRF4iL2dnPkFSbXatrQVoiJ1/1 ZzoJDOpE+Od6PX5hF+hAGJi9GXO+1rHeKkqGdd7bTXWe0a43h/Owt/AJTMRbvZ9u3EH7 wz4Q== X-Gm-Message-State: ANoB5pl0ORYz6UefZGHyhfO83MW+bu5FMpHvY5TbJzA9LwXflQVrpvZs gaUEpIqIWJ8AGgvVm+UV43ThTq/98jk= X-Received: by 2002:a17:902:e741:b0:188:572c:b9c3 with SMTP id p1-20020a170902e74100b00188572cb9c3mr6162956plf.53.1668550314211; Tue, 15 Nov 2022 14:11:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 14:11:53 -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 3/4] media: i2c: s5c73m3: remove support for platform data Date: Tue, 15 Nov 2022 14:11:44 -0800 Message-Id: <20221115221145.2550572-3-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 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?1749602325413431550?= X-GMAIL-MSGID: =?utf-8?q?1749602325413431550?= There are no existing users of s5c73m3_platform_data in the tree, and new users shoudl either be using device tree, ACPI, or static device properties, so let's remove it from the driver. Reviewed-by: Linus Walleij Signed-off-by: Dmitry Torokhov Reviewed-by: Tommaso Merciai --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 19 ++------ drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c | 2 - drivers/media/i2c/s5c73m3/s5c73m3.h | 6 ++- include/media/i2c/s5c73m3.h | 56 ----------------------- 4 files changed, 9 insertions(+), 74 deletions(-) delete mode 100644 include/media/i2c/s5c73m3.h diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index d96ba58ce1e5..561c1a1583ac 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "s5c73m3.h" @@ -1592,26 +1591,16 @@ static int s5c73m3_parse_gpios(struct s5c73m3 *state) return 0; } -static int s5c73m3_get_platform_data(struct s5c73m3 *state) +static int s5c73m3_get_dt_data(struct s5c73m3 *state) { struct device *dev = &state->i2c_client->dev; - const struct s5c73m3_platform_data *pdata = dev->platform_data; struct device_node *node = dev->of_node; struct device_node *node_ep; struct v4l2_fwnode_endpoint ep = { .bus_type = 0 }; int ret; - if (!node) { - if (!pdata) { - dev_err(dev, "Platform data not specified\n"); - return -EINVAL; - } - - state->mclk_frequency = pdata->mclk_frequency; - state->gpio[STBY] = pdata->gpio_stby; - state->gpio[RSET] = pdata->gpio_reset; - return 0; - } + if (!node) + return -EINVAL; state->clock = devm_clk_get(dev, S5C73M3_CLK_NAME); if (IS_ERR(state->clock)) @@ -1666,7 +1655,7 @@ static int s5c73m3_probe(struct i2c_client *client) return -ENOMEM; state->i2c_client = client; - ret = s5c73m3_get_platform_data(state); + ret = s5c73m3_get_dt_data(state); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c index 141ad0ba7f5a..1c8103670fa2 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-ctrls.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -24,7 +23,6 @@ #include #include #include -#include #include "s5c73m3.h" diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h index c3fcfdd3ea66..d68528898249 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3.h +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h @@ -15,7 +15,6 @@ #include #include #include -#include #define DRIVER_NAME "S5C73M3" @@ -357,6 +356,11 @@ enum s5c73m3_gpio_id { GPIO_NUM, }; +struct s5c73m3_gpio { + int gpio; + int level; +}; + enum s5c73m3_resolution_types { RES_ISP, RES_JPEG, diff --git a/include/media/i2c/s5c73m3.h b/include/media/i2c/s5c73m3.h deleted file mode 100644 index a51f1025ba1c..000000000000 --- a/include/media/i2c/s5c73m3.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Samsung LSI S5C73M3 8M pixel camera driver - * - * Copyright (C) 2012, Samsung Electronics, Co., Ltd. - * Sylwester Nawrocki - * Andrzej Hajda - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ -#ifndef MEDIA_S5C73M3__ -#define MEDIA_S5C73M3__ - -#include -#include - -/** - * 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 - * @gpio_reset: GPIO driving RESET pin - * @gpio_stby: GPIO driving STBY pin - * @bus_type: bus type - * @nlanes: maximum number of MIPI-CSI lanes used - * @horiz_flip: default horizontal image flip value, non zero to enable - * @vert_flip: default vertical image flip value, non zero to enable - */ - -struct s5c73m3_platform_data { - unsigned long mclk_frequency; - - struct s5c73m3_gpio gpio_reset; - struct s5c73m3_gpio gpio_stby; - - enum v4l2_mbus_type bus_type; - u8 nlanes; - u8 horiz_flip; - u8 vert_flip; -}; - -#endif /* MEDIA_S5C73M3__ */ From patchwork Tue Nov 15 22:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2968086wru; Tue, 15 Nov 2022 14:19:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rFEj2RBatLcTorP/Sy7Mwr4Rsz1Zg6f8VInDS0uLFXGGc2he8pdKXjLL2rAACZmbRh2DA X-Received: by 2002:a62:fb15:0:b0:572:d54:9647 with SMTP id x21-20020a62fb15000000b005720d549647mr11901154pfm.82.1668550791283; Tue, 15 Nov 2022 14:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668550791; cv=none; d=google.com; s=arc-20160816; b=lrpkYfnNb92uWFpzuKbpyEjZ9/EzrHK7vhCzwjGqozTgk2APrdp2q+OCwcChWGCw6l Gm3bUbzvQ4hjVDl2e3g0qYwQdQ0o2RWXKOcTwRhsdrSMITzLRjxQsSkke/zZ7ror8sBi tbGkCebpf5EcI45G718HkSjSjKlfWBxWXFh9L4ObrE46DEThdf905c062yS5GoUjX/Ux CF/Acsce417GOFk6M2Qta7w+8UOV+X/DhUse6xJpB4Rs9wftGRFrRG9LUkQTKOxafrh4 tZa7+3DusP4c9JI/KOYWZtZu9PiKLbJj5R2tgHrD06aV1XJjNUr66Bp+lFmPIfyGGP3b HW/g== 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 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.19.37; Tue, 15 Nov 2022 14:19: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=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 + 99 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 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?1749602314435045676?= X-GMAIL-MSGID: =?utf-8?q?1749602314435045676?= 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 Reviewed-by: Linus Walleij Reviewed-by: Tommaso Merciai --- 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;