From patchwork Tue Sep 5 18:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374931 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 9B86ECA0FFD for ; Tue, 5 Sep 2023 18:54:05 +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=lV2axnjL8bOnJI0LLiugMaXintiKWD9cSVFiHc2HaT4=; b=Tu2WCKsUo+JM9p q7pPe4xVFZSfObLUAFRQvpbZZI1khGED3oZUn/7KOvEP43g9dHUHSzZV3Gzl4xn4noe2qMPzbl79B mUD3AwjhNSCy6/n8BwfizfvpYQP5PwmfEE5R28NOa3AnNDh9kEbF7RxFaR2yzX7vrN6vUWMq3RihP BafGPUW7VI78XuIAT5So3LFSsPVylTKmNDRjun1Lbh9onBYnMSsOZ5c0GhViDcngdGrYQLG53ZMfi eZWGmiIkE8Nifk/tDIH57Bt5ytBrooQ3DZyzJpLubD0WGxtBKcvlG+ZCu+WIsGUbawjpHFF/Uc8bK OvJF6Q1ysGqqYxru928A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBD-006YRj-06; Tue, 05 Sep 2023 18:53:39 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB8-006YOR-2C for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:37 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-402be83929eso28291755e9.3 for ; Tue, 05 Sep 2023 11:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940007; x=1694544807; 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=A2GE4FHHqs6bBZBv794WL9eWtt6b/gcHhoE6C2vLyfs=; b=NrQnsZ2EDB8eEzQ57gM5hCzVSFbqm4zgVRc4HBsWMV5JS0O91dwFHwGh+Zf8DpYS0C wjM8oli1FAI9T7hHjLGoXcK5LVvUQi3vipeJRz7GNS1p15N9U06dNDoav1uR5sq2t7RU zgFCj43FhXeMn9iYqv4GJuae91y0OrsxlFyR7eFwbsmG7cqnfzqu7FaAvrT/xfDBGxWq WOrAVCIVfmvhzDILm6Az25ZJQwSnyyHceuMzevb42NzlOmVCOq8ef0g+TNWRO79gBvq1 1gvMOj9Yv0/jMHepo5TQvzuY6BqYpA6LDLaFO1bFwYCWNJXFB6MA/eBF42b9oau3QvBe EXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940007; x=1694544807; 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=A2GE4FHHqs6bBZBv794WL9eWtt6b/gcHhoE6C2vLyfs=; b=AJFcc+0XD22wNeA4A5Vwx0fVAQn3fvqFnYcZA614A9Yr7AnDJ3B6aTyF4NlfpRVs8D 2lPO7z4B+0ZzJiTXXz1wKWAYjdhtJcg7+VUIce+zjSKrg0++7+yWmG4uHaL5FAL6I4z7 CRoqOoE1PUb6Bw0ah4p3cNS+ONHVussdYMtv8wQPh39Sp71zPGiPI+RwnuuHEV5iQdYo nriuaNm/ZwCtCbs682hfd//XRexR6lEG+ihr1A9Lr+Gjn0NfaqpwZxQmX37Q4cwmIIUg UzTnq5rrqfrfyQv59BNAakZSCYEjiXwTWLf/lMXIK2z2yvc0131f0vLl6punCKPUBB+a 1P2w== X-Gm-Message-State: AOJu0YyAq6A22MYHJiMO+AqNizoYof4cizBLRtZFMQYGf0NPxpdkBeLo FZNSpfO7kgNJFwb+oPVBmDJKzw== X-Google-Smtp-Source: AGHT+IEMv51XL5FvHHG3cRgXKYfBtpCzIaG0xueCnriuyRygrFNOOQC3x8IGQeLMqwqbAjFRM5ODiw== X-Received: by 2002:adf:ce8c:0:b0:31c:762b:ceb3 with SMTP id r12-20020adfce8c000000b0031c762bceb3mr489509wrn.48.1693940007276; Tue, 05 Sep 2023 11:53:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:26 -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 01/21] gpiolib: make gpio_device_get() and gpio_device_put() public Date: Tue, 5 Sep 2023 20:52:49 +0200 Message-Id: <20230905185309.131295-2-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_115334_718173_45B46C06 X-CRM114-Status: GOOD ( 15.61 ) 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 In order to start migrating away from accessing struct gpio_chip by users other than their owners, let's first make the reference management functions for the opaque struct gpio_device public in the driver.h header. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 24 ++++++++++++++++++++++++ drivers/gpio/gpiolib.h | 10 ---------- include/linux/gpio/driver.h | 3 +++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index edffa0d2acaa..f84ad54d8dbd 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1058,6 +1058,30 @@ static struct gpio_chip *find_chip_by_name(const char *name) return gpiochip_find((void *)name, gpiochip_match_name); } +/** + * gpio_device_get() - Increase the reference count of this GPIO device + * @gdev: GPIO device to increase the refcount for + * + * Returns: + * Pointer to @gdev. + */ +struct gpio_device *gpio_device_get(struct gpio_device *gdev) +{ + return to_gpio_device(get_device(&gdev->dev)); +} +EXPORT_SYMBOL_GPL(gpio_device_get); + +/** + * gpio_device_put() - Decrease the reference count of this GPIO device and + * possibly free all resources associated with it. + * @gdev: GPIO device to decrease the reference count for + */ +void gpio_device_put(struct gpio_device *gdev) +{ + put_device(&gdev->dev); +} +EXPORT_SYMBOL_GPL(gpio_device_put); + #ifdef CONFIG_GPIOLIB_IRQCHIP /* diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 9bff5c2cf720..3ccacf3c1288 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -86,16 +86,6 @@ static inline struct gpio_device *to_gpio_device(struct device *dev) return container_of(dev, struct gpio_device, dev); } -static inline struct gpio_device *gpio_device_get(struct gpio_device *gdev) -{ - return to_gpio_device(get_device(&gdev->dev)); -} - -static inline void gpio_device_put(struct gpio_device *gdev) -{ - put_device(&gdev->dev); -} - /* gpio suffixes used for ACPI and device tree lookup */ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 8f0859ba7065..a2060dc3344b 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -606,6 +606,9 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +struct gpio_device *gpio_device_get(struct gpio_device *gdev); +void gpio_device_put(struct gpio_device *gdev); + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); From patchwork Tue Sep 5 18:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374934 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 1C233CA0FFA for ; Tue, 5 Sep 2023 18:54:09 +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=OvT5s7E9p3SWpUglzzJGjQAipwXqZ3ievNjVAsUdSLY=; b=HIWUII0sYRswF+ lRZLhQTFwC6GPGtLXrmmc1y3VRZkAA9iTzEHd8cvAbXV2HytGH/EsPgyGLkmeqje+7sRZ1QhvxP0L 3DiOOpV4/Qj7cH841/zGtwCFf5BkWWXKkVb9EhKdl48Y+AlrtvNXM1zP8sjN9v+8IIKrtsceAe3jq bu4EvhI+jmtDpphfBySYCxQi91Hwn+o1HBqux8m86lua/o8lVbAAAgXYiTF2zoNFXG0qlRj9Dw1G7 h5HpdQkrt52xD0bpaCazMy790a3pQLYez3jweY7RQuVSjRntf/FfrNrnEPE/QboCESzTQyvDmsDmy ePIN7s/ECw8sfuRv2PqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBB-006YQa-28; Tue, 05 Sep 2023 18:53:37 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB8-006YOe-0y for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:36 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbd33a57b6so26755865e9.2 for ; Tue, 05 Sep 2023 11:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940009; x=1694544809; 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=32AzIakwES8QNoZ2moYEZisZgGIsr9B20l41KqZ1PII=; b=Tv1/2KRE8aFwpgO7uLt7GElll9+pNAFEqjJFDcL7HWSQ1DXk4L5kR85h793X4UitNj itW5LWiRpj228oDnRIKoVhDv2wSS1TPKvIBeu9mXe1nIU9nVxk2xr08zYh0doTXV9h1V RkZNpXoMXPLFQJi37CPATFIFWs8+zOt+lDmyS7rwz4JFvrZC2cJtuBPZC6hk5gkk5TCu ugm8xPc9JHnucxKY3cK+o2zNps6NwYcZO5rQDoXOLziAMHna/zP6sSu/Sa6Nmisb2KK5 o+ZKGjlezCei0cmSdCFlpVStJ9W+z+rNfQflxE4jL9Z0i4ICq0Iqw1mA09+ssBDXgeFp n2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940009; x=1694544809; 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=32AzIakwES8QNoZ2moYEZisZgGIsr9B20l41KqZ1PII=; b=gNzNxznCBBepeHDHVVRlkA59IfGXq1khynNrImzR703NEbn1yBVKzYbHtOpAVE8pcW QqXaMOv1GjzvK/rWdrNMsmQqNpGa/cQvLOUOu8dsqW2LnA9wVepb9h8s2Bg6gTviRgGB rcI9ZDk70CO+tKOpXL60pCeZwoyczeaDymvdyfMIob9L0fqBQ7BOqMrq1v4XP6T9RJij KCW6hjyi+wVvUpGqwwIZSy08QwF+m9V2XMDAKLxv/+vlGtAA9SuDCgITDhga0D0W1Pxg wYTBUnAJWj7jYsXweOCf722gjh+zQD/08B49AJJKkPA42DoyamS03BJ+90clbKSyVmZz XqAg== X-Gm-Message-State: AOJu0YyHxudeYzFG2/oVw+CCRRkpm/VsjEb8+F8n0CkVabo7K/EMDZi/ q1kQEF316zLEHs0yU7fmUQEscg== X-Google-Smtp-Source: AGHT+IEMA7O/G04+pJVQEX0HMhuZh3/G19j9j9xyba1JCXjHsE+92yNux09q4RWquXB9Fm3Wgf4zQw== X-Received: by 2002:a7b:c7d9:0:b0:3fe:207c:1aea with SMTP id z25-20020a7bc7d9000000b003fe207c1aeamr433332wmk.23.1693940008588; Tue, 05 Sep 2023 11:53:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:28 -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 02/21] gpiolib: provide gpio_device_find() Date: Tue, 5 Sep 2023 20:52:50 +0200 Message-Id: <20230905185309.131295-3-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_115334_577182_C177E2CF X-CRM114-Status: GOOD ( 22.65 ) 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 gpiochip_find() is wrong and its kernel doc is misleading as the function doesn't return a reference to the gpio_chip but just a raw pointer. The chip itself is not guaranteed to stay alive, in fact it can be deleted at any point. Also: other than GPIO drivers themselves, nobody else has any business accessing gpio_chip structs. Provide a new gpio_device_find() function that returns a real reference to the opaque gpio_device structure that is guaranteed to stay alive for as long as there are active users of it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 64 ++++++++++++++++++++++++++----------- include/linux/gpio/driver.h | 4 +++ 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f84ad54d8dbd..9e083ecb8df0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1014,16 +1014,10 @@ void gpiochip_remove(struct gpio_chip *gc) } EXPORT_SYMBOL_GPL(gpiochip_remove); -/** - * gpiochip_find() - iterator for locating a specific gpio_chip - * @data: data to pass to match function - * @match: Callback function to check gpio_chip +/* + * FIXME: This will be removed soon. * - * Similar to bus_find_device. It returns a reference to a gpio_chip as - * determined by a user supplied @match callback. The callback should return - * 0 if the device doesn't match and non-zero if it does. If the callback is - * non-zero, this function will return to the caller and not iterate over any - * more gpio_chips. + * This function is depracated, don't use. */ struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, @@ -1031,21 +1025,55 @@ struct gpio_chip *gpiochip_find(void *data, { struct gpio_device *gdev; struct gpio_chip *gc = NULL; - unsigned long flags; - spin_lock_irqsave(&gpio_lock, flags); - list_for_each_entry(gdev, &gpio_devices, list) - if (gdev->chip && match(gdev->chip, data)) { - gc = gdev->chip; - break; - } - - spin_unlock_irqrestore(&gpio_lock, flags); + gdev = gpio_device_find(data, match); + if (gdev) { + gc = gdev->chip; + gpio_device_put(gdev); + } return gc; } EXPORT_SYMBOL_GPL(gpiochip_find); +/** + * gpio_device_find() - find a specific GPIO device + * @data: data to pass to match function + * @match: Callback function to check gpio_chip + * + * Returns: + * New reference to struct gpio_device. + * + * Similar to bus_find_device(). It returns a reference to a gpio_device as + * determined by a user supplied @match callback. The callback should return + * 0 if the device doesn't match and non-zero if it does. If the callback + * returns non-zero, this function will return to the caller and not iterate + * over any more gpio_devices. + * + * The callback takes the GPIO chip structure as argument. During the execution + * of the callback function the chip is protected from being freed. TODO: This + * actually has yet to be implemented. + * + * If the function returns non-NULL, the returned reference must be freed by + * the caller using gpio_device_put(). + */ +struct gpio_device *gpio_device_find(void *data, + int (*match)(struct gpio_chip *gc, + void *data)) +{ + struct gpio_device *gdev; + + guard(spinlock_irqsave)(&gpio_lock); + + list_for_each_entry(gdev, &gpio_devices, list) { + if (gdev->chip && match(gdev->chip, data)) + return gpio_device_get(gdev); + } + + return NULL; +} +EXPORT_SYMBOL_GPL(gpio_device_find); + static int gpiochip_match_name(struct gpio_chip *gc, void *data) { const char *name = data; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a2060dc3344b..5c5029cec226 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -606,6 +606,10 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +struct gpio_device *gpio_device_find(void *data, + int (*match)(struct gpio_chip *gc, + void *data)); + struct gpio_device *gpio_device_get(struct gpio_device *gdev); void gpio_device_put(struct gpio_device *gdev); From patchwork Tue Sep 5 18:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374928 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 79023CA0FFA for ; Tue, 5 Sep 2023 18:54:02 +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=fxQVuVUjOqpiDaiXoOmr5dffCjTqEh3LADHA+K/oQ/8=; b=xgaVfWOTMkgKbY 8OGmL2xLx/IW9MsOFIOb+9rpLNKPuC3GwS1EM+drXjHJCIhVH0PFbqUZGNdN97lOaaPZ0qywclDXX IOtm6Kn2yNs3ms5+fHoV5AdneuZGWhHwdR8fMMec+JYBwtK44+Q+irWjOcI6RIthexJ3Y8eWEpJS0 qqQ35MwKmYhR96JF9eiXd3rPKR8tGzA7tTYJJ5GoW3rqsMG6uB8GcmeMAhxl4GChAoCH4OOhmf1WD qGwvV+SeEbqjP4zQXfN05X6WrK+U18v25sYcjJoCbr6Q9/o+jks328bwKCYvfj4CoJBsErezwKGaw 3iAR3JQn0oicR9KYPA0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBD-006YSR-1l; Tue, 05 Sep 2023 18:53:39 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB9-006YOh-07 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:37 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-401b0d97850so30051635e9.2 for ; Tue, 05 Sep 2023 11:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940010; x=1694544810; 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=vqkLr0JyIMxB5faQNNXnf+zRj68nvo49fQs7ZKVuUBo=; b=thM2Xs+9mSJCjXxwzL8+ehUqoIDRPxpP061l8IIfoJ1043D6TakQjyjs4r1DlWEIgB WWSI3X+yMdpdT7aguvkJvsFSi7AvfNJEcWEfZbJslAGJAmIGv2x/2QhfLFw6MyRZuXXW ETsWXqcPyK5kiz9cB1jxXGB/luy8M5Aow/mOu15Indtzx8UQZXgGDehsssd8vK3CPfl9 W1V9Ou0C489TwdAE26lz/L6m56TFVOoxSXdXbyoBoTeR43wNAM8IXzRIuAcYLg6ev3xv S/FYMyVjwwz4WlSmf4A3SKeAaN3yTwo8DNbfv4cf3meYGRyMpzDFZDu+WqSEwlVRb/xT rsSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940010; x=1694544810; 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=vqkLr0JyIMxB5faQNNXnf+zRj68nvo49fQs7ZKVuUBo=; b=bpLP0CSgU6yqbYefE5eiWN6tL9NGnEl4sESZmjsPi9YizhJ7TC1Os0aETHJfn5RH9K tRB8MzizO5s1EBO9oCpTbW/sA5URR+WcgXnPM+PcreAEt6Gs7ln5o4yIAxp9J8n177i+ TYoL57aYaNTWVnUvIdFgCJjm0uWlBNLHslwI7O4LNe2KE9Azack74ZSy6QW0cowE59zv wXv73sSSBK43ayYgvzTW6CGIqoFHx7Ur/AxVM13XQbSVxluXA8uibUKZeDMsOotwIs9A OZhob55OtsLrI8xa/vIU92WVzBKFvL0DWznisnmKy54bUkx+NO7vYV1PVRTfd2G4SQot DPug== X-Gm-Message-State: AOJu0YxsS2QzB9r+Qsl1HIcuD6g0CU7IeQW9krVI5cp8vj/WL8iF8sWv nou5Ub/5Dx5loPowFJAklwozOQ== X-Google-Smtp-Source: AGHT+IG3KG15PaiG7DgNG5yZVi1RIG05HTUsTSLH76kG9iwAZEGSHThfSg45jv+oBWQBQS0UnnvYaw== X-Received: by 2002:a05:600c:2256:b0:3fe:1af6:6542 with SMTP id a22-20020a05600c225600b003fe1af66542mr449099wmm.33.1693940009775; Tue, 05 Sep 2023 11:53:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:29 -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 03/21] gpiolib: provide gpio_device_find_by_label() Date: Tue, 5 Sep 2023 20:52:51 +0200 Message-Id: <20230905185309.131295-4-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_115335_073808_B9B9E265 X-CRM114-Status: GOOD ( 12.77 ) 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 By far the most common way of looking up GPIO devices is using their label. Provide a helpers for that to avoid every user implementing their own matching function. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 21 +++++++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9e083ecb8df0..74b837671d30 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1074,6 +1075,26 @@ struct gpio_device *gpio_device_find(void *data, } EXPORT_SYMBOL_GPL(gpio_device_find); +static int gpio_chip_match_by_label(struct gpio_chip *gc, void *label) +{ + return gc->label && !strcmp(gc->label, label); +} + +/** + * gpio_device_find_by_label() - wrapper around gpio_device_find() finding the + * GPIO device by its backing chip's label + * @label: Label to lookup + * + * Returns: + * Reference to the GPIO device or NULL. Reference must be released with + * ``gpio_device_put``. + */ +struct gpio_device *gpio_device_find_by_label(const char *label) +{ + return gpio_device_find((void *)label, gpio_chip_match_by_label); +} +EXPORT_SYMBOL_GPL(gpio_device_find_by_label); + static int gpiochip_match_name(struct gpio_chip *gc, void *data) { const char *name = data; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 5c5029cec226..92f7143bad3e 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -609,6 +609,7 @@ struct gpio_chip *gpiochip_find(void *data, struct gpio_device *gpio_device_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +struct gpio_device *gpio_device_find_by_label(const char *label); struct gpio_device *gpio_device_get(struct gpio_device *gdev); void gpio_device_put(struct gpio_device *gdev); From patchwork Tue Sep 5 18:52:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374929 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 DEBEACA0FF7 for ; Tue, 5 Sep 2023 18:54:03 +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=v0f8COiSWUsgL65aE5Lm6IFgmvVFBrR8wGKB+Hxio/U=; b=PvCsRljsIfqL8m 8CEQSIz1PcrnATEj5JPiHGtO6lBmkHPa4dX/SwtZDx6OUlFBjTwpICcXoP3IkblMKdWrU5Os7jGqN bhjldWa66HvLA9/xlUaTJjLaGl2jDPmeGRSDlril5LBnFKTbmIKVuVaIEZdKzTDLE6bbsknNsLmBE 78LK6l2g3Ze0xpxMGVV2bYNzdvphITa2arS7mSF6NsLFAHPJwssyxIAk7LPE3wV7Bc7aaYJd23nOL 4I4kTAsM16r3Dfnk+cVB2TdbLcnv4hvoe4e0ztCE7s0nODQLAyvqA2Vb6R9qkH/41oeXXUiFuQHQl CKAm/gPn/3YAAf0uonKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YT5-23; Tue, 05 Sep 2023 18:53:40 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB9-006YOk-2K for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:37 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2bcfdadd149so48782701fa.0 for ; Tue, 05 Sep 2023 11:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940011; x=1694544811; 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=fLtpoodGmmx9hsi2x1jr+x7uccK8YI9bvvMsLPIMWWk=; b=if97paaYvnTMq5evYm8jEd9rJNDCd/zjH3CK617k0hGyBEEPeaAruw0nk2eVA8Sbwo 5GkqBm4EzMUe6Mt3DU1aG82AzmTtPEHl1FKix8tmLFwDt/BzJhc6aFkEO7GQRlCCZdZM jEnIlYelLt5Ju5405/hFltoNi5gPC4ab06yrYyxOBUmR9SrUDCU7i0Cjj5WQKpVD5CZH 9dxL1MZzpYg6x5xO7G6uhd0hQ7HpUA3La9smYe165cKIH9E0bhGD81BsurUVmOZc5L1W 3JepvdOgKlad1OjdPlCKKLlgbGnh3R3MBAPmC7r269z0QGvaDcOPyitfYcfgCgod7B/L RawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940011; x=1694544811; 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=fLtpoodGmmx9hsi2x1jr+x7uccK8YI9bvvMsLPIMWWk=; b=Kagp2mwHRRWGoJhpoVSl0qH2c3woqBbRRdNxlBtVU9utOe7Na0xTbf2xNr3Qh32ZIs G90C8I9cgmP7tLl+ssS7bOyKR2oXFmDNGraXattqxbfCZRvBE7CKHJUz3vS9qaynOd4M knLwh9URmTuU2k1Xw8CaUdS4i60yaOFLObU5zdzrQ06s29lbIOs0fN5sJ+XcOD+X3veQ LP58JK0fWsSMbMlV6/LiboSenLDTfFL4xgq1PIXBEogShYLQx4wyfC6S61NcDSpXv9Q9 cP2AGuErfP/s+roAim8vTbKOZ2IMIsU7i85r3bhSAN1lTCNQE1QivQi/JgGAfJRXnHPI JXVg== X-Gm-Message-State: AOJu0Yy5UHSHf4B8RCdzu7NeOGZa2hzt7ZgcAINJBCqJJ5BFvgvt0K87 LxdOAo6rhLT5QVkSs0U15If9yA== X-Google-Smtp-Source: AGHT+IFpB/13m0/nwakUzQdaNfC4LZV+lJxvCkU4V9X8PY52XKoEKpYjuE+lOSYCuwIRrrXtGPQ9RA== X-Received: by 2002:a2e:9f04:0:b0:2b9:ecab:d924 with SMTP id u4-20020a2e9f04000000b002b9ecabd924mr463291ljk.18.1693940010976; Tue, 05 Sep 2023 11:53:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:30 -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 04/21] gpiolib: provide gpio_device_get_desc() Date: Tue, 5 Sep 2023 20:52:52 +0200 Message-Id: <20230905185309.131295-5-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_115335_756316_2206C66D X-CRM114-Status: GOOD ( 18.80 ) 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 Getting the GPIO descriptor directly from the gpio_chip struct is dangerous as we don't take the reference to the underlying GPIO device. In order to start working towards removing gpiochip_get_desc(), let's provide a safer variant that works with an existing reference to struct gpio_device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 45 +++++++++++++++++++++++++++---------- include/linux/gpio/driver.h | 2 ++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 74b837671d30..4a9af6bfc6d4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -147,27 +147,48 @@ struct gpio_desc *gpio_to_desc(unsigned gpio) } EXPORT_SYMBOL_GPL(gpio_to_desc); -/** - * gpiochip_get_desc - get the GPIO descriptor corresponding to the given - * hardware number for this chip - * @gc: GPIO chip - * @hwnum: hardware number of the GPIO for this chip - * - * Returns: - * A pointer to the GPIO descriptor or ``ERR_PTR(-EINVAL)`` if no GPIO exists - * in the given chip for the specified hardware number. - */ +/* This function is deprecated and will be removed soon, don't use. */ struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, unsigned int hwnum) { - struct gpio_device *gdev = gc->gpiodev; + return gpio_device_get_desc(gc->gpiodev, hwnum); +} +EXPORT_SYMBOL_GPL(gpiochip_get_desc); + +/** + * gpio_device_get_desc() - get the GPIO descriptor corresponding to the given + * hardware number for this GPIO device + * @gdev: GPIO device to get the descriptor from + * @hwnum: hardware number of the GPIO for this chip + * + * Returns: + * A pointer to the GPIO descriptor or ``ERR_PTR(-EINVAL)`` if no GPIO exists + * in the given chip for the specified hardware number or ``ERR_PTR(-ENODEV)`` + * if the underlying chip already vanished. + * + * The reference count of struct gpio_device is *NOT* increased like when the + * GPIO is being requested for exclusive usage. It's up to the caller to make + * sure the GPIO device will stay alive together with the descriptor returned + * by this function. + */ +struct gpio_desc * +gpio_device_get_desc(struct gpio_device *gdev, unsigned int hwnum) +{ + struct gpio_chip *gc = gdev->chip; + + /* + * FIXME: This will be locked once we protect gdev->chip everywhere + * with SRCU. + */ + if (!gc) + return ERR_PTR(-ENODEV); if (hwnum >= gdev->ngpio) return ERR_PTR(-EINVAL); return &gdev->descs[hwnum]; } -EXPORT_SYMBOL_GPL(gpiochip_get_desc); +EXPORT_SYMBOL_GPL(gpio_device_get_desc); /** * desc_to_gpio - convert a GPIO descriptor to the integer namespace diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 92f7143bad3e..a769baf3d731 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -766,6 +766,8 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *gc, void gpiochip_free_own_desc(struct gpio_desc *desc); struct gpio_desc *gpiochip_get_desc(struct gpio_chip *gc, unsigned int hwnum); +struct gpio_desc * +gpio_device_get_desc(struct gpio_device *gdev, unsigned int hwnum); #ifdef CONFIG_GPIOLIB From patchwork Tue Sep 5 18:52:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374932 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 7937ACA0FF7 for ; Tue, 5 Sep 2023 18:54:06 +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=mwoDMzWzYJsr1IEb/rZf8cQLAPdn+9NcCWyb9L731fI=; b=hf1Z+DTOo8tBhi bbkk8Oc0g+9V+tD6CNEm+ul7Iswko5jynWXEXY2AypKSmNpxQXTPCmO9DouzwOeb+ShjnrlE3oqmS KHHWMdPqxZFBuV3MMIerO4mzqI9ncYKVs4Ki67zZ+UMkR9RU4ZRKhPbHqBsvIl503+HcVypsS6OsJ PnNQ1OptkrBPLWXsSGjPWjUUayriaJqHdS4gUA2BHRfjaj17VU3A0pymZ61UZVupRsLxK1xk+mHXQ 30SgDXbFo70RCWb8iCT0siaf3b4RzrqQgznB/keS2np8p9LDE3wOfSG6ysQPxlozMla4fPxrBY+Rr a7LMrGyxGlDYMa0LUsPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YSj-0B; Tue, 05 Sep 2023 18:53:40 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB9-006YOl-35 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:37 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-401b0d97850so30051975e9.2 for ; Tue, 05 Sep 2023 11:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940012; x=1694544812; 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=0ESplXfwHuP68mF4bwcKzJlFkniMRPzx/b85/cMF6oE=; b=NnIJunQoeciymnLI6YXleXY+NHvrBMNXHHIlGpydoS+QR9JRLuu1C7g3Eo65c9UZx9 EkQbAndm9EqkGFzyJOxZF6uYjVf5V6SHEQRPW3hDLSxKSRrbAlrAr4fgpFUMqhDaHqs9 Ucq3Up+Dz1DUnIjY3jWN2YMTpTZbXw0SjjQdWZ5I/rSFUIdaKAUbO9d613aLRCprx4DW 9ZyodZUzVA20wJdAbCbiBv5i8PYqExpi3DG4TDn0Nlce/wZ4y+xSd4dvYSgjDFmizm+m cUeVeqVSi4+vRgRU4It9QyIiBFSqkYDqllTLo755QCPM2C7tAoAaEXhhYOLxO+Tc9VVF v9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940012; x=1694544812; 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=0ESplXfwHuP68mF4bwcKzJlFkniMRPzx/b85/cMF6oE=; b=MhMcQkZC4B6nL13/zzL1hAOhHP8eX2ExuBqpOsTUiwqHMje+tUkzxWV957znZYQ8xX T3Wj0jrCq2IU6E9yOLVF0grfcX+Wr1D93v3d1MyMGwzOJTfzbmAcuvnUWZOqPFfnKIZ7 SEf/xU34Ib19W5sgmeI5U0hrU1HhohVK2Dcy3V0rP4ixxC0Pzbb2ep3cWhlP5zS4PUlj q6YdXPhOaj4hBdRO48xmSJoXF7FWWCOnAM9eonRJCEWq/mOSOE4QXSGSZ/K0wZu6GlHY zzrp2AfMF00aIN5a8leoiHMLtmbr2XYySDRH7KetvKes9WR4wNClzxP8MCrPFwMuel2P 073w== X-Gm-Message-State: AOJu0YxPIAAk30uaZTMXRfGRz27xNkKF0FeDg6/34Usx5aMZ1dqW4MJ+ 5cf/C8bvcRC3tHMjjYFruuXlqA== X-Google-Smtp-Source: AGHT+IH/VUJWjUGeUiwbD9fUfZeGiUcxVuhg9dWO0f7MJ889A/l01WqAkHMkYlgWTOb/EzfuaH05Kg== X-Received: by 2002:a7b:c411:0:b0:3fe:f45:772d with SMTP id k17-20020a7bc411000000b003fe0f45772dmr436878wmi.28.1693940012315; Tue, 05 Sep 2023 11:53:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:31 -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 05/21] gpiolib: add support for scope-based management to gpio_device Date: Tue, 5 Sep 2023 20:52:53 +0200 Message-Id: <20230905185309.131295-6-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_115335_991699_4731EA64 X-CRM114-Status: GOOD ( 13.23 ) 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 As the few users that need to get the reference to the GPIO device often release it right after inspecting its properties, let's add support for the automatic reference release to struct gpio_device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- include/linux/gpio/driver.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a769baf3d731..b2572b26c8e3 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -614,6 +614,8 @@ struct gpio_device *gpio_device_find_by_label(const char *label); struct gpio_device *gpio_device_get(struct gpio_device *gdev); void gpio_device_put(struct gpio_device *gdev); +DEFINE_FREE(gpio_device_put, struct gpio_device *, if (_T) gpio_device_put(_T)); + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); From patchwork Tue Sep 5 18:52:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374933 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 7F0BBCA0FFA for ; Tue, 5 Sep 2023 18:54:06 +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=qlg5xQnNRbkUt7WL2Imc0XkwT9IxTkV7l8TaUCeN+Oo=; b=d2E/9WR/8B/jn+ ooiAjKgoNcJzsv/LI3gwO/6UBceGVRDDhfOZWgZxXyCiTXxOtb/aG/Jfi1W8R/XdhEp1VOvpbvm+g Gcdu96eV1OQZePYrahpExdJUpRXKDPAjX7xodvYe99DjZy7VwNHENntruyGvyTgH3kfdSlsOa6CBY Bh4lGf46fwO3DeeM5t+cFQ2HZmlQt+3EqJOUDLDktGT2/S4i3xbPWxg7IMb0YfkudnhdWG3uUYthM LQ0y4rbgSdTfq+CbuXY8br+L/Nq4REsAd1XaeLymQrv+Nu0FC1cdwQyWY51jkyV0Jjt3DwLDg7neP TenXTQHdc4hM854NrwHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBI-006YVH-1k; Tue, 05 Sep 2023 18:53:44 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBB-006YOs-3D for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:39 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-401ec23be82so30149565e9.0 for ; Tue, 05 Sep 2023 11:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940013; x=1694544813; 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=rGZDmwAMqeUVhOTfv7ZtpSGAuFAAm5HZQ+raVbVaSso=; b=OkHnvR0aT4JQUucL4ECTEjcNA6FMBqV7iGsxNBT41HYAy0Wm+JQx2IDJaXradt/ZQA R3Q+R2CJA9omIVzcI+Xzh767Ybv4pkveiTMH4JXvToEWmDM11BNWU/jAhjSLIxpTRS8t FZJEZYTpK8XVXWmMF5IybDivmc4dNoDjnJ5nlPR1U08DJwJ2xOpUSZInTnwo6kiRIwNI CeryrmbNi6mX4gaJ4F9FLpTU3e+Qs728QZKi++sCPV9XrxqCW6PIZl0RHTQoNGRstqHN 62BSDDlAyHxlo+Nf0N1rfo5ZoveZZ51rlhllKwpPLD+a4fUTG71+IlW50lmiQyqLfyKp Gjww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940013; x=1694544813; 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=rGZDmwAMqeUVhOTfv7ZtpSGAuFAAm5HZQ+raVbVaSso=; b=N9/H3WhrF4GA0k50ok6PmZPfwLBFDGlFx+jrJtrh1a+kx82QUbhsVnwtnRPA682QLE Al1Og3iztUMBafRRwdIc0KRRTkEhVHKynvP/VeJAxBZqH7kzDUvPeBpyrBkImVx62BHR fZGUsjTy3+kdx8d7fmoOd3wbuSUdNA8C+lzsfy21rL66qEqPDTBwo/rNNkBdMAAB+ke8 DNqDnCFcJnEtHm6PyHnDbjcrKVvdiM2HfEYtDGT1W8qB2nyFsMciZoLSmWd3Wclmlw2k N5316xZ1WR1RIXWi9iC2dIehygcydwDaBNBpBgHGAWhIh32dKTAb1EY6+kwRztAdSv/e VunQ== X-Gm-Message-State: AOJu0Yy6cvlHzJK/TRUqRbiCoViZmwSk1J60+EXoUdQBcNiOKi+svaQw sXQcdd+ahQGiI8DeuDa90cW0Dw== X-Google-Smtp-Source: AGHT+IE6a92Y8/0xOq//9BYLFPzr9xAdeK40uWCbwfh4Inevy5jL9Qx5QtQIzqIf7nl+RNMdD6lXWg== X-Received: by 2002:a05:600c:2149:b0:402:8c7b:ceea with SMTP id v9-20020a05600c214900b004028c7bceeamr402336wml.30.1693940013467; Tue, 05 Sep 2023 11:53:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:33 -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 06/21] gpiolib: provide gpiod_to_device() Date: Tue, 5 Sep 2023 20:52:54 +0200 Message-Id: <20230905185309.131295-7-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_115338_069799_AE654432 X-CRM114-Status: GOOD ( 14.08 ) 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 struct gpio_desc is opaque so provide a way for users to retrieve the underlying GPIO device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 14 ++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4a9af6bfc6d4..9637a79a9a60 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -219,6 +219,20 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_to_chip); +/** + * gpiod_to_device() - Return the GPIO device owning this descriptor + * @desc: GPIO descriptor + * + * Returns: + * Pointer to the opaque struct gpio_device object. This function does not + * increase the reference count of gpio_device. + */ +struct gpio_device *gpiod_to_device(struct gpio_desc *desc) +{ + return gpio_device_get(desc->gdev); +} +EXPORT_SYMBOL_GPL(gpiod_to_device); + /* 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 b2572b26c8e3..e3747e730ed1 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -778,6 +778,7 @@ int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset); 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); #else /* CONFIG_GPIOLIB */ 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 From patchwork Tue Sep 5 18:52:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374937 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 06AEECA0FFA for ; Tue, 5 Sep 2023 18:54:13 +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=OZuSNWkC6Xu1PLFpLo/tQR41+9HKVSZ5GQicZw0mXg4=; b=hsIBIrZ6DY3tG4 t1Wn8WMLiv646eh3aIBxtS4nllWt/C9NUS+ttCU+sSF0FAFQCXWxL2NgwVbtk3EVa4bExNgHpeizP KvoCyg2p/m4IaRpNy3vJXR1blZP6Hn1BUn08hpOsY3TiSCE+0ApLLBCyP/uetl7N6BJ6dUlUKNAJf ifYVgG0JHqRE0Eag8w4txTm2ci1ob2/eXuygyNtDr2lDPwAnck9a5RjSdqpKjyG54Gpw490VZVT4T 3v0UI/ni9HlKaxLk8koFZuh1S/Cy4v92SeClXUvDfn1U6CsgZKPQZU5sEG86pSGj9d+pRGUo/dfeo LNodEm9ym6RCnvke+nSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBJ-006YVo-0a; Tue, 05 Sep 2023 18:53:45 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBC-006YQU-2I for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:40 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-401da71b7c5so28350865e9.2 for ; Tue, 05 Sep 2023 11:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940016; x=1694544816; 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=gD8mhbYtSpsp4MugkXhi33yXQT05nfWNxdtLBId4RL8=; b=rkC6tQy6JzYk+15ZwH22jHEo7Q+pBw7DeWe1HH7wBdWxjNtCivQ8s143XgAMdu+UqK ElA+nba3RtAYsHqJsuLxCrFu4X8W2K6g43zz68b3Wt/KjK5iWqaELtDxoROZL7yeZAHi AvmorZpxs9AB2RQ6I/TlWIn9N3lYvynagYl8WCcXWI+JRJAcBtZsT3GF2dPAGAm0ZuWc 0wpbfYOMDvmRAYKyvBogyYcftw7nMEZqFTRbWcNO8BP++02QQcv4F8q2IwEPRN30fcNV pHH2/dZuXq+xzQB7PEVgYmB0lUUHJMQLNdr83nR5VTJscb5YOE09re8gjNOrk13TrsWc 8WtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940016; x=1694544816; 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=gD8mhbYtSpsp4MugkXhi33yXQT05nfWNxdtLBId4RL8=; b=OQ77b3q2V9/7nWn7b/YbCi/NGbPISMHb1uHxn3KhCgvq01KqfaErO7QkfCqk20/qRU h++3eZEt+8TfKd232AmWg+NddJORw8B4XBmJJS9rDAKX7tSzfcQdmbp62ggxJkoZAF2T g/5J0mzyTnh16vaw1k885GMC2qMlK5y3/ZibUj+JT+0EDIfMj4AN5TliJ2zRS9c2noCd gVMso+ZSRbITI3ikBZfM8SUQxLaSNIH8F/jISejmJxiZZIxmsc0t3qq4/wC1gx6IMNu2 muPClHCDmxgV6Vd7jD5uKqZ8K5VtPM0e1APZecU9Ptx0peohLgDU5jJMzwPsUxU+qtKR AIgQ== X-Gm-Message-State: AOJu0Yx/XiCJoG5yVMKPcq+Yiwj0awa18zEuf7GpI5W3/D75lNiJq4LF YKrOZNUnrGAsplo3tbk24NLxWg== X-Google-Smtp-Source: AGHT+IFIMVvhNg464qJima4kezuYWuRmRs+hpxgOQnc+URZYC5BvtqpinR7GN44km7chTJtWGj8fDQ== X-Received: by 2002:a7b:c390:0:b0:401:38dc:8918 with SMTP id s16-20020a7bc390000000b0040138dc8918mr481515wmj.24.1693940015869; Tue, 05 Sep 2023 11:53:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:35 -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 08/21] gpio: acpi: provide acpi_gpio_device_free_interrupts() Date: Tue, 5 Sep 2023 20:52:56 +0200 Message-Id: <20230905185309.131295-9-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_115338_752111_42D2E503 X-CRM114-Status: GOOD ( 15.06 ) 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 We're moving away from public functions that take struct gpio_chip as argument as the chip - unlike struct gpio_device - is owned by its provider and tied to its lifetime. Provide an alternative to acpi_gpiochip_free_interrupts(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 29 +++++++++++++++++++++++------ include/linux/gpio/driver.h | 12 ++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index fbda452fb4d6..5633e39396bc 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -558,12 +558,9 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) } EXPORT_SYMBOL_GPL(acpi_gpiochip_request_interrupts); -/** - * acpi_gpiochip_free_interrupts() - Free GPIO ACPI event interrupts. - * @chip: GPIO chip - * - * Free interrupts associated with GPIO ACPI event method for the given - * GPIO chip. +/* + * This function is deprecated, use acpi_gpio_device_free_interrupts() + * instead. */ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { @@ -604,6 +601,26 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) } EXPORT_SYMBOL_GPL(acpi_gpiochip_free_interrupts); +/** + * acpi_gpio_device_free_interrupts() - Free GPIO ACPI event interrupts. + * @chip GPIO device + * + * Free interrupts associated with GPIO ACPI event method for the given + * GPIO device. + */ +void acpi_gpio_device_free_interrupts(struct gpio_device *gdev) +{ + struct gpio_chip *gc; + + /* TODO: protect gdev->chip once SRCU is in place in GPIOLIB. */ + gc = gdev->chip; + if (!gc) + return; + + acpi_gpiochip_free_interrupts(gc); +} +EXPORT_SYMBOL_GPL(acpi_gpio_device_free_interrupts); + int acpi_dev_add_driver_gpios(struct acpi_device *adev, const struct acpi_gpio_mapping *gpios) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index b68b3493b29d..47906bc56b3d 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -835,4 +835,16 @@ static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev) return NULL; } +/* + * FIXME: Remove this once the only driver that uses it - android tablets - + * becomes a good citizen and stops abusing GPIOLIB. + */ +#ifdef CONFIG_ACPI +void acpi_gpio_device_free_interrupts(struct gpio_device *gdev); +#else +static inline void acpi_gpio_device_free_interrupts(struct gpio_device *gdev) +{ +} +#endif + #endif /* __LINUX_GPIO_DRIVER_H */ From patchwork Tue Sep 5 18:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374935 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 B1D7CCA0FF7 for ; Tue, 5 Sep 2023 18:54:09 +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=DwnNs/1Iqw0+qhsW7yFcyCckPPFhFDwo/fGJRDjzHe4=; b=0Y0PV0iWZwJlD8 aPNQhlt21Oh90q2Uv8+PGueqWRRf7+wEz3vI1XqkbA22LX7KLJcX3lfNzQz05v4WIDWRI7RaMHjNX LB40M/TEk9Lg6i7QL4gQXfQmAtW1Y2MIbvN3m28EZvk2sYIPYSCa/H52qn8eeukAKqpKfVucd1cpH WEx53NirOFyhdr97hKaz2ZTngifcmE1WYKKfCeXYq1IY2cOoRhkNhHo9g72mmm2sWARM69dnvPWfR Z/yQNmQDI1a8196ifHiC1oaUYQAs8MEQarksqipBvGt6ii85y+fzn0MP6ZNQy/xt1ZT7qi2l6O81p I/UqrPkH0uPabrukSNdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBJ-006YWM-2T; Tue, 05 Sep 2023 18:53:45 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YQc-2R for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:42 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-401d6f6b2e0so912925e9.1 for ; Tue, 05 Sep 2023 11:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940017; x=1694544817; 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=LktKQq4MWoQ/qKoiT9d7DgSnCPQ1kCPUYmKK3IZgeGM=; b=rB6JYN9GsWpnBNSqQwnmXt06+pm+UnASe5nJKyfWEz45R9kvneNZinrbUVLZEOmxLS xG9HMGMpuOCqtV0nC2DcAA6sJ4QnfNqXqGRvYfsiUSM70je5ZwkN2EYW3hw3Gp0U5ZiN K8cPP8ceTelG5OGPyajKFfZt+hu3c0J+i8Gf3UPXLyo4inrN6+OZj7AooOEIvVigMYi6 oaCbF0sJ+9+LEkM2JNBbsr+BZ1iwjKVTjnevb52k/othnb1JULEEMLsb0YO7pmzGMWxK L/pnCWGD9DMEFvlVM7RsUcCFtAOCnWtTl3/gPKOw0bQHFnhVFmSORODamSXwD8VpQM9x Ae2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940017; x=1694544817; 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=LktKQq4MWoQ/qKoiT9d7DgSnCPQ1kCPUYmKK3IZgeGM=; b=kAQPWDsP6Bg6pNeecUzUSTeCh1oLyfhBHxEokwSsF80x1T+xMm0L5JWwwwrTQfx9kc Qe9JDOcFdyaHR75KDB14ChZpT2bh9cSRgoHx8Xuq+5FPvhL6ZcrTyOsSqAyBhaxfDDVs zfPxNcmUUZi/PiChIXWjPaKT59nKGWlPtL2BPjiVgRnYSNLOXNd71i/yvHl2x4s3Qx5z 8CxAwtyFfQ3J9KliVnk8M2p/R5q9c/sH+nJxXjPPkc1Xb4PcroRXRVqeQk+LtvaXcsLG GPrs3deKlWZxjNvvBlAau0qMO9YtyZNBDpzqWFvDuhTWH2mznx6skA0L3W15+hcEMKRu tPbA== X-Gm-Message-State: AOJu0YzbKd0ntaem0MJLAx5Jf0foTaBQH6OT0p5jBu/0EbgoaQtus0FE bk3A/eGdx7iee/5E7eb5BYdWzg== X-Google-Smtp-Source: AGHT+IEKE+XCvxCtmXJO+rvvHv5Ifn1+auM+4ZurnpxJ8t+aLjhMPMETigx/CB4V/gfiHQTOepYw2A== X-Received: by 2002:a05:600c:4b1f:b0:401:bcec:be3e with SMTP id i31-20020a05600c4b1f00b00401bcecbe3emr598796wmp.17.1693940017155; Tue, 05 Sep 2023 11:53:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:36 -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 09/21] gpiolib: reluctantly provide gpio_device_get_chip() Date: Tue, 5 Sep 2023 20:52:57 +0200 Message-Id: <20230905185309.131295-10-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_115340_796469_041ABCA5 X-CRM114-Status: GOOD ( 13.10 ) 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 The process of converting all unauthorized users of struct gpio_chip to using dedicated struct gpio_device function will be long so in the meantime we must provide a way of retrieving the pointer to struct gpio_chip from a GPIO device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 18 ++++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9715bbc698e9..408f8a7753f9 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -246,6 +246,24 @@ int gpio_device_get_base(struct gpio_device *gdev) } EXPORT_SYMBOL_GPL(gpio_device_get_base); +/** + * gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device + * @gdev: GPIO device + * + * Until we can get rid of all non-driver users struct gpio_chip, we must + * provide a way of retrieving the pointer to it from struct gpio_device. This + * is *NOT* safe as the GPIO API is considered to be hot-unpluggable and the + * chip can dissapear at any moment (unlike reference-counted struct + * gpio_device). + * + * Use at your own risk. + */ +struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev) +{ + return gdev->chip; +} +EXPORT_SYMBOL_GPL(gpio_device_get_chip); + /* 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 47906bc56b3d..bb9ec741bfda 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -782,6 +782,7 @@ struct gpio_device *gpiod_to_device(struct gpio_desc *desc); /* struct gpio_device getters */ int gpio_device_get_base(struct gpio_device *gdev); +struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev); #else /* CONFIG_GPIOLIB */ From patchwork Tue Sep 5 18:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374941 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 D2B71CA0FFA for ; Tue, 5 Sep 2023 18:54:15 +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=9qyQwR7nLVRQ4RXhnRXWT/rF7Ldjbu679PTPO4t/eN8=; b=PvgVos/py4Gr0p mTWu53lUTCShwhIqBEwtLXeB0Ae43agjuVoykgDnxPs5vxjXzqYVSXc0WT0NRJY3CH9sguVIJa04Y EwJjnvcsc5okhiHuPSZrC/FYREwpjwgtSEgOMA1FXCt/mypHfTlkfr4htHrXaJ6A03+mfimrqWEnr w/Du04Fznk8aBxao20B9HSMXgrLXDLtohNC+FeAro0A7hpAv3qC+6hUVjbNbBzD2o8vV9h66JGITo qPmxOKFiXoSx/dYTlX0/yNW2UZJlk1UXMebk1/9pBYPjbuq/CECbLsLaDWZj8ca2Bwk7N4uP+BRhC unpheIOiIL+mWci1u6fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBO-006YaN-0r; Tue, 05 Sep 2023 18:53:50 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBG-006YRk-0l for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:43 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31aeef88a55so2484866f8f.2 for ; Tue, 05 Sep 2023 11:53:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940018; x=1694544818; 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=0Lyvqa4ehdDUPxRvhVu2QVwAbbRfiYfIlEbafqal+r0=; b=3fKP3S7UpctAmLhpaXQt8LEnG6QdKmcla8UTAKW7spPqDu5bvqmabCiPyjKAgufLVb f9F52RUyz3NUg54cAE4MM0iwv4HTnx3bs+QYN4TmUACogPXRZtC9QFK4yXB95kAqm46b 9ASPVKXq1qIQnR7SWFKCRRb70TiZAiIbaYv3zAaL+R7+WOHr7mndp/NUzgA7IkUYcq15 bjEDx7t7ndbwxJjHsXNAlKbgeqfa1Mhg6AZvXSUlhf1AiADGSsqhurzpem0bkrAq+27b WWcY8RykEuuSjD6OuXNFILBez4Z4dcCdNm5/ztK+elHHzoNG2hViFtzHBeRy2Mdoj+aF f4Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940018; x=1694544818; 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=0Lyvqa4ehdDUPxRvhVu2QVwAbbRfiYfIlEbafqal+r0=; b=OPKhKFQHGfUDUL7h0ndQOcmMa6xH5qYfvhJ2fxKOxlAn6PojoFHDrgiACBQQOEj1L2 dA2yxzHdgILo0QmCWD+mJXXDdAOoLvgUwz53TvrcZ21DsJcBxNjYPDKAagZFO1vTXFM/ Jjk5yg8SnLMgCHSHn3RBpzRpeGamwU4NI2B7vMNZs19GqWeBcDjVPB4BlbkvqQRZ80wR JU4waTY1erz2IydR+iJNh9kxcMs17akraHXS+hgHl4iF6fsxhP/BhpKgq209msqFDmxD Gra4G18OVu/DiXJYHyMrTCp6xoW/xqK3fmAxUhA0TQ0xzlsg7ukG9PYweuVr9pjpRauA XotQ== X-Gm-Message-State: AOJu0YwYDkbs1cWdOGsdjSyl0oeRjodAQ/y2RVgLKhWmBY5BgY0GFeX4 bWXmbeIT4ZIKZCUb6d6wPHGPKA== X-Google-Smtp-Source: AGHT+IG/jv5LelRKHFkS+zSS/4W2MFsO0ZmIobecKNQDMGWNcj2BwZSzitK+fLdVa7TdoNhlKNwX4g== X-Received: by 2002:a05:6000:1190:b0:313:f399:6cea with SMTP id g16-20020a056000119000b00313f3996ceamr489890wrx.4.1693940018296; Tue, 05 Sep 2023 11:53:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:37 -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 10/21] gpiolib: replace find_chip_by_name() with gpio_device_find_by_label() Date: Tue, 5 Sep 2023 20:52:58 +0200 Message-Id: <20230905185309.131295-11-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_115342_275416_A93F5D7B X-CRM114-Status: GOOD ( 16.61 ) 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 Remove all remaining uses of find_chip_by_name() (and subsequently: gpiochip_find()) from gpiolib.c and use the new gpio_device_find_by_label() instead. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 408f8a7753f9..90e8c3d8b6f6 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1161,18 +1161,6 @@ struct gpio_device *gpio_device_find_by_label(const char *label) } EXPORT_SYMBOL_GPL(gpio_device_find_by_label); -static int gpiochip_match_name(struct gpio_chip *gc, void *data) -{ - const char *name = data; - - return !strcmp(gc->label, name); -} - -static struct gpio_chip *find_chip_by_name(const char *name) -{ - return gpiochip_find((void *)name, gpiochip_match_name); -} - /** * gpio_device_get() - Increase the reference count of this GPIO device * @gdev: GPIO device to increase the refcount for @@ -3924,21 +3912,22 @@ EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); */ void gpiod_add_hogs(struct gpiod_hog *hogs) { - struct gpio_chip *gc; struct gpiod_hog *hog; mutex_lock(&gpio_machine_hogs_mutex); for (hog = &hogs[0]; hog->chip_label; hog++) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; + list_add_tail(&hog->list, &gpio_machine_hogs); /* * The chip may have been registered earlier, so check if it * exists and, if so, try to hog the line now. */ - gc = find_chip_by_name(hog->chip_label); - if (gc) - gpiochip_machine_hog(gc, hog); + gdev = gpio_device_find_by_label(hog->chip_label); + if (gdev) + gpiochip_machine_hog(gdev->chip, hog); } mutex_unlock(&gpio_machine_hogs_mutex); @@ -3999,7 +3988,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return desc; for (p = &table->table[0]; p->key; p++) { - struct gpio_chip *gc; + struct gpio_device *gdev __free(gpio_device_put) = NULL; /* idx must always match exactly */ if (p->idx != idx) @@ -4021,9 +4010,8 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - gc = find_chip_by_name(p->key); - - if (!gc) { + gdev = gpio_device_find_by_label(p->key); + if (!gdev) { /* * As the lookup table indicates a chip with * p->key should exist, assume it may @@ -4036,15 +4024,15 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - if (gc->ngpio <= p->chip_hwnum) { + if (gdev->chip->ngpio <= p->chip_hwnum) { dev_err(dev, "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n", - idx, p->chip_hwnum, gc->ngpio - 1, - gc->label); + idx, p->chip_hwnum, gdev->chip->ngpio - 1, + gdev->chip->label); return ERR_PTR(-EINVAL); } - desc = gpiochip_get_desc(gc, p->chip_hwnum); + desc = gpiochip_get_desc(gdev->chip, p->chip_hwnum); *flags = p->flags; return desc; From patchwork Tue Sep 5 18:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374940 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 61852CA0FFD for ; Tue, 5 Sep 2023 18:54:14 +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=D2dloYMgh/IUdEe4rqsICw+zkmb5EhaE1NmERKF4LJY=; b=QOeJ0iKyGu75I6 dEH2dOEzQLUa8xA1dPRfJEdZRsmtzMpkgDPCCIZVCoMaWyopCdGvV/B1vWjca6TArrF6NUqGDkYZA 54mVKPMl6nednPQpji3nYRGTNOQsJKgPvt5q/G1jF0k+4izayTIIP3qVCwmZRlwDiyATR4hQWwFjX iW7cmHZci7chTumrcDv3WkwAjybFE5runXRYdJ8KmtcSWiLLmnkhHHPp/M1wJNvC/LCQTQ2cYhlxC AX6s2pop+/oT5NCnkOSAyOpTh3Cu4ZmF+5CWycnRMGbXPej+5OAmueTWF3KlJBoTCAtdWhPGj2CJx Gdx/xXWzundjyxWtONjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBK-006YWz-1b; Tue, 05 Sep 2023 18:53:46 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YSi-2G for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:42 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso24890885e9.1 for ; Tue, 05 Sep 2023 11:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940019; x=1694544819; 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=TyBIfAzUG/Tst2tDFyTRTa17LASZ2n9GApjCcuynorg=; b=sYpVLN+nfpsJUF5ItIfXp8VnJh7DC3y2FskyEUAoEJ+1DGKTwm2BtJFW9q6Tp758nH yeYsT43kOm0eTqU62bSoFOoqx6sKfvlkCAUxP1HnxXopRKIPvsttM/kBF/bKsp0Tnd+b YVkln04DxwhpL6JJ/O9NQpHd1erA+4z4SPGQMDSQagi1ft12ZQvofC59crAoWiXQ05kD ezwPUYoyRdtYts7Qz4j8Sitae3F95y4fmx0EAlXzB2Ku/lWE+EVgrZYbDVRAFrYy7Dmy vUjz8JRpPDaLtlPv6OEE1+WtqMXrW68qzXpp9RcTTjcuzcU7NAxLkECoZSX4WZEr30jO 3Odg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940019; x=1694544819; 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=TyBIfAzUG/Tst2tDFyTRTa17LASZ2n9GApjCcuynorg=; b=jnJsjW/PveERaymUX9/ZTA+GuOdScpUmupq0jvDdZFJEL+9FsfKsEpYx9/f83cgeTU SlelOfTQB/kAKN4kOFCX/OU5KkR9SiH/gxuq62Wbrh3V0BfzWFOa0Wng9cdSHvurzIkL SeZGGUhCQzHOlN/qcQdd6ZwzigxtIkp9oGlaIUksdk1DZ1oeTmk3dAAuQmeszYNvleyu iZh0L7Er5DQIpniSS31tiuFM+zH9H4JnZ9eQa4b39XHmgQHPIJJyDVd/9fsTODx8Oqpz HI1wum9XVpZ++Tv/L6/t+PPZNwTipzJ1zmPsvnR7aB9mF3PiZtztEtTctyXm7D44w24k KxrQ== X-Gm-Message-State: AOJu0Yyfn28V8PPBRpskhcHOymhLEMeOsLVWKc8cMNS63q41sqf7tAf1 /VUN+t1fo6KuGUOqxCnKi6neqQ== X-Google-Smtp-Source: AGHT+IG6EifQrYWqD0xKG3/BJghDnSpVupHCLvA51a9h0XWSNzRpKylYhH8S6fQzecUWzA90ZfjUyw== X-Received: by 2002:a7b:c8ca:0:b0:3fe:f667:4e4c with SMTP id f10-20020a7bc8ca000000b003fef6674e4cmr457674wml.12.1693940019484; Tue, 05 Sep 2023 11:53:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:39 -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: [RFT PATCH 11/21] platform: x86: android-tablets: don't access GPIOLIB private members Date: Tue, 5 Sep 2023 20:52:59 +0200 Message-Id: <20230905185309.131295-12-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_115340_756120_76BE82C7 X-CRM114-Status: GOOD ( 17.46 ) 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 We're slowly removing cases of abuse of the GPIOLIB public API. One of the biggest issues is looking up and accessing struct gpio_chip whose life-time is tied to the provider and which can disappear from under any user at any given moment. We have provided new interfaces that use the opaque struct gpio_device which is reference counted and will soon be thorougly protected with appropriate locking. Stop using old interfaces in this driver and switch to safer alternatives. Signed-off-by: Bartosz Golaszewski --- .../platform/x86/x86-android-tablets/core.c | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 2fd6060a31bb..687f84cd193c 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -21,27 +22,28 @@ #include #include "x86-android-tablets.h" -/* For gpiochip_get_desc() which is EXPORT_SYMBOL_GPL() */ -#include "../../../gpio/gpiolib.h" -#include "../../../gpio/gpiolib-acpi.h" - -static int gpiochip_find_match_label(struct gpio_chip *gc, void *data) -{ - return gc->label && !strcmp(gc->label, data); -} int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc) { + struct gpio_device *gdev; struct gpio_desc *gpiod; - struct gpio_chip *chip; - chip = gpiochip_find((void *)label, gpiochip_find_match_label); - if (!chip) { - pr_err("error cannot find GPIO chip %s\n", label); + /* + * FIXME: handle GPIOs correctly! This driver should really use struct + * device and GPIO lookup tables. + * + * WONTDO: We do leak this reference, but the whole approach to getting + * GPIOs in this driver is such an abuse of the GPIOLIB API that it + * doesn't make it much worse and it's the only way to keep the + * interrupt requested later functional... + */ + gdev = gpio_device_find_by_label(label); + if (!gdev) { + pr_err("error cannot find GPIO device %s\n", label); return -ENODEV; } - gpiod = gpiochip_get_desc(chip, pin); + gpiod = gpio_device_get_desc(gdev, pin); if (IS_ERR(gpiod)) { pr_err("error %ld getting GPIO %s %d\n", PTR_ERR(gpiod), label, pin); return PTR_ERR(gpiod); @@ -257,9 +259,9 @@ static void x86_android_tablet_cleanup(void) static __init int x86_android_tablet_init(void) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; const struct x86_dev_info *dev_info; const struct dmi_system_id *id; - struct gpio_chip *chip; int i, ret = 0; id = dmi_first_match(x86_android_tablet_ids); @@ -273,13 +275,13 @@ static __init int x86_android_tablet_init(void) * _AEI (ACPI Event Interrupt) handlers, disable these. */ if (dev_info->invalid_aei_gpiochip) { - chip = gpiochip_find(dev_info->invalid_aei_gpiochip, - gpiochip_find_match_label); - if (!chip) { + gdev = gpio_device_find_by_label( + dev_info->invalid_aei_gpiochip); + if (!gdev) { pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip); return -ENODEV; } - acpi_gpiochip_free_interrupts(chip); + acpi_gpio_device_free_interrupts(gdev); } /* From patchwork Tue Sep 5 18:53:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374939 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 DF303CA0FFB for ; Tue, 5 Sep 2023 18:54:14 +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=VEgaML3380mtHPh7/YntvpokaRNwAfnYdr5yApqRz3o=; b=chi3n/r88wZ5Va agGhMClP+R8OWDJsHY9vs3TbhIqgT89nYOJoLgVZTQeXRxANYxlbVjSbyxf6AqkBboNfWPb6zulIn jWWjgcNKnSRYj1cOG3ULD8B7V5BpMCeW/eBCymna2SDhzEK8Z6oH72/9kvTTP8d3vqQWjZTDTSJm1 PUG+XxjpG28Im12GHz6WUYnE1FFTbfXdv8osdwDlo5CVSgreMU3PY6c+owKEgpyrqwG3FRfAGbjfB DEm+8L52Psuo3R+sWNTMevUdTcl27E4aMKGwKJA1K08uKCtq6ZeLsKMR7uiqmsfiZ+nh+NrZaVFOu 2/7iQZk3Z8Kgt8ZiCvNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBP-006YbD-0S; Tue, 05 Sep 2023 18:53:51 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBI-006YTj-14 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:45 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4018af103bcso1013515e9.1 for ; Tue, 05 Sep 2023 11:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940020; x=1694544820; 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=c6tn4Tgcsi1O0hqP3FN/fJ4KrpHQM0EtczTKadJgTtw=; b=nzfVfedccFLfsc35Jyl6X5TFr2MmAwqthY0wpkkZEnec9xDAccuFQESqz5v79bsG9O ni2fTlQwV/CoZ5wbh2l4lIWukPlgrEqbvkij5NU6DAyhHBqBYOpmBWrmV4v2sTt7m3Cn YGjHaQrfH1WXFIMXLKDW7x1Hxuq91o0ydrR7HRACjuzI0kYyVGtCfG/7sZbG/iirLP3w jl9f86i0LvkMuxNo20ewSgA88UOm8fTO4M1X0DbFb59/qrkLeY2uQstm2oMtslwx9WH/ 3cIN3PHq0ttF9fa/5UxYew+TXrgHfsJKOhzMjEaLt36Q0RaPMHIoF8PK7KGPzypQKC+J 4eaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940020; x=1694544820; 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=c6tn4Tgcsi1O0hqP3FN/fJ4KrpHQM0EtczTKadJgTtw=; b=UAamuIpHNvWjmqcXSWo3ebR79qv/O/ikNtLgmKTCIZ/ULd8C7RVIVVPMsK1sbIm8r2 q8Wsywu3m8f6T0iuY9fbI2xCmf/MZ9y7L2a6CNaVE2aTXW8dtxXqW2juYYCw+qJpg5RE kDDjtnPxyrvjcQ0iLABxfHQgbnEme5tCagnzBQz2cmLwFrRoQ04wQHxrukpVyE2d2Zv2 uKTXEsKq86L4y5h7CLLNyVBRHDqS4ego1kMC2X+JZYUYYQ47aB5XXzGgX1r7mw93Z2VZ 7ZmBB0/zTAbfrwuQY3eIUJPt3iojssG76VISWAdjFtxEzn+hku+L6vZJT8NY4PSTGm7i u/mA== X-Gm-Message-State: AOJu0YyzGyaEJ1+PDFW/+U/JYAHjjpHgF37wrEnHg4haA7EcdCQj6suC WLl6/RJ3k3QjYAd7cMkPaIrf0A== X-Google-Smtp-Source: AGHT+IHaOumSDU3nr/8PNaqRqHS3aAWO3c0eVyPkb5h63GCpGBG6kfLxrczPHvapwSdIRLtHe1YhsQ== X-Received: by 2002:a7b:ce90:0:b0:3fe:1b5e:82 with SMTP id q16-20020a7bce90000000b003fe1b5e0082mr547652wmj.20.1693940020693; Tue, 05 Sep 2023 11:53:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:40 -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 12/21] hte: allow building modules with COMPILE_TEST enabled Date: Tue, 5 Sep 2023 20:53:00 +0200 Message-Id: <20230905185309.131295-13-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_115344_369988_7ECFAB6F X-CRM114-Status: GOOD ( 13.58 ) 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 Allow building all HTE modules with COMPILE_TEST Kconfig option enabled. Signed-off-by: Bartosz Golaszewski Acked-by: Linus Walleij --- drivers/hte/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hte/Kconfig b/drivers/hte/Kconfig index cf29e0218bae..083e67492bf2 100644 --- a/drivers/hte/Kconfig +++ b/drivers/hte/Kconfig @@ -16,7 +16,7 @@ if HTE config HTE_TEGRA194 tristate "NVIDIA Tegra194 HTE Support" - depends on ARCH_TEGRA_194_SOC + depends on (ARCH_TEGRA_194_SOC || COMPILE_TEST) help Enable this option for integrated hardware timestamping engine also known as generic timestamping engine (GTE) support on NVIDIA Tegra194 @@ -25,7 +25,7 @@ config HTE_TEGRA194 config HTE_TEGRA194_TEST tristate "NVIDIA Tegra194 HTE Test" - depends on HTE_TEGRA194 + depends on (HTE_TEGRA194 || COMPILE_TEST) help The NVIDIA Tegra194 GTE test driver demonstrates how to use HTE framework to timestamp GPIO and LIC IRQ lines. From patchwork Tue Sep 5 18:53:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374938 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 A1597CA0FF7 for ; Tue, 5 Sep 2023 18:54:13 +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=jiZ+7rn8sb018FVtN1duIrbdD5+58Am33SxaTKOAItM=; b=uzivI5duVh05w9 UNJFp4Z2BsyVLMRKX8vaJoyveVzNBErKWWPypR+fVh8i5AgCf3rjPR2v3kWnQLdGIo6OfpftHjneR 8Ans/PEwLmxlxafrQbj0j7YLrPFA83IZSgh0q95JenJ3vh6ITemNAvHC8VqwDAOtcOXAqRz52k3ZM r/XSrNtnp0QVmer9i2VGpVrse1M2M1F029onBIBMrV36SMiAftWyHwYk8AjrQO5O2PpDMZqg0I44J dgFoGipckW3oO52Ap+RN3U/Fjfu+E2jk9HtcNKyg0vYhVU5ni1/Kj0927YgQgltbOTEcxII2r4oJw wvAk0+DLuZ99jFrPEaFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBQ-006Yci-2I; Tue, 05 Sep 2023 18:53:52 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBJ-006YUM-1e for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:46 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-401b5516104so28222965e9.2 for ; Tue, 05 Sep 2023 11:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940022; x=1694544822; 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=vPYbcmhlviFwWzuYOu9Z0ne7hiPspJP6iTCWdpKZ06M=; b=Kx/F7Q8hIfX/OkBWIbpi9sXInxdqbaOvNTaZVWN/bWUNUucwBY5snPp4pxPv9L0UOp D9RDMWaewnN00VqhQ4seRBHg1wCUXKrBpjRQfAisEqUMPz6AktNt5dltXWeOd0r7dZfc ZQbhgV1ZA8jlA1p3FgdMc2Z/J4/8rmng1tiNoHnN6yVqdsI8/l+Gir13tH3KWPi0lyr+ KI12W+9QY3nxEMoUZoI5v6cDPwrPE1cRw5V51xdN4ceAK9xYfAd/kDIIGn6vrjSpjA65 2XVp0m4SdTBwU4lFkJyVFZzHNhlMyuqF+1OwD6NYLiumPa1hfUxqLnzjFlQjw8Uasko9 7ayQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940022; x=1694544822; 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=vPYbcmhlviFwWzuYOu9Z0ne7hiPspJP6iTCWdpKZ06M=; b=C5KWYFJ1ztwtVs4w84AfYhAfZACGKYvtZsDwZm3YESaDf/bG3NmkdJes6VoU8BB7Yp TXBwdg76bDAH7M2UpVtAVmDy4CzIsKu46SliP4K73r0coP/MfFdWl7nY7QFumGNRbnIO hMQEkiblbYHkxRj/DHAeW6BXgj5BsxjBXORc6GFALM1Ap4T0KC2YHZUVe3Ry3kvZ6iM2 5jXbGEFudo2dSG090E1t0p2LvH/rhDRkapLZK8t2H7k7kdSi/oIxvIkmN7yB0nW+LfMZ sYu9YYfQARtQoU86tZg6SAjftQvFFSw+EGo9BC0edUTh+Llnx+4S9+9luMdzjf5T0C8s ZQXw== X-Gm-Message-State: AOJu0Yydy90xx7JmmsuIg4OpcNVkWaZ3RRyf7E6G29pUnLmGvIgVwzQu PGvI/ngTwZMX+2sEPHbTE2KdWw== X-Google-Smtp-Source: AGHT+IH7bFhmwhJkbEP09mNLLK4toqHl75c1c56y8lKZfC2ULSFpMzvdc2De5dyozg7UIqDbZnvopw== X-Received: by 2002:a7b:cb96:0:b0:3fe:d6bf:f314 with SMTP id m22-20020a7bcb96000000b003fed6bff314mr414148wmi.39.1693940021910; Tue, 05 Sep 2023 11:53:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:41 -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 13/21] hte: tegra194: improve the GPIO-related comment Date: Tue, 5 Sep 2023 20:53:01 +0200 Message-Id: <20230905185309.131295-14-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_115345_553199_F3E8A852 X-CRM114-Status: GOOD ( 14.79 ) 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 Using any of the GPIO interfaces using the global numberspace is deprecated. Make it clear in the comment. Signed-off-by: Bartosz Golaszewski Acked-by: Linus Walleij --- drivers/hte/hte-tegra194.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c index 6fe6897047ac..9fd3c00ff695 100644 --- a/drivers/hte/hte-tegra194.c +++ b/drivers/hte/hte-tegra194.c @@ -407,12 +407,15 @@ static int tegra_hte_line_xlate(struct hte_chip *gc, return -EINVAL; /* + * GPIO consumers can access GPIOs in two ways: * - * There are two paths GPIO consumers can take as follows: - * 1) The consumer (gpiolib-cdev for example) which uses GPIO global - * number which gets assigned run time. - * 2) The consumer passing GPIO from the DT which is assigned - * statically for example by using TEGRA194_AON_GPIO gpio DT binding. + * 1) Using the global GPIO numberspace. + * + * This is the old, now DEPRECATED method and should not be used in + * new code. TODO: Check if tegra is even concerned by this. + * + * 2) Using GPIO descriptors that can be assigned to consumer devices + * using device-tree, ACPI or lookup tables. * * The code below addresses both the consumer use cases and maps into * HTE/GTE namespace. From patchwork Tue Sep 5 18:53:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374944 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 845F9CA0FFA for ; Tue, 5 Sep 2023 18:54:19 +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=dBSR8Mlda191Fe6BojbSxUEdKLVww25KaoFwL6qQKLM=; b=Rkjsx9z1VlC/jF 9559JVd1DmOvYDgkHq12DoT8NCUR3ME62Q5EhX14/Qf7zP9U2QPq9HARtkc/2+yz1G3ODj9o7HqrP m5N/bAxX3Me9xNVCdE7a5UK43coT2l7GM3bnlH9JY3JshocIqPgr/3ub8GSEFKHsXF2ltwsa+5jTn SyF3TQsbgW+RTS9Sy9H4SJPFt4tnN7xpQFWokQHH6xQ1FfnHSXjrmlqHPF5sv+q8JncHXrfcKSEcx qe+jnBiMZ2ENO5J/RQrg7JcSASmZuHhKtcUl7zOu53uqp4lM61Ciza6nRJ9e5e5MigGsODbpLRP0o eKBKIejASweh8VXAlAvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBP-006Ybs-32; Tue, 05 Sep 2023 18:53:51 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBI-006YUX-0x for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:45 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so28187515e9.1 for ; Tue, 05 Sep 2023 11:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940023; x=1694544823; 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=Xc0dHDvz9aPHwfkkXEcmr6XeU35JNlu/HGwkvzCIguI=; b=BlvtFHi2TeDPNdXfvmmLaKOfGSfUJuHaG2pAQjF3bXgb0rxXHlPIK5VWPFNwnaazJl 7hJ3UrUsHBcFb+Pf3ujtxiHMiVZIaDTLg5JbHtjtpm0ytoOIMBP3rn3vosTSkmY9tgIo mrMwFyyptnlm0csMXSB3HaJGrGXD3CvkwXZEcm2dq33t0PUxhvs9XNC3HUFoQ9rL4/S1 kwL3sPg84kAT4Iz+213SWuzTByFujw9PCoDYj8LX0k1i8hpv7qoBWEX4VNXWthQ75YXD QKk5GFFSQ+s1NuFR0vuitZ+VCod5/RUo/CslCwGHc1ymW/EDZF/h29bhYIBVZRk4eFuo ZsBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940023; x=1694544823; 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=Xc0dHDvz9aPHwfkkXEcmr6XeU35JNlu/HGwkvzCIguI=; b=JsvXXi2f9RJx1KBSYoRr5lRQI3kTzH7wYcxGlE5ipZKZuMh/fzumzG3P7wnrRbOxDs H2ZTM10/GGSjCttw5ehJ3oFIjMcESpS2Pq+DBWvWqff5ahugOfzkYBiYU2HBAugDjpxt vGy1I++CbrzVzRew70n9ljbx+qj7ocPqPhh2BX6CoE3/OzecRCnF2zGwWbPvFk9GCgdy i1mU/XJ6YIDAVnT4SPEY29oEQUecCPbcX6ATT5soS2kQHV4HKZqNBIra5h05BIzTE+yZ sOMzu+xJ0VbkzA1/dsQsh3BeXWnx7MZ4rPAWKjdWI5kg8OuKBs7tfcf682odKxOf419r j2wQ== X-Gm-Message-State: AOJu0Yx7rzPbFXhJQxtRINYXeaH3LD81K/EsnZQj8n5IX5FicP2K1l+O cUq/L32fEsn1Qw+Jj8jn96gVqw== X-Google-Smtp-Source: AGHT+IHuUeDvZm0XqMGiNP8BC9POVIvbxw89mmcaJKbgfsfvBj7DplEY4g0IVdJg6twQF2wl+B7cWQ== X-Received: by 2002:a1c:4c0a:0:b0:400:419c:bbe2 with SMTP id z10-20020a1c4c0a000000b00400419cbbe2mr502889wmf.24.1693940023108; Tue, 05 Sep 2023 11:53:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:42 -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: [RFT PATCH 14/21] hte: tegra194: don't access struct gpio_chip Date: Tue, 5 Sep 2023 20:53:02 +0200 Message-Id: <20230905185309.131295-15-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_115344_331897_0294A1CF X-CRM114-Status: GOOD ( 18.85 ) 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 Using struct gpio_chip is not safe as it will disappear if the underlying driver is unbound for any reason. Switch to using reference counted struct gpio_device and its dedicated accessors. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij Tested-by: Dipen Patel --- drivers/hte/hte-tegra194.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c index 9fd3c00ff695..d83ef30c9588 100644 --- a/drivers/hte/hte-tegra194.c +++ b/drivers/hte/hte-tegra194.c @@ -132,7 +132,7 @@ struct tegra_hte_soc { const struct tegra_hte_data *prov_data; struct tegra_hte_line_data *line_data; struct hte_chip *chip; - struct gpio_chip *c; + struct gpio_device *gdev; void __iomem *regs; }; @@ -421,7 +421,7 @@ static int tegra_hte_line_xlate(struct hte_chip *gc, * HTE/GTE namespace. */ if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && !args) { - line_id = desc->attr.line_id - gs->c->base; + line_id = desc->attr.line_id - gpio_device_get_base(gs->gdev); map = gs->prov_data->map; map_sz = gs->prov_data->map_sz; } else if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && args) { @@ -643,12 +643,15 @@ static irqreturn_t tegra_hte_isr(int irq, void *dev_id) static bool tegra_hte_match_from_linedata(const struct hte_chip *chip, const struct hte_ts_desc *hdesc) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct tegra_hte_soc *hte_dev = chip->data; if (!hte_dev || (hte_dev->prov_data->type != HTE_TEGRA_TYPE_GPIO)) return false; - return hte_dev->c == gpiod_to_chip(hdesc->attr.line_data); + gdev = gpiod_to_device(hdesc->attr.line_data); + + return hte_dev->gdev == gdev; } static const struct of_device_id tegra_hte_of_match[] = { @@ -676,16 +679,18 @@ static void tegra_gte_disable(void *data) tegra_hte_writel(gs, HTE_TECTRL, 0); } -static int tegra_get_gpiochip_from_name(struct gpio_chip *chip, void *data) -{ - return !strcmp(chip->label, data); -} - static int tegra_gpiochip_match(struct gpio_chip *chip, void *data) { return chip->fwnode == of_node_to_fwnode(data); } +static void tegra_hte_put_gpio_device(void *data) +{ + struct gpio_device *gdev = data; + + gpio_device_put(gdev); +} + static int tegra_hte_probe(struct platform_device *pdev) { int ret; @@ -763,8 +768,8 @@ static int tegra_hte_probe(struct platform_device *pdev) if (of_device_is_compatible(dev->of_node, "nvidia,tegra194-gte-aon")) { - hte_dev->c = gpiochip_find("tegra194-gpio-aon", - tegra_get_gpiochip_from_name); + hte_dev->gdev = + gpio_device_find_by_label("tegra194-gpio-aon"); } else { gpio_ctrl = of_parse_phandle(dev->of_node, "nvidia,gpio-controller", @@ -775,14 +780,19 @@ static int tegra_hte_probe(struct platform_device *pdev) return -ENODEV; } - hte_dev->c = gpiochip_find(gpio_ctrl, - tegra_gpiochip_match); + hte_dev->gdev = gpio_device_find(gpio_ctrl, + tegra_gpiochip_match); of_node_put(gpio_ctrl); } - if (!hte_dev->c) + if (!hte_dev->gdev) return dev_err_probe(dev, -EPROBE_DEFER, "wait for gpio controller\n"); + + ret = devm_add_action_or_reset(dev, tegra_hte_put_gpio_device, + hte_dev->gdev); + if (ret) + return ret; } hte_dev->chip = gc; From patchwork Tue Sep 5 18:53:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374945 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 8C276CA0FF7 for ; Tue, 5 Sep 2023 18:54:21 +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=k8DME9JlMA6/Q4gg/2GjCQ7mGMr3chkC3QFGQdMFNQw=; b=XL6K/sFmQFPKcz +3O9BxGDHY/oBwF68AR+YD1oMfgNMhdbJo4PiAEE7moWtfnyYzXpBPv62N/gEA7iYpyq7gPT6LCEZ 2GLEAnDP5p3aQCWiEEZwL2+jK4oDJkU0jmCgnSQoArnbyGJzpMoX9VCZXiXf69tszzg28B3Eqrsjm IrjVPcox0pgTortv4oUVBW6A8ltI2lFuzDbeZiJMoIK+EZ9UYLYTfUY565W/MSGzkLsN1ZgPMjlWp 8lOA4uFFf/Xtvu6Jk4joOwGmP+Zm+hLqwKut6Kt5+pG+inY10AB7oUW6M4TxechpBKjWtKYgcr7T+ /uP3+PiwnXrCSBLTCEKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBT-006Yf9-04; Tue, 05 Sep 2023 18:53:55 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBL-006YVg-36 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:49 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31c6d17aec4so2396234f8f.1 for ; Tue, 05 Sep 2023 11:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940024; x=1694544824; 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=gFpxyOwy5Bm9Qt9hRSpXKADqH+X+nrhUxL/zhVP0yhY=; b=cTyuVZRXdWg6q8NihY0x8Go/KD2QCUe3LoRUGZ08W+BUJXDvW24f495sdynqvPgud3 Wppjte9zqD+dHxYt9JiblalyKUDglF/eroZAMDKeEuf4v9hM2/Q4VAFmEAvztKssqJZw pQgJ5ew6WIXHfa4ZiDl2fYgviYqiNGDKwmDyPGyouAC1iKNox+l/mb/SvvuSPvxyfLRn 8k6JUY1nG8huiXg6CQaZR6MrhIRlYELR7TReoCjnlXsD2XMybItk+4Ou27MDrUdETP5l cpSuEDHYpWWQKxWkhxyUDcDqiJzO+tLlEImVTmU97e4lznSH3E2mw2IVNoWNmXUI3fu2 jPvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940024; x=1694544824; 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=gFpxyOwy5Bm9Qt9hRSpXKADqH+X+nrhUxL/zhVP0yhY=; b=MvetUN5LgmPBbnrwDXDsU2tZeEfnv5wbBlVCOjsmObkFDzDODBCHNWPxo6mbNCNKCo nX3aV6L1Edp3AdCHvwfJheLV8MdlQAlZdKtv8FjFrjTpx0S+KtxCgU0CbYDjSeP8Jxg1 IXTCUCTAqsqh4jQJ8czn/9n0NG0cpsFhtagGNgQernp3R6IZHxup++9gteWJvV1pPZTY C46G3WkJiUSYJ+gICUIbCKFLa3IMdRE3WP8tkpzk7wSBVFG01z06KYUX2xlj/PP3mIp7 8fhvF9lazEVeY4IwHSjo9NP1oyCLRCbqe8BlrNVG8Plw9an+6ueLkF6SLRGsh3f/QO+J 5KWg== X-Gm-Message-State: AOJu0Yzsaa7UuaL2pbwmkTZAP6uMe7XIzS+bAMBe+GC2WOeJ4mzoxntf Ub63KDyVuCdc6u/4pIY26v5H+78haP8jR4AjHKA= X-Google-Smtp-Source: AGHT+IFRNQIOeT3zr09E3n7bBEGrta/pNu8Vff14KdMD6sxtlr9ZDhLyFMZ76FUBno0gzmLiwhMBVA== X-Received: by 2002:a5d:5592:0:b0:317:54de:9719 with SMTP id i18-20020a5d5592000000b0031754de9719mr425005wrv.70.1693940024276; Tue, 05 Sep 2023 11:53:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:43 -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: [RFT PATCH 15/21] arm: omap1: ams-delta: stop using gpiochip_find() Date: Tue, 5 Sep 2023 20:53:03 +0200 Message-Id: <20230905185309.131295-16-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_115348_000078_887699DD X-CRM114-Status: GOOD ( 19.48 ) 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 gpiochip_find() is going away as it's not hot-unplug safe. This platform is not affected by any of the related problems as this GPIO controller cannot really go away but in order to finally remove this function, we need to convert it to using gpio_device_find() as well. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij Acked-by: Janusz Krzysztofik Acked-by: Tony Lindgren --- arch/arm/mach-omap1/board-ams-delta.c | 36 +++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 9808cd27e2cf..a28ea6ac1eba 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -560,22 +560,6 @@ static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { &ams_delta_nand_gpio_table, }; -/* - * Some drivers may not use GPIO lookup tables but need to be provided - * with GPIO numbers. The same applies to GPIO based IRQ lines - some - * drivers may even not use GPIO layer but expect just IRQ numbers. - * We could either define GPIO lookup tables then use them on behalf - * of those devices, or we can use GPIO driver level methods for - * identification of GPIO and IRQ numbers. For the purpose of the latter, - * defina a helper function which identifies GPIO chips by their labels. - */ -static int gpiochip_match_by_label(struct gpio_chip *chip, void *data) -{ - char *label = data; - - return !strcmp(label, chip->label); -} - static struct gpiod_hog ams_delta_gpio_hogs[] = { GPIO_HOG(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, "keybrd_dataout", GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW), @@ -615,14 +599,28 @@ static void __init modem_assign_irq(struct gpio_chip *chip) */ static void __init omap_gpio_deps_init(void) { + struct gpio_device *gdev; struct gpio_chip *chip; - chip = gpiochip_find(OMAP_GPIO_LABEL, gpiochip_match_by_label); - if (!chip) { - pr_err("%s: OMAP GPIO chip not found\n", __func__); + /* + * Some drivers may not use GPIO lookup tables but need to be provided + * with GPIO numbers. The same applies to GPIO based IRQ lines - some + * drivers may even not use GPIO layer but expect just IRQ numbers. + * We could either define GPIO lookup tables then use them on behalf + * of those devices, or we can use GPIO driver level methods for + * identification of GPIO and IRQ numbers. + * + * This reference will be leaked but that's alright as this device + * never goes down. + */ + gdev = gpio_device_find_by_label(OMAP_GPIO_LABEL); + if (!gdev) { + pr_err("%s: OMAP GPIO device not found\n", __func__); return; } + chip = gpio_device_get_chip(gdev); + /* * Start with FIQ initialization as it may have to request * and release successfully each OMAP GPIO pin in turn. From patchwork Tue Sep 5 18:53:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374942 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 5BE3ACA0FF7 for ; Tue, 5 Sep 2023 18:54:17 +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=5oUnURAyJRRc1OSaxLUJCDExdNGSJ4FMgM6A73EltqQ=; b=VYhO3mRIkSVtWY orGEIhrO+Le8Fln2FuEdNvmeq/6R/9l0+SR+4U37Nse3LHOkJJK7jXsXOzscONsgHN/gVO2ckUYwt iE+TDvtnokRxNMtxw5q/jFPzLPj7+1U6sjVr8OvCwyB38aVs59hnV1WI3zWau6QUuDTsmZEAXtsRj Sah4wks7SqRpZnEB0pwFyoceoPpV4N+R3wbcZwVAIfAE74z3nEjzM8RqCl7Mvm3/VPLIz9/8cqljs aS6BVrbNv0+ZXGUir1OmbVJvpWTRRraxostIL9KE43T+gIlsB1NclMMG7sFw4X8ENPGNb4ZI5goMD 8FAVDGpHRnrjNFYo1k/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBU-006YgP-18; Tue, 05 Sep 2023 18:53:56 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBM-006YWU-0Z for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:49 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-401d80f4ef8so28606415e9.1 for ; Tue, 05 Sep 2023 11:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940025; x=1694544825; 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=ENyvcqOYq6piL9aYNsmVNToV9MKgtDTkh/A8a81eQKQ=; b=Uz2xC47ArkJ+C1O6vIVzlGexblMEjfQmTHHQLLpwBiCIYP6uq38ZSo+oR34OdTL9bl Uu76IlAAJSABAXPnTddJutk9B6lbkKu+0irslIQIH87+XiN5T7yBoTcDifvTOgAIkO1E 25GS1bsa0x+N/Wxz131r5W1eiBSAmvReVgn9+eggfbjAbgK7ColObSHOHvRYNRXd+/4U wpN8RJIqxFvCrSwrhM7bixx+MAtB1qvEKPSR8wv6P5fH4hqwtu7MFrtVX7ugcwctjYEm 81kZwOSIR7ZBgVYJwKnvXSam4Hl/sFmq3FN8ZqXTDB4wQcU3RcumKiq4FESG2jCWjMoK er9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940025; x=1694544825; 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=ENyvcqOYq6piL9aYNsmVNToV9MKgtDTkh/A8a81eQKQ=; b=HWiLhJjtnDdj7klSf70poWfO6oTRKL4HZJjpM+YfTtzSSNXa4V3uREx2DN4zJlmUiZ cVPWw6bPTfBmR6wpyB+nNCy7cJmmaRg1HgXBgWb6LglpHoosl6ZftBPnGcjl7NXu2B09 YBCbKox2MPIAYiA04Rnru95XqEp5g8lVoSjxlyG29ztWyEwbbIGKPs1l37oxkEIYZkcX P/naszVsElZ7owmiWO58yMw0Yt9X/HV7PMbl6m1uKt3dMfO0NYHAgTWOxveNhGyLBFNf GnzFDZQ7aykPN5D52qImMGq0p0UBrJGir7SvOsvIJvHCg7v2fXK4891d7aDtsypZcxKG cIJg== X-Gm-Message-State: AOJu0YzVX8WV50VVCJSCvCI7aQ/VJHb2M+V/fwlbwIPnpBisEaUwMJ4a UZKRrLIG/rCJ9aHDvRo0RbD4ng== X-Google-Smtp-Source: AGHT+IETzIspKoYp23peY3Mtm+8LIAaFcti4lea83HydZgiIlGoA8ysWTU5DS/F06PC8tJEHYtDSiA== X-Received: by 2002:a1c:7410:0:b0:401:d1a3:d7f7 with SMTP id p16-20020a1c7410000000b00401d1a3d7f7mr407237wmc.30.1693940025441; Tue, 05 Sep 2023 11:53:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:45 -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 16/21] gpio: of: correct notifier return codes Date: Tue, 5 Sep 2023 20:53:04 +0200 Message-Id: <20230905185309.131295-17-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_115348_211410_322CF7D2 X-CRM114-Status: GOOD ( 14.77 ) 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 According to the comments in linux/notifier.h, the code to return when a notifications is "not for us" is NOTIFY_DONE, not NOTIFY_OK. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-of.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 531faabead0f..5515f32cf19b 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -834,14 +834,14 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action, switch (of_reconfig_get_state_change(action, arg)) { case OF_RECONFIG_CHANGE_ADD: if (!of_property_read_bool(rd->dn, "gpio-hog")) - return NOTIFY_OK; /* not for us */ + return NOTIFY_DONE; /* not for us */ if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) - return NOTIFY_OK; + return NOTIFY_DONE; chip = of_find_gpiochip_by_node(rd->dn->parent); if (chip == NULL) - return NOTIFY_OK; /* not for us */ + return NOTIFY_DONE; /* not for us */ ret = of_gpiochip_add_hog(chip, rd->dn); if (ret < 0) { @@ -850,22 +850,22 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action, of_node_clear_flag(rd->dn, OF_POPULATED); return notifier_from_errno(ret); } - break; + return NOTIFY_OK; case OF_RECONFIG_CHANGE_REMOVE: if (!of_node_check_flag(rd->dn, OF_POPULATED)) - return NOTIFY_OK; /* already depopulated */ + return NOTIFY_DONE; /* already depopulated */ chip = of_find_gpiochip_by_node(rd->dn->parent); if (chip == NULL) - return NOTIFY_OK; /* not for us */ + return NOTIFY_DONE; /* not for us */ of_gpiochip_remove_hog(chip, rd->dn); of_node_clear_flag(rd->dn, OF_POPULATED); - break; + return NOTIFY_OK; } - return NOTIFY_OK; + return NOTIFY_DONE; } struct notifier_block gpio_of_notifier = { From patchwork Tue Sep 5 18:53:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374943 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 E04BFCA0FFB for ; Tue, 5 Sep 2023 18:54:18 +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=jVlO5EGwqRJN8++xApxDJ3Z6jRPiHQldC9X300VO+jE=; b=nlHK5yO65YzKEc vk6bU5ENW7SviH0ixmSuTwhymwt1yz78U58sXiqIGvqZd1d2DkXs/eRRudlzI67OP8xgR25C3rwAM hQ6LFP4GKLdg53uRIFMdu3LJFvmk0h+2CHV0o92VyzQWNcdqE84w5kYQauFFZrFjrS6+6CjT0P9k3 JaSXaGC0SbTbPBm1XLxgiEfx4omZz8sgF5w1GQL/ihVLVILgBwWg/n5P5GmV5SrZt2t7w8yPL9h4s w4V0Pl2/A+JtVXqQsj8gVeRbK2b/65iXi0IEM591OZuq5KI3J3HfNDrYIJGLPcVkaXjXDiakL+49q AUhFFoeY74Wtt8tueogg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBW-006Yiv-2W; Tue, 05 Sep 2023 18:53:58 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBN-006YXN-1P for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:51 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401b0d97850so30054445e9.2 for ; Tue, 05 Sep 2023 11:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940026; x=1694544826; 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=Qoy9g9WNv1Ww8bf2JXz77er47AU9+iMJIALN2tP54MA=; b=jdVJOR/25i8j0jwDGV5b0JVAP50oP9mRmD8RtFu/X0KvFVMlUM32NWgAbJecDkTZrz GOVI2TuauI+EIXyVXTXRCAFEAeU7aEiXc2loNQaqkuDcFRQJzgJZiH5ccVki8OveXQHu nDbLkLHhbU3EUS00ZgtLejUpR92teSc9jFM8T78guIlxgMy7qWTtZldXyK7Kg5xIUj5r KDrf/aMsv+zDugKKjZz6jWyHfTE3aTPJPgbgwrKQ+eJsvSHQXD0V9Gqk+Z4PGuCcg1W1 QpBg2Imt0YAB/CDs3ieYbSSY4Zx+AtXMX4zKFkgpIKUjKzHbgy7gABLi9Ct/xWj3+wO1 HKGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940026; x=1694544826; 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=Qoy9g9WNv1Ww8bf2JXz77er47AU9+iMJIALN2tP54MA=; b=FYkCuJh6fbhnIz187sx5hWDB2YkkO9E+KcuBcnPMPj5HHwRBwVHeViPaGrxkip3Mmp TR5o3Pg4a8MCHEDYsbq90peMWLvCUhkRCEbZuK23aI2yR7Rwa0rcNX4fWirzmpTl8juO 5lJnIEGwB8jO+UMlriL1NYnAXAXWOQ9DetZ0SNzuGxKU+ke5HKKH/SbZtE5+iw0yGTOM d/ILa+nki1xn6vphuTKM5y+yiynRnE9YfBCfqIkiDpLvkGhISumXAxEORnvqG6NPTjXL Aa31yyZ0b3LlA7X6gDC7pz+e7hmwxHkFpESq9LgkuP5B8TveTODksdk2C+WeXHlukGiv jHRA== X-Gm-Message-State: AOJu0YzOseoJ7+FH5rikVpKzxz8uFkuge357eu6m9db3jYRuC/9e8TZf JZc4RjcFxbIDFjXp+5XvkvMaYp2K2ujJfW9+pko= X-Google-Smtp-Source: AGHT+IEhmajciJS3QAdA7TBRkBY7WkAdGBWeYPoavCET0UXaCYTtsM/vkqxleFzUGMa3M4KOPl8b/g== X-Received: by 2002:a05:600c:2945:b0:3fe:d1e9:e6b8 with SMTP id n5-20020a05600c294500b003fed1e9e6b8mr470001wmd.12.1693940026666; Tue, 05 Sep 2023 11:53:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:46 -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 17/21] gpio: of: replace gpiochip_find_* with gpio_device_find_* Date: Tue, 5 Sep 2023 20:53:05 +0200 Message-Id: <20230905185309.131295-18-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_115349_518690_E2538616 X-CRM114-Status: GOOD ( 15.90 ) 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 We're porting all users of gpiochip_find() to using gpio_device_find(). Update the OF GPIO code. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-of.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 5515f32cf19b..9b087f93e049 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -127,10 +127,10 @@ static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data) chip->of_xlate(chip, gpiospec, NULL) >= 0; } -static struct gpio_chip *of_find_gpiochip_by_xlate( - struct of_phandle_args *gpiospec) +static struct gpio_device * +of_find_gpio_device_by_xlate(struct of_phandle_args *gpiospec) { - return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate); + return gpio_device_find(gpiospec, of_gpiochip_match_node_and_xlate); } static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip, @@ -362,8 +362,8 @@ static void of_gpio_flags_quirks(const struct device_node *np, static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, const char *propname, int index, enum of_gpio_flags *flags) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct of_phandle_args gpiospec; - struct gpio_chip *chip; struct gpio_desc *desc; int ret; @@ -375,13 +375,13 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, return ERR_PTR(ret); } - chip = of_find_gpiochip_by_xlate(&gpiospec); - if (!chip) { + gdev = of_find_gpio_device_by_xlate(&gpiospec); + if (!gdev) { desc = ERR_PTR(-EPROBE_DEFER); goto out; } - desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags); + desc = of_xlate_and_get_gpiod_flags(gdev->chip, &gpiospec, flags); if (IS_ERR(desc)) goto out; @@ -813,16 +813,16 @@ static int of_gpiochip_match_node(struct gpio_chip *chip, void *data) return device_match_of_node(&chip->gpiodev->dev, data); } -static struct gpio_chip *of_find_gpiochip_by_node(struct device_node *np) +static struct gpio_device *of_find_gpio_device_by_node(struct device_node *np) { - return gpiochip_find(np, of_gpiochip_match_node); + return gpio_device_find(np, of_gpiochip_match_node); } static int of_gpio_notify(struct notifier_block *nb, unsigned long action, void *arg) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct of_reconfig_data *rd = arg; - struct gpio_chip *chip; int ret; /* @@ -839,11 +839,11 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action, if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) return NOTIFY_DONE; - chip = of_find_gpiochip_by_node(rd->dn->parent); - if (chip == NULL) + gdev = of_find_gpio_device_by_node(rd->dn->parent); + if (!gdev) return NOTIFY_DONE; /* not for us */ - ret = of_gpiochip_add_hog(chip, rd->dn); + ret = of_gpiochip_add_hog(gdev->chip, rd->dn); if (ret < 0) { pr_err("%s: failed to add hogs for %pOF\n", __func__, rd->dn); @@ -856,11 +856,11 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action, if (!of_node_check_flag(rd->dn, OF_POPULATED)) return NOTIFY_DONE; /* already depopulated */ - chip = of_find_gpiochip_by_node(rd->dn->parent); - if (chip == NULL) + gdev = of_find_gpio_device_by_node(rd->dn->parent); + if (!gdev) return NOTIFY_DONE; /* not for us */ - of_gpiochip_remove_hog(chip, rd->dn); + of_gpiochip_remove_hog(gdev->chip, rd->dn); of_node_clear_flag(rd->dn, OF_POPULATED); return NOTIFY_OK; } From patchwork Tue Sep 5 18:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374946 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 5C3D6CA0FF7 for ; Tue, 5 Sep 2023 18:54:26 +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=27FgTT7DriKC8mNm7LYZQYqxPGf6cquvB6Q80da1R+g=; b=d9KwLCFgH+LIw2 PzbI447UecdwYsxwgq/NiRHG4AG4+7eSpgw8cfEz+br2a+BjzEtvYBKnVfugmaa48eNooQ7qwexIy 8kvP1LStuLHVVogBBcDG7qwH9W1TpDozV7LY65s04bw8b3QpiH8Z/DTzyUhockcXib7pUpX3nQ3Fl ExEhg/V/qOJe0MulaRncLZmlounH2Y5Q63PIZcFXaV7J5SzRs1kO6bAMV+nbh+Lxt9CqTmU8WEIza sqE5Dd4h7sOpxCj5XlGFALNFCyxA2FLQe61PEf19/MOAv3YOYb1DW9SRF+ppFw/ShQzpe0+5F8OLU wRRaMihxT7mRiidZkuNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBW-006YhH-03; Tue, 05 Sep 2023 18:53:58 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBN-006YYM-0L for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:50 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40078c4855fso28209875e9.3 for ; Tue, 05 Sep 2023 11:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940028; x=1694544828; 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=v8EoAIqFLJCxUpfLhsvBV4jgy9F1vQzmq/NZ2XWmhPM=; b=nswag8TYgs4kQmHrnTAEBo4XNdGHiAQ4F806P3UcM2NQqPLX7TPHH5pLnXyoSdkU6y P5dAwxQEoks122oa68bV4r7QIFPkefVSzKGP3UcExWUJHPLyUGgSQ9No4mGHyumTq0tM A7e0NniMIBCb6QpHseFzX7ctV0I2uTMipJ61PeYuLkhsJmNbDxHW4aUQdNL3ljgUPVNV wQdg/p+sQqfuDvlOamxS0VzOytP+XeObGPSfmam2bRUE4u3gvugdUqitZBxrldzEUtzm TKHCkGj821jWiyQ2o0ItFiS0taujOmTNkIHv7BJ6+uhKAsrYvW56XLInu1aXQeQeS/kp exCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940028; x=1694544828; 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=v8EoAIqFLJCxUpfLhsvBV4jgy9F1vQzmq/NZ2XWmhPM=; b=hjTEKUfPiBiGJGNkii5N9i9bPX0MOuI7RDA4dhwTgDuI4u6MFXWXF1GpG4gAM6uFMY kCCO/3+qSi0fhk/W9aAfpfwZ/8SIIGaD+zU09RJxBNPXpYbXBSOKpJyT9//7auQ6ZsWb rbKYH3VaUZBt5EvY/994p+Kw1g9HCj2re2e9ePSefaWKP90oTTPyIfmsqDyx/8t2iPvp uxZ5Ykn7MNiA+2sfc/ETZl0TR/wUslqE618SETeX0IGtVI3cWMliVOrWOrLpfSYKSd9n 9inzU4zJP5Dwoi8of/okQV293RLoyPIkvwTI0YO50K62LIqoRH+U+jM1CrngHz7ICCH7 zAlg== X-Gm-Message-State: AOJu0YwvoZtvAEi6MqYeKuj5Wfyqu9suI2Bv/4ZKC8O/tmillxDpcnHb Y208EQ4UgRh5m9GewywZ7CWzhA== X-Google-Smtp-Source: AGHT+IGdmweLsvxMkviAD6X4Rb7LNMdeCjqz2Ypd3y+SG6ZL6d4+T9L7pYZxfgxQTgv+RGIUJmtJEw== X-Received: by 2002:a05:600c:2809:b0:3fe:dcd0:2e10 with SMTP id m9-20020a05600c280900b003fedcd02e10mr472155wmb.17.1693940027944; Tue, 05 Sep 2023 11:53:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:47 -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 18/21] gpio: acpi: replace gpiochip_find() with gpio_device_find() Date: Tue, 5 Sep 2023 20:53:06 +0200 Message-Id: <20230905185309.131295-19-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_115349_147573_23586367 X-CRM114-Status: GOOD ( 13.15 ) 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 We're porting all users of gpiochip_find() to using gpio_device_find(). Update the ACPI GPIO code. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-acpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 5633e39396bc..15d3350123d9 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -143,7 +143,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) */ static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin) { - struct gpio_chip *chip; + struct gpio_device *gdev __free(gpio_device_put) = NULL; acpi_handle handle; acpi_status status; @@ -151,11 +151,11 @@ static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin) if (ACPI_FAILURE(status)) return ERR_PTR(-ENODEV); - chip = gpiochip_find(handle, acpi_gpiochip_find); - if (!chip) + gdev = gpio_device_find(handle, acpi_gpiochip_find); + if (!gdev) return ERR_PTR(-EPROBE_DEFER); - return gpiochip_get_desc(chip, pin); + return gpiochip_get_desc(gdev->chip, pin); } /** From patchwork Tue Sep 5 18:53:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374947 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 0DD0BCA0FFA for ; Tue, 5 Sep 2023 18:54:27 +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=3rWXsnfeHumqYlFCxi8UO2w6Intm8LtKBNZvOl3k/o4=; b=e9XPiINHLz9bz4 7yq5odV/ueKZcOfqJ0bw6W3d3Ta7VwvWAgvoNLfFnmVN27kFiKu0U5QPFhYRn4SW7OSLriRXMsRM6 UR1DFN1gAS+fHPkc/0ou8zVOJ2ISijfWroW+uwxsPy8Nt7X2UoYcSdhA3YTi0JOu9ukzFSptghq4k u95oQbj13UtDRdNs0LKxRRhb8JAUfSxsvZi/h1m9XD7/4JWzdxOn9J4zTf2klMJI6zsLjc90pei/i 2/H6E9MQ8ZadyxHWR/whC2LOt3LkguuEP1trLezPX2nausVXrL+UEjr3F9TpUQpSlNBgxbNf900QN Tn0BS3CS/r3v4FCxlEbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBX-006Yk4-2V; Tue, 05 Sep 2023 18:53:59 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBO-006YZn-13 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:51 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-401187f8071so1120305e9.0 for ; Tue, 05 Sep 2023 11:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940029; x=1694544829; 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=5ZhpZtSP2svZAFrzaQvlM9FAg/vPyJ7DXBzIjcVtHYA=; b=ZVg0Y781WCTLU56x1HAIpJrSi962TgiGnWKeMJre8btE9tpvrmm2k3RfTZzuFIIYRl KZz8Ke0x6NJY8ciUQ0lLpeWtoD8WCwERwHdxG903yFiNNakBeHdZGw0KtghbW7GO5ECd U2vNhCQ+FCp9naq++bUmzvCp0M1DgFUex9d8+kRj+Quc2THu8LFHkdQfC5xPRgTKEGiF pl9RaKN0AyBaANRtyZb3hbKifqYVidHWWVjruYDsplmrvUL5zPdFyHfJqpoJ3Oo+dQ2e QOaX5VjhGLyvpsMFO7I82f1UTFJBgfhoFRVczgNsqTc5UyWsyUaNXHXb7hJS2M6oMU18 mNig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940029; x=1694544829; 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=5ZhpZtSP2svZAFrzaQvlM9FAg/vPyJ7DXBzIjcVtHYA=; b=BJFkLW5WH0jmoj7355ZfCd82xgspb1JSUBPP3jgKBRSesgfLxE5xaVDmRDhjzXtOXQ tULG74vkRANGFwEsHNwnRC8HwTmtWjE3A6/mqMnGWD+aW7Zvu1yBTVCTb+/o7xSUeY7R SZAmOlz8tc6EuVzLg66u5QWvqdxiXCsvT3CqdkIvNy3pJv58I+oa9hEumF+mW0d5X8SB OKGc7q7PK/IGZj51Z2HRIpcPIC6Fxbmo85ZPLC+JmnLjDY1GfqS1k83ou1cIeYpEQwSq 1jNIEBN6aCHQ7gDViGnuJbmcIqxvny5rP7KRhgwFz1n1f1PZMwiGJ5QVjhTwQ4HZU8um KUDw== X-Gm-Message-State: AOJu0YwxxELAymWtkqaTfgQjSeNR42DzpLjqt/7VvRg+6Q/pAn29FBLE 8gOcgDvPs0JldzY7IiRIhw8beA== X-Google-Smtp-Source: AGHT+IH6GCfGhH5bbknVyv1QFmzhhSWppXhliMEz+gshhPkUMADba7JqAHg0E1eXfiJxmPf9zlRrog== X-Received: by 2002:a05:600c:3d0d:b0:402:b8:d022 with SMTP id bh13-20020a05600c3d0d00b0040200b8d022mr609236wmb.16.1693940029130; Tue, 05 Sep 2023 11:53:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:48 -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 19/21] gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label() Date: Tue, 5 Sep 2023 20:53:07 +0200 Message-Id: <20230905185309.131295-20-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_115350_364614_73A68BFC X-CRM114-Status: GOOD ( 14.50 ) 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 We're porting all users of gpiochip_find() to using gpio_device_find(). Update the swnode GPIO code. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-swnode.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c index b5a6eaf3729b..56c8519be538 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -31,31 +31,26 @@ static void swnode_format_propname(const char *con_id, char *propname, strscpy(propname, "gpios", max_size); } -static int swnode_gpiochip_match_name(struct gpio_chip *chip, void *data) +static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode) { - return !strcmp(chip->label, data); -} + const struct software_node *gdev_node; + struct gpio_device *gdev; -static struct gpio_chip *swnode_get_chip(struct fwnode_handle *fwnode) -{ - const struct software_node *chip_node; - struct gpio_chip *chip; - - chip_node = to_software_node(fwnode); - if (!chip_node || !chip_node->name) + gdev_node = to_software_node(fwnode); + if (!gdev_node || !gdev_node->name) return ERR_PTR(-EINVAL); - chip = gpiochip_find((void *)chip_node->name, swnode_gpiochip_match_name); - return chip ?: ERR_PTR(-EPROBE_DEFER); + gdev = gpio_device_find_by_label((void *)gdev_node->name); + return gdev ?: ERR_PTR(-EPROBE_DEFER); } struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, unsigned long *flags) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; const struct software_node *swnode; struct fwnode_reference_args args; - struct gpio_chip *chip; struct gpio_desc *desc; char propname[32]; /* 32 is max size of property name */ int error; @@ -77,12 +72,12 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, return ERR_PTR(error); } - chip = swnode_get_chip(args.fwnode); + gdev = swnode_get_gpio_device(args.fwnode); fwnode_handle_put(args.fwnode); - if (IS_ERR(chip)) - return ERR_CAST(chip); + if (IS_ERR(gdev)) + return ERR_CAST(gdev); - desc = gpiochip_get_desc(chip, args.args[0]); + desc = gpiochip_get_desc(gdev->chip, args.args[0]); *flags = args.args[1]; /* We expect native GPIO flags */ pr_debug("%s: parsed '%s' property of node '%pfwP[%d]' - status (%d)\n", From patchwork Tue Sep 5 18:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374948 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 8AEC8CA0FF7 for ; Tue, 5 Sep 2023 18:54:28 +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=Xb3ak/M3Yo9C+zNGeG/dVZE8mHE1SP29NA0UwcJSBTQ=; b=wAKtLAJon5/Sm0 4ZNHnr1eJipHnEmO3eELfJ8pT36kdPyW4am73jPUraulaaIYdT7zlqa9Xo/TVtgEkO/R4VRDM9O45 5KfOxPbqsFpVaE3PWuhRU93wyRYOwgjticD4bZNSnrTOCWX4g5UCfDaIsXq0s/J5rQNJJAsMU+tVm YizPUPJ2wKFXAbsdPJlqDzs2A8Chy7+BQ2HDAjfYMHc2i4tYrAQyYEukjtdtRcnknK5xddtXLpaQc yIijiVFY39hL4BLdFA0A/zZHBDY3FLNL4NXFuK73o0W5Lbf0LtsUl6QV72Pb5VxF0vEqULh4wGmz2 +8norRO8z/pJsD0Nr/4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBe-006YsS-1x; Tue, 05 Sep 2023 18:54:06 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBS-006Yb8-0D for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:55 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40078c4855fso28210325e9.3 for ; Tue, 05 Sep 2023 11:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940030; x=1694544830; 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=Y08y4soco06KI/f6qh6fDW5G+nl2ifTZ323XD3WrKbY=; b=PuU0Mt0Sit58vKylRA02TnUAv94KoSuqd53memMtYrL2mKDz8TjGwpoFODbspBI4fX jX62po0eaZvpTLEnQSqkbEHw+Eyc7PvQoOTJAmrkyrSoz5LbTrPvATi7mcaAOxLB4PTE NA2wfauF/VzC5VWtP7gLdO6wZjhhYDFol0hEX3dkyzprFG2vQMt7+6Qct4P4Jnx/73ab pxF2dIIMRQGKkOfjJs+ixB1CVFIVBCrYKP0HiBSZrF20SBFZzHSE5aFPB3wuO/UuYzSC KykhXnizC6npyx1oH5u+g5hWuE7HvdJLP2QSHKSC7nG7kkh8VEeLcJwZZs5ApCSfdxsU Yt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940030; x=1694544830; 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=Y08y4soco06KI/f6qh6fDW5G+nl2ifTZ323XD3WrKbY=; b=bXkcqRBX3x/qCXe3oz1m0HMaJix+590ETyfsC/ACjHkmfYzey9+UdruCKB/J+fH0mB 202XbPKohIiRCY1TjxdwarKG9uvDrqQsulP0NFzQaBT4A0Z4QhmMAq3dFQBj/R9x7h/2 2RIwk3ScIP/wCIKwJ9uBwUQTUpQeGOwJwxmcz4mnRT8shq1usUARHbK/KNIQZE6BH+D1 bZt4hTvprkAWUuHMO7L73rL7n8hJuf2YV9dI+nRqYFWEWEbUZ/W3ZhoU9kjq8MNLyqhu e5lREQuuF8Rwe7yT6maf/FHob6Ac9QRapHTOLJz8eX9zPOCs2vY8C25fGa6H2NWFAvTe hQaw== X-Gm-Message-State: AOJu0Yzpv8tGLamV8akfWf0mj56l3PWDX21ItOVwsqumpd3B0E5dpRdT stnfzQRfuXOIhLbIQHKLSP7Skw== X-Google-Smtp-Source: AGHT+IEgNpZG6hg0L74CESnSvpfFz6XeLAbhQH8cNkX0kwXYqx/uTGgV7V6lKbCtezy+q5QbzDETKg== X-Received: by 2002:a05:600c:21cd:b0:401:38dc:8916 with SMTP id x13-20020a05600c21cd00b0040138dc8916mr474754wmj.10.1693940030455; Tue, 05 Sep 2023 11:53:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:49 -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 20/21] gpio: sysfs: drop the mention of gpiochip_find() from sysfs code Date: Tue, 5 Sep 2023 20:53:08 +0200 Message-Id: <20230905185309.131295-21-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_115354_121960_FCF47CED X-CRM114-Status: GOOD ( 14.71 ) 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 We have removed all callers of gpiochip_find() so don't mention it in gpiolib-sysfs.c. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 50503a4525eb..6f309a3b2d9a 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -814,7 +814,7 @@ static int __init gpiolib_sysfs_init(void) * gpiochip_sysfs_register() acquires a mutex. This is unsafe * and needs to be fixed. * - * Also it would be nice to use gpiochip_find() here so we + * Also it would be nice to use gpio_device_find() here so we * can keep gpio_chips local to gpiolib.c, but the yield of * gpio_lock prevents us from doing this. */ From patchwork Tue Sep 5 18:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374949 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 D14FCCA0FF7 for ; Tue, 5 Sep 2023 18:54:30 +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=AYuTJ9ILo6yOgaiUCmAPEUStBYTo9zu8d2vuJ1nD8mw=; b=36avQntYMGNIu1 lKkoZSTmau8hxk1nYNEf40YQc7H2rK3UNR3NORY3qc1rJfYUnWURut9+cyLE2lRfvq2keHsHRN+36 6zV37cwwNElVjJ/4LIgT0IQ33YLxVCFaS2HaLBz6jlLlL7bCCgSSVrxNUr+Pd9cn4BKsQNrXIuhMw YQzexpEsNiNzFiphVEOtFiIroTMWrNmzxFMNh2QVxOP25/2DlaE6zKiF0+0wkJdaggP+gpE1cBMJL 87Z/1kqnncvNtEERTUafEBaYtr7Nyd4e51cnvXCdUW3rS0+gWyGJCiX1hateQVHeKCWD3Oy/JLPSa pm0SKeS72TiAcGwB6Tlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBc-006Yq6-2X; Tue, 05 Sep 2023 18:54:04 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBR-006YcO-0O for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:54 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-401b393df02so28812815e9.1 for ; Tue, 05 Sep 2023 11:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940032; x=1694544832; 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=UrAFFOP3UXm+2vTLeazN1us+BKa1tnA/xN1dYjhLvHM=; b=OqQxaj6Xq+yaBbEa5HkGXMEpS52ajIjT+bUq/+rz0KtKupN0npG9wCWl+kxVsTre9l Cw8ml6EvB9qimSWu2XzvHZF9dN1QgGYL1A1Ozba/x6DuOxUa/3Dv3G9aw61DZ44YUO/I XXqE5RDCDwuQbwRtFTo0O456OLta416kivNBKvuxL3DmYfEnInQoc9+eeBOtXOtgi4nS f47qHvOYusS9GnsSyvQHKuX7d7Pbz/VSXW3T3nTv6Sa1FDabOFVzI2GRZY9EMcMR99wr k0BZTBp7Y9XGq85L6v/JQ60vMjkqG5z+7NgC+aRPG1xoa/EQ0qdbXEzB6X6Ugk286a3J CraA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940032; x=1694544832; 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=UrAFFOP3UXm+2vTLeazN1us+BKa1tnA/xN1dYjhLvHM=; b=fOTT9EoPwnuiVcgZ4LFzQ7Qtnc4KmspTtaikDulRxc5D6uUXfdrao9ZCrInh36mp7d Z9eswKvPee6nj3QBc+d7nMx+TKthJnoIcTqV0rXZY3hSyTJWF6QdUBZZcFAX/BBqoSaj jQ275nVqWx87wQ7/GlN/UQVezT89s6V/4MpBW2yp4QyIfTQSj+2f3bNS9TsC6UMJWEVj 7ZnqUxdmMzEAwXXcsG+dbh897f9Uc7W5eMKUT2jSIklunRtHho1u3nn2I2/u7w0GJpbN Q0xna6RVdSV35ZcsLKx8MkqkuHwjAJMat59zeMQapV3FW070vVNGax0gCbRXcz1KCSsZ Gr2A== X-Gm-Message-State: AOJu0Yz5qTe/4Eu3dx2l5D05zXlDHS3MJ0oeBDH1fuMAbW3gy1rWOF3d U9N9ukDxlPuB0vqJkfsXOG3gAA== X-Google-Smtp-Source: AGHT+IG5rvnvzkhR7zSqbm37o4SyQS5DF2Q3QExpMFHirbdRnNeCry1xvOOt3d5Fk7gOho9h35WBqA== X-Received: by 2002:a05:600c:11ce:b0:3fe:2011:a7ce with SMTP id b14-20020a05600c11ce00b003fe2011a7cemr453840wmi.6.1693940031710; Tue, 05 Sep 2023 11:53:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:51 -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 21/21] gpiolib: remove gpiochip_find() Date: Tue, 5 Sep 2023 20:53:09 +0200 Message-Id: <20230905185309.131295-22-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_115353_184023_65F3AF13 X-CRM114-Status: GOOD ( 13.42 ) 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 With all users of gpiochip_find() converted to using gpio_device_find(), we can now remove this function from the kernel. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 22 ---------------------- include/linux/gpio/driver.h | 3 --- 2 files changed, 25 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 90e8c3d8b6f6..bd700fb4871e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1081,28 +1081,6 @@ void gpiochip_remove(struct gpio_chip *gc) } EXPORT_SYMBOL_GPL(gpiochip_remove); -/* - * FIXME: This will be removed soon. - * - * This function is depracated, don't use. - */ -struct gpio_chip *gpiochip_find(void *data, - int (*match)(struct gpio_chip *gc, - void *data)) -{ - struct gpio_device *gdev; - struct gpio_chip *gc = NULL; - - gdev = gpio_device_find(data, match); - if (gdev) { - gc = gdev->chip; - gpio_device_put(gdev); - } - - return gc; -} -EXPORT_SYMBOL_GPL(gpiochip_find); - /** * gpio_device_find() - find a specific GPIO device * @data: data to pass to match function diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index bb9ec741bfda..7d2bf464478a 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -603,9 +603,6 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, void *data, struct lock_class_key *lock_key, struct lock_class_key *request_key); -struct gpio_chip *gpiochip_find(void *data, - int (*match)(struct gpio_chip *gc, void *data)); - struct gpio_device *gpio_device_find(void *data, int (*match)(struct gpio_chip *gc, void *data));