* [PATCH 0/4] gpio: kill dev-sync-probe
@ 2026-03-27 10:31 Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 1/4] gpio: sim: stop using dev-sync-probe Bartosz Golaszewski
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-03-27 10:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
I came up with this elaborate mechanism to synchronously wait for the
platform devices activated over configs to probe, involving notifiers
and completions (which was later factored out into what is today the
dev-sync-probe module) because I didn't know any better. It turns out
there's an idiomatic way of achieving the same goal with much less LOC.
Port the three drivers to using a combination of wait_for_probe() and
device_is_bound() and remove the dev-sync-probe module.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Bartosz Golaszewski (4):
gpio: sim: stop using dev-sync-probe
gpio: aggregator: stop using dev-sync-probe
gpio: virtuser: stop using dev-sync-probe
gpio: remove dev-sync-probe
drivers/gpio/Kconfig | 6 ---
drivers/gpio/Makefile | 3 --
drivers/gpio/dev-sync-probe.c | 97 ------------------------------------------
drivers/gpio/dev-sync-probe.h | 25 -----------
drivers/gpio/gpio-aggregator.c | 38 +++++++++--------
drivers/gpio/gpio-sim.c | 49 ++++++++++++---------
drivers/gpio/gpio-virtuser.c | 30 ++++++++-----
7 files changed, 70 insertions(+), 178 deletions(-)
---
base-commit: e77a5a5cfe43b4c25bd44a3818e487033287517f
change-id: 20260327-gpio-kill-dev-sync-probe-4027fab0c0a6
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/4] gpio: sim: stop using dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
@ 2026-03-27 10:31 ` Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 2/4] gpio: aggregator: " Bartosz Golaszewski
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-03-27 10:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/Kconfig | 1 -
drivers/gpio/gpio-sim.c | 49 +++++++++++++++++++++++++++++--------------------
2 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 4c3f6ec336c16129301613aadc8b22587b217005..a603406cb2e53a89e1da6214a3c1c256d5246be7 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -2036,7 +2036,6 @@ config GPIO_SIM
tristate "GPIO Simulator Module"
select IRQ_SIM
select CONFIGFS_FS
- select DEV_SYNC_PROBE
help
This enables the GPIO simulator - a configfs-based GPIO testing
driver.
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index f32674230237eb08bbf8dd1337a79b5d0aa13259..e19701c2ed673f8ec5a2475e632388197a78339c 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -36,8 +36,6 @@
#include <linux/sysfs.h>
#include <linux/types.h>
-#include "dev-sync-probe.h"
-
#define GPIO_SIM_NGPIO_MAX 1024
#define GPIO_SIM_PROP_MAX 5 /* Max 4 properties + sentinel. */
#define GPIO_SIM_HOG_PROP_MAX 5
@@ -546,7 +544,7 @@ static struct platform_driver gpio_sim_driver = {
};
struct gpio_sim_device {
- struct dev_sync_probe_data probe_data;
+ struct platform_device *pdev;
struct config_group group;
int id;
@@ -673,7 +671,7 @@ static bool gpio_sim_device_is_live(struct gpio_sim_device *dev)
{
lockdep_assert_held(&dev->lock);
- return !!dev->probe_data.pdev;
+ return !!dev->pdev;
}
static char *gpio_sim_strdup_trimmed(const char *str, size_t count)
@@ -695,7 +693,7 @@ static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item,
guard(mutex)(&dev->lock);
- pdev = dev->probe_data.pdev;
+ pdev = dev->pdev;
if (pdev)
return sprintf(page, "%s\n", dev_name(&pdev->dev));
@@ -900,6 +898,7 @@ static bool gpio_sim_bank_labels_non_unique(struct gpio_sim_device *dev)
static int gpio_sim_device_activate(struct gpio_sim_device *dev)
{
struct platform_device_info pdevinfo;
+ struct platform_device *pdev;
struct fwnode_handle *swnode;
struct gpio_sim_bank *bank;
int ret;
@@ -927,28 +926,39 @@ static int gpio_sim_device_activate(struct gpio_sim_device *dev)
bank->swnode = gpio_sim_make_bank_swnode(bank, swnode);
if (IS_ERR(bank->swnode)) {
ret = PTR_ERR(bank->swnode);
- gpio_sim_remove_swnode_recursive(swnode);
- return ret;
+ goto err_remove_swnode;
}
ret = gpio_sim_bank_add_hogs(bank);
- if (ret) {
- gpio_sim_remove_swnode_recursive(swnode);
- return ret;
- }
+ if (ret)
+ goto err_remove_swnode;
}
pdevinfo.name = "gpio-sim";
pdevinfo.fwnode = swnode;
pdevinfo.id = dev->id;
- ret = dev_sync_probe_register(&dev->probe_data, &pdevinfo);
- if (ret) {
- gpio_sim_remove_swnode_recursive(swnode);
- return ret;
+ pdev = platform_device_register_full(&pdevinfo);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
+ goto err_remove_swnode;
+ }
+
+ wait_for_device_probe();
+ if (!device_is_bound(&pdev->dev)) {
+ ret = -ENXIO;
+ goto err_unregister_pdev;
}
+ dev->pdev = pdev;
return 0;
+
+err_unregister_pdev:
+ platform_device_unregister(pdev);
+err_remove_swnode:
+ gpio_sim_remove_swnode_recursive(swnode);
+
+ return ret;
}
static void gpio_sim_device_deactivate(struct gpio_sim_device *dev)
@@ -957,8 +967,9 @@ static void gpio_sim_device_deactivate(struct gpio_sim_device *dev)
lockdep_assert_held(&dev->lock);
- swnode = dev_fwnode(&dev->probe_data.pdev->dev);
- dev_sync_probe_unregister(&dev->probe_data);
+ swnode = dev_fwnode(&dev->pdev->dev);
+ platform_device_unregister(dev->pdev);
+ dev->pdev = NULL;
gpio_sim_remove_swnode_recursive(swnode);
}
@@ -1060,7 +1071,7 @@ static ssize_t gpio_sim_bank_config_chip_name_show(struct config_item *item,
guard(mutex)(&dev->lock);
if (gpio_sim_device_is_live(dev))
- return device_for_each_child(&dev->probe_data.pdev->dev, &ctx,
+ return device_for_each_child(&dev->pdev->dev, &ctx,
gpio_sim_emit_chip_name);
return sprintf(page, "none\n");
@@ -1571,8 +1582,6 @@ gpio_sim_config_make_device_group(struct config_group *group, const char *name)
mutex_init(&dev->lock);
INIT_LIST_HEAD(&dev->bank_list);
- dev_sync_probe_init(&dev->probe_data);
-
return &no_free_ptr(dev)->group;
}
--
2.47.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/4] gpio: aggregator: stop using dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 1/4] gpio: sim: stop using dev-sync-probe Bartosz Golaszewski
@ 2026-03-27 10:31 ` Bartosz Golaszewski
2026-04-02 12:45 ` Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 3/4] gpio: virtuser: " Bartosz Golaszewski
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-03-27 10:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/Kconfig | 1 -
drivers/gpio/gpio-aggregator.c | 38 +++++++++++++++++++++-----------------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index a603406cb2e53a89e1da6214a3c1c256d5246be7..09db777938f3723e5dbd895dd1b30d39a21a2da1 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1984,7 +1984,6 @@ menu "Virtual GPIO drivers"
config GPIO_AGGREGATOR
tristate "GPIO Aggregator"
select CONFIGFS_FS
- select DEV_SYNC_PROBE
help
Say yes here to enable the GPIO Aggregator, which provides a way to
aggregate existing GPIO lines into a new virtual GPIO chip.
diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 9adf3228c12a84e098ab7ffd543fcad58951ba99..5915209e1e2168b0932de4d16aff38074b889c2b 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -32,8 +32,6 @@
#include <linux/gpio/forwarder.h>
#include <linux/gpio/machine.h>
-#include "dev-sync-probe.h"
-
#define AGGREGATOR_MAX_GPIOS 512
#define AGGREGATOR_LEGACY_PREFIX "_sysfs"
@@ -42,7 +40,7 @@
*/
struct gpio_aggregator {
- struct dev_sync_probe_data probe_data;
+ struct platform_device *pdev;
struct config_group group;
struct gpiod_lookup_table *lookups;
struct mutex lock;
@@ -135,7 +133,7 @@ static bool gpio_aggregator_is_active(struct gpio_aggregator *aggr)
{
lockdep_assert_held(&aggr->lock);
- return aggr->probe_data.pdev && platform_get_drvdata(aggr->probe_data.pdev);
+ return aggr->pdev && platform_get_drvdata(aggr->pdev);
}
/* Only aggregators created via legacy sysfs can be "activating". */
@@ -143,7 +141,7 @@ static bool gpio_aggregator_is_activating(struct gpio_aggregator *aggr)
{
lockdep_assert_held(&aggr->lock);
- return aggr->probe_data.pdev && !platform_get_drvdata(aggr->probe_data.pdev);
+ return aggr->pdev && !platform_get_drvdata(aggr->pdev);
}
static size_t gpio_aggregator_count_lines(struct gpio_aggregator *aggr)
@@ -909,6 +907,7 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
{
struct platform_device_info pdevinfo;
struct gpio_aggregator_line *line;
+ struct platform_device *pdev;
struct fwnode_handle *swnode;
unsigned int n = 0;
int ret = 0;
@@ -962,12 +961,23 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
gpiod_add_lookup_table(aggr->lookups);
- ret = dev_sync_probe_register(&aggr->probe_data, &pdevinfo);
- if (ret)
+ pdev = platform_device_register_full(&pdevinfo);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
goto err_remove_lookup_table;
+ }
+ wait_for_device_probe();
+ if (!device_is_bound(&pdev->dev)) {
+ ret = -ENXIO;
+ goto err_unregister_pdev;
+ }
+
+ aggr->pdev = pdev;
return 0;
+err_unregister_pdev:
+ platform_device_unregister(pdev);
err_remove_lookup_table:
kfree(aggr->lookups->dev_id);
gpiod_remove_lookup_table(aggr->lookups);
@@ -981,7 +991,8 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
static void gpio_aggregator_deactivate(struct gpio_aggregator *aggr)
{
- dev_sync_probe_unregister(&aggr->probe_data);
+ platform_device_unregister(aggr->pdev);
+ aggr->pdev = NULL;
gpiod_remove_lookup_table(aggr->lookups);
kfree(aggr->lookups->dev_id);
kfree(aggr->lookups);
@@ -1145,7 +1156,7 @@ gpio_aggregator_device_dev_name_show(struct config_item *item, char *page)
guard(mutex)(&aggr->lock);
- pdev = aggr->probe_data.pdev;
+ pdev = aggr->pdev;
if (pdev)
return sysfs_emit(page, "%s\n", dev_name(&pdev->dev));
@@ -1322,7 +1333,6 @@ gpio_aggregator_make_group(struct config_group *group, const char *name)
return ERR_PTR(ret);
config_group_init_type_name(&aggr->group, name, &gpio_aggregator_device_type);
- dev_sync_probe_init(&aggr->probe_data);
return &aggr->group;
}
@@ -1471,12 +1481,6 @@ static ssize_t gpio_aggregator_new_device_store(struct device_driver *driver,
scnprintf(name, sizeof(name), "%s.%d", AGGREGATOR_LEGACY_PREFIX, aggr->id);
config_group_init_type_name(&aggr->group, name, &gpio_aggregator_device_type);
- /*
- * Since the device created by sysfs might be toggled via configfs
- * 'live' attribute later, this initialization is needed.
- */
- dev_sync_probe_init(&aggr->probe_data);
-
/* Expose to configfs */
res = configfs_register_group(&gpio_aggregator_subsys.su_group,
&aggr->group);
@@ -1495,7 +1499,7 @@ static ssize_t gpio_aggregator_new_device_store(struct device_driver *driver,
goto remove_table;
}
- aggr->probe_data.pdev = pdev;
+ aggr->pdev = pdev;
module_put(THIS_MODULE);
return count;
--
2.47.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] gpio: virtuser: stop using dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 1/4] gpio: sim: stop using dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 2/4] gpio: aggregator: " Bartosz Golaszewski
@ 2026-03-27 10:31 ` Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 4/4] gpio: remove dev-sync-probe Bartosz Golaszewski
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-03-27 10:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/Kconfig | 1 -
drivers/gpio/gpio-virtuser.c | 30 ++++++++++++++++++++----------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 09db777938f3723e5dbd895dd1b30d39a21a2da1..56a7ddaa95eac07ee4f7b755335595805a316319 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -2072,7 +2072,6 @@ config GPIO_VIRTUSER
select DEBUG_FS
select CONFIGFS_FS
select IRQ_WORK
- select DEV_SYNC_PROBE
help
Say Y here to enable the configurable, configfs-based virtual GPIO
consumer testing driver.
diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c
index 955b5efc283ef565f8c1cfcaccd6d653f2f78f19..fe0eac920ced323926b2bc83ca0a2eb5f85c2154 100644
--- a/drivers/gpio/gpio-virtuser.c
+++ b/drivers/gpio/gpio-virtuser.c
@@ -36,8 +36,6 @@
#include <linux/string_helpers.h>
#include <linux/types.h>
-#include "dev-sync-probe.h"
-
#define GPIO_VIRTUSER_NAME_BUF_LEN 32
static DEFINE_IDA(gpio_virtuser_ida);
@@ -978,7 +976,7 @@ static struct platform_driver gpio_virtuser_driver = {
};
struct gpio_virtuser_device {
- struct dev_sync_probe_data probe_data;
+ struct platform_device *pdev;
struct config_group group;
int id;
@@ -1002,7 +1000,7 @@ gpio_virtuser_device_is_live(struct gpio_virtuser_device *dev)
{
lockdep_assert_held(&dev->lock);
- return !!dev->probe_data.pdev;
+ return !!dev->pdev;
}
struct gpio_virtuser_lookup {
@@ -1342,7 +1340,7 @@ gpio_virtuser_device_config_dev_name_show(struct config_item *item,
guard(mutex)(&dev->lock);
- pdev = dev->probe_data.pdev;
+ pdev = dev->pdev;
if (pdev)
return sprintf(page, "%s\n", dev_name(&pdev->dev));
@@ -1450,6 +1448,7 @@ static int
gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
{
struct platform_device_info pdevinfo;
+ struct platform_device *pdev;
struct fwnode_handle *swnode;
int ret;
@@ -1471,12 +1470,23 @@ gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
if (ret)
goto err_remove_swnode;
- ret = dev_sync_probe_register(&dev->probe_data, &pdevinfo);
- if (ret)
+ pdev = platform_device_register_full(&pdevinfo);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
goto err_remove_lookup_table;
+ }
+
+ wait_for_device_probe();
+ if (!device_is_bound(&pdev->dev)) {
+ ret = -ENXIO;
+ goto err_unregister_pdev;
+ }
+ dev->pdev = pdev;
return 0;
+err_unregister_pdev:
+ platform_device_unregister(pdev);
err_remove_lookup_table:
gpio_virtuser_remove_lookup_table(dev);
err_remove_swnode:
@@ -1492,8 +1502,9 @@ gpio_virtuser_device_deactivate(struct gpio_virtuser_device *dev)
lockdep_assert_held(&dev->lock);
- swnode = dev_fwnode(&dev->probe_data.pdev->dev);
- dev_sync_probe_unregister(&dev->probe_data);
+ swnode = dev_fwnode(&dev->pdev->dev);
+ platform_device_unregister(dev->pdev);
+ dev->pdev = NULL;
gpio_virtuser_remove_lookup_table(dev);
fwnode_remove_software_node(swnode);
}
@@ -1723,7 +1734,6 @@ gpio_virtuser_config_make_device_group(struct config_group *group,
&gpio_virtuser_device_config_group_type);
mutex_init(&dev->lock);
INIT_LIST_HEAD(&dev->lookup_list);
- dev_sync_probe_init(&dev->probe_data);
return &no_free_ptr(dev)->group;
}
--
2.47.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] gpio: remove dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
` (2 preceding siblings ...)
2026-03-27 10:31 ` [PATCH 3/4] gpio: virtuser: " Bartosz Golaszewski
@ 2026-03-27 10:31 ` Bartosz Golaszewski
2026-03-27 13:03 ` [PATCH 0/4] gpio: kill dev-sync-probe Linus Walleij
2026-04-07 10:44 ` Bartosz Golaszewski
5 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-03-27 10:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
There are no more users. Remove the dev-sync-probe module.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/Kconfig | 3 --
drivers/gpio/Makefile | 3 --
drivers/gpio/dev-sync-probe.c | 97 -------------------------------------------
drivers/gpio/dev-sync-probe.h | 25 -----------
4 files changed, 128 deletions(-)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 56a7ddaa95eac07ee4f7b755335595805a316319..257123b3568688ad86a742043af2c6e098a56c3c 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -2082,6 +2082,3 @@ config GPIO_VIRTUSER
endmenu
endif
-
-config DEV_SYNC_PROBE
- tristate
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 20d4a57afdaa6db0d01cd7e107a2e22004641ecb..199b9559a1892c4fce058cb95907de0be5d85780 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -21,9 +21,6 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
# directly supported by gpio-generic
gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o
-# Utilities for drivers that need synchronous fake device creation
-obj-$(CONFIG_DEV_SYNC_PROBE) += dev-sync-probe.o
-
obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o
obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o
obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o
diff --git a/drivers/gpio/dev-sync-probe.c b/drivers/gpio/dev-sync-probe.c
deleted file mode 100644
index 9ea733b863b2232a16ef9ccc411f180b43bad26e..0000000000000000000000000000000000000000
--- a/drivers/gpio/dev-sync-probe.c
+++ /dev/null
@@ -1,97 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Common code for drivers creating fake platform devices.
- *
- * Provides synchronous device creation: waits for probe completion and
- * returns the probe success or error status to the device creator.
- *
- * Copyright (C) 2021 Bartosz Golaszewski <brgl@bgdev.pl>
- * Copyright (C) 2025 Koichiro Den <koichiro.den@canonical.com>
- */
-
-#include <linux/device.h>
-#include <linux/slab.h>
-
-#include "dev-sync-probe.h"
-
-static int dev_sync_probe_notifier_call(struct notifier_block *nb,
- unsigned long action, void *data)
-{
- struct dev_sync_probe_data *pdata;
- struct device *dev = data;
-
- pdata = container_of(nb, struct dev_sync_probe_data, bus_notifier);
- if (!device_match_name(dev, pdata->name))
- return NOTIFY_DONE;
-
- switch (action) {
- case BUS_NOTIFY_BOUND_DRIVER:
- pdata->driver_bound = true;
- break;
- case BUS_NOTIFY_DRIVER_NOT_BOUND:
- pdata->driver_bound = false;
- break;
- default:
- return NOTIFY_DONE;
- }
-
- complete(&pdata->probe_completion);
- return NOTIFY_OK;
-}
-
-void dev_sync_probe_init(struct dev_sync_probe_data *data)
-{
- memset(data, 0, sizeof(*data));
- init_completion(&data->probe_completion);
- data->bus_notifier.notifier_call = dev_sync_probe_notifier_call;
-}
-EXPORT_SYMBOL_GPL(dev_sync_probe_init);
-
-int dev_sync_probe_register(struct dev_sync_probe_data *data,
- struct platform_device_info *pdevinfo)
-{
- struct platform_device *pdev;
- char *name;
-
- name = kasprintf(GFP_KERNEL, "%s.%d", pdevinfo->name, pdevinfo->id);
- if (!name)
- return -ENOMEM;
-
- data->driver_bound = false;
- data->name = name;
- reinit_completion(&data->probe_completion);
- bus_register_notifier(&platform_bus_type, &data->bus_notifier);
-
- pdev = platform_device_register_full(pdevinfo);
- if (IS_ERR(pdev)) {
- bus_unregister_notifier(&platform_bus_type, &data->bus_notifier);
- kfree(data->name);
- return PTR_ERR(pdev);
- }
-
- wait_for_completion(&data->probe_completion);
- bus_unregister_notifier(&platform_bus_type, &data->bus_notifier);
-
- if (!data->driver_bound) {
- platform_device_unregister(pdev);
- kfree(data->name);
- return -ENXIO;
- }
-
- data->pdev = pdev;
- return 0;
-}
-EXPORT_SYMBOL_GPL(dev_sync_probe_register);
-
-void dev_sync_probe_unregister(struct dev_sync_probe_data *data)
-{
- platform_device_unregister(data->pdev);
- kfree(data->name);
- data->pdev = NULL;
-}
-EXPORT_SYMBOL_GPL(dev_sync_probe_unregister);
-
-MODULE_AUTHOR("Bartosz Golaszewski <brgl@bgdev.pl>");
-MODULE_AUTHOR("Koichiro Den <koichiro.den@canonical.com>");
-MODULE_DESCRIPTION("Utilities for synchronous fake device creation");
-MODULE_LICENSE("GPL");
diff --git a/drivers/gpio/dev-sync-probe.h b/drivers/gpio/dev-sync-probe.h
deleted file mode 100644
index 4b3d52b705198dd153618b087ba9d813736a6f29..0000000000000000000000000000000000000000
--- a/drivers/gpio/dev-sync-probe.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-#ifndef DEV_SYNC_PROBE_H
-#define DEV_SYNC_PROBE_H
-
-#include <linux/completion.h>
-#include <linux/notifier.h>
-#include <linux/platform_device.h>
-
-struct dev_sync_probe_data {
- struct platform_device *pdev;
- const char *name;
-
- /* Synchronize with probe */
- struct notifier_block bus_notifier;
- struct completion probe_completion;
- bool driver_bound;
-};
-
-void dev_sync_probe_init(struct dev_sync_probe_data *data);
-int dev_sync_probe_register(struct dev_sync_probe_data *data,
- struct platform_device_info *pdevinfo);
-void dev_sync_probe_unregister(struct dev_sync_probe_data *data);
-
-#endif /* DEV_SYNC_PROBE_H */
--
2.47.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] gpio: kill dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
` (3 preceding siblings ...)
2026-03-27 10:31 ` [PATCH 4/4] gpio: remove dev-sync-probe Bartosz Golaszewski
@ 2026-03-27 13:03 ` Linus Walleij
2026-04-07 10:44 ` Bartosz Golaszewski
5 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2026-03-27 13:03 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Bartosz Golaszewski, Geert Uytterhoeven, Koichiro Den,
linux-gpio, linux-kernel
On Fri, Mar 27, 2026 at 11:31 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> I came up with this elaborate mechanism to synchronously wait for the
> platform devices activated over configs to probe, involving notifiers
> and completions (which was later factored out into what is today the
> dev-sync-probe module) because I didn't know any better. It turns out
> there's an idiomatic way of achieving the same goal with much less LOC.
> Port the three drivers to using a combination of wait_for_probe() and
> device_is_bound() and remove the dev-sync-probe module.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
That looks way better!
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/4] gpio: aggregator: stop using dev-sync-probe
2026-03-27 10:31 ` [PATCH 2/4] gpio: aggregator: " Bartosz Golaszewski
@ 2026-04-02 12:45 ` Bartosz Golaszewski
0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-04-02 12:45 UTC (permalink / raw)
To: Bartosz Golaszewski, Geert Uytterhoeven
Cc: Linus Walleij, Koichiro Den, linux-gpio, linux-kernel
On Fri, Mar 27, 2026 at 11:31 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> 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.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
Hi Geert!
Any objections to this being queued for v7.1?
Bart
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] gpio: kill dev-sync-probe
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
` (4 preceding siblings ...)
2026-03-27 13:03 ` [PATCH 0/4] gpio: kill dev-sync-probe Linus Walleij
@ 2026-04-07 10:44 ` Bartosz Golaszewski
5 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-04-07 10:44 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven,
Koichiro Den, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On Fri, 27 Mar 2026 11:31:10 +0100, Bartosz Golaszewski wrote:
> I came up with this elaborate mechanism to synchronously wait for the
> platform devices activated over configs to probe, involving notifiers
> and completions (which was later factored out into what is today the
> dev-sync-probe module) because I didn't know any better. It turns out
> there's an idiomatic way of achieving the same goal with much less LOC.
> Port the three drivers to using a combination of wait_for_probe() and
> device_is_bound() and remove the dev-sync-probe module.
>
> [...]
Applied, thanks!
[1/4] gpio: sim: stop using dev-sync-probe
https://git.kernel.org/brgl/c/7fb3287946f937a32adad35c9bec4bbc71e25bb8
[2/4] gpio: aggregator: stop using dev-sync-probe
https://git.kernel.org/brgl/c/3a27f40b457053e6112a63d14590e4a3ff553b44
[3/4] gpio: virtuser: stop using dev-sync-probe
https://git.kernel.org/brgl/c/c3e2a8aef28c48a94c0cf0525ca96aa308bcf961
[4/4] gpio: remove dev-sync-probe
https://git.kernel.org/brgl/c/dd84f7ce6fd12fb5d6648d6b5d8ea4bf6f834273
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-07 10:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 1/4] gpio: sim: stop using dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 2/4] gpio: aggregator: " Bartosz Golaszewski
2026-04-02 12:45 ` Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 3/4] gpio: virtuser: " Bartosz Golaszewski
2026-03-27 10:31 ` [PATCH 4/4] gpio: remove dev-sync-probe Bartosz Golaszewski
2026-03-27 13:03 ` [PATCH 0/4] gpio: kill dev-sync-probe Linus Walleij
2026-04-07 10:44 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®