From patchwork Wed Dec 17 15:51:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 422298 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 096FB1400B7 for ; Thu, 18 Dec 2014 02:52:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751047AbaLQPvj (ORCPT ); Wed, 17 Dec 2014 10:51:39 -0500 Received: from mail-la0-f42.google.com ([209.85.215.42]:64933 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751327AbaLQPvY (ORCPT ); Wed, 17 Dec 2014 10:51:24 -0500 Received: by mail-la0-f42.google.com with SMTP id gd6so13554868lab.15 for ; Wed, 17 Dec 2014 07:51:22 -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=Rl+8Yn12O6Nuha2qSl9eyFQ1jvTtxZU47dA4DU31DGo=; b=JNG5M/8LmbcdYIA0RsH6rdJQ7NhM0nEySt0iMUpNGKkmTidinkIwN4O2HUpZ47k/zP QD9lWQ0Ib4milMtkUCfY1rqfV2KeEMjEqK2JMS8hzXqusNHj3oDB7RA//R6JPUpn9fXc YTl4RywifHDuFefPrlZ5htXI7eB+4qYB+u7RaVoBtHxfXYFgTUIMWCPvZ9O0ivii+0Cm NOmPUmiNA7nW3mygFlp0yF6Fju6e8Y314E35Udnxw3pEjpyJ5hgIWzAX01KvcFY0XHoL zyragu9PzYoHNz75ghhVcVjvW6K+gFDsjVAy2GM/0yL6KkJL4aeJc9Z2yOXjwLcBwIeE bF7A== X-Received: by 10.152.20.98 with SMTP id m2mr40601066lae.49.1418831482392; Wed, 17 Dec 2014 07:51:22 -0800 (PST) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by mx.google.com with ESMTPSA id n4sm1031577lan.39.2014.12.17.07.51.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Dec 2014 07:51:21 -0800 (PST) From: Ricardo Ribalda Delgado To: Linus Walleij , Alexandre Courbot , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v5 6/7] gpio/gpiolib-of: Create of_mm_gpiochip_remove Date: Wed, 17 Dec 2014 16:51:13 +0100 Message-Id: <1418831474-24428-7-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418831474-24428-1-git-send-email-ricardo.ribalda@gmail.com> References: <1418831474-24428-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 Create counterpart of of_mm_gpiochip_add(). This way the modules that can be removable do not duplicate the cleanup code. Suggested-by: Alexandre Courbot Signed-off-by: Ricardo Ribalda Delgado --- drivers/gpio/gpiolib-of.c | 17 +++++++++++++++++ include/linux/of_gpio.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 604dbe6..3e2c6af 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -204,6 +204,23 @@ err0: } EXPORT_SYMBOL(of_mm_gpiochip_add); +/** + * of_mm_gpiochip_remove - Remove memory mapped GPIO chip (bank) + * @mm_gc: pointer to the of_mm_gpio_chip allocated structure + */ +void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc) +{ + struct gpio_chip *gc = &mm_gc->gc; + + if (!mm_gc) + return; + + gpiochip_remove(gc); + iounmap(mm_gc->regs); + kfree(gc->label); +} +EXPORT_SYMBOL(of_mm_gpiochip_remove); + #ifdef CONFIG_PINCTRL static void of_gpiochip_add_pin_range(struct gpio_chip *chip) { diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 38fc050..69dbe31 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -52,6 +52,7 @@ extern int of_get_named_gpio_flags(struct device_node *np, extern int of_mm_gpiochip_add(struct device_node *np, struct of_mm_gpio_chip *mm_gc); +extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); extern void of_gpiochip_add(struct gpio_chip *gc); extern void of_gpiochip_remove(struct gpio_chip *gc);