From patchwork Fri Sep 15 15:03:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 140721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1341409vqi; Fri, 15 Sep 2023 14:58:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXnq7NWXEZHkpvSJQE4I5ByaWVYLYONwVxmCRaEYpsQLjdBb4/9a4g6zGsI/vt3aPkXx9z X-Received: by 2002:a17:903:41c2:b0:1b8:6a09:9cf9 with SMTP id u2-20020a17090341c200b001b86a099cf9mr3769349ple.26.1694815132521; Fri, 15 Sep 2023 14:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694815132; cv=none; d=google.com; s=arc-20160816; b=N6p+NFs0X3784GJwqWFEfIOkY9B0bCNrX2/B0BjGW25F06GcEjOVtLArH1/mXp0jGE eM26WcBdKNHW+Pb3Mr5EgkKLt5PlGGxWn7h+9BS41/3kBWdsXFQ5515u8B+m4TJW/Jfd cw3ubCr3nubEiv1ah/Rwtmo+b9jmNuzoQQixXH8XgJd9NAEDEg/eSKse/4QSXryMNNob 88ULy0xYssLxVxaINunn8odaTETitvT3yc/XfKAsRIjwwgY8ODZnNnlsb2ksm0cGTKI0 /AcKcA7vn4sLhConY8gN5K/Y3MFytKq7YADDWnZGkHO0NdBkxh1QYTd8dm9eaqbmRMqP gqiA== 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=EwcFiXqSe9Ibi/9pcxNPtbib6rMgKb4QJbQ4Tu3YDqFa1W9cab98/bXhG4K/Ms1v1s 9Je7sUyPVStbnvkRLrlFOJJwsLc0PVbUwKCfXuFNAkXsOmTffHkOHwI2xoUDO4FQdafb x2Qj6sOGE8kDGUcOTrHxMCLZN5GryLCx64NgZ+8mKb7zs4qHdMudjPT4Z8ohcpIeefJK 8XNbv2ko3+fVYZnhjfHeMW6c/f0COvt8pjySZ55OjP474O1FfJVkOudSk2EvfsmSKgzM BPqkcx8CW8ZSTQvkAzvITSvpVBQ+NP7B8bhdcWkvofQT2PYr62chDeEwd6s9pBnHqg6x RM0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=KgZsQgba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d16-20020a170903231000b001b9da7af2c0si4201066plh.214.2023.09.15.14.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 14:58:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=KgZsQgba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 5A960831E373; Fri, 15 Sep 2023 08:03:59 -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 S235900AbjIOPDw (ORCPT + 31 others); Fri, 15 Sep 2023 11:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235489AbjIOPDj (ORCPT ); Fri, 15 Sep 2023 11:03:39 -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 4976A268A for ; Fri, 15 Sep 2023 08:03:33 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40472c3faadso19934865e9.2 for ; Fri, 15 Sep 2023 08:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790211; x=1695395011; 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=KgZsQgbaJxxknrew3W1dWx0u4Kyp/JlGh5TB440VWDQPUGXDMBCYVMTU5KHA3ndDf0 IsEn6f+SpJaS+riGd5ASGo1SEL9MYiM9qnInMYQhmHZEsfVoJQ+ro1BnrHnUzuMTkW4+ tagAZsxXh9s+bt0vv5uQZLiFT2eHwytY8QYeF65U9kxU3ac/vS5mx8drDw+9Ar/mTd+I dxpzAnF3YrxHqoJTHZBwfG9/4M4Yij8r4QfoJKkHNONxeNPqLXFe3R1H8hHWv3bHDkOO WdGxoZdghmu1bIVbo1xvD4rK9L/9WnHoacnoDfV+3nOfnJbvKLfJCSI1whOu7bjBzgME LQKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790211; x=1695395011; 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=jbT+IsZSthctz3G28uAMje2XxyI2eOf/nKJIQUR1YnnQmYRQ6BidBLr1F9esP1Jg1i iG5PMHWnjhkfGmruFSSlboeY9drV6IY5Lq69yzm/QaaRdTD+rKq8lacx3PBnFaX4kvBc ziIGAtIqnmYFXkdQ6ShUtz47qSdBDBjZ1GQPxRRdTAgKHjLSCos0LkpNeB5dnQ6VQcDN II8kPEY2JOEl6Ewjz/XRGwBME2HtphaQvIgjS2YlbluSRguFMddVw5NuFO2DLqS0pDMy a6KHPPYmYas3bjt/W3s++s2MlNoOh99gOp5ptVODZoyRjY4B69mzT75NiJK9HNwEkZ7K nPwA== X-Gm-Message-State: AOJu0YyItdKLwZltDiQFCe2X/hpx5EHHi8XJUKMMe3wkyjbPuUcgycZ8 YhWuorK5L4uBGo0do98mguKiOQ== X-Received: by 2002:a1c:ed10:0:b0:401:daf2:2737 with SMTP id l16-20020a1ced10000000b00401daf22737mr1945005wmh.30.1694790211489; Fri, 15 Sep 2023 08:03:31 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03:30 -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 v3 01/11] gpiolib: make gpio_device_get() and gpio_device_put() public Date: Fri, 15 Sep 2023 17:03:16 +0200 Message-Id: <20230915150327.81918-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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]); Fri, 15 Sep 2023 08:03:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777142472383490810 X-GMAIL-MSGID: 1777142472383490810 From: Bartosz Golaszewski In order to start migrating away from accessing struct gpio_chip by users other than their owners, let's first make the reference management functions for the opaque struct gpio_device public in the driver.h header. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 24 ++++++++++++++++++++++++ drivers/gpio/gpiolib.h | 10 ---------- include/linux/gpio/driver.h | 3 +++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index edffa0d2acaa..f84ad54d8dbd 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1058,6 +1058,30 @@ static struct gpio_chip *find_chip_by_name(const char *name) return gpiochip_find((void *)name, gpiochip_match_name); } +/** + * gpio_device_get() - Increase the reference count of this GPIO device + * @gdev: GPIO device to increase the refcount for + * + * Returns: + * Pointer to @gdev. + */ +struct gpio_device *gpio_device_get(struct gpio_device *gdev) +{ + return to_gpio_device(get_device(&gdev->dev)); +} +EXPORT_SYMBOL_GPL(gpio_device_get); + +/** + * gpio_device_put() - Decrease the reference count of this GPIO device and + * possibly free all resources associated with it. + * @gdev: GPIO device to decrease the reference count for + */ +void gpio_device_put(struct gpio_device *gdev) +{ + put_device(&gdev->dev); +} +EXPORT_SYMBOL_GPL(gpio_device_put); + #ifdef CONFIG_GPIOLIB_IRQCHIP /* diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 9bff5c2cf720..3ccacf3c1288 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -86,16 +86,6 @@ static inline struct gpio_device *to_gpio_device(struct device *dev) return container_of(dev, struct gpio_device, dev); } -static inline struct gpio_device *gpio_device_get(struct gpio_device *gdev) -{ - return to_gpio_device(get_device(&gdev->dev)); -} - -static inline void gpio_device_put(struct gpio_device *gdev) -{ - put_device(&gdev->dev); -} - /* gpio suffixes used for ACPI and device tree lookup */ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 8f0859ba7065..a2060dc3344b 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -606,6 +606,9 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +struct gpio_device *gpio_device_get(struct gpio_device *gdev); +void gpio_device_put(struct gpio_device *gdev); + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); From patchwork Fri Sep 15 15:03:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 140493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a55:b0:13f:353d:d1ed with SMTP id 21csp377953rwb; Fri, 15 Sep 2023 08:04:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmyRRpQaKaJmlFAH297LptQ60T3aY4T5sL2wcJBieKw4T7T3iG4P8YnCOAAVWBU6VKC5+V X-Received: by 2002:a17:903:2281:b0:1bf:193a:70b6 with SMTP id b1-20020a170903228100b001bf193a70b6mr2859520plh.5.1694790248452; Fri, 15 Sep 2023 08:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694790248; cv=none; d=google.com; s=arc-20160816; b=ZR36xc6krquRdyB4/LDuF7Nl4wqJGw1GRNkob2Uj/YIliwKvKWik0q0RwlIfQgZjlg i5f6CQ0RrN10KJvyyHIkHE+V/fgshsCWCaMIbbucbDllaYTPnooUyDuXK5Jlg/hGX71v svJOI1wkvsS90bcXyWQHbA2VTkrNOAviDgaw0WAmpDujpZpathdlmXBpT+W4ZIxZEskX XaEQdKA20AQsAnuncpI9zxeirIKXBMPuQ8b5H6Ed5RYUuO+/ZGMi+muoyjedrTWcMqpU NrrYTT10PEwl3W3X/wI5wm8wX0trpIk9wi1x7h8uszBJM2+8Lcbn0G4UuKkTec+f3Fgk qvkg== 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=SzkOpVAkLaJRZLZsg4HE74TQS3j5/+EbW50gcUtjdH2tbrkIN52IsNT4Z8585MDYXo n0PxCLJEVotSObOA8iVDHxjA3I7GQQYHVGcEkKXWdS3gYGDJAj7r4cSzN0Z0WPGAmzo0 49Cr2v6bBzlGQDV+Q+zZIENHgQ3wKHOBihag23d+J3wAvfHVfzUwVXjwVUQeabxCJU9G 9Lzl3W55ItzRt9hvm7HibK2H7c9UO5ZjIE8U3WJ9Zgo/Flxfed5P5bK13MdHGNNGvYtE HvLMttbErFrjs29JvmcjiHKMa5Y6ee25YBCn0Qf3BBZQsahF24vYs+0Z6LnxxWOfIGTo unAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=FgCMXmFD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d1-20020a170903230100b001c224748a65si3601798plh.476.2023.09.15.08.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:04:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=FgCMXmFD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 43C29843163A; Fri, 15 Sep 2023 08:03:55 -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 S235889AbjIOPDt (ORCPT + 31 others); Fri, 15 Sep 2023 11:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235495AbjIOPDk (ORCPT ); Fri, 15 Sep 2023 11:03:40 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF3C26B8 for ; Fri, 15 Sep 2023 08:03:34 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40475103519so18060585e9.0 for ; Fri, 15 Sep 2023 08:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790212; x=1695395012; 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=FgCMXmFDIzlAc1Y36Z7Gi2/D1nnyT9x6k3UmWu/N4YCnglJ3a+/cEOPsi3zWJLFk9O 7BB5tDMjrj6muGRofWTFYgNzaGeh85dBFDmB5g43M1LOfw8H5v9JR5P6UL3XH7lOz84U q/pciAQClXDG38V8rOzrBqPjRBgLY7WvNWaraU+Wg6MVFZY0oY7pXiwwJNRhbrD40VwO nRVrTmxruk0gaRlL8St5s58WNJSUXfrG2dCE6FLR8Y3eu6NAJ/E/BUw4QS99hidE8JqO 5i5b3etAIiWlJjppCRE82z4EqstOAMZMjwrYdJTOQXC24072sJpO5c9/c9aQ2rcSd/9G PyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790212; x=1695395012; 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=GU/7KOsO+PBgAy7LsBAIIlFRGUvSpoM+U4P6iIfF+xa7Re0Ok5bGBll+4ZMHtlblId UPpUrmjBAtxRGp9GdwdENaYzRbmZMhmPTe5Yl26hYYZin65e6ZiLwsDzoWir3ho03NEZ JXtrcEtFnbYsT7wueY02I73YBsz6scRjwhDg8zBcIUw3yiPgb3e0VfIJIeXpEX2l9nYW ukLMMkWAx2zw2ZTEO+aFaxYby5oFmdFvmUwVBYTe1wi/J/uGIp4nxE8NCN4nWNUJHVjn 3d6aYKW9mDyx8xNlkqcylMJgbbOJIZWN6XfqAIh1J/c6YPtrmvtQicOg/4KKD+GyoGUO teUg== X-Gm-Message-State: AOJu0YypPIgkZ/5d1sz4m7wCxnjEVS8gGH9PySrNUMT99f0ZcaErtMrC WNlcK91EmqEfAmr38qj9nMwWuw== X-Received: by 2002:a05:600c:ad7:b0:402:f555:6523 with SMTP id c23-20020a05600c0ad700b00402f5556523mr1833444wmr.9.1694790212546; Fri, 15 Sep 2023 08:03:32 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03:32 -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 v3 02/11] gpiolib: add support for scope-based management to gpio_device Date: Fri, 15 Sep 2023 17:03:17 +0200 Message-Id: <20230915150327.81918-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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]); Fri, 15 Sep 2023 08:03:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777116379101179142 X-GMAIL-MSGID: 1777116379101179142 From: Bartosz Golaszewski As the few users that need to get the reference to the GPIO device often release it right after inspecting its properties, let's add support for the automatic reference release to struct gpio_device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- include/linux/gpio/driver.h | 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 Fri Sep 15 15:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 140571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1210777vqi; Fri, 15 Sep 2023 10:32:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9Cr+KVoU49lYjJvHc0FUa4+WcTaB2GD7PdhBWgT3a5TkmrdxZT6RN06s/wQJ1wZiX4zHQ X-Received: by 2002:a05:6a00:21d5:b0:690:2ecd:a597 with SMTP id t21-20020a056a0021d500b006902ecda597mr2577872pfj.21.1694799156531; Fri, 15 Sep 2023 10:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694799156; cv=none; d=google.com; s=arc-20160816; b=vGk6H+YfF8xfu4yGPgeLY5dMpIOuQx6su8VPn9xkldtG5XHLUKDane3SHGSH95x/m0 086aQ7kP542YEqf/r+JpRlW7yzULJcRX/qe04CK+vMHO79Qpw7rbohCgYHgGnZdboyZY 8SPwbaWm2A1u5X1EIglZPD2qim1NrqDSqMIP728EDZ54FWS7ZCs8nNPriNLtWrvL790H X7evDeqNfDfNJERSLeMbpiWs+3jzTJB1ho7WBsLzj4lRDl52w8M/FzLLshzyHxXXAMjU RvvHbfIwAugwmCtgdi6k5Kbt75KN67XySZCOJPnsuzGfCcH51SwNb4bM5CcmIfKNvQVV 635w== 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=C6RA+YM77tzng+gshljulmC+UUdfp3uqsLp/s9TD9x2iVDQEHEUvz0r3jsjUtOIvWM X9fQTX3d77FuL2xggUevM1EMiniO/APP+VGqzaCzHjiqPTm8ROMvJCL6iOdu/+A8XeC1 HsFqmH5+cuaZYQLBfflG5IssfC54O/53Cwn1pnc520MzWr7b/N/XGTsCRKJSkDI2+GaE Oh+pW+6jod7UbiUHVdA2+Qfd4ZRAcloLaFXhEq2JRANNer8xhJMSwPZtVBn+Y5VbU6Jc RrX7D9jfKKqASFLsHQfpKHcoHflQhvlYTbnIX/fWl7LFvef7gv4UPqRkAS2A9SrN13e9 SB2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="lo08M29/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x40-20020a056a0018a800b0068fe810e8a1si3661654pfh.193.2023.09.15.10.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:32:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="lo08M29/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 D9208808206C; Fri, 15 Sep 2023 08:04:01 -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 S235733AbjIOPED (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235732AbjIOPDn (ORCPT ); Fri, 15 Sep 2023 11:03: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 710032703 for ; Fri, 15 Sep 2023 08:03:35 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-403004a96eeso24334085e9.3 for ; Fri, 15 Sep 2023 08:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790214; x=1695395014; 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=lo08M29/S8Ch6GA1Fi7eCGWgf9Ni+B+3SGHBw/M+1NwJ8x8Dry5xj9ByPK+WA0lcRr FEpQYv6zoyLLniYO9UvF/oQtW0QvH/rZahNI6oQbgYax6h4CVsOz1bKOYbjXKhjPaJiU LbYFCgN/ol63Dezd2kNVpQ0j+ah3WEl7YQV2gkcJTj+ZqXsHZEdtF16Rugz5OTMA5Vln Fn+zfcDQZ/qU1gtYM5aL1oW0f9a6EENQTruSA+6zRwe3j3AuuMU9ggmD0jQMrt4qmApb OMqG9W5gyz6qu+5tPJrvsOww5U5Lz/U2Ur4XGiXeOkFVRkSwQFMiksCTR3zjY8zQW31X ExBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790214; x=1695395014; 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=CNQTR/VuDYAo+C7Ow4cj+9XRKOyJzbHj4ITt46v0XwGAfwkvF037Xb7B37Fhc3Eotj Azmfurju5/dKNlS8J2gV0CTUBLc6y+hdRNi2b3/Xj51R1N3nU8sR4YD6A4Erc5JSEl8Z V5Xm80MXSZlZ//b5MIJdDi5hZ3WUpM3Nw0utpHX6gjN2n1OAmWqKmALZR60D0v+JjCoq K8Rwd//xp7CnUrjY2RwndUkMSCCHYPNkvlxpH/jFSc5RLIlbVF0HqQCK0jyRGn1GRd0u g5w+ZsVTOTuQTOt69YWXMmqH+V/Jel9tFoyH3opXzReZoHzbvoz9lBZQGd+VRYX1VY1a pvVA== X-Gm-Message-State: AOJu0Yyn9Ms7OEMh7cgcYTsFAyhq6hoLL4uWa4bUp6gUisZ23ZRxngDo 3/qRlg57ei4zn2vEDJPEiQffcQ== X-Received: by 2002:a05:600c:378f:b0:401:d258:ad26 with SMTP id o15-20020a05600c378f00b00401d258ad26mr1690953wmr.19.1694790213635; Fri, 15 Sep 2023 08:03:33 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03:33 -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 v3 03/11] gpiolib: provide gpio_device_find() Date: Fri, 15 Sep 2023 17:03:18 +0200 Message-Id: <20230915150327.81918-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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_BLOCKED,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]); Fri, 15 Sep 2023 08:04:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777125720060292599 X-GMAIL-MSGID: 1777125720060292599 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 Fri Sep 15 15:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 140736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1361247vqi; Fri, 15 Sep 2023 15:43:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8V/cHT2LAOEZwB9jeixVMpNzWtP8wjkV138K+AATDsU9RwUgbaWcI06++HyWnAxyuoJiP X-Received: by 2002:a05:6a00:cd1:b0:68a:4261:ab7f with SMTP id b17-20020a056a000cd100b0068a4261ab7fmr3379408pfv.31.1694817832183; Fri, 15 Sep 2023 15:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694817832; cv=none; d=google.com; s=arc-20160816; b=mbKpOMJUl3m5AgkIrbKKgvnEM9FNsEHNAhYVrDpVdZY1QLK7+yfyN0okzCrJ6X8XP9 tWi1FX3ZRow05q4kzlcO9+ceES3IDIl1LmLp1w9Gw06y2kyE15grqpzJl6Cg96mrVYSR xyjw92l0kPqAADJlYFb0GixDYMOF1XqKY0C2F+RYMDU+u6QMRRkif4cwHdpTYHVkDuJU jJ6185RPAEixdqz0TVZb/NjkNWks1uLch8xqLOMVxJ/GqtH6piY2Nmx63XVMUKFzzNDr KjzTutpyxsNI4qB2d1cg6DzvTF/0b7tbD8nYP1JU3PFs3Fr4G9hdOCTJd0iNnts3JNQQ AsIg== 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=obchAPgu6r1rkgKlo5Pjan22hRumlpyNJfPCrMS9lJEsK9YVVfye/V0ZP7b9dhymN0 lV476FBlhgtmMjG5dGgtpayqUEkXPNXvOwqRyickmUWcQjSRCB15+xIRMttQ0euEQHxJ 66n50naKVu69GTrhYxuAIkMtMwopmtHd5prQvuZT0gp8z1o923U/uhcQgSXuoYr0FSkV YGK8y3RXJ8dyELtZ4/mwbdalDenhC+ngk8Lwa0r+L6an+BLg1rEJANvhW1kOo+X62htr JivxM0XA/LumwUu2xTc+mP/6ytShqx+Eq3Xbg9FLGMzFD8KJKT5g/PN2u1PKcHHZnc88 4ilw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=rdjoB0xK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t8-20020a056a00138800b0068fbace96cesi4023344pfg.77.2023.09.15.15.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=rdjoB0xK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id C337A82DCAB9; Fri, 15 Sep 2023 08:04:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235935AbjIOPEA (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235820AbjIOPDn (ORCPT ); Fri, 15 Sep 2023 11:03:43 -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 81855270E for ; Fri, 15 Sep 2023 08:03:36 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-401ec23be82so23663465e9.0 for ; Fri, 15 Sep 2023 08:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790215; x=1695395015; 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=rdjoB0xKsHGM1x4R8s9X1xCAIsSLxu+2w6b65eLwNkKUp8wMQ+Qimk3fscXUeZBMy3 pKRHHtw9gnL3qMDHS0ZX4E+PVgQgT00bLeFR1oKcUGzHMhhHFKPU4rX7QlrJgTxO7CwX 2aJxIf3fTORUfXgp4JK/pUZNfOiCfv/cZuVAfeuym8iy3ZaZph6KzWFN/eBUC31uv9TR ruj7JWXFjAl6EN6KhhdP5bExQokO4RoCC2/9tmGOcDMlXLoygLiUy3fPb94XyAVgyudc bn5ioJMwdnx8nCo6RgVzsAM4n9bZJTUzGjdA8opuWIGHogu8du42FvQorsvZFpsbXSKb +Q3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790215; x=1695395015; 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=rbs/eySXcXtp04typCO+k10ztVBx02MsThJwwd+GE9Gp5oDEAjelzXg7qlbnUeRjJC VpS+a6EOIdtw1V0Ehe0XpMjmlO5uEmcScGF3XrN5JvRu/q9Pj7Y+JIpu705nBeWinH1b VmzRoWBhLd7jzzSPFA5wLarYin/4MuDQbXdeNfFf6dUH6GO2F55rlL3jVrmUGjjBzfXw ABXcVLkFg+hfrkzdMgluGWWaL36ctctxDbWMdmtAo1RbXZW1mfboIvuzDO+aA92YEEgB oRJXsgWUtddEKMGk0tC5Ghk7tXymUn9Xz0GhR3jDmhZoGfW1BrZFbgEqiLeuo78AIuYo FPig== X-Gm-Message-State: AOJu0YyIqF6v5eGILy7RC22ydc/xeQXAjDAThtjGPJPcOx3xNct1VxwJ vGzI/ZS2hgCX+tl6E6REV3Hh5Q== X-Received: by 2002:a05:600c:2144:b0:402:f55c:faee with SMTP id v4-20020a05600c214400b00402f55cfaeemr1732253wml.26.1694790214756; Fri, 15 Sep 2023 08:03:34 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03:34 -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 v3 04/11] gpiolib: provide gpio_device_find_by_label() Date: Fri, 15 Sep 2023 17:03:19 +0200 Message-Id: <20230915150327.81918-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:04:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777145303419166105 X-GMAIL-MSGID: 1777145303419166105 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 Fri Sep 15 15:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 140686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1310493vqi; Fri, 15 Sep 2023 13:48:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQawRrtHsKtE/RrjKwByTODP3w0cnYW679bsBMs/IkQfCVyRLqN1hQ6Nmx+iDLbo9ScYIY X-Received: by 2002:a17:902:db0b:b0:1bd:f314:7896 with SMTP id m11-20020a170902db0b00b001bdf3147896mr3201883plx.25.1694810924911; Fri, 15 Sep 2023 13:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694810924; cv=none; d=google.com; s=arc-20160816; b=hjjBOU81iTnBGIVWnXa9xOUYFi3HdAMBEIi4pEv8j5kFcMmUsTEoD55TR1gLniSOu7 EhsNEnVjd5TDDyVtbJt4Qi/D9K8SvGmTPG7qOi61SQRJjRfosj6NmcLUzzteoIlTNIsj Uutyd8chBjgOtTb1WWl8vfPrxYNA5byv781OtBwa2OpFelWpmIIHH9B1g3O849YsAG1v 5HN8gDNbUI6V+7RFDBOKhejdoQPwYqJNqidXRyU3RsX9Ol9Oz6VdphyHyrnUpKcqIYor L8Ptn14IpxPw3g1z5YT91l60keNHKq+DbV5aj0zQKWQl/uGBAB9X230na3ysql3fLGi6 PzvA== 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=E//qQakuzQqzKzos6JLkmJsfmkfTSDMR4XPw8vj17zMu0m3A1NYhCTBWzbaUgd3C8S ZogkjMAhWYMRIoYN0uxeFMhl/+L49hJVSvs8Yg59EJxIfmw7MXjmXN/fKDT518RSdsfy bx/wLI+wV07wX/ypUEiLiVnoW1OeRAztZebukJuTGHn5S4w0GCruY6AKfBiuWVYMlbZG 8LMD25/pwWIkuAW9R81HD1r5KdQu6mWlg2pqKXBFqQMTji8w/BlU0/cX44YQgTgs57EK W/NKNV92UghE5zyBdfR7EFy+kJtzlFBUFK55L8gltLOaXroH0Xk3g+jIbn+xUohGFmUx 59pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=ovMx446m; 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 kl16-20020a170903075000b001bb7b3e607dsi3772195plb.21.2023.09.15.13.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:48:44 -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=ovMx446m; 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 0E5FA832FDE2; Fri, 15 Sep 2023 08:03: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 S235920AbjIOPD5 (ORCPT + 31 others); Fri, 15 Sep 2023 11:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235812AbjIOPDn (ORCPT ); Fri, 15 Sep 2023 11:03:43 -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 77DBA2710 for ; Fri, 15 Sep 2023 08:03:37 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-401b5516104so24345365e9.2 for ; Fri, 15 Sep 2023 08:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790216; x=1695395016; 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=ovMx446miCN6Bwk7LD/i2LL5q2bLysDLpQ+dTbG+IKl1TjuOCpLSFEiyS/Oae5NSXD 3UY8l5dAZvXNCjJJ0PUH/KvaKJhhOrSbjyb/9jRhNH2ZfsXi4ET6RlyyaXYqT7+dSCSJ GP6ZQOcLvwxpBxDgrhxdFwGXEXXb29pCIEBEtyFYWPPpohjq7CKxkztLjp/4f7UmIaP0 pt7YTcoMmtqXNqdA2K/FQQJTshDpjiyO3yVMrnPQ7uwnJjRljcGCSAhD6BTnawkrpbid B8e6IIuDpnJy22c7WCi8KwppYXhhXjjokmswfOpuXzCi668Azc61ZlrzjQcJEe/7A+EP U5ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790216; x=1695395016; 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=ptH3+akgcdaZv0KuIdmZBdXdPleI/fo8VVwyfC+19S6OGqJHIqMlDOyFoS8JHyARHs LIgW+GGjkqs7G06uxbzq6umjUAjLdWos3BwBObshDQ3F9sQF5H4+iqcIQzo1Y5SEnLWY MuTVjJRogkxxL+y9oOsvZdzib+9bN0qRQo1xFANPyn2+XfA1Hw+HixE0uhNLcNwpIbHi rKTe0pE+RLA5XKPnRO5mpPH+tR5qxKzLeB/Kz+9ZFXu6+Y0vbq/rsYuKmjHVtWSBba54 mm5AkhqRf1KOJ9bB0f+3S8S6TrZclyZNLmATOMhovF8hLMIiQGlDsJrJK5ac+fbMVyuc 0XQQ== X-Gm-Message-State: AOJu0Yw8H2LdjDJIxTqLmgusE1Jyu2cUrOkylx+kYbVfMuQCZ3f9rkOf Hg8Ol3errcME5pdG/j2M09rMqA== X-Received: by 2002:a05:600c:2311:b0:402:e68f:888a with SMTP id 17-20020a05600c231100b00402e68f888amr2189966wmo.3.1694790215910; Fri, 15 Sep 2023 08:03:35 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 05/11] gpiolib: provide gpio_device_get_desc() Date: Fri, 15 Sep 2023 17:03:20 +0200 Message-Id: <20230915150327.81918-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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_BLOCKED,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]); Fri, 15 Sep 2023 08:03:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777138060169653007 X-GMAIL-MSGID: 1777138060169653007 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 Fri Sep 15 15:03: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: 140509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1130218vqi; Fri, 15 Sep 2023 08:30:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFuw4Av3YOaC8huZoTjKPLMeFivH3dchhUnA2Z0mR3BWDXyYcUNFi4j30rsOHM0rHi0oSa X-Received: by 2002:a17:90b:4a0b:b0:268:f38:b2a1 with SMTP id kk11-20020a17090b4a0b00b002680f38b2a1mr1829743pjb.41.1694791799712; Fri, 15 Sep 2023 08:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694791799; cv=none; d=google.com; s=arc-20160816; b=yQok3XaSV4Osp5ekgddJz9lUQ7WzTWmucvdJFJ0we25ZC0sCQAFgpW3r13xLLJHkNP sWhyyFaHBYuIK5ZCbSBZWP9qu111/hyKbjJxioOlZZmkLOq9omqmdoCOkbdLj374IdBS uHEfmirSIjTAw9R9W4Iu1ZqKMKD1Hhl9MpGtAJ+xn4RdC/h+SGHGFrUINMcy5Jcx8UoI /7tamheUICD6dIEzwVacOYcxu73ruRvO21LLmNnQWRIV5+nfgkLKWzoSlwSVuMapy0Vj /Cnnc/jnHoDUySb4Ul+hlm6sIzFFhMY9lBrXr/7mrDpZh5r/FQQKfFqfYhTGikFtl/bY 7A0w== 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=gb1XKNiggG7FyNHCYZdIsYO0EUwkXSwDjWMfibhNpoPzD0MqhB2VsCJMOkXlM+UZI1 /XZ+VbEHNIxnsrA58HU/FNS+TEcV7W43w1Nb1+TakrOxcxwQCTYzduur6sHKoYtHu7Di YPyAvYCxg2KnRx7cKGITgST23nTEHIGXIKD+5wao2jUDpS0Y7MKiXz7mlAnFhzvHEO5P GGHH8nCvNqPfYzFp5Z4TzbJfW4tSiLezF0lzljEHGu3XeHHpJr8BZml8Q4PNGWpzdfjz tZSHhx12mSav4hzpxu4uIPELfply0kQ67kSkrakJipDOInvpI5J3yWAbOUxT9nt+5Own Hibw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=Ev5euDCk; 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 i23-20020a17090acf9700b0026b502223cbsi3587602pju.10.2023.09.15.08.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:29:59 -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=Ev5euDCk; 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 86CDA8091C4A; Fri, 15 Sep 2023 08:04:11 -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 S235987AbjIOPEI (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235855AbjIOPDo (ORCPT ); Fri, 15 Sep 2023 11:03:44 -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 ACCC22718 for ; Fri, 15 Sep 2023 08:03:38 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-403012f276dso24530555e9.0 for ; Fri, 15 Sep 2023 08:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790217; x=1695395017; 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=Ev5euDCkEcMyo0Vi4HTUYVTfW9nuMoInIT+a1zskafF66mHsZ0IliYQHDC/CbYvCHv SgIa37TovU2rkGI02FnKLad5qhkl8OUkK1AQL6Gr2/1zsSjyQINW+r/yaRKMaaNQUdk1 NCCvfu2U2YdQXT4+QqX0uoRFEdcUqYaiKB9RyXDP670KYo5hA7GLgXZBzYKPCCULqkQX aGgzxcPj92fuZphAJyL5lRwpzkka1yEGmCVay1cjte1PCM561o74LNYhJkpsBE985je+ wEeGy24lDjysXDfmGJ36yYCVi3VTTgtMi1Exb27xcTYDNbNi14i74owlbvYPX9UwIptD aP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790217; x=1695395017; 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=cZ+HIyV9ArGaX/rJXWatZ0WpsFk0ucksnkQzioBp8AwQig2TpZ/TIDomsGukb5PUKC f0sLEYH0yIXr/B9RFWWNrgbCDbTeLLb7t7gjRthjRYQxZTD82d1+lct/D31aAa626qKI L+H6xSXDo7eIoRW15J5fD4qvsP01hXWwIoIdk956neXIqJSWHCfKbXUgs2plFrbFUEzv pUC6hPcNN8btXWPjAYh425e+VqWFZyyyZ7HiTZtU8IG9LKQH3BkmxqwE8VVQ0ugLy0Fh nJDTz18PkyTuFnzN+ofqpFsyfjIOScF7frimEpps92iquTeg4AmiDcUedhOmQUB6JgCf 2w0w== X-Gm-Message-State: AOJu0Yzi/hrSdPiZtAWwL4UMi+XLCh2/oQwjBQWMdNJ5I9inFIjK2gfJ PccZeb9XcpokQWF1gMFgoETmSSCPdey5FKgS/6A= X-Received: by 2002:a05:600c:203:b0:3fe:3004:1ffd with SMTP id 3-20020a05600c020300b003fe30041ffdmr1735651wmi.4.1694790216912; Fri, 15 Sep 2023 08:03:36 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 06/11] gpiolib: reluctantly provide gpio_device_get_chip() Date: Fri, 15 Sep 2023 17:03:21 +0200 Message-Id: <20230915150327.81918-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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_BLOCKED,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 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:04:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777118006055227796 X-GMAIL-MSGID: 1777118006055227796 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 Fri Sep 15 15:03: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: 140683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1309735vqi; Fri, 15 Sep 2023 13:46:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxeU9sDyEj6Ff48WqJuvVRmKD6VY2wsfoYAHid4kGb1aIJVHkBqqqhgQKBtqMNerX/alIU X-Received: by 2002:a05:6a00:39a5:b0:682:4c1c:a0fc with SMTP id fi37-20020a056a0039a500b006824c1ca0fcmr2950903pfb.19.1694810813568; Fri, 15 Sep 2023 13:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694810813; cv=none; d=google.com; s=arc-20160816; b=hD0l4L6r/Pl6FZU11kdAV2dLO3tFuUWP/ZNyGy0Y5aEQ/E0evES2yLz44bzf47GQSV K8WEer7YcmWc7wgcFLIsbckocz0UmFV2TCOxm75Y6jfAUSa0T487XZ2FyeXaaSjFC/lc 0YW6rypyU7628Bw8fFmgqgkyKMYPJNIguxgnfd6tXzWHNmON2y+Eh7S+1z7QJ4MWC/0P x+4qr/1QOwp1A68mh0O7PM1LVStgjhYwfHFmv4WP6yvPiuXg1N8Jv/C3tSf+vOJEUZJb dZHu5BXVgv56cQg3aQd686J9U8Opv2TXv7pZzViboFlcxSrYXTzrNN5ddN9B0i8B+OuL bJEw== 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=n58Dhj0yqYdpmSQPkjKhq0W6VxWWLeN7p34YZuk8uDg=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=JQsgIhhFx98A0qX6r1rA1IZqBSumjhXisOWyraQVU/BRX+81KrkGkZK8QCmbt/bs66 dXKW/Rg/5Zm9e7TLTZvE/ZZgrBTgvX0iUFbVf06yTVewLMwTsrORkBiR22j4Ncepwkvk t7Fxp52AxoSL7X0Lbc3BDlOcpbl7NxVT1IiH11zXjQz+nMXWYVU2doAvGoCmcW5EX46S KF/luC3M65SkhsTUJRu3O2OBNY6ZZjjLRsIfz4cKB6hDGqvwQwPy31KdVZ2sFFTM4e62 FzczWo6ckYmoANrR19THBklYThDCcuzBCnSLGgEIZls33YBjMoJs/1seGBb4C+7u8zaJ Yb0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SwHMEoMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b005697ed9a47csi3693451pgd.29.2023.09.15.13.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SwHMEoMH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 E749F8331E31; Fri, 15 Sep 2023 08:04:07 -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 S235981AbjIOPEG (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235863AbjIOPDo (ORCPT ); Fri, 15 Sep 2023 11:03:44 -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 79A80271B for ; Fri, 15 Sep 2023 08:03:39 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40476ce8b2fso14157375e9.3 for ; Fri, 15 Sep 2023 08:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790218; x=1695395018; 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=n58Dhj0yqYdpmSQPkjKhq0W6VxWWLeN7p34YZuk8uDg=; b=SwHMEoMHrQ46jSXfhSbUhB7JoShVJg5QKC/R+9Sabb9JmeDEHLtUw+VHymmBi6zVxz 9SkGiIcUnexESESBSuXLNL9TMwghUHAM7SfSGT5VRJxTtcBTI5r5vyzfHgUtFAx8R+RO CUMb1VKn3NMlkIG+cKGMlh8Ky7N1aohoV2u176A2goDbfdSbu9FN+7tMdvd0BVuU/t6a AIA4xWCgaryQrgEZq3seZRFOn1Ec3XE1DV0W5YSL2qjogD26iRgk1CwwOjGgDKtA9IwI qPOOnZ79yF9jx9Xx8nuiFAHJ9f62mvIVRqfPbn+hIk4krs1TLC7vvR/iKliX0r5kBoOY ywxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790218; x=1695395018; 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=n58Dhj0yqYdpmSQPkjKhq0W6VxWWLeN7p34YZuk8uDg=; b=wiDCZdSRSX68WBSIydnqUHh3/WOg+/MJ/rdcbyQA9k+Ar39eEaV6VKxDahQks23eIV UYtE2eCcY5BKhJBVql2RV8H/ewO+OD8zR0wNto7q+m9KzLph48N/qUD/lGiNIanO0vNJ hs2KhfS456gAKGNrOcQZOD4imufdLb5TuE+lHb0E2Rnp5jBL13YhPLaVgsNgBYvngmUN 5fFuHUKSfZNklO6AcH5DUxlQNz3PrCZ77RJ6zB8KYSSITVO9Gl0IfvTeSZR0TX135RE1 kLMv0azCgu6DRQWeMh8c6xkNe8UvH8i1769F/XoOCwcpFfcHPGp1jC9+MXXqyPi5n3MF xVbA== X-Gm-Message-State: AOJu0Yzuz13FuACIx6jg1SPQ2MVUB/UP/RMQnHoGDsJ7NVjKkBM/w/6q 9anuIaPe+5ssXEEQBhp2E2+yHg== X-Received: by 2002:a05:600c:b52:b0:401:eb0:a974 with SMTP id k18-20020a05600c0b5200b004010eb0a974mr2046484wmr.3.1694790217924; Fri, 15 Sep 2023 08:03:37 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 07/11] gpiolib: replace find_chip_by_name() with gpio_device_find_by_label() Date: Fri, 15 Sep 2023 17:03:22 +0200 Message-Id: <20230915150327.81918-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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_BLOCKED,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]); Fri, 15 Sep 2023 08:04:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777137944020968071 X-GMAIL-MSGID: 1777137944020968071 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, 12 insertions(+), 21 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e26cbd10a246..4c734bfe6d32 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,21 +3896,22 @@ EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); */ void gpiod_add_hogs(struct gpiod_hog *hogs) { - struct gpio_chip *gc; struct gpiod_hog *hog; mutex_lock(&gpio_machine_hogs_mutex); for (hog = &hogs[0]; hog->chip_label; hog++) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; + list_add_tail(&hog->list, &gpio_machine_hogs); /* * The chip may have been registered earlier, so check if it * exists and, if so, try to hog the line now. */ - gc = find_chip_by_name(hog->chip_label); - if (gc) - gpiochip_machine_hog(gc, hog); + gdev = gpio_device_find_by_label(hog->chip_label); + if (gdev) + gpiochip_machine_hog(gpio_device_get_chip(gdev), hog); } mutex_unlock(&gpio_machine_hogs_mutex); @@ -3977,13 +3966,14 @@ 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; + struct gpio_device *gdev __free(gpio_device_put) = NULL; /* idx must always match exactly */ if (p->idx != idx) @@ -4005,9 +3995,8 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - gc = find_chip_by_name(p->key); - - if (!gc) { + gdev = gpio_device_find_by_label(p->key); + if (!gdev) { /* * As the lookup table indicates a chip with * p->key should exist, assume it may @@ -4020,6 +4009,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 +4019,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 Fri Sep 15 15:03: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: 140708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1335546vqi; Fri, 15 Sep 2023 14:42:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoBCbV2/bNW1mNERCUMeZi0HE2rROf1X5jRltLheDZ1aYcUnmE/s39P9f7vlXAzRaFRhA3 X-Received: by 2002:a17:90b:4c4b:b0:268:2523:652c with SMTP id np11-20020a17090b4c4b00b002682523652cmr2910401pjb.31.1694814141990; Fri, 15 Sep 2023 14:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694814141; cv=none; d=google.com; s=arc-20160816; b=oWEWKzr5jBSvAKLEdTUtfb+fGgE7aoqukIXSAb91YQvnykFozqQ84VZ7sGFY7bUVId RnofQEv/d6hekuxitlCArv9z4CnamiRkiTEVbjoxschrUyvNvOm8PxRWPapsI/li7EJh llWKY5hkqesi4o0WpG5jSZ9i425rYjLSNsIQNUwfaaOIGh2Ct33CN85MDg50iLVx+xDm 799td2XYDXz3635cEN/p20mAiMQMBlxIAOFu5HLQAFviNZeF5zlOoAp4PxLMt2bwFKWP Yb0T7IKnpUVt37jcr1PsgmVEuRTRT4O9FGf0uTcriIRythCy3y6iesQ2ULELuvUKhrS8 9QpA== 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=edxEV8lZNyeIe2fc1/ECdrZnvrBbNnxqjxV4vEQlZ6k=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=tZ+NX2nRMGRVoLe5GOIquy450NJQNMJfV367LHqbB3F9GEtWOiDkhevVL0UB/sc78a UNZVSkeqqKxog7yd8iTxKFIXVFmA4xXy3c/+I9M9E3OphgEWISIrKSLrHBTv3L0ssg7B NnJ7sudNdtaxzxCuQu8PPi7Q6rnD9xf6F8HArVhKj+9DTSzAKq2+5kDZMS4Nj8qR2cqC CVsawSwxgk/M8kZzCWqXMEfgR0kSCPe95yvDIKRcHhP5vtbInCeuBzREp38OROUS0j/t a/Fx7guouB2K44xAiw8oyRCV8623+k3L+TVo8C2NtotK+yc3OoaEUVeCPLsS2LQyrm/4 c+Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=unxbODZv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bp18-20020a17090b0c1200b0026ceee6848asi5822695pjb.180.2023.09.15.14.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 14:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=unxbODZv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 634458320A01; Fri, 15 Sep 2023 08:04:31 -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 S235994AbjIOPEL (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235869AbjIOPDq (ORCPT ); Fri, 15 Sep 2023 11:03: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 6BD7D268A for ; Fri, 15 Sep 2023 08:03:40 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-403004a96a4so25119345e9.3 for ; Fri, 15 Sep 2023 08:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790219; x=1695395019; 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=edxEV8lZNyeIe2fc1/ECdrZnvrBbNnxqjxV4vEQlZ6k=; b=unxbODZv3/+gtWrSmauo07/beObjoMjXb5TxV71xYoUxGuCX1r8D2dTjXGFOmai2/Y DOnutSJkiccs2oWUcwtSnECWrNglBuV825scuvj8Dy0Qz/fd2woRrsCTXgUxhxKwui/J F/uxsbtzS39+xFRONRemEwYPLBajBym1iKAtshzTm4myf7dgcr85WT62tearrfM3VseN k1N2vxSOha7c4S5GL2/cbHhzklKMI3NUvEsWQ7MKN4IJ4HJeSzSQUvNL5RE74eSMu6vg m6ehkAPo3//DVlZRqJORrI3X39IiTo8aIGrbmsYLOSE4SZfj4fKlzx+pq5cCqlUU4K+D x/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790219; x=1695395019; 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=edxEV8lZNyeIe2fc1/ECdrZnvrBbNnxqjxV4vEQlZ6k=; b=E65JGgVl6tXWQGFmEPkfLLPmu27rSPnABUG/hdPRZiquUpiCTSsVRExzOrpL87TArd VsXIZguIzpNmxXd4qdXiTFFztdqZAAjQzq5vnaJKdLS5JDk8JnMY0rtmGpiP1rHx3Haf vqd/yVxYIgohbVT91QMRWQ2kynBdmKzakG0I4DVzsBNInVVBEngD0aH3AnBIy2pum4gM 49e0Tlae1EmbarrxoVo9eOIWm9UgqOmA1e++jkzl7WhMTQlW9b0h1mtmn1lZSqtsPped 37TaRbVmwHza6CA4mjAI5FwaEZyWbpFEUS8iw3Ac4WZhkmyC/pdAzYFLd2goosl7cjZ6 38vw== X-Gm-Message-State: AOJu0Yy6IQwTC8CrYjTNkYSSoh2xq+yzK3Plgf0XxQg76RZubu3pSIbv JFLd+NlY0pvpEU9KharIJNMujA== X-Received: by 2002:a7b:cc9a:0:b0:404:2dbb:8943 with SMTP id p26-20020a7bcc9a000000b004042dbb8943mr1889146wma.2.1694790218883; Fri, 15 Sep 2023 08:03:38 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 08/11] gpio: of: replace gpiochip_find_* with gpio_device_find_* Date: Fri, 15 Sep 2023 17:03:23 +0200 Message-Id: <20230915150327.81918-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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]); Fri, 15 Sep 2023 08:04:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777141434100378615 X-GMAIL-MSGID: 1777141434100378615 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 5515f32cf19b..4987c86010c1 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -127,10 +127,10 @@ static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data) chip->of_xlate(chip, gpiospec, NULL) >= 0; } -static struct gpio_chip *of_find_gpiochip_by_xlate( - struct of_phandle_args *gpiospec) +static struct gpio_device * +of_find_gpio_device_by_xlate(struct of_phandle_args *gpiospec) { - return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate); + return gpio_device_find(gpiospec, of_gpiochip_match_node_and_xlate); } static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip, @@ -362,8 +362,8 @@ static void of_gpio_flags_quirks(const struct device_node *np, static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, const char *propname, int index, enum of_gpio_flags *flags) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct of_phandle_args gpiospec; - struct gpio_chip *chip; struct gpio_desc *desc; int ret; @@ -375,13 +375,14 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, return ERR_PTR(ret); } - chip = of_find_gpiochip_by_xlate(&gpiospec); - if (!chip) { + gdev = of_find_gpio_device_by_xlate(&gpiospec); + if (!gdev) { desc = ERR_PTR(-EPROBE_DEFER); goto out; } - desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags); + desc = of_xlate_and_get_gpiod_flags(gpio_device_get_chip(gdev), + &gpiospec, flags); if (IS_ERR(desc)) goto out; @@ -813,16 +814,16 @@ static int of_gpiochip_match_node(struct gpio_chip *chip, void *data) return device_match_of_node(&chip->gpiodev->dev, data); } -static struct gpio_chip *of_find_gpiochip_by_node(struct device_node *np) +static struct gpio_device *of_find_gpio_device_by_node(struct device_node *np) { - return gpiochip_find(np, of_gpiochip_match_node); + return gpio_device_find(np, of_gpiochip_match_node); } static int of_gpio_notify(struct notifier_block *nb, unsigned long action, void *arg) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct of_reconfig_data *rd = arg; - struct gpio_chip *chip; int ret; /* @@ -839,11 +840,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); @@ -856,11 +857,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 Fri Sep 15 15:03: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: 140567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1202847vqi; Fri, 15 Sep 2023 10:18:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHShmtll5sq7Cmiz8fgiDLAP0GrvlJ28ST5SUXWJFgICUzuTjRbvTTyD2zeI03PCF66DTSr X-Received: by 2002:a05:6a00:804:b0:68e:4303:edb8 with SMTP id m4-20020a056a00080400b0068e4303edb8mr2609164pfk.30.1694798326231; Fri, 15 Sep 2023 10:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694798326; cv=none; d=google.com; s=arc-20160816; b=rwMeCJCupfiLwdM1BtUFrXAFy4T3FQGGGrdS3trPSnJN1fwzWIgdhpcx489VyGPWrh pcZ3l/ePv3yIRcG2TS6NfukiPR65JxkAYhYGJxdHjTpREE9D9+iCttWGPzjtPNBpgv8J hajmAl682ZUL5v06JsfG6ccFYtnZrAiJclkQuw3wsQuQtxOgLCfn62RBJnKrNi38ZI4F fS4FLDVD89zAZ8e3JaVD733DKoYK3/cxBzzcXfDlwqSgcsu2SSU0IsmNyd4NvIuSgdiU CdMlHBzdtliqYvVAx9WJi3KJXrkhw5O8v9nJjxpKxYWuZYCM/HGIcQOdklbkJoXG/g6S s4yw== 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=Db5q27N7A/juU4c9VZA3v3TCPgc+fDf9UmP/eHtAN2w=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=lqq0dJ5ScGbmv8Z4W4eKw4a3tc9R327YnUPKli4JG9KDoyzhhfm6c8SeXUPpxLEks+ T78KzNn/y90V5wIQ5yLpGCv7kvI4C40DBRyLlZTMFR61exm25QSest9j4wIYKQDZq5Pl /UzB1LwhzHFvg7imKg7L8htmOpb97pm/c+CzWQDRUTd41o+c7VX7n7+Kq+Cw8iOZspgw S9E9qgXlchRuUyysTnccsKoV/gkz6NGHJPTsUIfuiH4+qI4GM9lUkzDgkjTohir/y/h7 GU3Vi1Rxw8sN90mCpTMViH0rVD32b30+96gHBkJB12buL5NBB+YaJ1oytIJLoi3i+u/8 klaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=et9pcbrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t37-20020a056a0013a500b006901cda9176si3736169pfg.294.2023.09.15.10.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:18:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=et9pcbrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 736F783B9882; Fri, 15 Sep 2023 08:04:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236008AbjIOPER (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235872AbjIOPDq (ORCPT ); Fri, 15 Sep 2023 11:03:46 -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 5FD72211E for ; Fri, 15 Sep 2023 08:03:41 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-401da71b85eso24542365e9.1 for ; Fri, 15 Sep 2023 08:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790220; x=1695395020; 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=Db5q27N7A/juU4c9VZA3v3TCPgc+fDf9UmP/eHtAN2w=; b=et9pcbrFnd5xJv8e0uCGGte2O7CAZG8AlvRizXbv3fRaqlkjFrz+1sbJmYOqcdZXRa QtCAIxXy3kJRvHH6zSpaCr1UJeirwpKXPqwEAOjb/J3jtB0ELII/4BwMbGqJYQy1v2Ja pNWcG62V9rlJthh1CLYO2eCH8kbHSFr8Dm7FIPtdPngkc09Q+u/pyOyb8FgjITiZT5TW Tl84R8tngfNMZfWwrnHiHnv9SdYQLjPRjO0QZwxJm6ZNKTPDBPEIuhsDnv4Lj6UbmSuA 3V9mAFAXyWslcxW9pSH9kq4iuk6YeejPQDT9r8ue9sAy9OB0RbdvLiFw+eAsMvhwofd8 EB5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790220; x=1695395020; 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=Db5q27N7A/juU4c9VZA3v3TCPgc+fDf9UmP/eHtAN2w=; b=gOvMxmIlyMibcqns9Ni3RzJHGrBSlVqMtQk8nIGGEmjRA3676PCyBonSDbH4sF+qN/ MFdvpmSdwAv5uPaWJLyckiohmqp5u2jZeB1cbODjqv5vMYxlZVOptNn2UNwhp0BQMrqB D8+h7Dv1eVIBSufssulGTX1+ZH9YBqs1cUIcb6u2XWrg50O45G55KU6u5Q97etnhSdEL CPNGBKxpnaq7ks/Xng+oDImbIy9Qnek5t7RKKNA17lNFgT7Magiwf1IvslUfR3ht0FUq vAX83Opz7ElPnv9+ulWNBKwCxJOsTeu8PNvTdcUcFEGAXGMx6PweMWWViqthsGof2T9C +7Mw== X-Gm-Message-State: AOJu0YyWbnPyX1LyNccRNGs/cvIdy/a9qN92e8jS4OR3ZRQWSczW3hzR u7idf6mSBkw1KfEDUQGNSfIEIg== X-Received: by 2002:a1c:4c0c:0:b0:402:f557:2e46 with SMTP id z12-20020a1c4c0c000000b00402f5572e46mr1886650wmf.1.1694790219822; Fri, 15 Sep 2023 08:03:39 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 09/11] gpio: acpi: replace gpiochip_find() with gpio_device_find() Date: Fri, 15 Sep 2023 17:03:24 +0200 Message-Id: <20230915150327.81918-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:04:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777124849282715127 X-GMAIL-MSGID: 1777124849282715127 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..2378e1e7e8b9 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -143,7 +143,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) */ static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin) { - struct gpio_chip *chip; + struct gpio_device *gdev __free(gpio_device_put) = NULL; acpi_handle handle; acpi_status status; @@ -151,11 +151,15 @@ static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin) if (ACPI_FAILURE(status)) return ERR_PTR(-ENODEV); - chip = gpiochip_find(handle, acpi_gpiochip_find); - if (!chip) + gdev = gpio_device_find(handle, acpi_gpiochip_find); + if (!gdev) return ERR_PTR(-EPROBE_DEFER); - return gpiochip_get_desc(chip, pin); + /* + * 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 Fri Sep 15 15:03: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: 140506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a55:b0:13f:353d:d1ed with SMTP id 21csp392584rwb; Fri, 15 Sep 2023 08:22:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFt45NsGP5t53BNCmgsqOwVAhI6ed6f061wI72ezc14uaaGsB7c0+1zJK2WxXPiAPiak2b8 X-Received: by 2002:a17:902:e812:b0:1c0:b82a:b0d9 with SMTP id u18-20020a170902e81200b001c0b82ab0d9mr2046282plg.29.1694791378289; Fri, 15 Sep 2023 08:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694791378; cv=none; d=google.com; s=arc-20160816; b=0W3Z1eB7XhzCylUNgeoYBdg4N/bT5yCyBffosBlqeYc5RqWQ+IgqmLE91nsiQD6Omq dHOoyF/eqsbcNQAm0vgbOvOtu/eN9yYR09fUMnhKjaJoFyqfQt7YyBT6DtfUENrRnhy3 +0FPMLmEX3qFfrVIupf2L6S4kzzbsdL+dv/bDYhLnplQ+inDAzAt3imHDi32CKy8K/Dd xJT+0ib6eDKugvt4/QTzKbgdRIDY1e3QcgPFfqZutWoB+PQo0TPpunOdix08sFDdhsix DNeWlVSnJYdYQtO6+f2Eky0kgFdECMJaK43otE7g1RybxnKslefE3Jbuh0kyQ6T82Yqj 9YaA== 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=MflPL+QKb28SLjr67nvfLFxWVRN50mSzldVQJo+IR1w=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=vSCxnVVXA85pP+WQjISSJAscwe50FDw4/rwRpM75LmzdQgn6Voje2mz67U5adP/RC5 5BFLCZ9ZShwJCvHUz+Yui8FpA4W4Sg+sFXlW4KZgVNLKdysyfV/9VAmnroEdgtr7+KYV z/FJs9vjqFROoAd5THzEmtG/2tLe9l25RxGLerVbtbTFIZdkvz/BK/gsnOh565/grkq0 CB8imV76azTVLIrnXD9VZ7wi1qa0h/KzY02Pe08RHn31ErCzTGb6cTQGiJmv6Kg95KTt /M+CsVPX6/xtfqpstESakvC1mVHvgAOuFKRagK1KnExQDPX3fmc1VDHMJv2QwoUyRfMn YO9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=encZS12j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id le7-20020a170902fb0700b001bd949bcd75si3403042plb.575.2023.09.15.08.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:22:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=encZS12j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 A4C228446E66; Fri, 15 Sep 2023 08:04:28 -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 S235898AbjIOPEO (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235879AbjIOPDr (ORCPT ); Fri, 15 Sep 2023 11:03:47 -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 543812126 for ; Fri, 15 Sep 2023 08:03:42 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso21087385e9.1 for ; Fri, 15 Sep 2023 08:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790221; x=1695395021; 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=MflPL+QKb28SLjr67nvfLFxWVRN50mSzldVQJo+IR1w=; b=encZS12jQ1cC0ojsy04xKusqHk6btwsxQ2hEzufqDORTkaBdHRvgWU1Q/wQ9Q95DKG ae8KsmwjRMVn3YtC0DCf2M2N3iZsakSTdI0eipA54PV/GPojrZ2LZ/ANiYbrUjZCQYY/ gTnY3jcBigmA4nBv06hNYLOxpXorK+AbSDTyaomQlnrhNO33Tptn57kA1/lUgXLfcs76 Ffn78A4I6gLC+kcjbDCje+yCrwui+AUQhNUXI+gzenHGKzu5XhRIPfVgpxS5Cyib8Sig KVvtxPMyBQrq/+0JfcqPZRlHu7jnd6R+UYji1jOWNyBSkWGQA0v4dYQ4xEjthbDKLCWB jdHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790221; x=1695395021; 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=MflPL+QKb28SLjr67nvfLFxWVRN50mSzldVQJo+IR1w=; b=p/MUQV4Ynnp05ondopsSGyHmKxS63PCAk4yujpkwhHmXYUCxL/VhugbNgUYeU+m7qD xiE1ntQuav6rGYfDVOTUpUQ0PEjcb5hNoItEbUEBFklBBw0effDNXUd0jdS4Drv6W6Wr xsYXhFKZFKqiIz2E+jinIfqbmuCh13iy0Di5KulDKtlnTeAqEO68okdrD4TglElLlTBv bKf2C4XORJ3LX3qXTIuXpkS4M48w8AbTmz0PpVlR7xfm/5HQzyEfBIyIhvXMdxpbzI8Q eQ0BfmqXi3wHdlLIrmQ4IgERf1YzX6hifjPG+R5TV27KpNpidL62uUOwDx4W8verJLBQ o0Rg== X-Gm-Message-State: AOJu0YyWxYjsiBGb28HxqRv1O+GuEqymHHt3D7xKCh8iQY+IVbizeQjj 8RiB7JoQtsC0bauMsyCADFi4FeRCitXF9reyPXc= X-Received: by 2002:a05:600c:b59:b0:3fc:dd9:91fd with SMTP id k25-20020a05600c0b5900b003fc0dd991fdmr1616601wmr.40.1694790220840; Fri, 15 Sep 2023 08:03:40 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 10/11] gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label() Date: Fri, 15 Sep 2023 17:03:25 +0200 Message-Id: <20230915150327.81918-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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]); Fri, 15 Sep 2023 08:04:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777117564345217926 X-GMAIL-MSGID: 1777117564345217926 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..33c4b1a6c3c1 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -31,31 +31,26 @@ static void swnode_format_propname(const char *con_id, char *propname, strscpy(propname, "gpios", max_size); } -static int swnode_gpiochip_match_name(struct gpio_chip *chip, void *data) +static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode) { - return !strcmp(chip->label, data); -} + const struct software_node *gdev_node; + struct gpio_device *gdev; -static struct gpio_chip *swnode_get_chip(struct fwnode_handle *fwnode) -{ - const struct software_node *chip_node; - struct gpio_chip *chip; - - chip_node = to_software_node(fwnode); - if (!chip_node || !chip_node->name) + gdev_node = to_software_node(fwnode); + if (!gdev_node || !gdev_node->name) return ERR_PTR(-EINVAL); - chip = gpiochip_find((void *)chip_node->name, swnode_gpiochip_match_name); - return chip ?: ERR_PTR(-EPROBE_DEFER); + gdev = gpio_device_find_by_label((void *)gdev_node->name); + return gdev ?: ERR_PTR(-EPROBE_DEFER); } struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, unsigned long *flags) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; const struct software_node *swnode; struct fwnode_reference_args args; - struct gpio_chip *chip; struct gpio_desc *desc; char propname[32]; /* 32 is max size of property name */ int error; @@ -77,12 +72,16 @@ struct gpio_desc *swnode_find_gpio(struct fwnode_handle *fwnode, return ERR_PTR(error); } - chip = swnode_get_chip(args.fwnode); + gdev = swnode_get_gpio_device(args.fwnode); fwnode_handle_put(args.fwnode); - if (IS_ERR(chip)) - return ERR_CAST(chip); + if (IS_ERR(gdev)) + return ERR_CAST(gdev); - desc = gpiochip_get_desc(chip, args.args[0]); + /* + * 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 Fri Sep 15 15:03: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: 140530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1166290vqi; Fri, 15 Sep 2023 09:21:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERpMujzmoBzWqLfdOiIJcVHztrDN2MLFkFd/I6E06uAMzK3edoE6O1tav0fFX1SecdsOXV X-Received: by 2002:a17:903:1251:b0:1c3:8230:30d8 with SMTP id u17-20020a170903125100b001c3823030d8mr2722587plh.38.1694794860222; Fri, 15 Sep 2023 09:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694794860; cv=none; d=google.com; s=arc-20160816; b=nbktbQ04elMpjvJNaa51ENrG490nLR3eNbA1WxNPjfAsPakWmg8URPKN/c6GhIJpLc HTfqEfI/8FP+EQU4ErW0khg3HlTqdk2AJ2U3xSgdA62KG9x8EwnBcsLzExNmdW0KFnG8 B44YtExCGtjiIRk20lXbbHoI+eOT0Z0H9PqifvsdK6Jzxrhc2xZ1fPdHDtsvuhfc9VVa 4bB0SUQkaPrXFGasE4EQCOYApWPW/rWwz2MVZpOpp8jc6va1AeQIZLfKtCy68GH7anjM fV4pgeaQV/mea96iI5sGtR/zd9dOrx7kcFc2V5Bk4+Jg3xq2+jVwvfkgDvEsJTesLtKb WkeA== 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=zF3ZfEW8ajFlsK+M2RkZQuQXKXBwwo8BEssniCrQIkvSOYrJXtmHIUSo4X9jflj3iV 8SuEpDlLIxFlqGRvM6OjZYnuUbVW2Y3c/1YDbuzYUnOU1YlFZJT6BRfwAE0fiBOS6gUT UapGJAThU25Ni0i79C9O00kJZ2xdyoqVygUTg7coasrlu1dtqnYtNipeBSBHymZRXXbF AoMXog0ErhmFco7vSzjqymJgNCQzCb45HyYdUOCMBCF3Di3TnNKnyhmNxcC2TY2QdxjY eDXl7k2mM8Ub3P7ZF+KJrn3IiwK2osO469sEki+Cp6cgjnEI7bhNELFLkjH5ZcRLRh2p 1zKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=j2pacwyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lg3-20020a170902fb8300b001be025f8407si3566756plb.37.2023.09.15.09.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:21:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=j2pacwyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 9D93D82E47C1; Fri, 15 Sep 2023 08:04:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236016AbjIOPEV (ORCPT + 31 others); Fri, 15 Sep 2023 11:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235677AbjIOPDt (ORCPT ); Fri, 15 Sep 2023 11:03:49 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4F782126 for ; Fri, 15 Sep 2023 08:03:43 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso21087915e9.1 for ; Fri, 15 Sep 2023 08:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694790222; x=1695395022; 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=j2pacwyiuGqTLgRQPiPev31PTbwYrLft7UMISs+FzqeTwAHLotWLe9L6I7Lqlrmz78 M5HV2tZf+TZSSsMfSly/0lSta9ckePIJB/rtu84rsvU5bmMNFr8G08ic1NMs6YH9btCU w+NFXzByRrfe7SL9soj+SlQvt5Wbd1zBnUa0wmKQtWA2MbrFbFNrh5E1XVDmkk6w4BXK 1Z56/oXQSKcoGX0jN1pfMaqDEAICy+tShrY4WO8gH2SRL1Jo5aQcKyYED4b0uVoiIy/1 5ETSt1a5nAp40btPNN1cp+5z9XXgYCC0IkjCAFozHzPPuvebJvYGbWB9jitiQPYiCcB3 8PWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694790222; x=1695395022; 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=nTSn+PVjx6QC9e5qzuyKjZpKIAtGNI9DMdjZAs7y4uTkiVUM9yN33ogShDEyiQvn3q XblvLadXFHfNnBiu/ecEhIpomcChmdSjTO6zB/8CRI8k0E3hV8nwxpXpUJBIM0T6orXh nNq9Of0Q8mJNRPqkuINDShRdkcmtFvkt1q6HjrzYjZUmiT3AwnrDOFponr1jVq6MvL30 fzJc7z9pD5U6KKecQuL5kBuKqPQnKSpBMrgGqRzfZX0R7fAROg8omOmn2w078GU5Fecu JYefBBlnQ1cjVqoc84IEx5s9MjVHq0Kxof/sjp9r8PLGPaXUCWmnRBImVWHnS9P27wEr qD2A== X-Gm-Message-State: AOJu0YwdA1lDSMQgRSXtVmKokU+QfX390dxohM+JNaU0cCgT6lBB7qCO aVmgA4yLV4msVrQu3ULQm/3lsw== X-Received: by 2002:a05:600c:221a:b0:3fa:97ad:2ba5 with SMTP id z26-20020a05600c221a00b003fa97ad2ba5mr1881686wml.31.1694790221828; Fri, 15 Sep 2023 08:03:41 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:aa19:4569:aeeb:c0d3]) by smtp.gmail.com with ESMTPSA id hn40-20020a05600ca3a800b003fef19bb55csm4853369wmb.34.2023.09.15.08.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:03: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 v3 11/11] gpio: sysfs: drop the mention of gpiochip_find() from sysfs code Date: Fri, 15 Sep 2023 17:03:26 +0200 Message-Id: <20230915150327.81918-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915150327.81918-1-brgl@bgdev.pl> References: <20230915150327.81918-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:04:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777121215638525768 X-GMAIL-MSGID: 1777121215638525768 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. */