gpiolib: switch to simpler IDA interface
PATCH 1/1 gpiolib: switch to simpler IDA interface
From: Bartosz Golaszewski <[email protected]>
We don't need to specify any ranges when allocating IDs so we can switch to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.
ida_simple_get(ida, 0, 0, gfp) is equivalent to ida_alloc_range(ida, 0, UINT_MAX, gfp) which is equivalent to ida_alloc(ida, gfp). Note: IDR will never actually allocate an ID larger than INT_MAX.
--- drivers/gpio/gpiolib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +3 -3
@@ -426,7 +426,7 @@ static void gpiodevice_release(struct device *dev)struct gpio_device *gdev =dev_get_drvdata (dev);list_del (&gdev->list); -ida_simple_remove (&gpio_ida, gdev->id); +ida_free (&gpio_ida, gdev->id);kfree_const (gdev->label);kfree (gdev->descs);kfree (gdev);
@@ -537,7 +537,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gc->of_node = gdev->dev.of_node;#endif - gdev->id =ida_simple_get (&gpio_ida,0 ,0 ,GFP_KERNEL ); + gdev->id =ida_alloc (&gpio_ida,GFP_KERNEL );if (gdev->id <0 ) { ret = gdev->id; goto err_free_gdev;
@@ -705,7 +705,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, err_free_descs:kfree (gdev->descs); err_free_ida: -ida_simple_remove (&gpio_ida, gdev->id); +ida_free (&gpio_ida, gdev->id); err_free_gdev:/* failures here can mean systems won't boot... */ pr_err("%s: GPIOs %d..%d (%s) failed to register, %d\n", __func__,
Signature · 1 line
2.26.1
Quoted 9 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
We don't need to specify any ranges when allocating IDs so we can switch to
ida_alloc()andida_free()instead of theida_simple_counterparts.
ida_simple_get(ida, 0, 0, gfp)is equivalent toida_alloc_range(ida, 0, UINT_MAX, gfp)which is equivalent toida_alloc(ida, gfp). Note: IDR will never actually allocate an ID larger thanINT_MAX.
Quoted 39 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpiolib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpio/gpiolib.c +3
-3@@ -426,7 +426,7 @@ static void gpiodevice_release(struct device *dev)struct gpio_device *gdev =dev_get_drvdata (dev);list_del (&gdev->list); -ida_simple_remove (&gpio_ida, gdev->id); +ida_free (&gpio_ida, gdev->id);kfree_const (gdev->label);kfree (gdev->descs);kfree (gdev);@@ -537,7 +537,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gc->of_node = gdev->dev.of_node;#endif - gdev->id =ida_simple_get (&gpio_ida,0 ,0 ,GFP_KERNEL ); + gdev->id =ida_alloc (&gpio_ida,GFP_KERNEL );if (gdev->id <0 ) { ret = gdev->id; goto err_free_gdev;@@ -705,7 +705,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, err_free_descs:kfree (gdev->descs); err_free_ida: -ida_simple_remove (&gpio_ida, gdev->id); +ida_free (&gpio_ida, gdev->id); err_free_gdev:/* failures here can mean systems won't boot... */ pr_err("%s: GPIOs %d..%d (%s) failed to register, %d\n", __func__,Signature · 1 line
2.26.1
Signature · 2 lines
With Best Regards, Andy Shevchenko