Skip to content

Commit 3a27f40

Browse files
author
Bartosz Golaszewski
committed
gpio: aggregator: stop using dev-sync-probe
dev-err-probe is an overengineered solution to a simple problem. Use a combination of wait_for_probe() and device_is_bound() to synchronously wait for the platform device to probe. Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260327-gpio-kill-dev-sync-probe-v1-2-efac254f1a1d@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 7fb3287 commit 3a27f40

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

drivers/gpio/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,6 @@ menu "Virtual GPIO drivers"
20102010
config GPIO_AGGREGATOR
20112011
tristate "GPIO Aggregator"
20122012
select CONFIGFS_FS
2013-
select DEV_SYNC_PROBE
20142013
help
20152014
Say yes here to enable the GPIO Aggregator, which provides a way to
20162015
aggregate existing GPIO lines into a new virtual GPIO chip.

drivers/gpio/gpio-aggregator.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include <linux/gpio/forwarder.h>
3333
#include <linux/gpio/machine.h>
3434

35-
#include "dev-sync-probe.h"
36-
3735
#define AGGREGATOR_MAX_GPIOS 512
3836
#define AGGREGATOR_LEGACY_PREFIX "_sysfs"
3937

@@ -42,7 +40,7 @@
4240
*/
4341

4442
struct gpio_aggregator {
45-
struct dev_sync_probe_data probe_data;
43+
struct platform_device *pdev;
4644
struct config_group group;
4745
struct gpiod_lookup_table *lookups;
4846
struct mutex lock;
@@ -135,15 +133,15 @@ static bool gpio_aggregator_is_active(struct gpio_aggregator *aggr)
135133
{
136134
lockdep_assert_held(&aggr->lock);
137135

138-
return aggr->probe_data.pdev && platform_get_drvdata(aggr->probe_data.pdev);
136+
return aggr->pdev && platform_get_drvdata(aggr->pdev);
139137
}
140138

141139
/* Only aggregators created via legacy sysfs can be "activating". */
142140
static bool gpio_aggregator_is_activating(struct gpio_aggregator *aggr)
143141
{
144142
lockdep_assert_held(&aggr->lock);
145143

146-
return aggr->probe_data.pdev && !platform_get_drvdata(aggr->probe_data.pdev);
144+
return aggr->pdev && !platform_get_drvdata(aggr->pdev);
147145
}
148146

149147
static size_t gpio_aggregator_count_lines(struct gpio_aggregator *aggr)
@@ -909,6 +907,7 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
909907
{
910908
struct platform_device_info pdevinfo;
911909
struct gpio_aggregator_line *line;
910+
struct platform_device *pdev;
912911
struct fwnode_handle *swnode;
913912
unsigned int n = 0;
914913
int ret = 0;
@@ -962,12 +961,23 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
962961

963962
gpiod_add_lookup_table(aggr->lookups);
964963

965-
ret = dev_sync_probe_register(&aggr->probe_data, &pdevinfo);
966-
if (ret)
964+
pdev = platform_device_register_full(&pdevinfo);
965+
if (IS_ERR(pdev)) {
966+
ret = PTR_ERR(pdev);
967967
goto err_remove_lookup_table;
968+
}
968969

970+
wait_for_device_probe();
971+
if (!device_is_bound(&pdev->dev)) {
972+
ret = -ENXIO;
973+
goto err_unregister_pdev;
974+
}
975+
976+
aggr->pdev = pdev;
969977
return 0;
970978

979+
err_unregister_pdev:
980+
platform_device_unregister(pdev);
971981
err_remove_lookup_table:
972982
kfree(aggr->lookups->dev_id);
973983
gpiod_remove_lookup_table(aggr->lookups);
@@ -981,7 +991,8 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
981991

982992
static void gpio_aggregator_deactivate(struct gpio_aggregator *aggr)
983993
{
984-
dev_sync_probe_unregister(&aggr->probe_data);
994+
platform_device_unregister(aggr->pdev);
995+
aggr->pdev = NULL;
985996
gpiod_remove_lookup_table(aggr->lookups);
986997
kfree(aggr->lookups->dev_id);
987998
kfree(aggr->lookups);
@@ -1145,7 +1156,7 @@ gpio_aggregator_device_dev_name_show(struct config_item *item, char *page)
11451156

11461157
guard(mutex)(&aggr->lock);
11471158

1148-
pdev = aggr->probe_data.pdev;
1159+
pdev = aggr->pdev;
11491160
if (pdev)
11501161
return sysfs_emit(page, "%s\n", dev_name(&pdev->dev));
11511162

@@ -1322,7 +1333,6 @@ gpio_aggregator_make_group(struct config_group *group, const char *name)
13221333
return ERR_PTR(ret);
13231334

13241335
config_group_init_type_name(&aggr->group, name, &gpio_aggregator_device_type);
1325-
dev_sync_probe_init(&aggr->probe_data);
13261336

13271337
return &aggr->group;
13281338
}
@@ -1471,12 +1481,6 @@ static ssize_t gpio_aggregator_new_device_store(struct device_driver *driver,
14711481
scnprintf(name, sizeof(name), "%s.%d", AGGREGATOR_LEGACY_PREFIX, aggr->id);
14721482
config_group_init_type_name(&aggr->group, name, &gpio_aggregator_device_type);
14731483

1474-
/*
1475-
* Since the device created by sysfs might be toggled via configfs
1476-
* 'live' attribute later, this initialization is needed.
1477-
*/
1478-
dev_sync_probe_init(&aggr->probe_data);
1479-
14801484
/* Expose to configfs */
14811485
res = configfs_register_group(&gpio_aggregator_subsys.su_group,
14821486
&aggr->group);
@@ -1495,7 +1499,7 @@ static ssize_t gpio_aggregator_new_device_store(struct device_driver *driver,
14951499
goto remove_table;
14961500
}
14971501

1498-
aggr->probe_data.pdev = pdev;
1502+
aggr->pdev = pdev;
14991503
module_put(THIS_MODULE);
15001504
return count;
15011505

0 commit comments

Comments
 (0)