Skip to content

Commit 63bffc2

Browse files
robherringlinusw
authored andcommitted
pinctrl: 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]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e2b0bac commit 63bffc2

19 files changed

+59
-108
lines changed

drivers/pinctrl/bcm/pinctrl-ns.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include <linux/io.h>
88
#include <linux/module.h>
99
#include <linux/of.h>
10-
#include <linux/of_device.h>
1110
#include <linux/pinctrl/pinconf-generic.h>
1211
#include <linux/pinctrl/pinctrl.h>
1312
#include <linux/pinctrl/pinmux.h>
1413
#include <linux/platform_device.h>
14+
#include <linux/property.h>
1515
#include <linux/slab.h>
1616

1717
#include "../core.h"
@@ -208,7 +208,6 @@ static const struct of_device_id ns_pinctrl_of_match_table[] = {
208208
static int ns_pinctrl_probe(struct platform_device *pdev)
209209
{
210210
struct device *dev = &pdev->dev;
211-
const struct of_device_id *of_id;
212211
struct ns_pinctrl *ns_pinctrl;
213212
struct pinctrl_desc *pctldesc;
214213
struct pinctrl_pin_desc *pin;
@@ -225,10 +224,7 @@ static int ns_pinctrl_probe(struct platform_device *pdev)
225224

226225
ns_pinctrl->dev = dev;
227226

228-
of_id = of_match_device(ns_pinctrl_of_match_table, dev);
229-
if (!of_id)
230-
return -EINVAL;
231-
ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;
227+
ns_pinctrl->chipset_flag = (uintptr_t)device_get_match_data(dev);
232228

233229
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
234230
"cru_gpio_control");

drivers/pinctrl/berlin/berlin-bg2.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include <linux/init.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415

1516
#include "berlin.h"
@@ -227,10 +228,7 @@ static const struct of_device_id berlin2_pinctrl_match[] = {
227228

228229
static int berlin2_pinctrl_probe(struct platform_device *pdev)
229230
{
230-
const struct of_device_id *match =
231-
of_match_device(berlin2_pinctrl_match, &pdev->dev);
232-
233-
return berlin_pinctrl_probe(pdev, match->data);
231+
return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev));
234232
}
235233

236234
static struct platform_driver berlin2_pinctrl_driver = {

drivers/pinctrl/berlin/berlin-bg2cd.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include <linux/init.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415

1516
#include "berlin.h"
@@ -172,10 +173,7 @@ static const struct of_device_id berlin2cd_pinctrl_match[] = {
172173

173174
static int berlin2cd_pinctrl_probe(struct platform_device *pdev)
174175
{
175-
const struct of_device_id *match =
176-
of_match_device(berlin2cd_pinctrl_match, &pdev->dev);
177-
178-
return berlin_pinctrl_probe(pdev, match->data);
176+
return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev));
179177
}
180178

181179
static struct platform_driver berlin2cd_pinctrl_driver = {

drivers/pinctrl/berlin/berlin-bg2q.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include <linux/init.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415

1516
#include "berlin.h"
@@ -389,10 +390,7 @@ static const struct of_device_id berlin2q_pinctrl_match[] = {
389390

390391
static int berlin2q_pinctrl_probe(struct platform_device *pdev)
391392
{
392-
const struct of_device_id *match =
393-
of_match_device(berlin2q_pinctrl_match, &pdev->dev);
394-
395-
return berlin_pinctrl_probe(pdev, match->data);
393+
return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev));
396394
}
397395

398396
static struct platform_driver berlin2q_pinctrl_driver = {

drivers/pinctrl/berlin/berlin-bg4ct.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include <linux/init.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415

1516
#include "berlin.h"
@@ -449,8 +450,8 @@ static const struct of_device_id berlin4ct_pinctrl_match[] = {
449450

450451
static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
451452
{
452-
const struct of_device_id *match =
453-
of_match_device(berlin4ct_pinctrl_match, &pdev->dev);
453+
const struct berlin_pinctrl_desc *desc =
454+
device_get_match_data(&pdev->dev);
454455
struct regmap_config *rmconfig;
455456
struct regmap *regmap;
456457
struct resource *res;
@@ -473,7 +474,7 @@ static int berlin4ct_pinctrl_probe(struct platform_device *pdev)
473474
if (IS_ERR(regmap))
474475
return PTR_ERR(regmap);
475476

476-
return berlin_pinctrl_probe_regmap(pdev, match->data, regmap);
477+
return berlin_pinctrl_probe_regmap(pdev, desc, regmap);
477478
}
478479

479480
static struct platform_driver berlin4ct_pinctrl_driver = {

drivers/pinctrl/berlin/pinctrl-as370.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
*/
99

1010
#include <linux/init.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415

1516
#include "berlin.h"
@@ -330,8 +331,8 @@ static const struct of_device_id as370_pinctrl_match[] = {
330331

331332
static int as370_pinctrl_probe(struct platform_device *pdev)
332333
{
333-
const struct of_device_id *match =
334-
of_match_device(as370_pinctrl_match, &pdev->dev);
334+
const struct berlin_pinctrl_desc *desc =
335+
device_get_match_data(&pdev->dev);
335336
struct regmap_config *rmconfig;
336337
struct regmap *regmap;
337338
struct resource *res;
@@ -354,7 +355,7 @@ static int as370_pinctrl_probe(struct platform_device *pdev)
354355
if (IS_ERR(regmap))
355356
return PTR_ERR(regmap);
356357

357-
return berlin_pinctrl_probe_regmap(pdev, match->data, regmap);
358+
return berlin_pinctrl_probe_regmap(pdev, desc, regmap);
358359
}
359360

360361
static struct platform_driver as370_pinctrl_driver = {

drivers/pinctrl/mvebu/pinctrl-armada-38x.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <linux/io.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/pinctrl/pinctrl.h>
16+
#include <linux/property.h>
1717

1818
#include "pinctrl-mvebu.h"
1919

@@ -404,13 +404,8 @@ static struct pinctrl_gpio_range armada_38x_mpp_gpio_ranges[] = {
404404
static int armada_38x_pinctrl_probe(struct platform_device *pdev)
405405
{
406406
struct mvebu_pinctrl_soc_info *soc = &armada_38x_pinctrl_info;
407-
const struct of_device_id *match =
408-
of_match_device(armada_38x_pinctrl_of_match, &pdev->dev);
409407

410-
if (!match)
411-
return -ENODEV;
412-
413-
soc->variant = (unsigned) match->data & 0xff;
408+
soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff;
414409
soc->controls = armada_38x_mpp_controls;
415410
soc->ncontrols = ARRAY_SIZE(armada_38x_mpp_controls);
416411
soc->gpioranges = armada_38x_mpp_gpio_ranges;

drivers/pinctrl/mvebu/pinctrl-armada-39x.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <linux/io.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/pinctrl/pinctrl.h>
16+
#include <linux/property.h>
1717

1818
#include "pinctrl-mvebu.h"
1919

@@ -386,13 +386,8 @@ static struct pinctrl_gpio_range armada_39x_mpp_gpio_ranges[] = {
386386
static int armada_39x_pinctrl_probe(struct platform_device *pdev)
387387
{
388388
struct mvebu_pinctrl_soc_info *soc = &armada_39x_pinctrl_info;
389-
const struct of_device_id *match =
390-
of_match_device(armada_39x_pinctrl_of_match, &pdev->dev);
391389

392-
if (!match)
393-
return -ENODEV;
394-
395-
soc->variant = (unsigned) match->data & 0xff;
390+
soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff;
396391
soc->controls = armada_39x_mpp_controls;
397392
soc->ncontrols = ARRAY_SIZE(armada_39x_mpp_controls);
398393
soc->gpioranges = armada_39x_mpp_gpio_ranges;

drivers/pinctrl/mvebu/pinctrl-armada-ap806.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/io.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/of.h>
16-
#include <linux/of_device.h>
1716
#include <linux/pinctrl/pinctrl.h>
1817

1918
#include "pinctrl-mvebu.h"
@@ -106,10 +105,8 @@ static struct pinctrl_gpio_range armada_ap806_mpp_gpio_ranges[] = {
106105
static int armada_ap806_pinctrl_probe(struct platform_device *pdev)
107106
{
108107
struct mvebu_pinctrl_soc_info *soc = &armada_ap806_pinctrl_info;
109-
const struct of_device_id *match =
110-
of_match_device(armada_ap806_pinctrl_of_match, &pdev->dev);
111108

112-
if (!match || !pdev->dev.parent)
109+
if (!pdev->dev.parent)
113110
return -ENODEV;
114111

115112
soc->variant = 0; /* no variants for Armada AP806 */

drivers/pinctrl/mvebu/pinctrl-armada-cp110.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <linux/io.h>
1313
#include <linux/mfd/syscon.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/pinctrl/pinctrl.h>
1716
#include <linux/platform_device.h>
17+
#include <linux/property.h>
1818

1919
#include "pinctrl-mvebu.h"
2020

@@ -638,8 +638,6 @@ static void mvebu_pinctrl_assign_variant(struct mvebu_mpp_mode *m,
638638
static int armada_cp110_pinctrl_probe(struct platform_device *pdev)
639639
{
640640
struct mvebu_pinctrl_soc_info *soc;
641-
const struct of_device_id *match =
642-
of_match_device(armada_cp110_pinctrl_of_match, &pdev->dev);
643641
int i;
644642

645643
if (!pdev->dev.parent)
@@ -650,7 +648,7 @@ static int armada_cp110_pinctrl_probe(struct platform_device *pdev)
650648
if (!soc)
651649
return -ENOMEM;
652650

653-
soc->variant = (unsigned long) match->data & 0xff;
651+
soc->variant = (unsigned long)device_get_match_data(&pdev->dev) & 0xff;
654652
soc->controls = armada_cp110_mpp_controls;
655653
soc->ncontrols = ARRAY_SIZE(armada_cp110_mpp_controls);
656654
soc->modes = armada_cp110_mpp_modes;

drivers/pinctrl/mvebu/pinctrl-armada-xp.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <linux/platform_device.h>
2020
#include <linux/clk.h>
2121
#include <linux/of.h>
22-
#include <linux/of_device.h>
2322
#include <linux/pinctrl/pinctrl.h>
23+
#include <linux/property.h>
2424
#include <linux/bitops.h>
2525

2626
#include "pinctrl-mvebu.h"
@@ -568,14 +568,9 @@ static int armada_xp_pinctrl_resume(struct platform_device *pdev)
568568
static int armada_xp_pinctrl_probe(struct platform_device *pdev)
569569
{
570570
struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info;
571-
const struct of_device_id *match =
572-
of_match_device(armada_xp_pinctrl_of_match, &pdev->dev);
573571
int nregs;
574572

575-
if (!match)
576-
return -ENODEV;
577-
578-
soc->variant = (unsigned) match->data & 0xff;
573+
soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff;
579574

580575
switch (soc->variant) {
581576
case V_MV78230:

drivers/pinctrl/mvebu/pinctrl-dove.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <linux/platform_device.h>
1313
#include <linux/clk.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/mfd/syscon.h>
1716
#include <linux/pinctrl/pinctrl.h>
17+
#include <linux/property.h>
1818
#include <linux/regmap.h>
1919

2020
#include "pinctrl-mvebu.h"
@@ -765,13 +765,11 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
765765
{
766766
struct resource *res, *mpp_res;
767767
struct resource fb_res;
768-
const struct of_device_id *match =
769-
of_match_device(dove_pinctrl_of_match, &pdev->dev);
770768
struct mvebu_mpp_ctrl_data *mpp_data;
771769
void __iomem *base;
772770
int i;
773771

774-
pdev->dev.platform_data = (void *)match->data;
772+
pdev->dev.platform_data = (void *)device_get_match_data(&pdev->dev);
775773

776774
/*
777775
* General MPP Configuration Register is part of pdma registers.

drivers/pinctrl/mvebu/pinctrl-kirkwood.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <linux/platform_device.h>
1212
#include <linux/clk.h>
1313
#include <linux/of.h>
14-
#include <linux/of_device.h>
1514
#include <linux/pinctrl/pinctrl.h>
15+
#include <linux/property.h>
1616

1717
#include "pinctrl-mvebu.h"
1818

@@ -470,10 +470,7 @@ static const struct of_device_id kirkwood_pinctrl_of_match[] = {
470470

471471
static int kirkwood_pinctrl_probe(struct platform_device *pdev)
472472
{
473-
const struct of_device_id *match =
474-
of_match_device(kirkwood_pinctrl_of_match, &pdev->dev);
475-
476-
pdev->dev.platform_data = (void *)match->data;
473+
pdev->dev.platform_data = (void *)device_get_match_data(&pdev->dev);
477474

478475
return mvebu_pinctrl_simple_mmio_probe(pdev);
479476
}

drivers/pinctrl/mvebu/pinctrl-orion.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <linux/platform_device.h>
2020
#include <linux/clk.h>
2121
#include <linux/of.h>
22-
#include <linux/of_device.h>
2322
#include <linux/pinctrl/pinctrl.h>
23+
#include <linux/property.h>
2424

2525
#include "pinctrl-mvebu.h"
2626

@@ -218,10 +218,7 @@ static const struct of_device_id orion_pinctrl_of_match[] = {
218218

219219
static int orion_pinctrl_probe(struct platform_device *pdev)
220220
{
221-
const struct of_device_id *match =
222-
of_match_device(orion_pinctrl_of_match, &pdev->dev);
223-
224-
pdev->dev.platform_data = (void*)match->data;
221+
pdev->dev.platform_data = (void*)device_get_match_data(&pdev->dev);
225222

226223
mpp_base = devm_platform_ioremap_resource(pdev, 0);
227224
if (IS_ERR(mpp_base))

drivers/pinctrl/nomadik/pinctrl-abx500.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/of.h>
1818
#include <linux/of_device.h>
1919
#include <linux/platform_device.h>
20+
#include <linux/property.h>
2021
#include <linux/seq_file.h>
2122
#include <linux/slab.h>
2223
#include <linux/types.h>
@@ -985,7 +986,6 @@ static const struct of_device_id abx500_gpio_match[] = {
985986
static int abx500_gpio_probe(struct platform_device *pdev)
986987
{
987988
struct device_node *np = pdev->dev.of_node;
988-
const struct of_device_id *match;
989989
struct abx500_pinctrl *pct;
990990
unsigned int id = -1;
991991
int ret;
@@ -1006,12 +1006,7 @@ static int abx500_gpio_probe(struct platform_device *pdev)
10061006
pct->chip.parent = &pdev->dev;
10071007
pct->chip.base = -1; /* Dynamic allocation */
10081008

1009-
match = of_match_device(abx500_gpio_match, &pdev->dev);
1010-
if (!match) {
1011-
dev_err(&pdev->dev, "gpio dt not matching\n");
1012-
return -ENODEV;
1013-
}
1014-
id = (unsigned long)match->data;
1009+
id = (unsigned long)device_get_match_data(&pdev->dev);
10151010

10161011
/* Poke in other ASIC variants here */
10171012
switch (id) {

0 commit comments

Comments
 (0)