Skip to content

Commit

Permalink
gpio/gpiolib-of: Create of_mm_gpiochip_remove
Browse files Browse the repository at this point in the history
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 <gnurou@gmail.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Ricardo Ribalda Delgado authored and Linus Walleij committed Jan 15, 2015
1 parent 1d6902d commit d621e8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/gpio/gpiolib-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@ int of_mm_gpiochip_add(struct device_node *np,
}
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)
{
Expand Down
1 change: 1 addition & 0 deletions include/linux/of_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d621e8b

Please sign in to comment.