From patchwork Mon Jan 31 12:33:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12730658 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 871CBC433FE for ; Mon, 31 Jan 2022 12:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377679AbiAaMeh (ORCPT ); Mon, 31 Jan 2022 07:34:37 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:59410 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiAaMeh (ORCPT ); Mon, 31 Jan 2022 07:34:37 -0500 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1643632475; 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=9t0l66X+9+rOkZ0CpBJw8Upffgz+ZzqJoLeQyVHWW5g=; b=obux4keDpJq+njhJHJRgeO/GrKtUnbH3Ymq8SlsxTOHyetBB1sXOBGThc+7g84EQTNeyMg Q2Bxplobgr+pAdpuM2CBPHjsSqrycwCQ6b+jlfAtjM95vIfLKK7K0MbWYSxEWI5MF2YlAS nAHiV8sR1xr3e9fWWRdEPjjUXZbgM6D0CyAK9uJDL2I5o/KPY9heigp1yExL7w1h1DFpDe 3+FvFmI/FVHSI0SvEP3BinCQJIWKo6i7sI8n8/Moxyf3mK6kuJbPrSYtuoGL1XhMBH4Euw uPCGndsGH4lITQQVMDahzrm6julaTBuSWxKyZhcLYGu5gK/fHOKZ8AtHfOb1zg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1643632475; 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=9t0l66X+9+rOkZ0CpBJw8Upffgz+ZzqJoLeQyVHWW5g=; b=IBw/srGY3rzYIpvWDICG/4UlhGAOGaNaVFhhnyWsQENyUqbX5K0weOOSICPjdQGbbkEFc3 QOcFD+eFNpeh6rCw== To: greybus-dev@lists.linaro.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Alex Elder , Arnd Bergmann , Greg Kroah-Hartman , Hans de Goede , Jakub Kicinski , Johan Hovold , Lee Jones , Rui Miguel Silva , Thomas Gleixner , UNGLinuxDriver@microchip.com, Wolfram Sang , Woojung Huh , Sebastian Andrzej Siewior , Oleksandr Natalenko Subject: [PATCH v2 1/7] genirq: Provide generic_handle_irq_safe(). Date: Mon, 31 Jan 2022 13:33:58 +0100 Message-Id: <20220131123404.175438-2-bigeasy@linutronix.de> In-Reply-To: <20220131123404.175438-1-bigeasy@linutronix.de> References: <20220131123404.175438-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Provide generic_handle_irq_safe() which can used from any context. Suggested-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Hans de Goede Reviewed-by: Oleksandr Natalenko Reviewed-by: Wolfram Sang --- include/linux/irqdesc.h | 1 + kernel/irq/irqdesc.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h index 93d270ca0c567..a77584593f7d1 100644 --- a/include/linux/irqdesc.h +++ b/include/linux/irqdesc.h @@ -160,6 +160,7 @@ static inline void generic_handle_irq_desc(struct irq_desc *desc) int handle_irq_desc(struct irq_desc *desc); int generic_handle_irq(unsigned int irq); +int generic_handle_irq_safe(unsigned int irq); #ifdef CONFIG_IRQ_DOMAIN /* diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 2267e6527db3c..4c58fa940a61c 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -662,6 +662,29 @@ int generic_handle_irq(unsigned int irq) } EXPORT_SYMBOL_GPL(generic_handle_irq); +/** + * generic_handle_irq_safe - Invoke the handler for a particular irq from any + * context. + * @irq: The irq number to handle + * + * Returns: 0 on success, a negative value on error. + * + * This function can be called any context (IRQ or process context). It will + * report an error if not invoked from IRQ context and the irq has been marked + * to enforce IRQ-contex only. + */ +int generic_handle_irq_safe(unsigned int irq) +{ + unsigned long flags; + int ret; + + local_irq_save(flags); + ret = handle_irq_desc(irq_to_desc(irq)); + local_irq_restore(flags); + return ret; +} +EXPORT_SYMBOL_GPL(generic_handle_irq_safe); + #ifdef CONFIG_IRQ_DOMAIN /** * generic_handle_domain_irq - Invoke the handler for a HW irq belonging