From patchwork Wed Sep 27 14:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2762938vqu; Wed, 27 Sep 2023 09:53:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSp8J+zZOhZ4uDsoCzNLnHPqeMGZV0KMxqKM1U6tZ9LjwgLNCe0MO5lJhMHmHckVXmu1Kz X-Received: by 2002:a05:6a20:a103:b0:13f:8153:7e31 with SMTP id q3-20020a056a20a10300b0013f81537e31mr2665749pzk.20.1695833629889; Wed, 27 Sep 2023 09:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695833629; cv=none; d=google.com; s=arc-20160816; b=n/DoHxn9u46Zj8APDA8EX7FjAjmyebEQwzACe6BcsPfFmVXF4yF4/zd3DW4TCF2BVO Qy0epMLdeh49I/Mr2pPM6kAV4aLrrcs8z/Ot0jiXy1sJN6N+pDB2We+thUKQi7V9eoJM 9Aq8zBcHHSryYyL1UbOYmZFaNhWRFgd3TFQtqFqhA+tXfEdFkqPEc8EZ54t6eROp29xN e2MoZOxOCx04M2xpzrxmpPavM+ffNgj4AzWvxa2IgA7DLClJvmNgItF7CT7ppHy0JYQ1 YIlhoxyaBeFovkxlRx4y6jvP9Qh1yWooq5RCBV6uFolEqd8JLeJhw0HkFO1+ganHB+Kt tzOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nxu4Stw3TnchTs3E1ZMW4avWovvpHjhxTZTeZz76j+U=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=Iw9o4nArt5wMBu6hesCmUEiwvU/v4ZAXqYpPHUq5HwMd5hYIPInF4bbfTIBoTKRMTZ t1F+oLzJu84BlksRhom5AE/qoZTJqAwcMRBeLeDBnumpSxu/aall91RPxDmobqjV0Wrn 3aG02UH8yl4eLpJivihkCyrV/XSn4LWYuse5iOZSyXI+kfsEinFQlkxGnZupYJQCixPS mJYlbvPfApIshTn12zz/JFhjb3A4i/Gh6jQk6O2Lv2h2YC1vHYAQdhncJx30+KBZtFMb a1bszjWBiguZ0+L/ClWPhIgCqkVqu2swVGCDoYc9yZVLVqeKx45EKGoKpU3hs+O386BO PXtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=2Be4sSYl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ef7-20020a056a002c8700b00689f1186cfdsi16231213pfb.29.2023.09.27.09.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:53:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=2Be4sSYl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7A8C4805C3D9; Wed, 27 Sep 2023 07:29:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbjI0O3m (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbjI0O3j (ORCPT ); Wed, 27 Sep 2023 10:29:39 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3002139 for ; Wed, 27 Sep 2023 07:29:37 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-405361bb9f7so114648565e9.2 for ; Wed, 27 Sep 2023 07:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824976; x=1696429776; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nxu4Stw3TnchTs3E1ZMW4avWovvpHjhxTZTeZz76j+U=; b=2Be4sSYl7+rX2U8AdvQGMmIAmC4om8V069XxAlmXPmjXEBCtwzueVqzfoXra3zy6aj ci08IPZfzwTPTzvqd812mI+67Cde8gIVCAenB5rnD6Zv9we4kfFdpxgwwQ09rSem1sOt gLhE8kku/5CW0g8lzysNmOJqwLujgTFOOOf1TXIgLPbFtl7+TCAjRe1Uy/kzI9pf630p su7eBb+LeqiDJ/GOCPXZTdWmJSGlXFaHcy/UiUOkNGpd8NmhyQIiYYI5zMVIPZRxnpoL fAqfo19tSzlvtxV9qdOgJOIqyY03Ljdp9w0Y0NF+eJDVY+CcwbzGXsgTRxohY1peCrn+ q+xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824976; x=1696429776; 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=nxu4Stw3TnchTs3E1ZMW4avWovvpHjhxTZTeZz76j+U=; b=SeqNj97hQs/AvrCIbZeXCoMgpjr4371jHL7/KJYEdY9ozkP4qCgXEhly4ByWJMhuGm wWQEAMDe0KmA/Crjkjy+ZHZHN+wv2913815ZoiHnWQGuoSK9El+aqNWtECTpvAIL4xHn ybgfe8yn/M5Wz3x2JXaC3sFUOU2FTxUoZ5kclHfNl2C/PnLLw0jkoVNjFbzyuuKt7CfH 4+1wlp+0BlhVNGsdKeXjowEXvKYeHk7APXnrATIpXmvO61xfUVKSoF/AhXZK+Z2p8ziQ yVg74csX9NUdU3HtGO4CV50SuLTrJSx3oorpNRcOCpLYl6CNBgv5sC8DGL/CI3o7amGQ P8BQ== X-Gm-Message-State: AOJu0YwizKyDJw+lGnQnccqXXcKtk7PNFuanChgAM4e46LSn0FvWS4FR 6LcF41Nr3jtM332soF/LP/0qHQ== X-Received: by 2002:a7b:c415:0:b0:405:377f:5417 with SMTP id k21-20020a7bc415000000b00405377f5417mr2073680wmi.39.1695824976201; Wed, 27 Sep 2023 07:29:36 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:35 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 01/11] gpiolib: make gpio_device_get() and gpio_device_put() public Date: Wed, 27 Sep 2023 16:29:21 +0200 Message-Id: <20230927142931.19798-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:29:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778210444399745571 X-GMAIL-MSGID: 1778210444399745571 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 Reviewed-by: Andy Shevchenko --- 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 Wed Sep 27 14:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2814945vqu; Wed, 27 Sep 2023 11:20:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFWj6mTEdvLE9t2SHSner0vlq13vTamiRecP7flCoOu7mws4SP3viS0kbkZpegVgkDwcyj X-Received: by 2002:a17:90b:4109:b0:279:5e3:7f6c with SMTP id io9-20020a17090b410900b0027905e37f6cmr1268069pjb.7.1695838841022; Wed, 27 Sep 2023 11:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695838841; cv=none; d=google.com; s=arc-20160816; b=Hgg6ZDxPUvQvLBDFvqIR3dSoO29hMLpHTbtSgfatOepzTA+od5D4UCAoy3duC0KMM+ wPM3qwAqjt1yTSN0P96pNOOxBYBT2hI2kZ0ZBeq5CgPWvzzPGN/Ag03yrc3dvQ29Dw3O oEAiSl4B1L9X1kE7M/9mdslufcfyKM7kbjkgyca10+gJzJXEvQ8zYnsTPSEsmkfXsYji me24LMfMStjJSz+jE1y+IXmpVeho4zIvvd40EGDVu0Cuq7qEzDvQHK0nvXs/mxKLIN4Y IFPIQw+fajv6MmaAZ3I5/pHZsBVdDij8Da2c3sgovCcHaE5MZUsMtRr7fhCdMmJL0wia MdPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zrpKHVqqTjrma0ET7OV7WLFI0tFo3wgKkZ5ACtzRvkE=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=AcG8oQmJSqulPBYCljVCWyi8yHFS/EdjmxFzVZPrfHEekYkzOKxJdG8+wHm8Xu9kTY QKVlNlIqx52Y/B6VqVES1sp6TSlDgl3vksHg88Q+Tp0INMGpc3kVEu2lQtseIO1aE159 Cupq6SdGT1VXVeoCY0JWb7v96tRGbgXzSpoYg+H3IobWvsExvIaMKhUfnC2snWRXquHx 2snZ7+jQoUmRUZWjzd0qL230eHPtDB0R7r/mXfhfmn3T10rKmpbYwtRtKdlCkUwm4ETb b12Jx8ZAKixkzurOdDSSXhwF/sJBZUCPrIHtvancPb3iPA/ujEtg2OkNtRly6ecbnkXs bJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nmzlb36S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f2-20020a17090a700200b0026f9b5fe711si8941389pjk.108.2023.09.27.11.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nmzlb36S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A10868029DE7; Wed, 27 Sep 2023 07:29:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbjI0O3p (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbjI0O3j (ORCPT ); Wed, 27 Sep 2023 10:29:39 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98681193 for ; Wed, 27 Sep 2023 07:29:38 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-405417465aaso103913715e9.1 for ; Wed, 27 Sep 2023 07:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824977; x=1696429777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zrpKHVqqTjrma0ET7OV7WLFI0tFo3wgKkZ5ACtzRvkE=; b=nmzlb36S3PRwkaDm7sCBLiyf9gzPtuYW5+71NYnSTODLPEkvxqD6eFEDjzLV/BhDEC ZZ3HJgr/KtREJEjzG/QfVqlti7zgG5zq2NwUZX2tH2VT3DpYf4IbeepDRN8b+vHzCKLB x2XB/rWcW48Sg7zVcYZuZdcbPLOulbTGmjvLRr5Nnzg1MI+0lxf8mQHd1m6Pbb7eBrad javetCA1nJuUJuTfqd+OLM9wXAiKFJwMBUT45iq9uHWeaXR17ko5Y44xEmdIQ0ktRnlD a4jeje0kXF50jGUabgvIbPB06qJ7HQ1SjN6erZPzou/YeS1CqjfzTO2jEXGtIdQzgOWF MCWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824977; x=1696429777; 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=zrpKHVqqTjrma0ET7OV7WLFI0tFo3wgKkZ5ACtzRvkE=; b=amtyUfqbFtHk2dBS1Uoz6dEuq3JuVvvVDXg19Ycr0IgxjQ3VCGXSioinIHyBezf61U Lhs8g33T6mewlPXCDHEAFpQfjnVCdP0Rjcxi27x4lioDtWp7IhkrVy24SPkdemnS8xSj GSbe+sXTm7LNSnLcfZGRpM2zplgyx3MiXJlREB0qOtymDiIMS9U1BVS0r1b3MfMoPaQE 7Apv2JJcNLNXVudpvptZYEl1O2rEyQ+Z5g8XTY/CAeJkWJg2/7ojN7i3eDPHmiZ80xY7 5bTehbZTNcRcFeU9JyBmQ45/rXaHk0Ak7lX3CsqvOmg1z+uLUKt+kMZ2viI8Z+MwBoGq PH2g== X-Gm-Message-State: AOJu0Yw6VM/zNH55i6EcSUh2RMxf4j+7dmDNwwu9bchZMYkKBHSsvUBi tkd9Dq87+F3VtdieZiSYdl12ZCeFinUZInZrX1k= X-Received: by 2002:a05:600c:21d4:b0:405:34e4:e756 with SMTP id x20-20020a05600c21d400b0040534e4e756mr2081697wmj.36.1695824977012; Wed, 27 Sep 2023 07:29:37 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:36 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 02/11] gpiolib: add support for scope-based management to gpio_device Date: Wed, 27 Sep 2023 16:29:22 +0200 Message-Id: <20230927142931.19798-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:29:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778215908784033803 X-GMAIL-MSGID: 1778215908784033803 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 Reviewed-by: Andy Shevchenko --- include/linux/gpio/driver.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a2060dc3344b..1cedbc3d3200 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -3,6 +3,8 @@ #define __LINUX_GPIO_DRIVER_H #include +#include +#include #include #include #include @@ -609,6 +611,9 @@ struct gpio_chip *gpiochip_find(void *data, 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 (IS_ERR_OR_NULL(_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 Wed Sep 27 14:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2918633vqu; Wed, 27 Sep 2023 14:50:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWzn6p4MBPcuPxcsyqulFI0Nl1hvuYN4v46c4nN7kVwtAIpm3JfDo84qg9jCTQUQZLoXZX X-Received: by 2002:a81:9406:0:b0:594:ea4f:f5a7 with SMTP id l6-20020a819406000000b00594ea4ff5a7mr3550142ywg.31.1695851427088; Wed, 27 Sep 2023 14:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695851427; cv=none; d=google.com; s=arc-20160816; b=o4StyRE2Zg09YzOtowSn80IssdTVF8+vqKTUQsAP4Z6BEfb3c6tRgxBjeJV4/J19uA +F1Ij3jXisuckZMnRAf1ep+AlOKJPKFC6uMOW7SlvbfHvLHWK6/yMy+/iwfQpmivnoXM bv4ol1cHX61/l8plV2GyrpiWExsDCLqkL5pXReqI+p0XLzoNwDP441Mpopuw9Bv6fzyf nxDOMdC0jHzYDBFjhqvv4oZ61gMHI3/fSGApKfDXyJM9rw0O8qysJPzYhkCIUtJiBJ4o 26IT6eDakdJlpJxmk+wL6sjysliC6iHNo9SLG1uxyPGAMqZ7WhFCM9D883pbiYfGeqSh VcLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AG+MBGFlKyeqAoI+zBkkhuwZdyh02KZ6W2Oat6+x/rc=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=zSgqeY8XR1Y2/v0LrJ/a93i0qGO6M7WvI1DByK4LC1B43d6phTONnguXyPhP2VRHzN OpM+LoqLCLvCYIbrluSL0szB4QjWcx6xs1F6mRaDEa6+dsX35v1N48C7iaTPUb/mDiL8 f9Pjcvy8sIjLfsjzWLL1Wvt4SBlPYWBv4MW8TWhY9hz88xs76G5OtB6UdA8mLzmQEKPH 2hDo7DyRl4N0qVRVF851IXOFUJvF2+607OeuVmKeCLhdgBLSilgUOcuziH7d/4qC5mwi xinGE3ZWQ/DzYhqQWPuysScAY7M0jPlCWOfx7+dxyxr6Du15p3OYuVm2Zu8JL58vBNXD RGaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=jkomhgG+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e26-20020a63545a000000b00573f6ee58fasi16508268pgm.376.2023.09.27.14.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:50:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=jkomhgG+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id AF666809AF9C; Wed, 27 Sep 2023 07:29:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbjI0O3s (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232122AbjI0O3l (ORCPT ); Wed, 27 Sep 2023 10:29:41 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D7E139 for ; Wed, 27 Sep 2023 07:29:39 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4054f790190so101036855e9.2 for ; Wed, 27 Sep 2023 07:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824978; x=1696429778; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AG+MBGFlKyeqAoI+zBkkhuwZdyh02KZ6W2Oat6+x/rc=; b=jkomhgG+Tbn+oHqiYbAzwP2qCyxutFq51q9Fcs/01QlhQvId6oAl7FycrwCnFlrjsP sFnHWdJplfjXkdFGs10AxABLEmXzvBcojyjCRce58rUUFnjvblmIRqem2hLSpQpZ/CSU RWKgx0Dibhagns2lZgXIXSyMlWd8KAjfr5sFc1P4RIN42SgwxOymINpdCKa3UmUj6L0w AMgRHOTp5Sg9Mp1KM6Q9d4JZycK14633XP0FZxYiZ1DGh4tpMnwhvMkgqbBztPtzhVnw DYK29q0dQlq6ncDrikvt8yTgJlZg/WOS2j24Iu2KDuUmXxmSiLZPCUbYjM1XuEUcTIo7 ZJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824978; x=1696429778; 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=AG+MBGFlKyeqAoI+zBkkhuwZdyh02KZ6W2Oat6+x/rc=; b=E232xm4Wya7JC8a9vVKWEs7mNvSRg3XNHWFO0ihQ9y2JdN6VFs4ZPme1uJL69imK6N +XpsWUp4QSHKUMBR824H9qlmFDKUQpwMrr0Ml+mOUxHZLjAyj8mmB1YKvYlGVKCoZbOj ALA4Uqp3nkmzGIOmPbi5cOFxFjgiy7p6ZZYUVLRGE18Un7y2y1dlkR3GgyEBdq7Ir2PM C0aq2+HFPryNIVRkQdT1DKtdzXxk3sipBr8wFY6ZGJpvZtUX2T/ShUonLI9tUYMcYC3l 2KPkhHELgQ4mkzz7I5OX6Im/dfU3sAFovJKHFcHbulX9TD4c2cWbUSFgYLUvwTI0GQme bPBw== X-Gm-Message-State: AOJu0YyQRjy0Yg9v38EnZpKQ0RbHnl+zqvk+PJ64P+ezteYaoy2YzjbK iVSAj0GxohR+W+YSzOex0Xpn8Q== X-Received: by 2002:a7b:c456:0:b0:405:3ca1:f6c6 with SMTP id l22-20020a7bc456000000b004053ca1f6c6mr2188112wmi.0.1695824978053; Wed, 27 Sep 2023 07:29:38 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:37 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 03/11] gpiolib: provide gpio_device_find() Date: Wed, 27 Sep 2023 16:29:23 +0200 Message-Id: <20230927142931.19798-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:29:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778229105814379733 X-GMAIL-MSGID: 1778229105814379733 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 | 71 +++++++++++++++++++++++++++---------- include/linux/gpio/driver.h | 3 ++ 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f84ad54d8dbd..0371d23f0a46 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,62 @@ 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; + + /* + * Not yet but in the future the spinlock below will become a mutex. + * Annotate this function before anyone tries to use it in interrupt + * context like it happened with gpiochip_find(). + */ + might_sleep(); + + 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 1cedbc3d3200..6ad1f1a8ef2e 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -608,6 +608,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_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 Wed Sep 27 14:29:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3009872vqu; Wed, 27 Sep 2023 18:35:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUbKLFN0GENk+vHFTJV7SZseRGmGDR0xzZQMiNO4s2x1vPZwuGY4jIZnlRDnxK4vYs+4+9 X-Received: by 2002:a25:dd2:0:b0:d81:4107:7a3 with SMTP id 201-20020a250dd2000000b00d81410707a3mr3517903ybn.23.1695864910327; Wed, 27 Sep 2023 18:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695864910; cv=none; d=google.com; s=arc-20160816; b=tz9gglUFtaXkIHc4vTZ9ZHWPH7aOAx1xjrZYPqHCAvYcjeuBBz7nI8lg03BT3d3Eia BPRucjftTMPfT0Wfxglpn6ntXVwYIpatssRkvMs07amR4f3FZ/yxggC/3NzzAjscGY9Q fqGP8VhWcGmjhbBdKHVNXHR7Nu8Xiw6eT3a7EWgY2RH060ISgIp7o5rd0+ILD5kSUd1n r80EhUwvGhFRxcH5Cnr6DmyWCidcRXb6A+rqNTuPiNCkPHO1SsJMWZp8fRkhbQ56jOrH tvm8xOLFy2FioslPty27mw7teU6y+3IoEo1wZysYRP6DsJRICk9moTBzKUBAlh9ktt+H A2ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fTcEgfPoq9MntpjrBDVs2nRvtCmOFJGrOAf8mTlZ6ic=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=j7R49EHrBQ8kIqZQKnHHGNbXg0sHoIroWFQUt7Ig3qOwez29FYE1uf/aHwXg1whcdC Q140Da+gxs3FPNQ3IEK+ByMk/m8xfTMW/yYPsbnMOmNhptqvr9lrTnTRARhCeU0SnllZ +KNBiBBmcXVkrncmeP1J4si58u34IGGwSJL5JMZqDYW682lq/tSN+QZCPDBUxQHA4VL8 ftqefgcanO+KxT9sMyR6T5d5gma/4UdFn2cMNbmspFlrwRomQmNFEtZnE1w50x9wNHee lEzIqS14sMUuRmhDpvJkhgz5w33ZgjpwMt9K53eJb6r15kOtjhvDGD2VfZNzAE7fpaC/ pTww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=yMGNr1kd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bs6-20020a632806000000b0057458518e20si2792932pgb.164.2023.09.27.18.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=yMGNr1kd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 30698809B9CB; Wed, 27 Sep 2023 07:30:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbjI0O3u (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbjI0O3m (ORCPT ); Wed, 27 Sep 2023 10:29:42 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EE22180 for ; Wed, 27 Sep 2023 07:29:40 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-307d58b3efbso9564626f8f.0 for ; Wed, 27 Sep 2023 07:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824979; x=1696429779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fTcEgfPoq9MntpjrBDVs2nRvtCmOFJGrOAf8mTlZ6ic=; b=yMGNr1kd3hLtrwjjnHhdG5D7rrhYIkgDkk4BxMJ6QcP26LpenmcAAuDPnHf2x5ArVt EgoK3A847GtHVbvzEw6m7lGUfHRpOEIlkETZaMT+0uBkyCCc4cyRTx91CSDrdjS6dx7b VlMWCtmFop9dmPdfsGynvahT/rsGD39zjTGZG7j1M8Fvb/t7eVpGu2Ni5rRpS5ixnY+X WhqaNKJgs/c145/0CyW2xlyasxa8FgO3ISVEs8QG8/OwNGCUU4xeLtMiM4Pzo2mG5FKp TXYoUbHI/YlQ9AGP8ed46DMSFpQzaXCONn4HUeRWYpoMXkQJ9LXrJNn97R0Q0r+K3i++ tpjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824979; x=1696429779; 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=fTcEgfPoq9MntpjrBDVs2nRvtCmOFJGrOAf8mTlZ6ic=; b=QD8g5xtOM4kqcWSKfo44WQ4W/mhWFG4juOEydK21eHBLW+i7wOdPcTY7jgTrQEh298 WejTTaxiQDO/3NpnjfIwphC1BEAqdhN3f8TR+SecsG6mPQJERp3JY4QoBzIhEISlwg0A dsCdo5aW84urrnFZJZPcGMIV7xMh/R5Feqnp2yECFg1ImdOE6p/zBX5aDKJJEidT8uE+ paoaTr0PccrGHhwQJLwAjgM4ZXg4OV2sNEKxvhG9zpQdt3ZFpqHZ7ceZNZwVAwAiBWfM JDGjCje1AiohU36O6pwl1dq6M2QOm5lAalDiT4sZHlX0rGWj3CmqER0SSGnJI3xVK34T SVTw== X-Gm-Message-State: AOJu0YyCbtXeicnocwfDTpidCr5ERMxOg/ThFlwFYEaPYjSAWsI5En3u 55+nDCgeru1vKRKPkLJ6zm3ivw== X-Received: by 2002:a5d:5582:0:b0:31a:ddf0:93b with SMTP id i2-20020a5d5582000000b0031addf0093bmr1944891wrv.33.1695824978901; Wed, 27 Sep 2023 07:29:38 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:38 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 04/11] gpiolib: provide gpio_device_find_by_label() Date: Wed, 27 Sep 2023 16:29:24 +0200 Message-Id: <20230927142931.19798-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778243244065702220 X-GMAIL-MSGID: 1778243244065702220 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 0371d23f0a46..9f20311e4c1a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1081,6 +1082,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 6ad1f1a8ef2e..24996cba6465 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -610,6 +610,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 Wed Sep 27 14:29:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2765466vqu; Wed, 27 Sep 2023 09:59:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZJL4zJJBKiFL8HWqtz9C3S8OOEPM52zpPVYWF6TPKuAToI+heb1xrplMWNbN/H1drqYVa X-Received: by 2002:a05:6a00:d8a:b0:68f:cdb8:ae33 with SMTP id bf10-20020a056a000d8a00b0068fcdb8ae33mr7617338pfb.10.1695833944110; Wed, 27 Sep 2023 09:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695833944; cv=none; d=google.com; s=arc-20160816; b=BbsNug/OUbnvDCQccyW8ZwztzR1uAKFSajM+4UKRTIe90YD2YdRYgloXSHER5gNuXi oWgf5RbVrnzRbS2pV5mCa8qaLDm6/L5hjNCr1ldtAjeVLXDx3y/+ycevY9gjcExGugn9 il0a1kMSfSCWhu0T93xAx3fzGXqRTHI1IqHO1ne7l9lVkErx+5W7TJi61Inv7HkHB6u/ nPyVplX5PUjsrztJXvG8kCjNGuEbQybIMpcv67lCXN9/wqa/FmofQfEfm37QX6+Au4md uYlLat8/dGgMjkcEhHWSVsEbouHS5ONd8O4np2v7n3LYFNdsIzP7yGUCkKDWx+Pkhdyk sK5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1mbb2H4Qaojfy2/yoEXeeCLJJ5JJqMUu7q1KHHOeyZs=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=BcTg3bLWHreu6w91QZQDePSFDm6kXFVnudyDMMKVzdmsgyvivxt/PK/aKUMOBDKSkV ZMpgUzp/YPfbu0SCBLmzLBIbm+1NrMvRMoIGTxutXF1htdFRlgywFHQK4YtsNj/5jUu1 r8KQnbEPuW38rgJgwYmKFXRWrBsDAP5y2YOfP4IkJRNCGuxPWhMw+ejEiVRUNz99HMz8 skDIpSPKxXX4umb4ct3D1mY8DI4FswWLOk+DtMqcLTSonxIer7fEInA/CputrS7wxqm1 J63QkjNOGikHsRLL+p1F3x9punIbEuumwUic1Aq0S/MYt4Q+kMCVlQSmq6WseJ7AdzjW aRvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=beNfaO7v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h2-20020a631202000000b0056546b5fef5si15206363pgl.561.2023.09.27.09.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=beNfaO7v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id EA867809AFA9; Wed, 27 Sep 2023 07:29:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbjI0O3v (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjI0O3n (ORCPT ); Wed, 27 Sep 2023 10:29:43 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9982E198 for ; Wed, 27 Sep 2023 07:29:41 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40566f8a093so81658295e9.3 for ; Wed, 27 Sep 2023 07:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824980; x=1696429780; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1mbb2H4Qaojfy2/yoEXeeCLJJ5JJqMUu7q1KHHOeyZs=; b=beNfaO7vtzNB2Pyfcuez8POH8XxZ3SkjhjM/O+iNprbBoE2mXyteg9PHFMAdlkgsta fCZ7PaKf/FiQWONO8Zl52nBgtTyzJDoniLPUI9XvXpgaiILAVm3y+vCdAezAy1ZEZH2U M/ZfCaCpY7+KX8I9TUk1j9f8sanGU7HdYKMP9EaFAY7wFQxDq/nVsdtdtcVdvHswP1TX Rrkx0hUwzeVdVeSULUsYety3Jc3HqodnNO6TVYIUDoBUy0W3l3l0TgqWTraA4odR5ksl 20tDbQjpW3zQdFkPSXjeobPHjaS94j1OwcO9d0SpBwnOhLYGWiOnMgPxNCSa4QmPi1uW HWaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824980; x=1696429780; 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=1mbb2H4Qaojfy2/yoEXeeCLJJ5JJqMUu7q1KHHOeyZs=; b=qE2OhZM+pL8Pc+BwdNlnsXziQn2yud82FF0rEhb+CdDuAo9Nd5m4ZnDOvCbgw6GQ9Y e9aV/a7RoRiQVJACUM6YsULnR8DA4/XslyVUN9JcfP5GsI2HidQBflYhWUQTZg+4KaFk 5o2qs7DGXR6t/DN6yeInvO0obiCG8g1N+1fsUzACgjwovRtlb9BBn5+npe0tyKW3Kz0P OExfcAz4S/+J7QQt53JiniVp8avkWGCL801wvLD/dyBKs6eTYp1K5blcVmFXfFuSrLR1 QyiGszx1y8vachvkai54yYoys+atwes062uZ34XKjpOzbWucLdoguyQEUzSA1oz2vQ5D QxVg== X-Gm-Message-State: AOJu0YwceELcYSg5QBmquoo9KiShu5yuMarzcgXFUMFmENg6RSO/cnO+ D2EN7i6n5+7vI0cGLp6YtzhbMw== X-Received: by 2002:a05:600c:151:b0:401:8225:14ee with SMTP id w17-20020a05600c015100b00401822514eemr2024171wmm.41.1695824980062; Wed, 27 Sep 2023 07:29:40 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:39 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 05/11] gpiolib: provide gpio_device_get_desc() Date: Wed, 27 Sep 2023 16:29:25 +0200 Message-Id: <20230927142931.19798-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778210773750375005 X-GMAIL-MSGID: 1778210773750375005 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 | 46 +++++++++++++++++++++++++++---------- include/linux/gpio/driver.h | 2 ++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9f20311e4c1a..7d2574b3dbe5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -147,27 +147,49 @@ 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 %EINVAL if no GPIO exists in the given + * chip for the specified hardware number or %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; + + /* + * FIXME: This will be locked once we protect gdev->chip everywhere + * with SRCU. + */ + gc = gdev->chip; + 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 24996cba6465..3fdf3f14bb13 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -770,6 +770,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 Wed Sep 27 14:29:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2878199vqu; Wed, 27 Sep 2023 13:16:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjw6x1JwCRBDAi866tNu7N8xPkvYLZRgzdhK1RVxNrbJdsLBreqqdQegRq6dNQfifkeMiP X-Received: by 2002:a05:6a20:8414:b0:153:78c1:c40f with SMTP id c20-20020a056a20841400b0015378c1c40fmr3479857pzd.15.1695845793923; Wed, 27 Sep 2023 13:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695845793; cv=none; d=google.com; s=arc-20160816; b=YNxotmYyVKbE6S43R4HQL4UTHDwOHvA3ZuOA2fe/Wcgchbn6jGClE84Ytla0+hresZ 9l4a4ZdN/ozFSTBWTdGdoD95AdrD2Cr4WtXGmAsMb0Z/CxCZ65+t5lONdtFt0xCsvvf3 uKDdiBCXrL+genHQLESzfsAZ+oKatOYTjwTM7Um3Zdze8LLpeXDeLBI1GYK+4Jx+LejU Rv562VgqOvkhDWtrE0jUpouXkw3sTHbfc6Lc1wfoX2vUgTmJGAy63SXkN815Rinc18LC lAM15q4xq1XyRx+1h0Gnr81kR8k/Zo8komkr+CZcA2ckXhsYyrLIIcxL45c7iFXVD7pU 7brw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f7cnFQaXE5hgNGVsFuhD31Dbn34C6HVkTSPK79EhhMo=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=O2nG1AmXAlfpbQuHfNPgNfiQPSLBWybvflozztK/+DEr0WV1u/iD1KzhZEXrTkzcZE WJhaSj81EZYBzstbYIe1IC0DfCInzbTnt6Vszk24EwuKkOgDzEiKW3M4OyyeoQnsg0ZL znX6I3ucCS5TTue91D/hFtxPGT1nimE2tmaJ3rx/ruZC4NfqM0/2Yp3jMZeVxEiesniF CQpjVtPvp3AhHEZV075jS68S5XfUxy8D0B/zz7RNMgG7kQHtFRKKAZA8EuTJX9l/SKSb JGeaGMBM0wFnJk2sJKcmNi4NM18aB8UzApd9e0+KdkYxXpKWMN2299ZdaNGJq8qv/mFN g4aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=tC786oom; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id fd7-20020a056a002e8700b00690a7aefa50si3287541pfb.325.2023.09.27.13.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=tC786oom; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EEF72806155C; Wed, 27 Sep 2023 07:30:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232203AbjI0O3x (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjI0O3n (ORCPT ); Wed, 27 Sep 2023 10:29:43 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70316180 for ; Wed, 27 Sep 2023 07:29:42 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-405361bb9f7so114650845e9.2 for ; Wed, 27 Sep 2023 07:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824981; x=1696429781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f7cnFQaXE5hgNGVsFuhD31Dbn34C6HVkTSPK79EhhMo=; b=tC786oomOp9enwi6Np8ApnZ28cXmNnrL49M8rxAn6ZaocPCrDJwgmiCuvSNBldGGdR /ptSvgYl85A90cuDupuz6zw91SEhvwPLtFfZNO0VwGUtSsseXB1sf+RoaMJ8OF6QxC5h apa8qVJVyfq7ZeQhVMZfRU+n6nKo45EC48r+4y0VfEPpH0ooiOiEfHeJe9Gs5UHSwHBD TSlsXtoXaiuqHwTHWnzc0Lk5lO9Er+Tm5X6eejMXZiTMhRK0oY6fsmUBv4MoTMZbf1vp 2fUXBdNtbwEqxrDiuBjRbqzIsOeCu2OPXxdOcN66lf+wZ98CwE2m7jhcEJDWkZ1mYQlI ecfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824981; x=1696429781; 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=f7cnFQaXE5hgNGVsFuhD31Dbn34C6HVkTSPK79EhhMo=; b=io6nhDmPK05E8xUh/kBd8fNTOGY34oluSjvoE51nwCFVCtHpf5WEg4jAwvuBWHIyUz H4BJCmdPYl1QzZhbDv3cdgle87a3yLR0M5zIsa0YGYv8A18qqb8EhBOWWV1aijgAJD8E CEbO4h2hV4G/4m0X/vi+cRuCoLYIMwfPXSrwCknMHHUDdrwIbkXd4Igj68h9XS3qpEH+ xXp3clOESApLU7jHFvanRofX7RDBFrfFMOjHCozOTi9hrgdk1WE2LY0ym5TKmMGwh9k/ SAex3Ss6js4pmibwx9he8aUx+JQqQIyjL7p7xGf1Q+kc+cE9Ipw+Q+FQHpiaMm0GRrCG 3qBw== X-Gm-Message-State: AOJu0YxXndJy2aVXCL/yv07NKSGDuXJpBHGEQA6dR3YSOeajVh6AosPY cwEecv0uGkhgJsI9+69WSORVKA== X-Received: by 2002:a7b:c8c7:0:b0:405:75f0:fd31 with SMTP id f7-20020a7bc8c7000000b0040575f0fd31mr2054487wml.31.1695824980880; Wed, 27 Sep 2023 07:29:40 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:40 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 06/11] gpiolib: reluctantly provide gpio_device_get_chip() Date: Wed, 27 Sep 2023 16:29:26 +0200 Message-Id: <20230927142931.19798-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778223199398353238 X-GMAIL-MSGID: 1778223199398353238 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 | 21 +++++++++++++++++++++ include/linux/gpio/driver.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7d2574b3dbe5..e26cbd10a246 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -220,6 +220,27 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_to_chip); +/** + * gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device + * @gdev: GPIO device + * + * Returns: + * Address of the GPIO chip backing this device. + * + * Until we can get rid of all non-driver users of 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 3fdf3f14bb13..f8ad7f40100c 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -773,6 +773,8 @@ 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); +struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev); + #ifdef CONFIG_GPIOLIB /* lock/unlock as IRQ */ From patchwork Wed Sep 27 14:29:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2679503vqu; Wed, 27 Sep 2023 07:44:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBKF3ViQN4z00d9girdP27g4cVuHz7vdF3OAiOOVslDPYusxoqgmam1lmxVx2t/s58ucg2 X-Received: by 2002:a05:6830:14e:b0:6b8:807b:b50 with SMTP id j14-20020a056830014e00b006b8807b0b50mr2371189otp.22.1695825886339; Wed, 27 Sep 2023 07:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695825886; cv=none; d=google.com; s=arc-20160816; b=qi5KhOjk10c/uDIMGBXaqcil+Sa/NOiah+d6HoeVQiwbgL0KZijz86Rj/hdC42Wlvc GapcUmFIG/l6tLdloC7MGOjlgyS7z3+9w8Rh/wSTwx9UBAiMCvErlofhodCvHL2HJI5u 5RwaRyRxUWeget3odmtYRn+Wwhx/0+weE9gsZDTaZIn5oiEDBysXlNoN9S+8JWJveDtA mzmUA6UuKqE70U0z/XZUHIah6o9eOREI4NNP8xO6RhSpDMgntIwX2TjK1DhyEl7OoIuJ puIeFA8QbNxzD6LXKLuaQxzhjZlWhT0Ls1g7XWXedwUCQyGuTeMIePRiNZ8DGKWwbrMB WrZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iq/2l1G2X3VlbEMC4JGFIfoN51ntSJ8lHp3eH0L/8mM=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=wGpr4LeYEl3IIM9Ku+ZvC7hcNAUGEpR3AVstI7NpmLU3sP7WcuMQKH8m3quXqPHHGb +o7Q04Wt7DEjIsHkrVUO73JJCrzqy2Vr8u0JI5Hp1nAjdsCaPqD5GoJHmNS7BghiMcQD oAc4ZsSrznbTzsme3+nSOhDpAf3vM5+9shJTkwwfFl1pe2I97OAkDNyffKtNk1TuNgpQ FcgNENjOTbHdm6T8tqqeZqkLWAqKxOmErKH7GoGDJJvqbgTUYNtgupI6CaWBr9cCgzdA HwguGw6LHoZRkS4b5vizBb1yl6z8Kaip85yHfDBnNwcDDnm7EKz8UHybHgNNfSxqm2uf PL4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="Zh0x/nQ8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t24-20020aa79398000000b00690228b1d45si14507161pfe.342.2023.09.27.07.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:44:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="Zh0x/nQ8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DCE7C809B9CE; Wed, 27 Sep 2023 07:30:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232227AbjI0O3y (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbjI0O3q (ORCPT ); Wed, 27 Sep 2023 10:29:46 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D4619C for ; Wed, 27 Sep 2023 07:29:43 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4054496bde3so94752775e9.1 for ; Wed, 27 Sep 2023 07:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824981; x=1696429781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iq/2l1G2X3VlbEMC4JGFIfoN51ntSJ8lHp3eH0L/8mM=; b=Zh0x/nQ8jDWZNzIy56w3kaBAtLR+osipmo88W5sFXVC33xhvCRFVY+qQLQLZzC/ol3 28ZKDh8pc2n5a69EGixt07TL7L/R7LKHyX8MUk0l10Gt52hj9bb5rANxsC+jaUmi0DNI Nrt3yiUpII1G5b6KF0utSyif3vrpl0Y5fCgGImqPP/jHpvpLVna+ouOhPYcRkg1D4irN Mp2SO/AZUZto5GqMrb3KRJsQcFGWFd3AAIu7d7hUbGY7AHiLgBrc1xvIk9GUKN3cZGNQ f6GUivMKgotTrt2d0GhuGVkHbEiSdQqxJc7QEX1u0T3NE1HXCmDast4xGbfB4wVHvk6E 3rtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824981; x=1696429781; 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=iq/2l1G2X3VlbEMC4JGFIfoN51ntSJ8lHp3eH0L/8mM=; b=YLCZZnqwM7HD0p31G9VvOiULufbR7GSTLd9EfcfIzMpRwoKdQYa6Pv9bucyAlMrNFp g29ptEVYaHb/KreaDj1Yov6XtnQywBuqsGLiFcxxXlb4T/5iV2lR5toeDyTbMJ7/uCUJ lxi8ps9Vhc04raK7yfLFztyatfHw9onsbxsGWiLjF5A7jucXieQT1ejR+A16G1eyVCH2 oL9Q9SETxgEpfLxUBvB3JDO/4D54lZF/zwGPLt8dQiLanem/tpI5iaMTH9S2KmCkgLxR HeCL/mjAux4kahxJ2mS6cowlVatGahavbf+TP/vsq4lpM7Ip5+xoSq9IVZ3BNedQDRd9 vHHw== X-Gm-Message-State: AOJu0Yx91OrbFBINDxU6ALQOs0g6J0KF4+TFUkE6xFAbRJco5sQ8+NKO TwsVhleseyGsgZAsIzx6fY0qiw== X-Received: by 2002:a05:600c:230b:b0:405:3955:5872 with SMTP id 11-20020a05600c230b00b0040539555872mr1986626wmo.18.1695824981656; Wed, 27 Sep 2023 07:29:41 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:41 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 07/11] gpiolib: replace find_chip_by_name() with gpio_device_find_by_label() Date: Wed, 27 Sep 2023 16:29:27 +0200 Message-Id: <20230927142931.19798-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778202324878485740 X-GMAIL-MSGID: 1778202324878485740 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 | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e26cbd10a246..dcdac508dcd4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1145,18 +1145,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 @@ -3908,7 +3896,6 @@ 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); @@ -3920,9 +3907,10 @@ void gpiod_add_hogs(struct gpiod_hog *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); + struct gpio_device *gdev __free(gpio_device_put) = + gpio_device_find_by_label(hog->chip_label); + if (gdev) + gpiochip_machine_hog(gpio_device_get_chip(gdev), hog); } mutex_unlock(&gpio_machine_hogs_mutex); @@ -3977,14 +3965,13 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, struct gpio_desc *desc = ERR_PTR(-ENOENT); struct gpiod_lookup_table *table; struct gpiod_lookup *p; + struct gpio_chip *gc; table = gpiod_find_lookup_table(dev); if (!table) return desc; for (p = &table->table[0]; p->key; p++) { - struct gpio_chip *gc; - /* idx must always match exactly */ if (p->idx != idx) continue; @@ -4005,9 +3992,9 @@ 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) { + struct gpio_device *gdev __free(gpio_device_put) = + gpio_device_find_by_label(p->key); + if (!gdev) { /* * As the lookup table indicates a chip with * p->key should exist, assume it may @@ -4020,6 +4007,8 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } + gc = gpio_device_get_chip(gdev); + if (gc->ngpio <= p->chip_hwnum) { dev_err(dev, "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n", @@ -4028,7 +4017,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EINVAL); } - desc = gpiochip_get_desc(gc, p->chip_hwnum); + desc = gpio_device_get_desc(gdev, p->chip_hwnum); *flags = p->flags; return desc; From patchwork Wed Sep 27 14:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2829036vqu; Wed, 27 Sep 2023 11:46:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLR5H00k6TwD+CQNxR87Pn3PblY7ZMsekejEZyvawVJfuCC/cqwlQ/Xjvl+5b/H/1J1iqV X-Received: by 2002:a05:6830:1189:b0:6bc:8afe:8a15 with SMTP id u9-20020a056830118900b006bc8afe8a15mr2609077otq.38.1695840400363; Wed, 27 Sep 2023 11:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695840400; cv=none; d=google.com; s=arc-20160816; b=Q9wNSN75JZuOq2vcZtzaA/9y6ut+xDVx1GfMy2wsh2pOfqsaZqy+FPXhd22sbYfh/X ou+F/QDWvJsPwWjgChL0DpeG3Zac6+d/AIHRbeUNhHnj0Q7q1mW/+GBroff4bAa/p3aj 0bJ9Eo3dSJsux37/XfzvaxAoD6Un+ssNM4/ucoOlT3IB8nLfyhMzd84B+EpJTX4+o+mb c+Cmo9N/pc+ADJCk0RAetFyOLhi/4IUB1F0f38/cBr6I/H8b9XUFkOBwk2S6mCIgRs9/ w4iLjmXTCPbOT5l1e2P1S0Lmr7dBbDsmed4HbyTdOTDmvWaJPxLHcKLcNVqWUADuZWOp afkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oE8FiVQ373WPhEqnnd0k+Q8JE+kP4cy31sdBOoqrMw8=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=tZIQNBufly0giZ5DZs5vo6+2tw+zp2ZGhXAz3vge4owPo2dmV8ZeqXjhl98iXywwh7 /2Zm72BiGF7F4KprVoRSHYawK7jp1x4+B8B/g0PwGk3f5iAHPCTKdQog5u6GB1HLJ5jT d7QgMwGlKRZho194GDZBlN4x9FRWVYCBocsYwz+qZ0+VXhfq/KDkVCXTyWiesQSmv6kF RpqkuIXi8ZoY38IzfbFlD3SJphUaYlHwX93XRhbdQdYwFzB56Jt+3rUABC1Phq5Nof4T DCQM/MauNWH6VyJ2rM4oi4z3pyswU6OWTdVvNqYVK8cfAYSvrIyJ+XLrs+RmbTd/tDeE g/Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=sbouSzjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k83-20020a628456000000b0068e3f55075esi16100139pfd.134.2023.09.27.11.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=sbouSzjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A6A42801CBC8; Wed, 27 Sep 2023 07:30:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232231AbjI0O35 (ORCPT + 21 others); Wed, 27 Sep 2023 10:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232137AbjI0O3r (ORCPT ); Wed, 27 Sep 2023 10:29:47 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AD3819F for ; Wed, 27 Sep 2023 07:29:44 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4053cf48670so101218685e9.0 for ; Wed, 27 Sep 2023 07:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824982; x=1696429782; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oE8FiVQ373WPhEqnnd0k+Q8JE+kP4cy31sdBOoqrMw8=; b=sbouSzjOVd8ltn4tAEi/FEWXTjCdMfo/mYaQjAD8QmocqofoCee9CszmOgufxFCVtr SFfMPymQLA0G8W/k7/mcZRtET+jNBkM8rX7EiZjyRaT125jzTpRbNQ67eI63mq1jXRah WuSkaaXuF9l0wTzAe1kINn/2XtV+wLSc1CWB1vRGhKxsiE8+5GDTJZJ1YQDt3dNcCyTj O9P5PLTNbfbAzdHcoS3JxAvyzq4YVaCeaLyAAdWtE1Jz0/Jfk2UN+BbJz0vniAx5Xc5M D2wxKsmbow5aOtGic4+UHZkV3PyRevTELg5eQTNEsOU0LP7PPOcwS5T4JBwn6ZIp80kQ INEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824982; x=1696429782; 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=oE8FiVQ373WPhEqnnd0k+Q8JE+kP4cy31sdBOoqrMw8=; b=VpcDW4MsBg2paLKssp9/fPQGvzrQciAoTw06tU9Etkz1EddqwQAReEVJK74f30FMBW zqWYWUrONCilt1cLNMv++hg6zwpcJ438E2ssIuqCK2n7F+Xs+NVgObiRKsr3MYYRbs/j 6d+aroZtz+9IQfFbVfSZSV+dTKvqvWNtFLQFYvfeN0BoCe4plV3F3XMkPsvOmVPYV/Mc Fc6szW9FC39keS+OlpGwCHXnWr+dWSkrFh3gDl+ua0ApDu+dZP/vvok8gAxKk3oIAanE Fdi6cID0zlN07FZeafV2jRZlYqnGSymhRfPIXZSYlNowjU75B8pvYRvzJ3M0wEvne+Mw 3YUQ== X-Gm-Message-State: AOJu0Yy/om5+gBJVMomj1HxTdl9KNCF6WxOJI4CLZF1bP24ZaFPH4gOv PpQae7IrKOdEanDfFnW1xJPi0Q== X-Received: by 2002:a1c:4c13:0:b0:401:be77:9a50 with SMTP id z19-20020a1c4c13000000b00401be779a50mr2103103wmf.8.1695824982520; Wed, 27 Sep 2023 07:29:42 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:42 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 08/11] gpio: of: replace gpiochip_find_* with gpio_device_find_* Date: Wed, 27 Sep 2023 16:29:28 +0200 Message-Id: <20230927142931.19798-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778217543318719208 X-GMAIL-MSGID: 1778217543318719208 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 | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 58c0bbe9d569..5ea97c14d77a 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, @@ -372,7 +372,6 @@ 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 of_phandle_args gpiospec; - struct gpio_chip *chip; struct gpio_desc *desc; int ret; @@ -384,13 +383,15 @@ 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) { + struct gpio_device *gdev __free(gpio_device_put) = + 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(gpio_device_get_chip(gdev), + &gpiospec, flags); if (IS_ERR(desc)) goto out; @@ -822,16 +823,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; /* @@ -848,11 +849,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(gpio_device_get_chip(gdev), rd->dn); if (ret < 0) { pr_err("%s: failed to add hogs for %pOF\n", __func__, rd->dn); @@ -865,11 +866,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(gpio_device_get_chip(gdev), rd->dn); of_node_clear_flag(rd->dn, OF_POPULATED); return NOTIFY_OK; } From patchwork Wed Sep 27 14:29:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2772752vqu; Wed, 27 Sep 2023 10:08:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5sRvO3jOlKZgOP9SyjDijjp8/FOha4sjfsWCBDGS/o0gZl3i1sMuOdRbrHhebg/yOc+8j X-Received: by 2002:a17:90a:d194:b0:274:a5a6:120b with SMTP id fu20-20020a17090ad19400b00274a5a6120bmr2069632pjb.36.1695834508174; Wed, 27 Sep 2023 10:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695834508; cv=none; d=google.com; s=arc-20160816; b=kyb68jcfZD/QcC1jV2JYTqYFCTmHMm/4psgqwVUu1uMVcl1Y48Mfff3Im7oawB0fas uvI9EvrV0iy/m7/1yfcFFcKkQf2nuqAs3QdVgL1Bv28i6LKoRY9TetUpSOT4/yqo/z5Z 3kgteojKpQJz6dQ1/frMeo53n8X9DcIqc7VqFbxS10iUWndaE+kwhXyd8fU9Jm8xkkGj COWfE+K1SsVs0tF6oKka2QYWCbf1jpfa+UT8gl35SIG4EW2t8LU95eOMfphgJPXoqXBg MHbFyvLeFmlVamjZQRHOd8zLmQmJn12ZxVu2nAdRv5ZX0bMWDWD2yiGbB++OoKIbAZ71 uJuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NLhg+4lYTY7FPYRXcNep77vyeRRzOTuTNwtgzvDeQR4=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=U68yshNXFZ3PkMI68jI21TluHYZQwmtQdRH5IKmJr7VAXNde7dngGAZdFrl8gGp1Kh uxKOZVOubQuhFhjOC8Dvdv1+SUO/Gmm0V1o76VWM8oacZNRXZNOESiHAkXHulOx5Rsbw 6n+Z/3ut+y1znJdDkR7KmBkwz4gCqWKHE/+3T8Oo5I74zJdKyzVA7XxhXf4xKpFFJ2sC nrHoGHb2tfE/ZVzHqiGmLWcGYF55YKfxkiqQV9cKc958zAkywLfKD8iBEwD2XVw8f3vi H1N8Rsqaj8xS9973oH55fcT2u2qJByiSVTfTdM4Q7v5AGhlPTGYJjC+MCgQOd8VP/f4L g6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=HO1mAQU6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id n10-20020a17090ade8a00b0026803b4ddfcsi8044977pjv.103.2023.09.27.10.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=HO1mAQU6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id CFFA080811C0; Wed, 27 Sep 2023 07:30:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232168AbjI0OaD (ORCPT + 21 others); Wed, 27 Sep 2023 10:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbjI0O3r (ORCPT ); Wed, 27 Sep 2023 10:29:47 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 285D81A7 for ; Wed, 27 Sep 2023 07:29:45 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4064867903cso8329995e9.2 for ; Wed, 27 Sep 2023 07:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824983; x=1696429783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NLhg+4lYTY7FPYRXcNep77vyeRRzOTuTNwtgzvDeQR4=; b=HO1mAQU6tmaCPTS9JAZrlTTnCInqtgPEMjxrsAIbYIe3YO4W5jK/aCM/aW1bczfu7x 9m6S8G9Hyw2njR5JiKPkM7LrtGvV7oERGBSk8Fmfby6PDlV7AiErJCDg8ejwri6yZ0Kj R8KTIGiuVevz9Jk66B3amISn3JjvA5bZvGITWr92Map+b6cj4C4Nz+tslvN9FMtMA+T3 8Mf4wWPX7LbwEqsjkY9orVPhPLn3IWvMFCqxWQYMZd8xEfCB3CIMMx387x6OR4wFs/Hm if/P3XPbOBWH1VRfrXNohBGBlHHLzyn6Q9bUs6pWBgSDnR/P/ZeZ2/Y38ZSMen3fI5yh qXFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824983; x=1696429783; 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=NLhg+4lYTY7FPYRXcNep77vyeRRzOTuTNwtgzvDeQR4=; b=Dn+ewIzEDLfU1+wASSgFonRLOpi/6xe3/rsnY/m/x62HNBaNOpGI/SCI1u5kAKBaIP n9DKMYzSWsLwYf3yW4SLK3UmqaL4xNks/fBiWkzGClRNDqQDRdgz/43WQXoMO3OtdYyj OeW0y29c6tDlBX9PjqC+ewq9D1kPUaH0MJ2iiO7SzRVz8kJpOflLoD7Suhr2ztvbvFwp dCM1IdoVAUpZN4CeCVRFbOiXM17Jc0uhf5mSHVCnkJQ4VMlIyUTYKkjL2PccUsS2nKWz +LRv4XTD7nDZkAG68LRVxeZH1GYo5Y1JzJ6+53K/MFryaVRIp2RnhtdVuamAM73G4K3Z jSiA== X-Gm-Message-State: AOJu0YxbrmGQFHKNj1lhW5GM3Qe5kKLg8TTIyol9AdsO/f/bskNvjkWx NvRZxMXrJZSmh7txFL4q7d4V8w== X-Received: by 2002:a7b:c4cb:0:b0:403:8fb9:8d69 with SMTP id g11-20020a7bc4cb000000b004038fb98d69mr2229061wmk.25.1695824983655; Wed, 27 Sep 2023 07:29:43 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:43 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 09/11] gpio: acpi: replace gpiochip_find() with gpio_device_find() Date: Wed, 27 Sep 2023 16:29:29 +0200 Message-Id: <20230927142931.19798-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778211365234341031 X-GMAIL-MSGID: 1778211365234341031 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 Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 17a86bdd9609..2ad21f34ee62 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -143,7 +143,6 @@ 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; acpi_handle handle; acpi_status status; @@ -151,11 +150,16 @@ 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) + struct gpio_device *gdev __free(gpio_device_put) = + gpio_device_find(handle, acpi_gpiochip_find); + if (!gdev) return ERR_PTR(-EPROBE_DEFER); - return gpiochip_get_desc(chip, pin); + /* + * FIXME: keep track of the reference to the GPIO device somehow + * instead of putting it here. + */ + return gpio_device_get_desc(gdev, pin); } /** From patchwork Wed Sep 27 14:29:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2997375vqu; Wed, 27 Sep 2023 18:01:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErfKivQZJfMt/QJt4r7/S0sq8lwvIeLYnnSQvpfrxR+3Uv5VEBsrR23LLW4VQLgKsYp9F0 X-Received: by 2002:a17:902:c94b:b0:1b9:e9b2:124b with SMTP id i11-20020a170902c94b00b001b9e9b2124bmr3840615pla.64.1695862903397; Wed, 27 Sep 2023 18:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695862903; cv=none; d=google.com; s=arc-20160816; b=KuuNrf8qZvyw6VMPZMcs4xzxYOc0F/99tPnepKbLthdQ7OYK+WyjvoFJJt2FCxTFxJ JzXFX7bq3pfzPDGuN0pMbp8gt/dBa1wY/wfAucolnPIe6V+fMT2AGWEecwbzoJ4qi15q gtNSzsaSXchmBVP9NroA40K3XdsPYtqpCZAfO0iVW3LqXwGXOsPV9a67lkVZbbaf4umA nimvn7K9cZnDdXHDjS43y4EzhzN8/8CvSc/KJL3KoGA79c7KziygEj+dBwvUnvdqqIRr lkpgpIvXlDoTgLm9wW2woFoQ0FUH93dqSX8cv4DRxZeVf+6I6iMIJ+m4NDVmL0MO68fn 3Dsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gEkEuyWHPwtkJqqx/zp65rsN/kW+vWLAZiPV4yAfo60=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=mzbm40rlKswmPvh+wnb/z+DOduntrB5C9+udlgsX9t5dpPjRV2xfmMT0jdDvooiJ0t ++Yo5c8tSSXAd+SPnfpc0+A4w2MVAFkPNXziSoeGkA4kO6aFbnaFCvfWGFyK1xqYiUNH M0DqM83Cgehk7nUeHrBAGe9NTe6IqT7GD+xppQ5qOE9wpaCiWp89F5ZW3zqk1zfqUKj7 f1ckTQWJnSF3KMtQWFjnh60n+vWrVOGEYZD2FHH2JZZSKdwCCzuqQStRE79bZGVvHMRL cLKKPEbVX/jAvR7WyxBxKGc6QWGf416Uy2/C5Sl1cQuby7oZhiYNK1mYUKsEEV/wOCkM inwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="T53P/S8/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bc3-20020a170902930300b001c72c893ad0si1985462plb.48.2023.09.27.18.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="T53P/S8/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CB02F809B9D0; Wed, 27 Sep 2023 07:30:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbjI0OaA (ORCPT + 21 others); Wed, 27 Sep 2023 10:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbjI0O3r (ORCPT ); Wed, 27 Sep 2023 10:29:47 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F123C12A for ; Wed, 27 Sep 2023 07:29:45 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32336a30d18so3385549f8f.2 for ; Wed, 27 Sep 2023 07:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824984; x=1696429784; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gEkEuyWHPwtkJqqx/zp65rsN/kW+vWLAZiPV4yAfo60=; b=T53P/S8/9T02hxwplxxwI5HIC6fr8wFlqdkgtP2ngolZGGyetwJ2OesfrNIJvamTYS 1KidFj6uhuN1LYs8XhqPz5ftp/0k6f366XXwijR2Qf4JWqPqN5wyCrv74tQ62c0diTdQ NsVzgg2zhYJ3wN8S/odCzkspPbl76jzMgml5pMqbUFwkxZ/AB1VlA9/oCQxwwzNCfOlV klGOy0zium87DDvTYfDBzoeas+R4ddkY2mOYSlIUJSptOk8nanwVOEZMDIDTeI7xi1o8 hvr8x787z1GFZz/bpcaWZsK39DcIgUnU9kbEE9XJy1RfF3wiy5cVAlNl4Pw+zBE/H4Rb kWsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824984; x=1696429784; 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=gEkEuyWHPwtkJqqx/zp65rsN/kW+vWLAZiPV4yAfo60=; b=GTBWin1b3K9ZPMnUgpIBQusQD5+Cm88cUccFdGAVc442LKwNCxbZ6uaRF4AaRLSn3I EKMebnBooMOYZzH3g4gZCmj9gDJS+/Nt6K/di+/2zs0Ly4x1wh2U65udHn7O9Je3Uzx1 aWQ36jMHs+7pbycNpV5be90r4EXFPw/438MLFfccxo7YmylSjjSKVpmNqw9SsIqDfp8x VEly7CkPEPh3VaZ6rYKay9oEUpWhkOZPZQqbmFJdqu/QDLnwwWLvh/EFoGTCC4Uv2XKL bsocLUQ0LMoXxgw6m8y5mqIeX7yOc2zaKHk/Ib/seoTcPP34oJCZVmyei19HusrC7Tde MXsQ== X-Gm-Message-State: AOJu0YxzCxubjFdoOmGQHU9bP3uAl8ryREA371JdXx/CTfX6JjWd3fPc svyy7X+gLWPKs6pHhLa9xG4MJBGwtNcaW3qJE64= X-Received: by 2002:a5d:67cd:0:b0:323:306e:65cf with SMTP id n13-20020a5d67cd000000b00323306e65cfmr2124281wrw.10.1695824984517; Wed, 27 Sep 2023 07:29:44 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:44 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 10/11] gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label() Date: Wed, 27 Sep 2023 16:29:30 +0200 Message-Id: <20230927142931.19798-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778241140042594084 X-GMAIL-MSGID: 1778241140042594084 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 | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c index b5a6eaf3729b..fa52bdb1a29a 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -31,22 +31,17 @@ 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(gdev_node->name); + return gdev ?: ERR_PTR(-EPROBE_DEFER); } struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, @@ -55,7 +50,6 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, { 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 +71,17 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, return ERR_PTR(error); } - chip = swnode_get_chip(args.fwnode); + struct gpio_device *gdev __free(gpio_device_put) = + 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]); + /* + * FIXME: The GPIO device reference is put at return but the descriptor + * is passed on. Find a proper solution. + */ + desc = gpio_device_get_desc(gdev, 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 Wed Sep 27 14:29:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 145597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2906367vqu; Wed, 27 Sep 2023 14:19:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHkVjv9cUuA6bZpuVOTl+0LjWG0adEuiRLhxl1KoOOz8THTnCKeAppcm09KaPKQ+sZ0Xo9 X-Received: by 2002:a17:902:b582:b0:1bf:c59:c944 with SMTP id a2-20020a170902b58200b001bf0c59c944mr2533378pls.22.1695849585773; Wed, 27 Sep 2023 14:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695849585; cv=none; d=google.com; s=arc-20160816; b=vv2xZfJGPHpaddqjCD8WI53zDun40uMQOI7ogTrp/QI83K8ZZC3+HvLEzSeJ13SJrY ySjyE/krpp6wdsZ6m7cDmQYoSeZqNxOQBdPJ6mV0MxgBnGZ1R8S47ZR2SoIKBvYHJ/3C wdqxrT2vY6SPUsT0k6CLWB9n40KOUlsbV4dYJO2vVYUe3I7kl7O4b3RRJb45d/NzTK6c yRhu/DRvYatpOXwcl9vbAmznuSBCW+8ApvsOxd/mAUZpDtGI5Bx/K27QaPwh/0x3Mty5 lqNeWtoAalJUE5Y3pRsCvRqLymlyVmLHhxtPgAvhqlwPypK/Y9z3U2pZrh1/ZIpZjda8 QG1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MZXaGIIfZuiGEdZwV32Js1I7wu0xbFZLpMopu8S/63c=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=v2Q8yUqSwEh4ViVDrQhUV4OlMc1l91oZOpCxHIdLOXdox7ZKwDNREiBkLJFSUyLxHi Q3/mHBr5ajK0vEFFsJ0c5wXCa7z+kzlgz1HGqSdWVLxezQ4ZYfFohP2zs1nyO+bIHJKv w5e7iZesTN0Vef3hGuKkwKGPY/Pje0hcVG7iw02x6+PUVnOfkbmtQpWmH4Pp8XQHXamm lNjFW8Is695QJKbTC4yLzfrYFbweatNa39HgPvpcvoKUogPcVltRlM326oVo8mL6Vw67 c8hlnJdGI2PcH6FQKSx8VFHR885xwq+oHpXcPhHO45gZLLqPmG3Cpisn9ayod+voM83g UzOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LRr+WyT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w17-20020a170902e89100b001bf193a70b3si9610737plg.298.2023.09.27.14.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:19:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LRr+WyT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 036628060C8C; Wed, 27 Sep 2023 07:30:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbjI0OaI (ORCPT + 21 others); Wed, 27 Sep 2023 10:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232170AbjI0O3s (ORCPT ); Wed, 27 Sep 2023 10:29:48 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B7F1B6 for ; Wed, 27 Sep 2023 07:29:46 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4053d53a1bfso101430885e9.1 for ; Wed, 27 Sep 2023 07:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695824985; x=1696429785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MZXaGIIfZuiGEdZwV32Js1I7wu0xbFZLpMopu8S/63c=; b=LRr+WyT+pJrvtzeFl3/fK+ENRQ+D1e0hsD+RYczEWKCCDSfkFSRWt4FSYjeXCZD9Kp GyWvm2X6/1LKNL6TZAYKYS6ht5cszmolglAiC/8c4D6CgAjxPZUVvb4Ro7F7jIN+mJr9 9QUrTlbND7s6NJlmOzLc404VWq8LDsLHYi2qsK1qIuybIH8JoBqrVW+voJmD1lTJVYQw pYeAx+hjxY8RSBKSOlL3x3lB8jAFSTB8w9OO3qTLr40WSgcZXQ8aNLNlpHYX33BtsNo2 W12MVKhQ/RaB15Oij4eRJm/nbjabyZ3ifwQTuom524ifc/F+xiRgd124dftTVaLC2Uz1 0nDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695824985; x=1696429785; 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=MZXaGIIfZuiGEdZwV32Js1I7wu0xbFZLpMopu8S/63c=; b=m26yoyut1FxzS67+kK4Es+rBQz4JUVz7ZQaBKPJNVkMrkw71hSK/6bI9Ae4pSAFZJd nu5j2w5iFiyhYPNqtg+iip2IjwVZFqDjiI1Wqz6r1ZMF+5bzc/+lqzWG/W8Dup2JhCM/ QlTolv+Pd11kaI0r9LhG3VMJiM4AMdUtqwCTjlFNXe9y/BqI05HYxuftnfMa0DuOIgH6 6Xnv5H/ZT1I2jGuvtHr7pOYP2nWYt26dMxN4MOtJ5ftMJzYu0mEDoXMpAbHIUQbs8IvQ 8wAcpt9yUaIXogAnyrJ+FHdfyNOkpbO5g8+xAoFQx4K+ln74Z+rgy5y8zdPYMK3r7WEi Q2ag== X-Gm-Message-State: AOJu0YwoE94KOeDpq2tBV8j8+ahX2/xEbrkiJqUxhbaK4BV2UgnlIrHd m/IbFqwzaNxdtpyDjtwmsFccZA== X-Received: by 2002:a7b:c3d1:0:b0:405:3d27:70e8 with SMTP id t17-20020a7bc3d1000000b004053d2770e8mr2265430wmj.36.1695824985281; Wed, 27 Sep 2023 07:29:45 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4bb6:1525:9e22:4a15]) by smtp.gmail.com with ESMTPSA id v2-20020a1cf702000000b003feae747ff2sm20448303wmh.35.2023.09.27.07.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:29:44 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Mika Westerberg Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 11/11] gpio: sysfs: drop the mention of gpiochip_find() from sysfs code Date: Wed, 27 Sep 2023 16:29:31 +0200 Message-Id: <20230927142931.19798-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927142931.19798-1-brgl@bgdev.pl> References: <20230927142931.19798-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:30:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778227175237607075 X-GMAIL-MSGID: 1778227175237607075 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. */