* [PATCH] gpio: Use device_get_match_data()
@ 2023-10-06 22:45 Rob Herring
2023-10-09 7:08 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2023-10-06 22:45 UTC (permalink / raw)
To: Keerthy, Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
Thierry Reding, Uwe Kleine-König
Cc: linux-gpio, linux-kernel, linux-pwm
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/gpio/gpio-davinci.c | 9 +++------
drivers/gpio/gpio-mmio.c | 4 ++--
drivers/gpio/gpio-mvebu.c | 10 +++-------
3 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 8db5717bdabe..bb499e362912 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -16,10 +16,10 @@
#include <linux/irqdomain.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/platform_data/gpio-davinci.h>
+#include <linux/property.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/spinlock.h>
#include <linux/pm_runtime.h>
@@ -486,7 +486,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
struct davinci_gpio_platform_data *pdata = dev->platform_data;
struct davinci_gpio_regs __iomem *g;
struct irq_domain *irq_domain = NULL;
- const struct of_device_id *match;
struct irq_chip *irq_chip;
struct davinci_gpio_irq_data *irqdata;
gpio_get_irq_chip_cb_t gpio_get_irq_chip;
@@ -495,10 +494,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
* Use davinci_gpio_get_irq_chip by default to handle non DT cases
*/
gpio_get_irq_chip = davinci_gpio_get_irq_chip;
- match = of_match_device(of_match_ptr(davinci_gpio_ids),
- dev);
- if (match)
- gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
+ if (dev->of_node)
+ gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)device_get_match_data(dev);
ngpio = pdata->ngpio;
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 74fdf0d87b2c..3ff0ea1e351c 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -56,9 +56,9 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include "gpiolib.h"
@@ -702,7 +702,7 @@ static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
{
struct bgpio_pdata *pdata;
- if (!of_match_device(bgpio_of_match, &pdev->dev))
+ if (!pdev->dev.of_node)
return NULL;
pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata),
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 67497116ce27..8f80ca8ec1ed 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -42,9 +42,10 @@
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/mfd/syscon.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -1122,7 +1123,6 @@ static void mvebu_gpio_remove_irq_domain(void *data)
static int mvebu_gpio_probe(struct platform_device *pdev)
{
struct mvebu_gpio_chip *mvchip;
- const struct of_device_id *match;
struct device_node *np = pdev->dev.of_node;
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
@@ -1132,11 +1132,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
int i, cpu, id;
int err;
- match = of_match_device(mvebu_gpio_of_match, &pdev->dev);
- if (match)
- soc_variant = (unsigned long) match->data;
- else
- soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION;
+ soc_variant = (unsigned long)device_get_match_data(&pdev->dev);
/* Some gpio controllers do not provide irq support */
err = platform_irq_count(pdev);
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: Use device_get_match_data()
2023-10-06 22:45 [PATCH] gpio: Use device_get_match_data() Rob Herring
@ 2023-10-09 7:08 ` Bartosz Golaszewski
0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2023-10-09 7:08 UTC (permalink / raw)
To: Rob Herring
Cc: Keerthy, Linus Walleij, Andy Shevchenko, Thierry Reding,
Uwe Kleine-König, linux-gpio, linux-kernel, linux-pwm
On Sat, Oct 7, 2023 at 12:45 AM Rob Herring <robh@kernel.org> wrote:
>
> Use preferred device_get_match_data() instead of of_match_device() to
> get the driver match data. With this, adjust the includes to explicitly
> include the correct headers.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
Applied, thanks!
Bart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-09 7:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 22:45 [PATCH] gpio: Use device_get_match_data() Rob Herring
2023-10-09 7:08 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).