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>
This commit is contained in:
Krzysztof Kozlowski
2025-12-19 13:13:14 +01:00
committed by Bartosz Golaszewski
parent da7c18a457
commit 48befae0d6

View 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);