diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-04-25 06:38:31 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-04-29 04:58:21 -0400 |
commit | 171b92c830f48bd546e2d68d6f511b3d87e0544e (patch) | |
tree | 47cb5e1a0fc16174220c2d52a863b83ba8147f56 /drivers/gpio/gpio-tegra.c | |
parent | 3484f1be2dbf520ad150a0be11f04464b930a4e6 (diff) |
gpio: tegra: Don't open code of_device_get_match_data()
Use of_device_get_match_data() for getting matched data
instead of implementing this locally.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-tegra.c')
-rw-r--r-- | drivers/gpio/gpio-tegra.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 790bb111b2cb..1b0c4975fc97 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -75,6 +75,11 @@ struct tegra_gpio_bank { | |||
75 | #endif | 75 | #endif |
76 | }; | 76 | }; |
77 | 77 | ||
78 | struct tegra_gpio_soc_config { | ||
79 | u32 bank_stride; | ||
80 | u32 upper_offset; | ||
81 | }; | ||
82 | |||
78 | static struct device *dev; | 83 | static struct device *dev; |
79 | static struct irq_domain *irq_domain; | 84 | static struct irq_domain *irq_domain; |
80 | static void __iomem *regs; | 85 | static void __iomem *regs; |
@@ -445,27 +450,6 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = { | |||
445 | SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) | 450 | SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) |
446 | }; | 451 | }; |
447 | 452 | ||
448 | struct tegra_gpio_soc_config { | ||
449 | u32 bank_stride; | ||
450 | u32 upper_offset; | ||
451 | }; | ||
452 | |||
453 | static struct tegra_gpio_soc_config tegra20_gpio_config = { | ||
454 | .bank_stride = 0x80, | ||
455 | .upper_offset = 0x800, | ||
456 | }; | ||
457 | |||
458 | static struct tegra_gpio_soc_config tegra30_gpio_config = { | ||
459 | .bank_stride = 0x100, | ||
460 | .upper_offset = 0x80, | ||
461 | }; | ||
462 | |||
463 | static const struct of_device_id tegra_gpio_of_match[] = { | ||
464 | { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config }, | ||
465 | { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, | ||
466 | { }, | ||
467 | }; | ||
468 | |||
469 | /* This lock class tells lockdep that GPIO irqs are in a different | 453 | /* This lock class tells lockdep that GPIO irqs are in a different |
470 | * category than their parents, so it won't report false recursion. | 454 | * category than their parents, so it won't report false recursion. |
471 | */ | 455 | */ |
@@ -473,8 +457,7 @@ static struct lock_class_key gpio_lock_class; | |||
473 | 457 | ||
474 | static int tegra_gpio_probe(struct platform_device *pdev) | 458 | static int tegra_gpio_probe(struct platform_device *pdev) |
475 | { | 459 | { |
476 | const struct of_device_id *match; | 460 | const struct tegra_gpio_soc_config *config; |
477 | struct tegra_gpio_soc_config *config; | ||
478 | struct resource *res; | 461 | struct resource *res; |
479 | struct tegra_gpio_bank *bank; | 462 | struct tegra_gpio_bank *bank; |
480 | int ret; | 463 | int ret; |
@@ -484,12 +467,11 @@ static int tegra_gpio_probe(struct platform_device *pdev) | |||
484 | 467 | ||
485 | dev = &pdev->dev; | 468 | dev = &pdev->dev; |
486 | 469 | ||
487 | match = of_match_device(tegra_gpio_of_match, &pdev->dev); | 470 | config = of_device_get_match_data(&pdev->dev); |
488 | if (!match) { | 471 | if (!config) { |
489 | dev_err(&pdev->dev, "Error: No device match found\n"); | 472 | dev_err(&pdev->dev, "Error: No device match found\n"); |
490 | return -ENODEV; | 473 | return -ENODEV; |
491 | } | 474 | } |
492 | config = (struct tegra_gpio_soc_config *)match->data; | ||
493 | 475 | ||
494 | tegra_gpio_bank_stride = config->bank_stride; | 476 | tegra_gpio_bank_stride = config->bank_stride; |
495 | tegra_gpio_upper_offset = config->upper_offset; | 477 | tegra_gpio_upper_offset = config->upper_offset; |
@@ -578,6 +560,22 @@ static int tegra_gpio_probe(struct platform_device *pdev) | |||
578 | return 0; | 560 | return 0; |
579 | } | 561 | } |
580 | 562 | ||
563 | static struct tegra_gpio_soc_config tegra20_gpio_config = { | ||
564 | .bank_stride = 0x80, | ||
565 | .upper_offset = 0x800, | ||
566 | }; | ||
567 | |||
568 | static struct tegra_gpio_soc_config tegra30_gpio_config = { | ||
569 | .bank_stride = 0x100, | ||
570 | .upper_offset = 0x80, | ||
571 | }; | ||
572 | |||
573 | static const struct of_device_id tegra_gpio_of_match[] = { | ||
574 | { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config }, | ||
575 | { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, | ||
576 | { }, | ||
577 | }; | ||
578 | |||
581 | static struct platform_driver tegra_gpio_driver = { | 579 | static struct platform_driver tegra_gpio_driver = { |
582 | .driver = { | 580 | .driver = { |
583 | .name = "tegra-gpio", | 581 | .name = "tegra-gpio", |