From patchwork Tue Sep 5 18:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374936 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 E0CC1CA0FFB for ; Tue, 5 Sep 2023 18:54:10 +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:References:In-Reply-To: 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: List-Owner; bh=2QlZ3fFzhgfIUd5Erf1Ds1AIe7zFW32Bs4AyKOr9e1M=; b=DXywEDLJWJYwL2 BPY+YbfuddQPRRA73j54Si2EYOBX/PGECHkKzW1QIN/9xii6BVH3+1OZczsmOOQOwFhLdnjLQmAUm YFo3RF3fmCZjceC1pIerjDm8CXD3hxbpk/zikCy82MP2Mcv/4D72iDCRLCJ1UaroOpDLz0jrUWQ6f GrQuXGp+Nn9TFretNA/bnBp2Eiw/iq4z5Z0jlSsky5SkB8SoSm1LqjoYi85W24MY3iMbOa5rnRYjL jf9jty9G+8KbT0OAkiUoBBrsJj8Oan4mW4ToHIdri0TKxqk4mhMmBgQ3P7mwfYm2jgO95GVzc8mpc zzI5XIB0vKS78a+WfYFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBH-006YUd-34; Tue, 05 Sep 2023 18:53:43 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBB-006YPn-2H for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:39 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31c4d5bd69cso2517518f8f.3 for ; Tue, 05 Sep 2023 11:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940014; x=1694544814; darn=lists.infradead.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=2+MC7OlTYjYmYcid9pUzzxXRyDGKxkUAmb4nz8uCexs=; b=OclLqdnqx3WS4PvE0c5gxCj2Ln4jO97Le4vMf5lAyBblEHIZP6RXhTQslOMAbBA8eG laBghq4JEXFcDjtxLgZopwpO1qSZjiVHvJzAKd5FBfNYKj5O4Bhql1Ki8+7lYvoc+GcQ NaBk9Rurr3zWZLb6wdyPXFRujMqCOSn+2CHSixrI6ApAPNl0HkgGgVcw2DPYbXMKMHia l1QrTXABrTuYaNVYh5B26Tye/t0Mll2p2dJ9mweF60oZIvejil3sn4A5gVoM6KcOzYxQ beDKooxBuXQor2EWx+vedGPgd/BpuBqPddZoz+CE7sbRuJyOlP50BrvLEY2SiVyjuk1l MlGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940014; x=1694544814; 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=2+MC7OlTYjYmYcid9pUzzxXRyDGKxkUAmb4nz8uCexs=; b=TVB0TMoJIz6wWfpdYq7LEjwNhqc59J8ZVhBc3dzznG9d1ayFf4+zDOHxSKaGAOza65 fy4WWQ3iO8I4AWdgB4b1Mf6/LRTS/zuA1qjChZ7WaL8+QaOK3G0iq0KSwx/zQRCN8i8h eKn41Je7WuQNx6xBliaiVl7wSRORu+7SGPY/bp6FLqqkYtpNhZveL/zfycQLRWVcoPJw aeFCKxGPjFjLLbUwWlvXxrm4aGRbLrGRS0I4m3Kk+LA10LyM+GK2gFRd2ZajFAqqpCs+ eHeTcxx7Ds76T/HymntS61KUcw0hZ52qQUfBzJZ2JA/f6NK/l/+8CKj0DR0TVsJZ448x Ul5w== X-Gm-Message-State: AOJu0YxjTJYI6QcbbDUa5PWLcUB1GYAZni6lUx7YQ0Ad8rv+lyqQFE5r 6/sIMC63f3IcUj2MNWb25ZoRPw== X-Google-Smtp-Source: AGHT+IGj2EuAvHtXRXD8rdSvHdyQNmCzp7/4dD7j6aPqgw+n/kXSu9aLQQjPpRIFRE646UdFzsOLag== X-Received: by 2002:adf:e0c5:0:b0:319:6b6c:dd01 with SMTP id m5-20020adfe0c5000000b003196b6cdd01mr477303wri.17.1693940014702; Tue, 05 Sep 2023 11:53:34 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7a54:5dbc:6d09:48b7]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c249100b003fbc30825fbsm17550010wms.39.2023.09.05.11.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:34 -0700 (PDT) From: Bartosz Golaszewski To: Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Dipen Patel , Thierry Reding , Jonathan Hunter , Hans de Goede , Mark Gross Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org, platform-driver-x86@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 07/21] gpiolib: provide gpio_device_get_base() Date: Tue, 5 Sep 2023 20:52:55 +0200 Message-Id: <20230905185309.131295-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230905185309.131295-1-brgl@bgdev.pl> References: <20230905185309.131295-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_115337_772689_044FAF2E X-CRM114-Status: GOOD ( 12.81 ) 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: Bartosz Golaszewski Let's start adding getters for the opaque struct gpio_device. Start with a function allowing to retrieve the base GPIO number. Signed-off-by: Bartosz Golaszewski Acked-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 +++++++++++++ include/linux/gpio/driver.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9637a79a9a60..9715bbc698e9 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -233,6 +233,19 @@ struct gpio_device *gpiod_to_device(struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_to_device); +/** + * gpio_device_get_base() - Get the base GPIO number allocated by this device + * @gdev: GPIO device + * + * Returns: + * First GPIO number in the global GPIO numberspace for this device. + */ +int gpio_device_get_base(struct gpio_device *gdev) +{ + return gdev->base; +} +EXPORT_SYMBOL_GPL(gpio_device_get_base); + /* dynamic allocation of GPIOs, e.g. on a hotplugged device */ static int gpiochip_find_base(int ngpio) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index e3747e730ed1..b68b3493b29d 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -780,6 +780,9 @@ void gpiochip_unlock_as_irq(struct gpio_chip *gc, unsigned int offset); struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); struct gpio_device *gpiod_to_device(struct gpio_desc *desc); +/* struct gpio_device getters */ +int gpio_device_get_base(struct gpio_device *gdev); + #else /* CONFIG_GPIOLIB */ #include