From patchwork Tue Feb 11 13:12:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 407E1C352A3 for ; Tue, 11 Feb 2020 13:13:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1844B20870 for ; Tue, 11 Feb 2020 13:13:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="vCbyLf9V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729039AbgBKNNZ (ORCPT ); Tue, 11 Feb 2020 08:13:25 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38851 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729045AbgBKNNE (ORCPT ); Tue, 11 Feb 2020 08:13:04 -0500 Received: by mail-wm1-f68.google.com with SMTP id a9so3515073wmj.3 for ; Tue, 11 Feb 2020 05:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uc8xQCON5zDwR8DUMLyo3MIMMq2WPuIE9JxQ1gURZh8=; b=vCbyLf9VWyEXfKLjEe55OgreiTorLdlet6cpkzjqgxySZKumn1sFYmLj9u46YTXTM5 C10ATKL3noqzpXBqonK2a+V9tZW/B9DutE0bifDGmfEuCjj1if8zk8Kb3FYLWn8i2+8S axXX7eVfj6It1jztvxpRbJcPSiQxzO8IYhd2jgp043VGQ70nNKiKsPRtxU/AzHsHMBv4 0kGjGCHa5+3Sf1gp8X7kgGs+c+ZX4bQK6eZF2Sd+iDxOGvGRvYgqjUYMavUPd8JVgGvj eqf6oEJG9Ue3SUD47SWPTe5gtdpHt5ks/m0E8+GGajVB4UtLuPPxbHFGAvp6H9xtHr/Q PWeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uc8xQCON5zDwR8DUMLyo3MIMMq2WPuIE9JxQ1gURZh8=; b=DdgJskQi+r1fiSpX/15dOfZKGfTj7pom/uHC9lG/KwqUCBrP+7GkTU+9BVmi/ixNWZ xwN9WRuYiM8buYLl1bY1w32yqw345X013fZgd1BwX157JmJ8yalvsaDVKJk5vXAsOZPB V0iAeB45kbrgIv30k1xSko9NYp3ZvgweaU+pQvzcUubrbPIAZkMhuvpgQLopIBuFkOCd 864YlGWwYKekCg3iNJFHHw/vMP7Ev8YEkc2ohju9l192ogaZ99bLWVtOJt9XgXNKtmVY aDiKgh0y41EUlI63mAce0Pui38niQlJfG+7s7o7obUufk03gQ29eo/mJU8+ZDpl0x/+v 9Ymw== X-Gm-Message-State: APjAAAVum/B+gTUmwVEhk9DbRbOILHVGdbRR3Bsr5bYbei5QQNkArxLi bFWXKS4y7Y8XFEj8ru7Gr4eexHmuf3s= X-Google-Smtp-Source: APXvYqxzfbcatJyy+RYI1cefcr1daJmFQcMYqV3T4tUbL6cK8/4aHjxYt4gy3CW5BTPxHR6EPF93Og== X-Received: by 2002:a7b:c147:: with SMTP id z7mr5567366wmi.168.1581426782790; Tue, 11 Feb 2020 05:13:02 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id b21sm3873013wmd.37.2020.02.11.05.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 05:13:01 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 3/6] irq/domain: add a new callback to domain ops Date: Tue, 11 Feb 2020 14:12:37 +0100 Message-Id: <20200211131240.15853-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200211131240.15853-1-brgl@bgdev.pl> References: <20200211131240.15853-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Add the remove() callback to irq_domain_ops which can be used to automatically dispose of any host data associated with the domain when irq_domain_remove() is called. Signed-off-by: Bartosz Golaszewski --- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 20d38621e2f8..fbc25f464f62 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -95,6 +95,8 @@ enum irq_domain_bus_token { * @unmap: Dispose of such a mapping * @xlate: Given a device tree node and interrupt specifier, decode * the hardware irq number and linux irq type value. + * @remove: Free any custom resources associated with this domain. This is + * called from irq_domain_remove() before any other code. * * Functions below are provided by the driver and called whenever a new mapping * is created or an old mapping is disposed. The driver can then proceed to @@ -126,6 +128,7 @@ struct irq_domain_ops { void (*debug_show)(struct seq_file *m, struct irq_domain *d, struct irq_data *irqd, int ind); #endif + void (*remove)(struct irq_domain *d); }; extern struct irq_domain_ops irq_generic_chip_ops; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 039427c98af8..b391d2e65bdd 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -242,6 +242,9 @@ EXPORT_SYMBOL_GPL(__irq_domain_add); */ void irq_domain_remove(struct irq_domain *domain) { + if (domain->ops->remove) + domain->ops->remove(domain); + mutex_lock(&irq_domain_mutex); debugfs_remove_domain_dir(domain); From patchwork Tue Feb 11 13:12:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85B9AC352A3 for ; Tue, 11 Feb 2020 13:13:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DBE820848 for ; Tue, 11 Feb 2020 13:13:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="1jvVusFz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728840AbgBKNNJ (ORCPT ); Tue, 11 Feb 2020 08:13:09 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55787 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729062AbgBKNNG (ORCPT ); Tue, 11 Feb 2020 08:13:06 -0500 Received: by mail-wm1-f66.google.com with SMTP id q9so3460708wmj.5 for ; Tue, 11 Feb 2020 05:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f+82O1OuBB3itFL0o65sBPeQjxKbsseoBh5Dt/Kun5Y=; b=1jvVusFzmlhzxZfNTJYcIcWAhYOXsvC8wyNQkaeYZ5qJyntOxfoWQgnmgOXW6jchYp Iu02eDVYR6McIUfUL/VvFFm0qrea5OtXU2TrWDUC627cE+5bkdrK64ofCM/jOnYhQRWb c44LrAvxURzTDxJYWAe1B4TztYkJxXOgxPMA0Z5+tRseJu0hF6zckMivlEPCqIIUWedp ztA1RAOwZ86g50jC5ePdx1lesa/MPL2wdo4qGVDBfFpbUu1sCFqt8+OFsYMlkLoTMV/t R1czk5ccNrwYP0oixc766Su6GZMmsCdZ3Cir8rx47YZ/LzVmn5wRrLqEze0l3sfRm2lF ymWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f+82O1OuBB3itFL0o65sBPeQjxKbsseoBh5Dt/Kun5Y=; b=glpubgf+Vryke6fGTqmGfjli/Q/U1Zu1IVkT2oK0mD7EzZvJVfP7kigLuWwDMVrxfF NKQoxsn40z9Bcx8ofFAbdjFZqdOqSaje2FhaoEqjZ9zMesrUOJ4Hp4CcoaYwI4+6xAMV +LM1OWHI30j6oK91FsvmYIunEPG8gKK4fBzvlCZXM3VF5t7/3SinlB91pEmeCczpnNLh UyY2vs/RT54dDqKO4lnQBMgUsr5d0wERjKByYYUJEeXtNG+C/0FxF7ylusLDrsKQTLWS 9TnQ/yGmphyVY0NusgSFZv2i3ffjDgFMmrDL4rk8aNeEvUfOuB+JhfU65qxMR39ycoy6 bcTg== X-Gm-Message-State: APjAAAWSZOptw/xrloDgxC39VkCnqyrE7jVPk/SNTR0Fqi7T1/KREamc /CRYFuDkb+LSERU/NUnYHiZwuQ== X-Google-Smtp-Source: APXvYqzljNsEnWt6VAXASHyN5ZUk1Glg/tkFgMB+ilT6DVfsMIc5l3auu39ziddsgEQzSNQdJY1mqw== X-Received: by 2002:a7b:c4c5:: with SMTP id g5mr5768157wmk.85.1581426783999; Tue, 11 Feb 2020 05:13:03 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id b21sm3873013wmd.37.2020.02.11.05.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 05:13:03 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 4/6] irq/irq_sim: remove irq_domain_remove_sim() Date: Tue, 11 Feb 2020 14:12:38 +0100 Message-Id: <20200211131240.15853-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200211131240.15853-1-brgl@bgdev.pl> References: <20200211131240.15853-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Use the new remove() callback in irq_domain_ops to dispose of any private data associated with the sim domain. This allows us to drop the dedicated irq_domain_remove_sim() function and instead just use the regular irq_domain_remove(). Signed-off-by: Bartosz Golaszewski --- drivers/iio/dummy/iio_dummy_evgen.c | 2 +- include/linux/irq_sim.h | 1 - kernel/irq/irq_sim.c | 32 ++++++++++++----------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/iio/dummy/iio_dummy_evgen.c b/drivers/iio/dummy/iio_dummy_evgen.c index 31c9e012abeb..47620bdae845 100644 --- a/drivers/iio/dummy/iio_dummy_evgen.c +++ b/drivers/iio/dummy/iio_dummy_evgen.c @@ -118,7 +118,7 @@ EXPORT_SYMBOL_GPL(iio_dummy_evgen_get_regs); static void iio_dummy_evgen_free(void) { - irq_domain_remove_sim(iio_evgen->irq_sim_domain); + irq_domain_remove(iio_evgen->irq_sim_domain); kfree(iio_evgen); } diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h index 26bf6164dcc7..90e910fa2f91 100644 --- a/include/linux/irq_sim.h +++ b/include/linux/irq_sim.h @@ -21,7 +21,6 @@ struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, struct irq_domain *devm_irq_domain_create_sim(struct device *dev, struct fwnode_handle *fwnode, unsigned int num_irqs); -void irq_domain_remove_sim(struct irq_domain *domain); void irq_sim_fire(int virq); #endif /* _LINUX_IRQ_SIM_H */ diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index 575c1e3d32a9..a4400aed5fb2 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -108,9 +108,19 @@ static void irq_sim_domain_unmap(struct irq_domain *domain, unsigned int virq) kfree(irq_ctx); } +static void irq_sim_domain_remove(struct irq_domain *domain) +{ + struct irq_sim_work_ctx *work_ctx = domain->host_data; + + irq_work_sync(&work_ctx->work); + bitmap_free(work_ctx->pending); + kfree(work_ctx); +} + static const struct irq_domain_ops irq_sim_domain_ops = { .map = irq_sim_domain_map, .unmap = irq_sim_domain_unmap, + .remove = irq_sim_domain_remove, }; /** @@ -122,6 +132,8 @@ static const struct irq_domain_ops irq_sim_domain_ops = { * * On success: return a new irq_domain object. * On failure: a negative errno wrapped with ERR_PTR(). + * + * The returned domain can be freed using irq_domain_remove(). */ struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, unsigned int num_irqs) @@ -156,29 +168,11 @@ struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, } EXPORT_SYMBOL_GPL(irq_domain_create_sim); -/** - * irq_domain_remove_sim - Deinitialize the interrupt simulator domain: free - * the interrupt descriptors and allocated memory. - * - * @domain: The interrupt simulator domain to tear down. - */ -void irq_domain_remove_sim(struct irq_domain *domain) -{ - struct irq_sim_work_ctx *work_ctx = domain->host_data; - - irq_work_sync(&work_ctx->work); - bitmap_free(work_ctx->pending); - kfree(work_ctx); - - irq_domain_remove(domain); -} -EXPORT_SYMBOL_GPL(irq_domain_remove_sim); - static void devm_irq_domain_release_sim(struct device *dev, void *res) { struct irq_sim_devres *this = res; - irq_domain_remove_sim(this->domain); + irq_domain_remove(this->domain); } /** From patchwork Tue Feb 11 13:12:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A8B5C352A3 for ; Tue, 11 Feb 2020 13:13:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D87B208C4 for ; Tue, 11 Feb 2020 13:13:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="LcrMHtCU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729084AbgBKNNH (ORCPT ); Tue, 11 Feb 2020 08:13:07 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39898 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbgBKNNH (ORCPT ); Tue, 11 Feb 2020 08:13:07 -0500 Received: by mail-wr1-f67.google.com with SMTP id y11so12328077wrt.6 for ; Tue, 11 Feb 2020 05:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=anPiy+Oai5eVC9epbsqPoMEWmUp50/yoIqvuC47WE5o=; b=LcrMHtCUppxeolsKFGx6QsBeDzCgd+5f8d/Oq/d8bQLTe2OeansixpI49rk7VTtwHO TAadngLfrWrhX/Za4qdIf48h7osfj+UtUjkYt8J+GCrXmU3esu+ojHKWvQPt39Cw0EmU 8iwhyTdDSKEuJwjPVx2LSG1K+4AZ2eHca+Pt/hpgb3HSE0TJRzk7+/6vxp+A9MQcK2g5 WxLqITqfiEcblyk3kcL8wB0WDcrtnF8YEuApH4lNvz2SbbUmBdKrW2BpMVkOXQPlDMzc mPmY3MEo4I7MsTQ6a5JLe7mIygDcVOKtUqN9hKS/JM0sKW02t0qiGKxQ/L81g4zm1bkC blQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=anPiy+Oai5eVC9epbsqPoMEWmUp50/yoIqvuC47WE5o=; b=Bq/qZtqjOKwdgFjflPRkSijJ7UhUA3m8F6Rli1fG7Omr+Wnp3QnepS4xK6lYMJG4ng Q2rFvmmZRTh7lbCe9Z2x6k16+3QAMrA9OaORzXRlJ2fMIpMe9ZCkW3nlPERgotvarVcJ Q023ufvB1g6N1Kkgut6nC8FEylVFX+D9JNAO0Hxn01iIgdj5vl6YGl21LdprJ9jTEWlR iAoqrj2wRXNb/rSqwY2p0TI4I/mBnH6zUq4UaqktBjll1r/fO/wTXogS9TD0WoBsM3Uu 7+9QtF5LgvGQxLggADl2QgsF1kEcf8Vx9YAe2e521lvfipoggTr6CVr1R4/x/dxhp0uL 1KcA== X-Gm-Message-State: APjAAAX3Lysu54cOHPAenxzgbdkrd6Hik7AmWcPdMz2EnhVAUy9kA8i/ tw2TnZloO/RKrCdhdj5t+G5uIw== X-Google-Smtp-Source: APXvYqzzhUz5QJgJfU2ox7SdgabZbIVUaJl7QIQdgt8cnPmLLHB161BbLwhKlnx0AUyBK9UVc6nz1A== X-Received: by 2002:a5d:51c9:: with SMTP id n9mr8771950wrv.334.1581426785134; Tue, 11 Feb 2020 05:13:05 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id b21sm3873013wmd.37.2020.02.11.05.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 05:13:04 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 5/6] irq/domain: provide irq_domain_dispose_mappings() helper Date: Tue, 11 Feb 2020 14:12:39 +0100 Message-Id: <20200211131240.15853-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200211131240.15853-1-brgl@bgdev.pl> References: <20200211131240.15853-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Unmapping all interrupts before removing an irq_domain is a common use-case. Provide an appropriate helper that can also be used with the remove() callback in irq_domain ops. Signed-off-by: Bartosz Golaszewski --- include/linux/irqdomain.h | 2 ++ kernel/irq/irqdomain.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index fbc25f464f62..8fd27614dafd 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -390,6 +390,7 @@ extern unsigned int irq_create_mapping(struct irq_domain *host, irq_hw_number_t hwirq); extern unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec); extern void irq_dispose_mapping(unsigned int virq); +extern void irq_domain_dispose_mappings(struct irq_domain *domain); /** * irq_linear_revmap() - Find a linux irq from a hw irq number. @@ -594,6 +595,7 @@ irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain) #else /* CONFIG_IRQ_DOMAIN */ static inline void irq_dispose_mapping(unsigned int virq) { } +static inline void irq_domain_dispose_mappings(struct irq_domain *domain) { } static inline struct irq_domain *irq_find_matching_fwnode( struct fwnode_handle *fwnode, enum irq_domain_bus_token bus_token) { diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index b391d2e65bdd..d09de9f2411a 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -888,6 +888,23 @@ void irq_dispose_mapping(unsigned int virq) } EXPORT_SYMBOL_GPL(irq_dispose_mapping); +/** + * irq_domain_dispose_mappings() - Unmap all interrupts + * @domain: domain for which to unmap all interrupts + */ +void irq_domain_dispose_mappings(struct irq_domain *domain) +{ + unsigned int virq; + int i; + + for (i = 0; i < domain->hwirq_max; i++) { + virq = irq_find_mapping(domain, i); + if (virq) + irq_dispose_mapping(virq); + } +} +EXPORT_SYMBOL_GPL(irq_domain_dispose_mappings); + /** * irq_find_mapping() - Find a linux irq from a hw irq number. * @domain: domain owning this hardware interrupt