From patchwork Sun Jan 18 11:39:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 430173 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 A2EC41401AC for ; Sun, 18 Jan 2015 22:40:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751617AbbARLkg (ORCPT ); Sun, 18 Jan 2015 06:40:36 -0500 Received: from mail-lb0-f170.google.com ([209.85.217.170]:49222 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752608AbbARLkA (ORCPT ); Sun, 18 Jan 2015 06:40:00 -0500 Received: by mail-lb0-f170.google.com with SMTP id 10so24256345lbg.1; Sun, 18 Jan 2015 03:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Xs68SXDNC3D0/5b4yFCLLyB3d1TYgtx8b3vOTsIop4=; b=sTBI47wgFc2DJ25tfDXP9hu1mMwfkbYUEOz6g9rmV51GiCa8rohZ9SagA5r4v1wQGN 4YmCAMM6pKXUSSlc8s8/NgM8i75LfRx0ryvXDhe0TzVoxv4vnWKr7gsJy9bW1iGrRwoP VZYFW4DQUyjhGdS3ucg26e08ZWYKkUp8ousGOKVIFc86Wu3iSo66FIGvGUfY0iLXVnt9 OwScgTluD86Z5Bo5j8D3ADvXmcXRFb0QgSq/oakHnpVfuDt/ZkkL/UGxI25kQ5TuNZIx 6c6ImhtoR8x1nBWLyFYIOExrC5uOLBdlBOuvlVMdX/4bVf6nRzB4OHGFCl6huNeVvE8B QKTg== X-Received: by 10.112.154.70 with SMTP id vm6mr24633149lbb.18.1421581199314; Sun, 18 Jan 2015 03:39:59 -0800 (PST) Received: from localhost.localdomain (x1-6-30-46-9a-6d-3c-54.cpe.webspeed.dk. [2.108.161.190]) by mx.google.com with ESMTPSA id s16sm2829856lal.5.2015.01.18.03.39.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Jan 2015 03:39:58 -0800 (PST) From: Ricardo Ribalda Delgado To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado , Linus Walleij , Alexandre Courbot , Peter Korsgaard Subject: [PATCH 8/8] gpio/mpc8xxx: Use of_mm_gpiochip_remove Date: Sun, 18 Jan 2015 12:39:33 +0100 Message-Id: <1421581173-28416-9-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421581173-28416-1-git-send-email-ricardo.ribalda@gmail.com> References: <1421581173-28416-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Since d621e8bae5ac9c67 (Create of_mm_gpiochip_remove), there is a counterpart for of_mm_gpiochip_add. This patch implements the remove function of the driver making use of it. Cc: Linus Walleij Cc: Alexandre Courbot Cc: Peter Korsgaard Signed-off-by: Ricardo Ribalda Delgado Acked-by: Peter Korsgaard --- drivers/gpio/gpio-mpc8xxx.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 57eb794..a6952ba3 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -40,6 +40,7 @@ struct mpc8xxx_gpio_chip { */ u32 data; struct irq_domain *irq; + unsigned int irqn; const void *of_dev_id_data; }; @@ -350,13 +351,14 @@ static int mpc8xxx_probe(struct platform_device *pdev) struct of_mm_gpio_chip *mm_gc; struct gpio_chip *gc; const struct of_device_id *id; - unsigned hwirq; int ret; mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); if (!mpc8xxx_gc) return -ENOMEM; + platform_set_drvdata(pdev, mpc8xxx_gc); + spin_lock_init(&mpc8xxx_gc->lock); mm_gc = &mpc8xxx_gc->mm_gc; @@ -377,8 +379,8 @@ static int mpc8xxx_probe(struct platform_device *pdev) if (ret) return ret; - hwirq = irq_of_parse_and_map(np, 0); - if (hwirq == NO_IRQ) + mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0); + if (mpc8xxx_gc->irqn == NO_IRQ) return 0; mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, @@ -394,14 +396,30 @@ static int mpc8xxx_probe(struct platform_device *pdev) out_be32(mm_gc->regs + GPIO_IER, 0xffffffff); out_be32(mm_gc->regs + GPIO_IMR, 0); - irq_set_handler_data(hwirq, mpc8xxx_gc); - irq_set_chained_handler(hwirq, mpc8xxx_gpio_irq_cascade); + irq_set_handler_data(mpc8xxx_gc->irqn, mpc8xxx_gc); + irq_set_chained_handler(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade); + + return 0; +} + +static int mpc8xxx_remove(struct platform_device *pdev) +{ + struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev); + + if (mpc8xxx_gc->irq) { + irq_set_handler_data(mpc8xxx_gc->irqn, NULL); + irq_set_chained_handler(mpc8xxx_gc->irqn, NULL); + irq_domain_remove(mpc8xxx_gc->irq); + } + + of_mm_gpiochip_remove(&mpc8xxx_gc->mm_gc); return 0; } static struct platform_driver mpc8xxx_plat_driver = { .probe = mpc8xxx_probe, + .remove = mpc8xxx_remove, .driver = { .name = "gpio-mpc8xxx", .of_match_table = mpc8xxx_gpio_ids,