From patchwork Tue Sep 12 10:07: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: 138089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp304360vqx; Tue, 12 Sep 2023 03:19:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGN6rngMZX9IKoRxbqHe3vi+5ryTWCRv/2tNsqtx5EgxNyeU8eLS3e3pCkx4HV7q/ahQTeZ X-Received: by 2002:a17:903:22c7:b0:1bc:4415:3c1 with SMTP id y7-20020a17090322c700b001bc441503c1mr3224030plg.7.1694513992843; Tue, 12 Sep 2023 03:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694513992; cv=none; d=google.com; s=arc-20160816; b=VbsLk0B6i+A1WMg4w4PEo6WcejY0NPUJ+gZuN26dUtOEl/lGat+dcxCQzbghy3+FgO H7oAjea22S2yms6tWaDuo6qDyl27qJBWjI75oo5nvJ2+/RaY2skDCC5vaiIuQzy56+Rh VfXZ4J0SlH8BzjAHcCaLFq6p6FHmk70xxE0EGm+G8WjSvPoWHf1d3uFkJ/02dh6lB3l5 BNnpOLrEAhic1x5toFh01x5Wm3epdILK7Ot7gsgmKtKXpgUGvzaB2OtBI4KfHiryRwqd y9eqtHA2kYTkYpVZ6hINHWfa5eV9wI9LXY7s61RwgeK6nUXSwaF7dp7bqU2PZA+zhdVK o9kQ== 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=ooPiibuin/T1BXM3ci9G/toRB2k62lYI6dDd6XnUFKA=; fh=sKfwLbYyGsqFA9J5964tfV31zxizqPhzkdLiyF/udjc=; b=bcgVR9LJzFejhroncYOlYLN8FeD2y6/Wrh26LmHvT4AoeTcToVNO4zZc3e6QXhTxSf YhIAJn5ar7/SU3JURq2gLy+Lt+mDn8DZY/jorBiECr8ZchPlt1Qmy63XVYOnyC9JTiRJ Qqsy8f0CWyRIbVAtZBsoaI+fjzmxM6w3YXYLlVvC4bOYFkVeT9UtF2J839sApuFTczOu yBAgCSHOtWWIvK5MemrUoqGzxaArz2jlfSLsamEu0zvRYWJe1Eda4KhoOkJR85QbPnlS X3OG2eMnTvL9Syx0CuKqNC9MMtb9+BrnyWk1mnh7PFSzFEgGZ3k7f+dSL5EmDlmmLBrp jLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=JzQ9L+NI; 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 kr12-20020a170903080c00b001bf0714e0d5si7572436plb.108.2023.09.12.03.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 03:19:52 -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=JzQ9L+NI; 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 6FDAD85062A4; Tue, 12 Sep 2023 03:08:17 -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 S233946AbjILKIF (ORCPT + 37 others); Tue, 12 Sep 2023 06:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234030AbjILKHn (ORCPT ); Tue, 12 Sep 2023 06:07:43 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A1D5172B for ; Tue, 12 Sep 2023 03:07:39 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so2158413f8f.2 for ; Tue, 12 Sep 2023 03:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694513257; x=1695118057; 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=ooPiibuin/T1BXM3ci9G/toRB2k62lYI6dDd6XnUFKA=; b=JzQ9L+NIMBtxp4S6so12CVzTrS6VMV+PvLooJ2BjBkgHqO1plgvKW8RCbgKEloeGFD 046DZjmXeH5knUu9bc6eutPrKq0yni51vumVr6ShmB12dLDrWw/MQWZC5vkBNr20ItW/ DBy00PvwvdN24+s5uxIPwJp0PLfkcByOuT4FFQswwlY/y/ZzRb44/2u0nMMgFUII/hxt ACkRhcuQ0bjVj2RKBtnEM/ZYLN/UzbxefyZBSccVGY9MEZronwaft3F6VI9IYd6erjCW O6F5FWTIEJI2zKBrpUKG/6QK6+jY8ABAp3BzHUt9fCydufEMWx3OjW00/AemRiE4TOZB 79LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694513257; x=1695118057; 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=ooPiibuin/T1BXM3ci9G/toRB2k62lYI6dDd6XnUFKA=; b=E0/Fze5Vv0MR2dHM4Pj4dJQhopqmZ6OaKZnJnoXLZYhFbOZ9GSZJEZ1EG6+B3CwnOf /Zt6kqb8HYGCAnfSoCw7Om7EaYsIM1jcGZJc5ebraD1kAEtv+iA80sR4tYoxs/rzuBTp bCXHJv8YyLVMZdftsdLCX7dXAsdmVrYFVuKBKMqWG/1hYOfMbgtPv8QmiPga2bcjwotX 0JPibTwwNn4Ec1/JWTnd3BI0xo0gjeJaMXDBb/ntu7LkGnlY99VPDmfHE1mEWKzLPZyK yBn2si6qRx49Kx7n2sjx0W4Ok/Ul2RHYuTHu195QLKRqZUKXibaDUJBaz50RhIdCV70j Fhjw== X-Gm-Message-State: AOJu0Yy0rDFJ+4013akBf3iFi04HjztH3eaA0fUVwL8ov7ctFihW/wTO ZGd2ue0TFjN7xCvQjYAQY6q/fw== X-Received: by 2002:a5d:560e:0:b0:314:1ebc:6e19 with SMTP id l14-20020a5d560e000000b003141ebc6e19mr9289691wrv.64.1694513257604; Tue, 12 Sep 2023 03:07:37 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:907f:4cd7:f0ae:6b2a]) by smtp.gmail.com with ESMTPSA id h5-20020adfe985000000b0031ae8d86af4sm12351417wrm.103.2023.09.12.03.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 03:07: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 v2 02/11] gpiolib: add support for scope-based management to gpio_device Date: Tue, 12 Sep 2023 12:07:18 +0200 Message-Id: <20230912100727.23197-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230912100727.23197-1-brgl@bgdev.pl> References: <20230912100727.23197-1-brgl@bgdev.pl> MIME-Version: 1.0 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]); Tue, 12 Sep 2023 03:08:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776826704494106042 X-GMAIL-MSGID: 1776826704494106042 From: Bartosz Golaszewski As the few users that need to get the reference to the GPIO device often release it right after inspecting its properties, let's add support for the automatic reference release to struct gpio_device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- include/linux/gpio/driver.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a2060dc3344b..a52c6cc5162b 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -609,6 +609,8 @@ 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 (_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);