Commit 171b92c8 authored by Laxman Dewangan's avatar Laxman Dewangan Committed by Linus Walleij

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: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: default avatarStephen Warren <swarren@nvidia.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Acked-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 3484f1be
...@@ -75,6 +75,11 @@ struct tegra_gpio_bank { ...@@ -75,6 +75,11 @@ struct tegra_gpio_bank {
#endif #endif
}; };
struct tegra_gpio_soc_config {
u32 bank_stride;
u32 upper_offset;
};
static struct device *dev; static struct device *dev;
static struct irq_domain *irq_domain; static struct irq_domain *irq_domain;
static void __iomem *regs; static void __iomem *regs;
...@@ -445,27 +450,6 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = { ...@@ -445,27 +450,6 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume)
}; };
struct tegra_gpio_soc_config {
u32 bank_stride;
u32 upper_offset;
};
static struct tegra_gpio_soc_config tegra20_gpio_config = {
.bank_stride = 0x80,
.upper_offset = 0x800,
};
static struct tegra_gpio_soc_config tegra30_gpio_config = {
.bank_stride = 0x100,
.upper_offset = 0x80,
};
static const struct of_device_id tegra_gpio_of_match[] = {
{ .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config },
{ .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config },
{ },
};
/* This lock class tells lockdep that GPIO irqs are in a different /* This lock class tells lockdep that GPIO irqs are in a different
* category than their parents, so it won't report false recursion. * category than their parents, so it won't report false recursion.
*/ */
...@@ -473,8 +457,7 @@ static struct lock_class_key gpio_lock_class; ...@@ -473,8 +457,7 @@ static struct lock_class_key gpio_lock_class;
static int tegra_gpio_probe(struct platform_device *pdev) static int tegra_gpio_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct tegra_gpio_soc_config *config;
struct tegra_gpio_soc_config *config;
struct resource *res; struct resource *res;
struct tegra_gpio_bank *bank; struct tegra_gpio_bank *bank;
int ret; int ret;
...@@ -484,12 +467,11 @@ static int tegra_gpio_probe(struct platform_device *pdev) ...@@ -484,12 +467,11 @@ static int tegra_gpio_probe(struct platform_device *pdev)
dev = &pdev->dev; dev = &pdev->dev;
match = of_match_device(tegra_gpio_of_match, &pdev->dev); config = of_device_get_match_data(&pdev->dev);
if (!match) { if (!config) {
dev_err(&pdev->dev, "Error: No device match found\n"); dev_err(&pdev->dev, "Error: No device match found\n");
return -ENODEV; return -ENODEV;
} }
config = (struct tegra_gpio_soc_config *)match->data;
tegra_gpio_bank_stride = config->bank_stride; tegra_gpio_bank_stride = config->bank_stride;
tegra_gpio_upper_offset = config->upper_offset; tegra_gpio_upper_offset = config->upper_offset;
...@@ -578,6 +560,22 @@ static int tegra_gpio_probe(struct platform_device *pdev) ...@@ -578,6 +560,22 @@ static int tegra_gpio_probe(struct platform_device *pdev)
return 0; return 0;
} }
static struct tegra_gpio_soc_config tegra20_gpio_config = {
.bank_stride = 0x80,
.upper_offset = 0x800,
};
static struct tegra_gpio_soc_config tegra30_gpio_config = {
.bank_stride = 0x100,
.upper_offset = 0x80,
};
static const struct of_device_id tegra_gpio_of_match[] = {
{ .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config },
{ .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config },
{ },
};
static struct platform_driver tegra_gpio_driver = { static struct platform_driver tegra_gpio_driver = {
.driver = { .driver = {
.name = "tegra-gpio", .name = "tegra-gpio",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment