From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Koichiro Den <koichiro.den@canonical.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH 1/4] gpio: sim: stop using dev-sync-probe
Date: Fri, 27 Mar 2026 11:31:11 +0100 [thread overview]
Message-ID: <20260327-gpio-kill-dev-sync-probe-v1-1-efac254f1a1d@oss.qualcomm.com> (raw)
In-Reply-To: <20260327-gpio-kill-dev-sync-probe-v1-0-efac254f1a1d@oss.qualcomm.com>
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
next prev parent reply other threads:[~2026-03-27 10:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 10:31 [PATCH 0/4] gpio: kill dev-sync-probe Bartosz Golaszewski
2026-03-27 10:31 ` Bartosz Golaszewski [this message]
2026-03-27 10:31 ` [PATCH 2/4] gpio: aggregator: stop using dev-sync-probe 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260327-gpio-kill-dev-sync-probe-v1-1-efac254f1a1d@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=geert+renesas@glider.be \
--cc=koichiro.den@canonical.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).