From patchwork Tue May 12 17:12:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 471414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 39CF6140D2E for ; Wed, 13 May 2015 03:12:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=v5wh+b3R; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932814AbbELRMh (ORCPT ); Tue, 12 May 2015 13:12:37 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:34991 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932918AbbELRMg (ORCPT ); Tue, 12 May 2015 13:12:36 -0400 Received: by widdi4 with SMTP id di4so163452346wid.0 for ; Tue, 12 May 2015 10:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NvXkJiPGoMj/YdihEftweY0E9b6jLT0uQbVVqg8HYfs=; b=v5wh+b3RTvXilrRV4pJNr5mN5EFHKCa9jsj8ZC7H2hgSCF/l4tnoC+XTZZ+4YsBIJi vsZpxfHCxJ8/1WxDP0ZcjseJnuzooadpP2ZuEBMj453kODCgAWYthvZ/X3R2/ZwHyS3F r6wT8jNZ+Ds7vKeyaZ/dtMnHNGhI+JHcwKGG2IHpT3eMCM2jXeEAQLF45BZ2Huj2A4nE pj4U9dEdrDFhKX0y2/ylC4X5ycwsThviB16pS9u6Zf3fwrhjdFmB6Lc0LjmSj2G2Xjns BrKoaPMj9fvU/DGXrk3N1SEFoDbh6YzGsQVxWs9S1g3FiQSfJezkb37/mJ1gtP14GrmI lReg== X-Received: by 10.180.188.35 with SMTP id fx3mr31766041wic.43.1431450755593; Tue, 12 May 2015 10:12:35 -0700 (PDT) Received: from fangorn.rup.mentorg.com (nat-min.mentorg.com. [139.181.32.34]) by mx.google.com with ESMTPSA id l3sm3788062wiv.18.2015.05.12.10.12.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 10:12:33 -0700 (PDT) From: Dmitry Eremin-Solenikov To: Linus Walleij , Alexandre Courbot Cc: linux-gpio@vger.kernel.org Subject: [PATCH] gpiolib: cleanup chained handler and data Date: Tue, 12 May 2015 20:12:23 +0300 Message-Id: <1431450743-25528-1-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Clean up chained handler and handler data if they were set by gpiochip_set_chained_irqchip(). Signed-off-by: Dmitry Eremin-Solenikov --- drivers/gpio/gpiolib.c | 7 +++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 59eaa23..0f40a7f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -439,6 +439,8 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, */ irq_set_handler_data(parent_irq, gpiochip); irq_set_chained_handler(parent_irq, parent_handler); + + gpiochip->irq_parent = parent_irq; } /* Set the parent IRQ for all affected IRQs */ @@ -547,6 +549,11 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) acpi_gpiochip_free_interrupts(gpiochip); + if (gpiochip->irq_parent) { + irq_set_chained_handler(gpiochip->irq_parent, NULL); + irq_set_handler_data(gpiochip->irq_parent, NULL); + } + /* Remove all IRQ mappings and delete the domain */ if (gpiochip->irqdomain) { for (offset = 0; offset < gpiochip->ngpio; offset++) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index f1b3659..d656577 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -121,6 +121,7 @@ struct gpio_chip { unsigned int irq_base; irq_flow_handler_t irq_handler; unsigned int irq_default_type; + int irq_parent; #endif #if defined(CONFIG_OF_GPIO)