Skip to content

Commit 03a975c

Browse files
robherringBartosz Golaszewski
authored andcommitted
gpio: Use device_get_match_data()
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 <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 8a58cd5 commit 03a975c

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

drivers/gpio/gpio-davinci.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
#include <linux/irqdomain.h>
1717
#include <linux/module.h>
1818
#include <linux/of.h>
19-
#include <linux/of_device.h>
2019
#include <linux/pinctrl/consumer.h>
2120
#include <linux/platform_device.h>
2221
#include <linux/platform_data/gpio-davinci.h>
22+
#include <linux/property.h>
2323
#include <linux/irqchip/chained_irq.h>
2424
#include <linux/spinlock.h>
2525
#include <linux/pm_runtime.h>
@@ -486,7 +486,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
486486
struct davinci_gpio_platform_data *pdata = dev->platform_data;
487487
struct davinci_gpio_regs __iomem *g;
488488
struct irq_domain *irq_domain = NULL;
489-
const struct of_device_id *match;
490489
struct irq_chip *irq_chip;
491490
struct davinci_gpio_irq_data *irqdata;
492491
gpio_get_irq_chip_cb_t gpio_get_irq_chip;
@@ -495,10 +494,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
495494
* Use davinci_gpio_get_irq_chip by default to handle non DT cases
496495
*/
497496
gpio_get_irq_chip = davinci_gpio_get_irq_chip;
498-
match = of_match_device(of_match_ptr(davinci_gpio_ids),
499-
dev);
500-
if (match)
501-
gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
497+
if (dev->of_node)
498+
gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)device_get_match_data(dev);
502499

503500
ngpio = pdata->ngpio;
504501

drivers/gpio/gpio-mmio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.`
5656
#include <linux/slab.h>
5757
#include <linux/bitops.h>
5858
#include <linux/platform_device.h>
59+
#include <linux/property.h>
5960
#include <linux/mod_devicetable.h>
6061
#include <linux/of.h>
61-
#include <linux/of_device.h>
6262

6363
#include "gpiolib.h"
6464

@@ -702,7 +702,7 @@ static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev,
702702
{
703703
struct bgpio_pdata *pdata;
704704

705-
if (!of_match_device(bgpio_of_match, &pdev->dev))
705+
if (!pdev->dev.of_node)
706706
return NULL;
707707

708708
pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata),

drivers/gpio/gpio-mvebu.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@
4242
#include <linux/irqchip/chained_irq.h>
4343
#include <linux/irqdomain.h>
4444
#include <linux/mfd/syscon.h>
45-
#include <linux/of_device.h>
45+
#include <linux/of.h>
4646
#include <linux/pinctrl/consumer.h>
4747
#include <linux/platform_device.h>
48+
#include <linux/property.h>
4849
#include <linux/pwm.h>
4950
#include <linux/regmap.h>
5051
#include <linux/slab.h>
@@ -1122,7 +1123,6 @@ static void mvebu_gpio_remove_irq_domain(void *data)
11221123
static int mvebu_gpio_probe(struct platform_device *pdev)
11231124
{
11241125
struct mvebu_gpio_chip *mvchip;
1125-
const struct of_device_id *match;
11261126
struct device_node *np = pdev->dev.of_node;
11271127
struct irq_chip_generic *gc;
11281128
struct irq_chip_type *ct;
@@ -1132,11 +1132,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
11321132
int i, cpu, id;
11331133
int err;
11341134

1135-
match = of_match_device(mvebu_gpio_of_match, &pdev->dev);
1136-
if (match)
1137-
soc_variant = (unsigned long) match->data;
1138-
else
1139-
soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION;
1135+
soc_variant = (unsigned long)device_get_match_data(&pdev->dev);
11401136

11411137
/* Some gpio controllers do not provide irq support */
11421138
err = platform_irq_count(pdev);

0 commit comments

Comments
 (0)