* [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc()
@ 2019-07-18 6:51 Masahiro Yamada
2019-07-18 15:30 ` Stephen Boyd
2019-08-02 22:26 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-07-18 6:51 UTC (permalink / raw)
To: linux-gpio, Linus Walleij
Cc: Stephen Boyd, Masahiro Yamada, Bartosz Golaszewski, linux-kernel
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>
---
drivers/gpio/gpiolib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3ee99d070608..5ac2daa01a53 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -350,7 +350,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;
@@ -391,7 +391,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;
}
@@ -1626,7 +1626,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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc()
2019-07-18 6:51 [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc() Masahiro Yamada
@ 2019-07-18 15:30 ` Stephen Boyd
2019-08-02 22:26 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2019-07-18 15:30 UTC (permalink / raw)
To: Linus Walleij, Masahiro Yamada, linux-gpio
Cc: Masahiro Yamada, Bartosz Golaszewski, linux-kernel
Quoting Masahiro Yamada (2019-07-17 23:51:01)
> 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>
> ---
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc()
2019-07-18 6:51 [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc() Masahiro Yamada
2019-07-18 15:30 ` Stephen Boyd
@ 2019-08-02 22:26 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2019-08-02 22:26 UTC (permalink / raw)
To: Masahiro Yamada
Cc: open list:GPIO SUBSYSTEM, Stephen Boyd, Bartosz Golaszewski,
linux-kernel
On Thu, Jul 18, 2019 at 8:51 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 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>
Patch applied with Stephen's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-02 22:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18 6:51 [PATCH] gpio: refactor gpiochip_allocate_mask() with bitmap_alloc() Masahiro Yamada
2019-07-18 15:30 ` Stephen Boyd
2019-08-02 22:26 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).