Skip to content

Commit f8d05e2

Browse files
author
Bartosz Golaszewski
committed
gpiolib: remove gpiochip_is_requested()
We have no external users of gpiochip_is_requested(). Let's remove it and replace its internal calls with direct testing of the REQUESTED flag. Signed-off-by: Bartosz Golaszewski <[email protected]> Acked-by: Linus Walleij <[email protected]>
1 parent 6fd9c99 commit f8d05e2

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

drivers/gpio/gpiolib.c

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ void gpiochip_remove(struct gpio_chip *gc)
10711071

10721072
spin_lock_irqsave(&gpio_lock, flags);
10731073
for (i = 0; i < gdev->ngpio; i++) {
1074-
if (gpiochip_is_requested(gc, i))
1074+
if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags))
10751075
break;
10761076
}
10771077
spin_unlock_irqrestore(&gpio_lock, flags);
@@ -2359,33 +2359,6 @@ void gpiod_free(struct gpio_desc *desc)
23592359
gpio_device_put(desc->gdev);
23602360
}
23612361

2362-
/**
2363-
* gpiochip_is_requested - return string iff signal was requested
2364-
* @gc: controller managing the signal
2365-
* @offset: of signal within controller's 0..(ngpio - 1) range
2366-
*
2367-
* Returns NULL if the GPIO is not currently requested, else a string.
2368-
* The string returned is the label passed to gpio_request(); if none has been
2369-
* passed it is a meaningless, non-NULL constant.
2370-
*
2371-
* This function is for use by GPIO controller drivers. The label can
2372-
* help with diagnostics, and knowing that the signal is used as a GPIO
2373-
* can help avoid accidentally multiplexing it to another controller.
2374-
*/
2375-
const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset)
2376-
{
2377-
struct gpio_desc *desc;
2378-
2379-
desc = gpiochip_get_desc(gc, offset);
2380-
if (IS_ERR(desc))
2381-
return NULL;
2382-
2383-
if (test_bit(FLAG_REQUESTED, &desc->flags) == 0)
2384-
return NULL;
2385-
return desc->label;
2386-
}
2387-
EXPORT_SYMBOL_GPL(gpiochip_is_requested);
2388-
23892362
/**
23902363
* gpiochip_dup_line_label - Get a copy of the consumer label.
23912364
* @gc: GPIO chip controlling this line.
@@ -2400,18 +2373,23 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested);
24002373
*/
24012374
char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset)
24022375
{
2403-
const char *label;
2404-
char *copy;
2376+
struct gpio_desc *desc;
2377+
char *label;
24052378

2406-
label = gpiochip_is_requested(gc, offset);
2407-
if (!label)
2379+
desc = gpiochip_get_desc(gc, offset);
2380+
if (IS_ERR(desc))
24082381
return NULL;
24092382

2410-
copy = kstrdup(label, GFP_KERNEL);
2411-
if (!copy)
2383+
guard(spinlock_irqsave)(&gpio_lock);
2384+
2385+
if (!test_bit(FLAG_REQUESTED, &desc->flags))
2386+
return NULL;
2387+
2388+
label = kstrdup(desc->label, GFP_KERNEL);
2389+
if (!label)
24122390
return ERR_PTR(-ENOMEM);
24132391

2414-
return copy;
2392+
return label;
24152393
}
24162394
EXPORT_SYMBOL_GPL(gpiochip_dup_line_label);
24172395

include/linux/gpio/driver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ struct gpio_chip {
531531
#endif /* CONFIG_OF_GPIO */
532532
};
533533

534-
const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset);
535534
char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset);
536535

537536

0 commit comments

Comments
 (0)