Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp972514lqs; Fri, 14 Jun 2024 10:43:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUp5ssdbs+L9906TjAccgLl3AQwvXxZLFE4X+n9xu+2jkryKPl1N6ksbHarsUr8orAvGXGApl/E8b3Y71b0lJOzNStWflxVtcpKMMtPRw== X-Google-Smtp-Source: AGHT+IGqa8tf8SunYLPREY+es04D4WgQUJLlDEIEccLqvsA+yFgX/tC0xslyzBK/PFVGd6TX6IkM X-Received: by 2002:a17:902:f552:b0:1f8:3f23:94d6 with SMTP id d9443c01a7336-1f8620dd35dmr60472405ad.19.1718387013491; Fri, 14 Jun 2024 10:43:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718387013; cv=pass; d=google.com; s=arc-20160816; b=mu+X+ZTDgoaanZJmd9/PaQ+2dVkeLIRgUdUgIH8BP882nZ0cOuWFN73t9+IRL9MypN msvhvskBNh+i0qk5U44vLMsC0ApXcFZxaZoT92gqODrW/RROUZnXZZRBc92kDfN7x/yr C6Mg4Gp4u8WxWTrikCzmIqk0Am+staPxLFMuEvdRRrlI1IEMKjSuPTjUwpHD0rEcwtmt 5E7GQm6Lanb5JkRb2wSyVAzAB7lYgGJu6dMTUOViozie/mJ6PBvtvvi8VaetQUPzg4Rf e84fnSEKGW0ORPbbnMQ/+cEnh5PNWfxSH0OjyijzYZXTU/XF2vnyAdl9qLhehjgMQFYZ UR7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TgSTclGEyMVNAcyML8FqLvo4YRpuke6IGp+WHuItynU=; fh=bujJSrd+k1h/0aZbC1LeFD2/cY2NpcCgJFppOaBslqM=; b=GO7YKnykSRus71yaWScKg2YZ/cONdxg9u9Fms2X2+6AR3/yGl4VSDDQ1kCg41qIBhQ CpplEEospWfp80coNfbzjeft0DCgSSsXCGl4KuRsvix9zJPXzijywl2aVu0D+SesjiEe lkhLQMoIYPuC7A0vG8nLor78EQL9NFXkJ5Yidu4ytxHHg3va4vQiV7voeVV5c4jOuao2 0+H0OZIrYzmR0KDf2rIDWXaO66yl5sJXtZ/TWA1mFiaCKhHpMsNgK2CPMQtervhFiaN1 DkrB5XJYezzg5pOP+DE6uAVNqa1V2qcu7j+xTVyzdNb2YjEO+0xveLQFWJJmUILkkA2f JjBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dEv8F+Yn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-215377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855efe473si27760155ad.462.2024.06.14.10.43.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 10:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dEv8F+Yn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-215377-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B9998289230 for ; Fri, 14 Jun 2024 17:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 442E81B0130; Fri, 14 Jun 2024 17:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dEv8F+Yn" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 543591AD9F5; Fri, 14 Jun 2024 17:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386383; cv=none; b=kUNwLD9ju9P/mUiqF7Xb+VeA8m4hV/T90zf8M8EXaiSRLbdkrsXhCjZ/CQR9Dtefl8UXI3SjgwmtqxaIimIgLqQ/IfUhDqfQVjpwZBh+wNdPy6skitLnPzohqQXKkApejmADDHfxDJEW/pQHo58SRfWlfA09eNQ9UDPZrgGjglE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386383; c=relaxed/simple; bh=+GEMoT9fsybF2t6htFlaw8fkxkNsZBe9GF9d/ejPY80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SKP5q/QW5MEcUDxAzeaTt4YZ/+/GLCQeyH8egSf92n9SZSW6wF6jPg50PgpUwiAmGpKi0XUarqWe75cTmGqXu9liVsjIPgnr86LUoeGz2aCu3C40YKiDPVa0p5rwy+YkNvdAGLN+B/BSGZX2+AMEXVJu6yky7TsX0tPEzBzO+7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dEv8F+Yn; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 1569EFF806; Fri, 14 Jun 2024 17:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718386379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TgSTclGEyMVNAcyML8FqLvo4YRpuke6IGp+WHuItynU=; b=dEv8F+YnoNI0QIBoh3E5anMu3hKDqUOCr8ora+u+Di5YR922JEF+cKtDfeUAM6W3MK1yuU zZOBncfdU/J4snrEKG7burRvMzc4gCJW3fkvfKsNmQHoqJONN3PsE0v9DnEoQmk9YTLrGq qayVRK9g3/daqT9BizVyKmQ3aUZB9THh5TNa7QG0rKRcPQvql4rEY+9UmapVDWiWcwXB5H j7kvJWE4WvIqxaPjsT3Z3oIrgdU3gzhyzre0jNOb7NyoJX9+VbQ+hT8MuOJhiIh5ZI1tfe Smx+ZrOZpDDru6tzqqm/opoLeAehq5Q9LUWxuz12kWrsMi262Zx2akJKw4gYww== From: Herve Codina To: Matti Vaittinen , Herve Codina , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Weinberger , Anton Ivanov , Johannes Berg , Marc Zyngier Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-um@lists.infradead.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni Subject: [PATCH 16/23] irqdomain: Add a resource managed version of irq_domain_instantiate() Date: Fri, 14 Jun 2024 19:32:17 +0200 Message-ID: <20240614173232.1184015-17-herve.codina@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240614173232.1184015-1-herve.codina@bootlin.com> References: <20240614173232.1184015-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com Add a devres version of irq_domain_instantiate(). Signed-off-by: Herve Codina --- include/linux/irqdomain.h | 2 ++ kernel/irq/devres.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 5540b22a755c..8820317582c4 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -304,6 +304,8 @@ struct irq_domain_info { }; struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *info); +struct irq_domain *devm_irq_domain_instantiate(struct device *dev, + const struct irq_domain_info *info); struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int size, irq_hw_number_t hwirq_max, int direct_max, diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c index f6e5515ee077..b3e98668f4dd 100644 --- a/kernel/irq/devres.c +++ b/kernel/irq/devres.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include @@ -282,3 +283,43 @@ int devm_irq_setup_generic_chip(struct device *dev, struct irq_chip_generic *gc, } EXPORT_SYMBOL_GPL(devm_irq_setup_generic_chip); #endif /* CONFIG_GENERIC_IRQ_CHIP */ + +#ifdef CONFIG_IRQ_DOMAIN +static void devm_irq_domain_remove(struct device *dev, void *res) +{ + struct irq_domain **domain = res; + + irq_domain_remove(*domain); +} + +/** + * devm_irq_domain_instantiate() - Instantiate a new irq domain data for a + * managed device. + * @dev: Device to instantiate the domain for + * @info: Domain information pointer pointing to the information for this + * domain + * + * Return: A pointer to the instantiated irq domain or an ERR_PTR value. + */ +struct irq_domain *devm_irq_domain_instantiate(struct device *dev, + const struct irq_domain_info *info) +{ + struct irq_domain *domain; + struct irq_domain **dr; + + dr = devres_alloc(devm_irq_domain_remove, sizeof(*dr), GFP_KERNEL); + if (!dr) + return ERR_PTR(-ENOMEM); + + domain = irq_domain_instantiate(info); + if (!IS_ERR(domain)) { + *dr = domain; + devres_add(dev, dr); + } else { + devres_free(dr); + } + + return domain; +} +EXPORT_SYMBOL_GPL(devm_irq_domain_instantiate); +#endif /* CONFIG_IRQ_DOMAIN */ -- 2.45.0