Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp433140rdb; Thu, 5 Oct 2023 09:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGLn3b9HTnnLLSkxktTLF5sA6jshzNBSXto9z1AEf3rAJcEmSQgEFIrx89XNLWn4BZaQk5 X-Received: by 2002:a05:6a20:96db:b0:153:8754:8a7e with SMTP id hq27-20020a056a2096db00b0015387548a7emr5212027pzc.3.1696525184233; Thu, 05 Oct 2023 09:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525184; cv=none; d=google.com; s=arc-20160816; b=vNnHAi6JmoOonHr9PjotkvO9OaA2sNHZzr8wUe2BsATxCjEtxtiJ8aCZrHdadePNEv D5wURZ068JkG5NzP0CDNDUWqNmJvMweRz6GRWcrPQJcWHy95CWIC6Vzm1XNN1AZZebN4 yFQ8D4gMAxWPwFp+kEL5U8H3TzMlqnEktb5iJtdlsb5RMeHGpnlrn7fpFhgzvx0Fh+YK DH1jdcXU5Kz9GDz1Q6hkR8X5uhSVmcYBh9W9tg/lnzNsjcLfkmrcZ/xKfBY55KD9xBLs FNKmln2CaiwHb9l5DCFCqot8LZ/WjPhRjLXTi5ht1xepy2mNIRlOW4ypABBtAsyHQpOU M2TQ== 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=10JswCDtKjfsgUgjTt05ZkVWjMO4ZebDQWE8d7lo6tc=; fh=5LIWo2D/PeZk6SC/rjjkha3vijtdzmZAJYKHEnFRQDY=; b=OUldgUZI9i5c605eK7nOO6s7JwHoJT+pfqaqQYxZkX8DD0BQMcHf2JEqqz9CxhupHQ /3IX6jDtBrSHWoTMuhMoA9vqxZyM2dkYDaDe7pVafKZpwVhySRGp2Mbpd+LMAqKgBTpY WI3S8fDe6LP7WYLT787z+75irOpSudi6O2whTvXCpxG4ZkyR4BHg/hhGd7+HSv6ZCl01 KWMLwNTYu//KZO8qYq0mPBOmqFjr0rKqDZ9EEw4D7mapuSPVSXdSiT7VeV41FFa5slLv t0UA7XeIxb38gMkkmNwiy1BywaJeWm4IFuqsqSoc+iUQ+3W7VrzKV7O+ayR0tbxtmWaH I4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VKUQsTLh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bs70-20020a632849000000b00565f182839asi1794542pgb.28.2023.10.05.09.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VKUQsTLh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id F291F8725CC6; Thu, 5 Oct 2023 09:59:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235644AbjJEQd6 (ORCPT + 99 others); Thu, 5 Oct 2023 12:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjJEQck (ORCPT ); Thu, 5 Oct 2023 12:32:40 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414CE196 for ; Wed, 4 Oct 2023 19:59:31 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6c7a4735a30so92743a34.1 for ; Wed, 04 Oct 2023 19:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696474770; x=1697079570; darn=vger.kernel.org; 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=10JswCDtKjfsgUgjTt05ZkVWjMO4ZebDQWE8d7lo6tc=; b=VKUQsTLhCArnRioaPv2u3UlcoY7e8nqdOs9Fb8algbw+e/Qb7F1MxBH78hSGbgQeN1 TwlbgeZPvk3tZQ7Lq8E6ic5XwdO/8VtzCHs1nfuxFf+Sw7/p8277olzuPDWtgoIFuGNn qHw0a1+iIxDAu2HGCyUgI4HJ8wQkn8ADY4recjFsosL/9dYBfb14a2x3Gk115QhSo2z7 DE9EzsnfoW6uLCk6ubnPJ4tilrCnrOPxFYiD6zYXGZ+kF/Y1eX2AAHjoaQhsnxF0bg3i Sazzd3ecdU00wp6MoWT9BsqGzcmwqGrT+wb5AO1OPrrQPxBu8AyFISFRW2OzSSoc25yl vUuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696474770; x=1697079570; 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=10JswCDtKjfsgUgjTt05ZkVWjMO4ZebDQWE8d7lo6tc=; b=ZFN64OFqlHYL+a6FtGIAVLHe5VTxaMfYQyKtXfuuy+bBBIo2FErUHbL0EIhyWRNKUP MmwmxGoURTmwjpp7j3sID1oIToDbyN8VMY+TOJ4QexPQaEonv3+Cs0mbDGOp/0wv3Ni4 OqaQQIj/DoC3jJp3QzezQLpxz2rMfdNbTyURiCZgIwUR3CZmnoMTD+73p2jSrEg0ooXz Ne9wpHNJGp46KNNfLZZQIEoXXm97vLq5kzsgDBlt05PurFVKTkKVDFCscSfmifJbTXg7 EU5C/3Noc43fq7EGUozGi6xfqntYGrqonbgjG9NMJmTUcYPZRNuGX5trY7MIL5N9pl5a /Krg== X-Gm-Message-State: AOJu0YzfURc57MXq2anWz+GupF3oVhkpU/1gJYaPFxzLbPC277AvLhP3 d4UC2BiaTn4jDE2/WIG+oCdzgw== X-Received: by 2002:a05:6808:15a8:b0:3ad:f3c0:5da3 with SMTP id t40-20020a05680815a800b003adf3c05da3mr4643158oiw.3.1696474770489; Wed, 04 Oct 2023 19:59:30 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:a16d:fce2:497:afb7]) by smtp.gmail.com with ESMTPSA id b18-20020a637152000000b005782ad723casm269265pgn.27.2023.10.04.19.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 19:59:30 -0700 (PDT) From: AKASHI Takahiro To: sudeep.holla@arm.com, cristian.marussi@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linus.walleij@linaro.org Cc: Oleksii_Moisieiev@epam.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, AKASHI Takahiro Subject: [RFC v2 3/5] pinctrl: add pinctrl_gpio_get_config() Date: Thu, 5 Oct 2023 11:58:41 +0900 Message-Id: <20231005025843.508689-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005025843.508689-1-takahiro.akashi@linaro.org> References: <20231005025843.508689-1-takahiro.akashi@linaro.org> 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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:59:43 -0700 (PDT) This is a counterpart of pinctrl_gpio_set_config() which will be used, at least initially, to implement gpio_get interface in pin controller based generic gpio driver. Signed-off-by: AKASHI Takahiro Reviewed-by: Linus Walleij --- RFC (Oct 2, 2023) --- drivers/pinctrl/core.c | 19 +++++++++++++++++++ include/linux/pinctrl/consumer.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index e9dc9638120a..2f9c2efdfe0e 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -926,6 +926,25 @@ int pinctrl_gpio_set_config(unsigned gpio, unsigned long config) } EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config); +int pinctrl_gpio_get_config(unsigned int gpio, unsigned long *config) +{ + struct pinctrl_gpio_range *range; + struct pinctrl_dev *pctldev; + int ret, pin; + + ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); + if (ret) + return ret; + + mutex_lock(&pctldev->mutex); + pin = gpio_to_pin(range, gpio); + ret = pin_config_get_for_pin(pctldev, pin, config); + mutex_unlock(&pctldev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config); + static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 4729d54e8995..852fac97a79b 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -31,6 +31,8 @@ extern void pinctrl_gpio_free(unsigned gpio); extern int pinctrl_gpio_direction_input(unsigned gpio); extern int pinctrl_gpio_direction_output(unsigned gpio); extern int pinctrl_gpio_set_config(unsigned gpio, unsigned long config); +extern int pinctrl_gpio_get_config(unsigned int gpio, + unsigned long *config); extern struct pinctrl * __must_check pinctrl_get(struct device *dev); extern void pinctrl_put(struct pinctrl *p); @@ -92,6 +94,12 @@ static inline int pinctrl_gpio_set_config(unsigned gpio, unsigned long config) return 0; } +static inline int pinctrl_gpio_get_config(unsigned int gpio, + unsigned long *config) +{ + return 0; +} + static inline struct pinctrl * __must_check pinctrl_get(struct device *dev) { return NULL; -- 2.34.1