]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: zynq: Simplify with device_get_match_data()
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Fri, 19 Dec 2025 12:13:14 +0000 (13:13 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 22 Dec 2025 16:57:36 +0000 (17:57 +0100)
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>
drivers/gpio/gpio-zynq.c

index 97780c57ab560e6ad3c5e6f826e477ad524e0f9a..571e366624d2af586bc4daa34fbe0e1738418c4f 100644 (file)
@@ -903,18 +903,16 @@ static int zynq_gpio_probe(struct platform_device *pdev)
        struct zynq_gpio *gpio;
        struct gpio_chip *chip;
        struct gpio_irq_chip *girq;
-       const struct of_device_id *match;
 
        gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
        if (!gpio)
                return -ENOMEM;
 
-       match = of_match_node(zynq_gpio_of_match, pdev->dev.of_node);
-       if (!match) {
-               dev_err(&pdev->dev, "of_match_node() failed\n");
-               return -EINVAL;
-       }
-       gpio->p_data = match->data;
+       gpio->p_data = device_get_match_data(&pdev->dev);
+       if (!gpio->p_data)
+               return dev_err_probe(&pdev->dev, -EINVAL,
+                                    "device_get_match_data() failed\n");
+
        platform_set_drvdata(pdev, gpio);
 
        gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);