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

Configure Feed

Select the types of activity you want to include in your feed.

gpio: zynq: Simplify with device_get_match_data()

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with device_get_match_data().

While changing the error message, switch to dev_err_probe() so error
path is a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251219-gpio-of-match-v3-3-6b84194a02a8@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Krzysztof Kozlowski and committed by
Bartosz Golaszewski
48befae0 da7c18a4

+5 -7
+5 -7
drivers/gpio/gpio-zynq.c
··· 903 903 struct zynq_gpio *gpio; 904 904 struct gpio_chip *chip; 905 905 struct gpio_irq_chip *girq; 906 - const struct of_device_id *match; 907 906 908 907 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 909 908 if (!gpio) 910 909 return -ENOMEM; 911 910 912 - match = of_match_node(zynq_gpio_of_match, pdev->dev.of_node); 913 - if (!match) { 914 - dev_err(&pdev->dev, "of_match_node() failed\n"); 915 - return -EINVAL; 916 - } 917 - gpio->p_data = match->data; 911 + gpio->p_data = device_get_match_data(&pdev->dev); 912 + if (!gpio->p_data) 913 + return dev_err_probe(&pdev->dev, -EINVAL, 914 + "device_get_match_data() failed\n"); 915 + 918 916 platform_set_drvdata(pdev, gpio); 919 917 920 918 gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);