diff options
author | Masahiro Yamada | 2019-07-18 15:51:01 +0900 |
---|---|---|
committer | Linus Walleij | 2019-08-03 00:25:25 +0200 |
commit | 7bdbd1eccc9fb3875f33af1a2257001128824e81 (patch) | |
tree | 939dc5de5c863d10210f193b8b1bbe7c3d90df1a /drivers/gpio/gpiolib.c | |
parent | bd4bd337039df9d5c6a3c11c439511fd99e11f52 (diff) |
gpio: refactor gpiochip_allocate_mask() with bitmap_alloc()
Refactor gpiochip_allocate_mask() slightly by using bitmap_alloc().
I used bitmap_free() for the corresponding free parts. Actually,
bitmap_free() is a wrapper of kfree(), but I did this for consistency.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://lore.kernel.org/r/20190718065101.26994-1-yamada.masahiro@socionext.com
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 20f13129cdaa..537a37a89891 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -351,7 +351,7 @@ static unsigned long *gpiochip_allocate_mask(struct gpio_chip *chip) { unsigned long *p; - p = kmalloc_array(BITS_TO_LONGS(chip->ngpio), sizeof(*p), GFP_KERNEL); + p = bitmap_alloc(chip->ngpio, GFP_KERNEL); if (!p) return NULL; @@ -385,7 +385,7 @@ static int gpiochip_init_valid_mask(struct gpio_chip *gpiochip) static void gpiochip_free_valid_mask(struct gpio_chip *gpiochip) { - kfree(gpiochip->valid_mask); + bitmap_free(gpiochip->valid_mask); gpiochip->valid_mask = NULL; } @@ -1620,7 +1620,7 @@ static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip) static void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gpiochip) { - kfree(gpiochip->irq.valid_mask); + bitmap_free(gpiochip->irq.valid_mask); gpiochip->irq.valid_mask = NULL; } |