Skip to content

Commit 5d60c1e

Browse files
author
Bartosz Golaszewski
committed
gpio: don't warn about removing GPIO chips with active users anymore
With SRCU we can now correctly handle the situation when a GPIO provider is removed while having users still holding references to GPIO descriptors. Remove all warnings emitted in this situation. Suggested-by: Kent Gibson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Herve Codina <[email protected]>
1 parent 840a97e commit 5d60c1e

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

drivers/gpio/gpiolib.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,6 @@ EXPORT_SYMBOL_GPL(gpiochip_add_data_with_key);
11061106
void gpiochip_remove(struct gpio_chip *gc)
11071107
{
11081108
struct gpio_device *gdev = gc->gpiodev;
1109-
unsigned int i;
11101109

11111110
/* FIXME: should the legacy sysfs handling be moved to gpio_device? */
11121111
gpiochip_sysfs_unregister(gdev);
@@ -1130,15 +1129,6 @@ void gpiochip_remove(struct gpio_chip *gc)
11301129
*/
11311130
gpiochip_set_data(gc, NULL);
11321131

1133-
for (i = 0; i < gdev->ngpio; i++) {
1134-
if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags))
1135-
break;
1136-
}
1137-
1138-
if (i != gdev->ngpio)
1139-
dev_crit(&gdev->dev,
1140-
"REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
1141-
11421132
/*
11431133
* The gpiochip side puts its use of the device to rest here:
11441134
* if there are no userspace clients, the chardev and device will
@@ -2329,10 +2319,9 @@ int gpiod_request(struct gpio_desc *desc, const char *label)
23292319
return ret;
23302320
}
23312321

2332-
static bool gpiod_free_commit(struct gpio_desc *desc)
2322+
static void gpiod_free_commit(struct gpio_desc *desc)
23332323
{
23342324
unsigned long flags;
2335-
bool ret = false;
23362325

23372326
might_sleep();
23382327

@@ -2357,23 +2346,18 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
23572346
#ifdef CONFIG_OF_DYNAMIC
23582347
WRITE_ONCE(desc->hog, NULL);
23592348
#endif
2360-
ret = true;
23612349
desc_set_label(desc, NULL);
23622350
WRITE_ONCE(desc->flags, flags);
23632351

23642352
gpiod_line_state_notify(desc, GPIOLINE_CHANGED_RELEASED);
23652353
}
2366-
2367-
return ret;
23682354
}
23692355

23702356
void gpiod_free(struct gpio_desc *desc)
23712357
{
23722358
VALIDATE_DESC_VOID(desc);
23732359

2374-
if (!gpiod_free_commit(desc))
2375-
WARN_ON(1);
2376-
2360+
gpiod_free_commit(desc);
23772361
module_put(desc->gdev->owner);
23782362
gpio_device_put(desc->gdev);
23792363
}

0 commit comments

Comments
 (0)