From patchwork Tue Sep 5 18:52:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7937ACA0FF7 for ; Tue, 5 Sep 2023 18:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mwoDMzWzYJsr1IEb/rZf8cQLAPdn+9NcCWyb9L731fI=; b=hf1Z+DTOo8tBhi bbkk8Oc0g+9V+tD6CNEm+ul7Iswko5jynWXEXY2AypKSmNpxQXTPCmO9DouzwOeb+ShjnrlE3oqmS KHHWMdPqxZFBuV3MMIerO4mzqI9ncYKVs4Ki67zZ+UMkR9RU4ZRKhPbHqBsvIl503+HcVypsS6OsJ PnNQ1OptkrBPLWXsSGjPWjUUayriaJqHdS4gUA2BHRfjaj17VU3A0pymZ61UZVupRsLxK1xk+mHXQ 30SgDXbFo70RCWb8iCT0siaf3b4RzrqQgznB/keS2np8p9LDE3wOfSG6ysQPxlozMla4fPxrBY+Rr a7LMrGyxGlDYMa0LUsPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YSj-0B; Tue, 05 Sep 2023 18:53:40 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbB9-006YOl-35 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:37 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-401b0d97850so30051975e9.2 for ; Tue, 05 Sep 2023 11:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940012; x=1694544812; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0ESplXfwHuP68mF4bwcKzJlFkniMRPzx/b85/cMF6oE=; b=NnIJunQoeciymnLI6YXleXY+NHvrBMNXHHIlGpydoS+QR9JRLuu1C7g3Eo65c9UZx9 EkQbAndm9EqkGFzyJOxZF6uYjVf5V6SHEQRPW3hDLSxKSRrbAlrAr4fgpFUMqhDaHqs9 Ucq3Up+Dz1DUnIjY3jWN2YMTpTZbXw0SjjQdWZ5I/rSFUIdaKAUbO9d613aLRCprx4DW 9ZyodZUzVA20wJdAbCbiBv5i8PYqExpi3DG4TDn0Nlce/wZ4y+xSd4dvYSgjDFmizm+m cUeVeqVSi4+vRgRU4It9QyIiBFSqkYDqllTLo755QCPM2C7tAoAaEXhhYOLxO+Tc9VVF v9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940012; x=1694544812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0ESplXfwHuP68mF4bwcKzJlFkniMRPzx/b85/cMF6oE=; b=MhMcQkZC4B6nL13/zzL1hAOhHP8eX2ExuBqpOsTUiwqHMje+tUkzxWV957znZYQ8xX T3Wj0jrCq2IU6E9yOLVF0grfcX+Wr1D93v3d1MyMGwzOJTfzbmAcuvnUWZOqPFfnKIZ7 SEf/xU34Ib19W5sgmeI5U0hrU1HhohVK2Dcy3V0rP4ixxC0Pzbb2ep3cWhlP5zS4PUlj q6YdXPhOaj4hBdRO48xmSJoXF7FWWCOnAM9eonRJCEWq/mOSOE4QXSGSZ/K0wZu6GlHY zzrp2AfMF00aIN5a8leoiHMLtmbr2XYySDRH7KetvKes9WR4wNClzxP8MCrPFwMuel2P 073w== X-Gm-Message-State: AOJu0YxPIAAk30uaZTMXRfGRz27xNkKF0FeDg6/34Usx5aMZ1dqW4MJ+ 5cf/C8bvcRC3tHMjjYFruuXlqA== X-Google-Smtp-Source: AGHT+IH/VUJWjUGeUiwbD9fUfZeGiUcxVuhg9dWO0f7MJ889A/l01WqAkHMkYlgWTOb/EzfuaH05Kg== X-Received: by 2002:a7b:c411:0:b0:3fe:f45:772d with SMTP id k17-20020a7bc411000000b003fe0f45772dmr436878wmi.28.1693940012315; Tue, 05 Sep 2023 11:53:32 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7a54:5dbc:6d09:48b7]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c249100b003fbc30825fbsm17550010wms.39.2023.09.05.11.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:31 -0700 (PDT) From: Bartosz Golaszewski To: Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Dipen Patel , Thierry Reding , Jonathan Hunter , Hans de Goede , Mark Gross Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org, platform-driver-x86@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 05/21] gpiolib: add support for scope-based management to gpio_device Date: Tue, 5 Sep 2023 20:52:53 +0200 Message-Id: <20230905185309.131295-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230905185309.131295-1-brgl@bgdev.pl> References: <20230905185309.131295-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_115335_991699_4731EA64 X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski As the few users that need to get the reference to the GPIO device often release it right after inspecting its properties, let's add support for the automatic reference release to struct gpio_device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- include/linux/gpio/driver.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a769baf3d731..b2572b26c8e3 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -614,6 +614,8 @@ struct gpio_device *gpio_device_find_by_label(const char *label); struct gpio_device *gpio_device_get(struct gpio_device *gdev); void gpio_device_put(struct gpio_device *gdev); +DEFINE_FREE(gpio_device_put, struct gpio_device *, if (_T) gpio_device_put(_T)); + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset);