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 of_device_get_match_data().
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
drivers/gpio/gpio-zynq.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 97780c57ab56..d69773318888 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -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");
+ gpio->p_data = device_get_match_data(&pdev->dev);
+ if (!gpio->p_data) {
+ dev_err(&pdev->dev, "of_device_get_match_data() failed\n");
return -EINVAL;
}
- gpio->p_data = match->data;
platform_set_drvdata(pdev, gpio);
gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);
--
2.51.0
On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> wrote: > > 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 of_device_get_match_data(). > > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> > --- I think there are some copy-paste leftovers in your commit messages. You're saying you're using of_ functions but you're really going for the device_ ones. Also update error messages. And possibly use dev_err_probe() too while at it? Same elsewhere. Bart
On 19/12/2025 11:15, Bartosz Golaszewski wrote: > On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski > <krzysztof.kozlowski@oss.qualcomm.com> wrote: >> >> 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 of_device_get_match_data(). >> >> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> >> --- > > I think there are some copy-paste leftovers in your commit messages. I just did not update the commit msg. > You're saying you're using of_ functions but you're really going for > the device_ ones. Also update error messages. And possibly use > dev_err_probe() too while at it? Sure > > Same elsewhere. > > Bart Best regards, Krzysztof
On 12/19/25 11:11, Krzysztof Kozlowski wrote:
> 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 of_device_get_match_data().
device_get_match_data() right?
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> ---
> drivers/gpio/gpio-zynq.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 97780c57ab56..d69773318888 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -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");
> + gpio->p_data = device_get_match_data(&pdev->dev);
> + if (!gpio->p_data) {
> + dev_err(&pdev->dev, "of_device_get_match_data() failed\n");
device_get_match_data() ?
> return -EINVAL;
> }
> - gpio->p_data = match->data;
> platform_set_drvdata(pdev, gpio);
>
> gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);
>
M
© 2016 - 2025 Red Hat, Inc.