Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+29 -21
-1
drivers/gpio/Kconfig
··· 2062 2062 tristate "GPIO Simulator Module" 2063 2063 select IRQ_SIM 2064 2064 select CONFIGFS_FS 2065 - select DEV_SYNC_PROBE 2066 2065 help 2067 2066 This enables the GPIO simulator - a configfs-based GPIO testing 2068 2067 driver.
+29 -20
drivers/gpio/gpio-sim.c
··· 36 36 #include <linux/sysfs.h> 37 37 #include <linux/types.h> 38 38 39 - #include "dev-sync-probe.h" 40 - 41 39 #define GPIO_SIM_NGPIO_MAX 1024 42 40 #define GPIO_SIM_PROP_MAX 5 /* Max 4 properties + sentinel. */ 43 41 #define GPIO_SIM_HOG_PROP_MAX 5 ··· 544 546 }; 545 547 546 548 struct gpio_sim_device { 547 - struct dev_sync_probe_data probe_data; 549 + struct platform_device *pdev; 548 550 struct config_group group; 549 551 550 552 int id; ··· 671 673 { 672 674 lockdep_assert_held(&dev->lock); 673 675 674 - return !!dev->probe_data.pdev; 676 + return !!dev->pdev; 675 677 } 676 678 677 679 static char *gpio_sim_strdup_trimmed(const char *str, size_t count) ··· 693 695 694 696 guard(mutex)(&dev->lock); 695 697 696 - pdev = dev->probe_data.pdev; 698 + pdev = dev->pdev; 697 699 if (pdev) 698 700 return sprintf(page, "%s\n", dev_name(&pdev->dev)); 699 701 ··· 898 900 static int gpio_sim_device_activate(struct gpio_sim_device *dev) 899 901 { 900 902 struct platform_device_info pdevinfo; 903 + struct platform_device *pdev; 901 904 struct fwnode_handle *swnode; 902 905 struct gpio_sim_bank *bank; 903 906 int ret; ··· 926 927 bank->swnode = gpio_sim_make_bank_swnode(bank, swnode); 927 928 if (IS_ERR(bank->swnode)) { 928 929 ret = PTR_ERR(bank->swnode); 929 - gpio_sim_remove_swnode_recursive(swnode); 930 - return ret; 930 + goto err_remove_swnode; 931 931 } 932 932 933 933 ret = gpio_sim_bank_add_hogs(bank); 934 - if (ret) { 935 - gpio_sim_remove_swnode_recursive(swnode); 936 - return ret; 937 - } 934 + if (ret) 935 + goto err_remove_swnode; 938 936 } 939 937 940 938 pdevinfo.name = "gpio-sim"; 941 939 pdevinfo.fwnode = swnode; 942 940 pdevinfo.id = dev->id; 943 941 944 - ret = dev_sync_probe_register(&dev->probe_data, &pdevinfo); 945 - if (ret) { 946 - gpio_sim_remove_swnode_recursive(swnode); 947 - return ret; 942 + pdev = platform_device_register_full(&pdevinfo); 943 + if (IS_ERR(pdev)) { 944 + ret = PTR_ERR(pdev); 945 + goto err_remove_swnode; 948 946 } 949 947 948 + wait_for_device_probe(); 949 + if (!device_is_bound(&pdev->dev)) { 950 + ret = -ENXIO; 951 + goto err_unregister_pdev; 952 + } 953 + 954 + dev->pdev = pdev; 950 955 return 0; 956 + 957 + err_unregister_pdev: 958 + platform_device_unregister(pdev); 959 + err_remove_swnode: 960 + gpio_sim_remove_swnode_recursive(swnode); 961 + 962 + return ret; 951 963 } 952 964 953 965 static void gpio_sim_device_deactivate(struct gpio_sim_device *dev) ··· 967 957 968 958 lockdep_assert_held(&dev->lock); 969 959 970 - swnode = dev_fwnode(&dev->probe_data.pdev->dev); 971 - dev_sync_probe_unregister(&dev->probe_data); 960 + swnode = dev_fwnode(&dev->pdev->dev); 961 + platform_device_unregister(dev->pdev); 962 + dev->pdev = NULL; 972 963 gpio_sim_remove_swnode_recursive(swnode); 973 964 } 974 965 ··· 1071 1060 guard(mutex)(&dev->lock); 1072 1061 1073 1062 if (gpio_sim_device_is_live(dev)) 1074 - return device_for_each_child(&dev->probe_data.pdev->dev, &ctx, 1063 + return device_for_each_child(&dev->pdev->dev, &ctx, 1075 1064 gpio_sim_emit_chip_name); 1076 1065 1077 1066 return sprintf(page, "none\n"); ··· 1581 1570 dev->id = id; 1582 1571 mutex_init(&dev->lock); 1583 1572 INIT_LIST_HEAD(&dev->bank_list); 1584 - 1585 - dev_sync_probe_init(&dev->probe_data); 1586 1573 1587 1574 return &no_free_ptr(dev)->group; 1588 1575 }