mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
gpio: virtuser: 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-3-efac254f1a1d@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
@@ -2098,7 +2098,6 @@ config GPIO_VIRTUSER
|
|||||||
select DEBUG_FS
|
select DEBUG_FS
|
||||||
select CONFIGFS_FS
|
select CONFIGFS_FS
|
||||||
select IRQ_WORK
|
select IRQ_WORK
|
||||||
select DEV_SYNC_PROBE
|
|
||||||
help
|
help
|
||||||
Say Y here to enable the configurable, configfs-based virtual GPIO
|
Say Y here to enable the configurable, configfs-based virtual GPIO
|
||||||
consumer testing driver.
|
consumer testing driver.
|
||||||
|
|||||||
@@ -36,8 +36,6 @@
|
|||||||
#include <linux/string_helpers.h>
|
#include <linux/string_helpers.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
#include "dev-sync-probe.h"
|
|
||||||
|
|
||||||
#define GPIO_VIRTUSER_NAME_BUF_LEN 32
|
#define GPIO_VIRTUSER_NAME_BUF_LEN 32
|
||||||
|
|
||||||
static DEFINE_IDA(gpio_virtuser_ida);
|
static DEFINE_IDA(gpio_virtuser_ida);
|
||||||
@@ -978,7 +976,7 @@ static struct platform_driver gpio_virtuser_driver = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct gpio_virtuser_device {
|
struct gpio_virtuser_device {
|
||||||
struct dev_sync_probe_data probe_data;
|
struct platform_device *pdev;
|
||||||
struct config_group group;
|
struct config_group group;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
@@ -1002,7 +1000,7 @@ gpio_virtuser_device_is_live(struct gpio_virtuser_device *dev)
|
|||||||
{
|
{
|
||||||
lockdep_assert_held(&dev->lock);
|
lockdep_assert_held(&dev->lock);
|
||||||
|
|
||||||
return !!dev->probe_data.pdev;
|
return !!dev->pdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gpio_virtuser_lookup {
|
struct gpio_virtuser_lookup {
|
||||||
@@ -1342,7 +1340,7 @@ gpio_virtuser_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));
|
||||||
|
|
||||||
@@ -1450,6 +1448,7 @@ static int
|
|||||||
gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
|
gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
|
||||||
{
|
{
|
||||||
struct platform_device_info pdevinfo;
|
struct platform_device_info pdevinfo;
|
||||||
|
struct platform_device *pdev;
|
||||||
struct fwnode_handle *swnode;
|
struct fwnode_handle *swnode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -1471,12 +1470,23 @@ gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err_remove_swnode;
|
goto err_remove_swnode;
|
||||||
|
|
||||||
ret = dev_sync_probe_register(&dev->probe_data, &pdevinfo);
|
pdev = platform_device_register_full(&pdevinfo);
|
||||||
if (ret)
|
if (IS_ERR(pdev)) {
|
||||||
|
ret = PTR_ERR(pdev);
|
||||||
goto err_remove_lookup_table;
|
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;
|
return 0;
|
||||||
|
|
||||||
|
err_unregister_pdev:
|
||||||
|
platform_device_unregister(pdev);
|
||||||
err_remove_lookup_table:
|
err_remove_lookup_table:
|
||||||
gpio_virtuser_remove_lookup_table(dev);
|
gpio_virtuser_remove_lookup_table(dev);
|
||||||
err_remove_swnode:
|
err_remove_swnode:
|
||||||
@@ -1492,8 +1502,9 @@ gpio_virtuser_device_deactivate(struct gpio_virtuser_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_virtuser_remove_lookup_table(dev);
|
gpio_virtuser_remove_lookup_table(dev);
|
||||||
fwnode_remove_software_node(swnode);
|
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);
|
&gpio_virtuser_device_config_group_type);
|
||||||
mutex_init(&dev->lock);
|
mutex_init(&dev->lock);
|
||||||
INIT_LIST_HEAD(&dev->lookup_list);
|
INIT_LIST_HEAD(&dev->lookup_list);
|
||||||
dev_sync_probe_init(&dev->probe_data);
|
|
||||||
|
|
||||||
return &no_free_ptr(dev)->group;
|
return &no_free_ptr(dev)->group;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user