mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
gpio: sim: 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-1-efac254f1a1d@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
15cbd66b69
commit
7fb3287946
|
|
@ -2062,7 +2062,6 @@ config GPIO_SIM
|
||||||
tristate "GPIO Simulator Module"
|
tristate "GPIO Simulator Module"
|
||||||
select IRQ_SIM
|
select IRQ_SIM
|
||||||
select CONFIGFS_FS
|
select CONFIGFS_FS
|
||||||
select DEV_SYNC_PROBE
|
|
||||||
help
|
help
|
||||||
This enables the GPIO simulator - a configfs-based GPIO testing
|
This enables the GPIO simulator - a configfs-based GPIO testing
|
||||||
driver.
|
driver.
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
#include <linux/sysfs.h>
|
#include <linux/sysfs.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
#include "dev-sync-probe.h"
|
|
||||||
|
|
||||||
#define GPIO_SIM_NGPIO_MAX 1024
|
#define GPIO_SIM_NGPIO_MAX 1024
|
||||||
#define GPIO_SIM_PROP_MAX 5 /* Max 4 properties + sentinel. */
|
#define GPIO_SIM_PROP_MAX 5 /* Max 4 properties + sentinel. */
|
||||||
#define GPIO_SIM_HOG_PROP_MAX 5
|
#define GPIO_SIM_HOG_PROP_MAX 5
|
||||||
|
|
@ -546,7 +544,7 @@ static struct platform_driver gpio_sim_driver = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gpio_sim_device {
|
struct gpio_sim_device {
|
||||||
struct dev_sync_probe_data probe_data;
|
struct platform_device *pdev;
|
||||||
struct config_group group;
|
struct config_group group;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
|
@ -673,7 +671,7 @@ static bool gpio_sim_device_is_live(struct gpio_sim_device *dev)
|
||||||
{
|
{
|
||||||
lockdep_assert_held(&dev->lock);
|
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)
|
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);
|
guard(mutex)(&dev->lock);
|
||||||
|
|
||||||
pdev = dev->probe_data.pdev;
|
pdev = dev->pdev;
|
||||||
if (pdev)
|
if (pdev)
|
||||||
return sprintf(page, "%s\n", dev_name(&pdev->dev));
|
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)
|
static int gpio_sim_device_activate(struct gpio_sim_device *dev)
|
||||||
{
|
{
|
||||||
struct platform_device_info pdevinfo;
|
struct platform_device_info pdevinfo;
|
||||||
|
struct platform_device *pdev;
|
||||||
struct fwnode_handle *swnode;
|
struct fwnode_handle *swnode;
|
||||||
struct gpio_sim_bank *bank;
|
struct gpio_sim_bank *bank;
|
||||||
int ret;
|
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);
|
bank->swnode = gpio_sim_make_bank_swnode(bank, swnode);
|
||||||
if (IS_ERR(bank->swnode)) {
|
if (IS_ERR(bank->swnode)) {
|
||||||
ret = PTR_ERR(bank->swnode);
|
ret = PTR_ERR(bank->swnode);
|
||||||
gpio_sim_remove_swnode_recursive(swnode);
|
goto err_remove_swnode;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_sim_bank_add_hogs(bank);
|
ret = gpio_sim_bank_add_hogs(bank);
|
||||||
if (ret) {
|
if (ret)
|
||||||
gpio_sim_remove_swnode_recursive(swnode);
|
goto err_remove_swnode;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pdevinfo.name = "gpio-sim";
|
pdevinfo.name = "gpio-sim";
|
||||||
pdevinfo.fwnode = swnode;
|
pdevinfo.fwnode = swnode;
|
||||||
pdevinfo.id = dev->id;
|
pdevinfo.id = dev->id;
|
||||||
|
|
||||||
ret = dev_sync_probe_register(&dev->probe_data, &pdevinfo);
|
pdev = platform_device_register_full(&pdevinfo);
|
||||||
if (ret) {
|
if (IS_ERR(pdev)) {
|
||||||
gpio_sim_remove_swnode_recursive(swnode);
|
ret = PTR_ERR(pdev);
|
||||||
return ret;
|
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;
|
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)
|
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);
|
lockdep_assert_held(&dev->lock);
|
||||||
|
|
||||||
swnode = dev_fwnode(&dev->probe_data.pdev->dev);
|
swnode = dev_fwnode(&dev->pdev->dev);
|
||||||
dev_sync_probe_unregister(&dev->probe_data);
|
platform_device_unregister(dev->pdev);
|
||||||
|
dev->pdev = NULL;
|
||||||
gpio_sim_remove_swnode_recursive(swnode);
|
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);
|
guard(mutex)(&dev->lock);
|
||||||
|
|
||||||
if (gpio_sim_device_is_live(dev))
|
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);
|
gpio_sim_emit_chip_name);
|
||||||
|
|
||||||
return sprintf(page, "none\n");
|
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);
|
mutex_init(&dev->lock);
|
||||||
INIT_LIST_HEAD(&dev->bank_list);
|
INIT_LIST_HEAD(&dev->bank_list);
|
||||||
|
|
||||||
dev_sync_probe_init(&dev->probe_data);
|
|
||||||
|
|
||||||
return &no_free_ptr(dev)->group;
|
return &no_free_ptr(dev)->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user