summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/tegra/pinctrl-tegra.c
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2023-05-30 13:53:07 +0300
committerLinus Walleij <linus.walleij@linaro.org>2023-06-01 14:17:35 +0300
commitfad57233501beb5bd25f037cb9128a533e710600 (patch)
tree8695fd6cde5ff376ba61dd280ae34758c9d50c35 /drivers/pinctrl/tegra/pinctrl-tegra.c
parenta5961bed5429cf1134d7f539b4ed60317012f84d (diff)
downloadlinux-fad57233501beb5bd25f037cb9128a533e710600.tar.xz
pinctrl: tegra: Duplicate pinmux functions table
The function table is filled with group information based on other instance-specific data at runtime. However, the function table can be shared between multiple instances, causing the ->probe() function for one instance to overwrite the table of a previously probed instance. Fix this by sharing only the function names and allocating a separate function table for each instance. Fixes: 5a0047360743 ("pinctrl: tegra: Separate Tegra194 instances") Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20230530105308.1292852-1-thierry.reding@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/tegra/pinctrl-tegra.c')
-rw-r--r--drivers/pinctrl/tegra/pinctrl-tegra.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index 1729b7ddfa94..21e08fbd1df0 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -232,7 +232,7 @@ static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev,
{
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
- return pmx->soc->functions[function].name;
+ return pmx->functions[function].name;
}
static int tegra_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
@@ -242,8 +242,8 @@ static int tegra_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
{
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
- *groups = pmx->soc->functions[function].groups;
- *num_groups = pmx->soc->functions[function].ngroups;
+ *groups = pmx->functions[function].groups;
+ *num_groups = pmx->functions[function].ngroups;
return 0;
}
@@ -795,10 +795,17 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
if (!pmx->group_pins)
return -ENOMEM;
+ pmx->functions = devm_kcalloc(&pdev->dev, pmx->soc->nfunctions,
+ sizeof(*pmx->functions), GFP_KERNEL);
+ if (!pmx->functions)
+ return -ENOMEM;
+
group_pins = pmx->group_pins;
+
for (fn = 0; fn < soc_data->nfunctions; fn++) {
- struct tegra_function *func = &soc_data->functions[fn];
+ struct tegra_function *func = &pmx->functions[fn];
+ func->name = pmx->soc->functions[fn];
func->groups = group_pins;
for (gn = 0; gn < soc_data->ngroups; gn++) {