pinctrl/rockchip: Use temporary variable for struct device
[ Upstream commite4dd7fd5ff
] Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Stable-dep-of:31b62a98de
("pinctrl: rockchip: fix reading pull type on rk3568") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
8cbf932c5c
Коммит
259ab8fb8c
|
@ -285,6 +285,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
{
|
||||
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
|
||||
const struct rockchip_pin_group *grp;
|
||||
struct device *dev = info->dev;
|
||||
struct pinctrl_map *new_map;
|
||||
struct device_node *parent;
|
||||
int map_num = 1;
|
||||
|
@ -296,8 +297,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
*/
|
||||
grp = pinctrl_name_to_group(info, np->name);
|
||||
if (!grp) {
|
||||
dev_err(info->dev, "unable to find group for node %pOFn\n",
|
||||
np);
|
||||
dev_err(dev, "unable to find group for node %pOFn\n", np);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
new_map[i].data.configs.num_configs = grp->data[i].nconfigs;
|
||||
}
|
||||
|
||||
dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n",
|
||||
dev_dbg(dev, "maps: function %s group %s num %d\n",
|
||||
(*map)->data.mux.function, (*map)->data.mux.group, map_num);
|
||||
|
||||
return 0;
|
||||
|
@ -927,20 +927,20 @@ static int rockchip_verify_mux(struct rockchip_pin_bank *bank,
|
|||
int pin, int mux)
|
||||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct device *dev = info->dev;
|
||||
int iomux_num = (pin / 8);
|
||||
|
||||
if (iomux_num > 3)
|
||||
return -EINVAL;
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
|
||||
dev_err(info->dev, "pin %d is unrouted\n", pin);
|
||||
dev_err(dev, "pin %d is unrouted\n", pin);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
|
||||
if (mux != RK_FUNC_GPIO) {
|
||||
dev_err(info->dev,
|
||||
"pin %d only supports a gpio mux\n", pin);
|
||||
dev_err(dev, "pin %d only supports a gpio mux\n", pin);
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
}
|
||||
|
@ -964,6 +964,7 @@ static int rockchip_verify_mux(struct rockchip_pin_bank *bank,
|
|||
static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
|
||||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct device *dev = info->dev;
|
||||
int iomux_num = (pin / 8);
|
||||
struct regmap *regmap;
|
||||
int reg, ret, mask, mux_type;
|
||||
|
@ -977,8 +978,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
|
|||
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY)
|
||||
return 0;
|
||||
|
||||
dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n",
|
||||
bank->bank_num, pin, mux);
|
||||
dev_dbg(dev, "setting mux of GPIO%d-%d to %d\n", bank->bank_num, pin, mux);
|
||||
|
||||
regmap = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU)
|
||||
? info->regmap_pmu : info->regmap_base;
|
||||
|
@ -1630,6 +1630,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct rockchip_pin_ctrl *ctrl = info->ctrl;
|
||||
struct device *dev = info->dev;
|
||||
struct regmap *regmap;
|
||||
int reg, ret;
|
||||
u32 data, temp, rmask_bits;
|
||||
|
@ -1675,7 +1676,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
bit -= 16;
|
||||
break;
|
||||
default:
|
||||
dev_err(info->dev, "unsupported bit: %d for pinctrl drive type: %d\n",
|
||||
dev_err(dev, "unsupported bit: %d for pinctrl drive type: %d\n",
|
||||
bit, drv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1687,8 +1688,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
rmask_bits = RK3288_DRV_BITS_PER_PIN;
|
||||
break;
|
||||
default:
|
||||
dev_err(info->dev, "unsupported pinctrl drive type: %d\n",
|
||||
drv_type);
|
||||
dev_err(dev, "unsupported pinctrl drive type: %d\n", drv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1707,13 +1707,14 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct rockchip_pin_ctrl *ctrl = info->ctrl;
|
||||
struct device *dev = info->dev;
|
||||
struct regmap *regmap;
|
||||
int reg, ret, i;
|
||||
u32 data, rmask, rmask_bits, temp;
|
||||
u8 bit;
|
||||
int drv_type = bank->drv[pin_num / 8].drv_type;
|
||||
|
||||
dev_dbg(info->dev, "setting drive of GPIO%d-%d to %d\n",
|
||||
dev_dbg(dev, "setting drive of GPIO%d-%d to %d\n",
|
||||
bank->bank_num, pin_num, strength);
|
||||
|
||||
ctrl->drv_calc_reg(bank, pin_num, ®map, ®, &bit);
|
||||
|
@ -1735,8 +1736,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
}
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "unsupported driver strength %d\n",
|
||||
strength);
|
||||
dev_err(dev, "unsupported driver strength %d\n", strength);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1775,7 +1775,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
bit -= 16;
|
||||
break;
|
||||
default:
|
||||
dev_err(info->dev, "unsupported bit: %d for pinctrl drive type: %d\n",
|
||||
dev_err(dev, "unsupported bit: %d for pinctrl drive type: %d\n",
|
||||
bit, drv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1786,8 +1786,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank,
|
|||
rmask_bits = RK3288_DRV_BITS_PER_PIN;
|
||||
break;
|
||||
default:
|
||||
dev_err(info->dev, "unsupported pinctrl drive type: %d\n",
|
||||
drv_type);
|
||||
dev_err(dev, "unsupported pinctrl drive type: %d\n", drv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1821,6 +1820,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num)
|
|||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct rockchip_pin_ctrl *ctrl = info->ctrl;
|
||||
struct device *dev = info->dev;
|
||||
struct regmap *regmap;
|
||||
int reg, ret, pull_type;
|
||||
u8 bit;
|
||||
|
@ -1855,7 +1855,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num)
|
|||
|
||||
return rockchip_pull_list[pull_type][data];
|
||||
default:
|
||||
dev_err(info->dev, "unsupported pinctrl type\n");
|
||||
dev_err(dev, "unsupported pinctrl type\n");
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
@ -1865,13 +1865,13 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
|
|||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct rockchip_pin_ctrl *ctrl = info->ctrl;
|
||||
struct device *dev = info->dev;
|
||||
struct regmap *regmap;
|
||||
int reg, ret, i, pull_type;
|
||||
u8 bit;
|
||||
u32 data, rmask;
|
||||
|
||||
dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n",
|
||||
bank->bank_num, pin_num, pull);
|
||||
dev_dbg(dev, "setting pull of GPIO%d-%d to %d\n", bank->bank_num, pin_num, pull);
|
||||
|
||||
/* rk3066b does support any pulls */
|
||||
if (ctrl->type == RK3066B)
|
||||
|
@ -1914,8 +1914,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
|
|||
}
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "unsupported pull setting %d\n",
|
||||
pull);
|
||||
dev_err(dev, "unsupported pull setting %d\n", pull);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1927,7 +1926,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
|
|||
ret = regmap_update_bits(regmap, reg, rmask, data);
|
||||
break;
|
||||
default:
|
||||
dev_err(info->dev, "unsupported pinctrl type\n");
|
||||
dev_err(dev, "unsupported pinctrl type\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2018,12 +2017,13 @@ static int rockchip_set_schmitt(struct rockchip_pin_bank *bank,
|
|||
{
|
||||
struct rockchip_pinctrl *info = bank->drvdata;
|
||||
struct rockchip_pin_ctrl *ctrl = info->ctrl;
|
||||
struct device *dev = info->dev;
|
||||
struct regmap *regmap;
|
||||
int reg, ret;
|
||||
u8 bit;
|
||||
u32 data, rmask;
|
||||
|
||||
dev_dbg(info->dev, "setting input schmitt of GPIO%d-%d to %d\n",
|
||||
dev_dbg(dev, "setting input schmitt of GPIO%d-%d to %d\n",
|
||||
bank->bank_num, pin_num, enable);
|
||||
|
||||
ret = ctrl->schmitt_calc_reg(bank, pin_num, ®map, ®, &bit);
|
||||
|
@ -2083,10 +2083,11 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
|
|||
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
|
||||
const unsigned int *pins = info->groups[group].pins;
|
||||
const struct rockchip_pin_config *data = info->groups[group].data;
|
||||
struct device *dev = info->dev;
|
||||
struct rockchip_pin_bank *bank;
|
||||
int cnt, ret = 0;
|
||||
|
||||
dev_dbg(info->dev, "enable function %s group %s\n",
|
||||
dev_dbg(dev, "enable function %s group %s\n",
|
||||
info->functions[selector].name, info->groups[group].name);
|
||||
|
||||
/*
|
||||
|
@ -2392,6 +2393,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
|
|||
struct rockchip_pinctrl *info,
|
||||
u32 index)
|
||||
{
|
||||
struct device *dev = info->dev;
|
||||
struct rockchip_pin_bank *bank;
|
||||
int size;
|
||||
const __be32 *list;
|
||||
|
@ -2399,7 +2401,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
|
|||
int i, j;
|
||||
int ret;
|
||||
|
||||
dev_dbg(info->dev, "group(%d): %pOFn\n", index, np);
|
||||
dev_dbg(dev, "group(%d): %pOFn\n", index, np);
|
||||
|
||||
/* Initialise group */
|
||||
grp->name = np->name;
|
||||
|
@ -2412,18 +2414,14 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
|
|||
/* we do not check return since it's safe node passed down */
|
||||
size /= sizeof(*list);
|
||||
if (!size || size % 4) {
|
||||
dev_err(info->dev, "wrong pins number or pins and configs should be by 4\n");
|
||||
dev_err(dev, "wrong pins number or pins and configs should be by 4\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
grp->npins = size / 4;
|
||||
|
||||
grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
|
||||
GFP_KERNEL);
|
||||
grp->data = devm_kcalloc(info->dev,
|
||||
grp->npins,
|
||||
sizeof(struct rockchip_pin_config),
|
||||
GFP_KERNEL);
|
||||
grp->pins = devm_kcalloc(dev, grp->npins, sizeof(*grp->pins), GFP_KERNEL);
|
||||
grp->data = devm_kcalloc(dev, grp->npins, sizeof(*grp->data), GFP_KERNEL);
|
||||
if (!grp->pins || !grp->data)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -2457,6 +2455,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
|
|||
struct rockchip_pinctrl *info,
|
||||
u32 index)
|
||||
{
|
||||
struct device *dev = info->dev;
|
||||
struct device_node *child;
|
||||
struct rockchip_pmx_func *func;
|
||||
struct rockchip_pin_group *grp;
|
||||
|
@ -2464,7 +2463,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
|
|||
static u32 grp_index;
|
||||
u32 i = 0;
|
||||
|
||||
dev_dbg(info->dev, "parse function(%d): %pOFn\n", index, np);
|
||||
dev_dbg(dev, "parse function(%d): %pOFn\n", index, np);
|
||||
|
||||
func = &info->functions[index];
|
||||
|
||||
|
@ -2474,8 +2473,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
|
|||
if (func->ngroups <= 0)
|
||||
return 0;
|
||||
|
||||
func->groups = devm_kcalloc(info->dev,
|
||||
func->ngroups, sizeof(char *), GFP_KERNEL);
|
||||
func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL);
|
||||
if (!func->groups)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -2503,20 +2501,14 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
|
|||
|
||||
rockchip_pinctrl_child_count(info, np);
|
||||
|
||||
dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
|
||||
dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
|
||||
dev_dbg(dev, "nfunctions = %d\n", info->nfunctions);
|
||||
dev_dbg(dev, "ngroups = %d\n", info->ngroups);
|
||||
|
||||
info->functions = devm_kcalloc(dev,
|
||||
info->nfunctions,
|
||||
sizeof(struct rockchip_pmx_func),
|
||||
GFP_KERNEL);
|
||||
info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), GFP_KERNEL);
|
||||
if (!info->functions)
|
||||
return -ENOMEM;
|
||||
|
||||
info->groups = devm_kcalloc(dev,
|
||||
info->ngroups,
|
||||
sizeof(struct rockchip_pin_group),
|
||||
GFP_KERNEL);
|
||||
info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), GFP_KERNEL);
|
||||
if (!info->groups)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -2528,7 +2520,7 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
|
|||
|
||||
ret = rockchip_pinctrl_parse_functions(child, info, i++);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to parse function\n");
|
||||
dev_err(dev, "failed to parse function\n");
|
||||
of_node_put(child);
|
||||
return ret;
|
||||
}
|
||||
|
@ -2543,6 +2535,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
|
|||
struct pinctrl_desc *ctrldesc = &info->pctl;
|
||||
struct pinctrl_pin_desc *pindesc, *pdesc;
|
||||
struct rockchip_pin_bank *pin_bank;
|
||||
struct device *dev = &pdev->dev;
|
||||
int pin, bank, ret;
|
||||
int k;
|
||||
|
||||
|
@ -2552,9 +2545,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
|
|||
ctrldesc->pmxops = &rockchip_pmx_ops;
|
||||
ctrldesc->confops = &rockchip_pinconf_ops;
|
||||
|
||||
pindesc = devm_kcalloc(&pdev->dev,
|
||||
info->ctrl->nr_pins, sizeof(*pindesc),
|
||||
GFP_KERNEL);
|
||||
pindesc = devm_kcalloc(dev, info->ctrl->nr_pins, sizeof(*pindesc), GFP_KERNEL);
|
||||
if (!pindesc)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -2579,9 +2570,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
info->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, info);
|
||||
info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info);
|
||||
if (IS_ERR(info->pctl_dev)) {
|
||||
dev_err(&pdev->dev, "could not register pinctrl driver\n");
|
||||
dev_err(dev, "could not register pinctrl driver\n");
|
||||
return PTR_ERR(info->pctl_dev);
|
||||
}
|
||||
|
||||
|
@ -2595,8 +2586,9 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(
|
|||
struct rockchip_pinctrl *d,
|
||||
struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *node = dev->of_node;
|
||||
const struct of_device_id *match;
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
struct rockchip_pin_ctrl *ctrl;
|
||||
struct rockchip_pin_bank *bank;
|
||||
int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j;
|
||||
|
@ -2648,7 +2640,7 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(
|
|||
drv_pmu_offs : drv_grf_offs;
|
||||
}
|
||||
|
||||
dev_dbg(d->dev, "bank %d, iomux %d has iom_offset 0x%x drv_offset 0x%x\n",
|
||||
dev_dbg(dev, "bank %d, iomux %d has iom_offset 0x%x drv_offset 0x%x\n",
|
||||
i, j, iom->offset, drv->offset);
|
||||
|
||||
/*
|
||||
|
@ -2757,8 +2749,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
|||
{
|
||||
struct rockchip_pinctrl *info;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node, *node;
|
||||
struct rockchip_pin_ctrl *ctrl;
|
||||
struct device_node *np = pdev->dev.of_node, *node;
|
||||
struct resource *res;
|
||||
void __iomem *base;
|
||||
int ret;
|
||||
|
@ -2795,8 +2787,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
|||
|
||||
rockchip_regmap_config.max_register = resource_size(res) - 4;
|
||||
rockchip_regmap_config.name = "rockchip,pinctrl";
|
||||
info->regmap_base = devm_regmap_init_mmio(&pdev->dev, base,
|
||||
&rockchip_regmap_config);
|
||||
info->regmap_base =
|
||||
devm_regmap_init_mmio(dev, base, &rockchip_regmap_config);
|
||||
|
||||
/* to check for the old dt-bindings */
|
||||
info->reg_size = resource_size(res);
|
||||
|
@ -2808,12 +2800,10 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
rockchip_regmap_config.max_register =
|
||||
resource_size(res) - 4;
|
||||
rockchip_regmap_config.max_register = resource_size(res) - 4;
|
||||
rockchip_regmap_config.name = "rockchip,pinctrl-pull";
|
||||
info->regmap_pull = devm_regmap_init_mmio(&pdev->dev,
|
||||
base,
|
||||
&rockchip_regmap_config);
|
||||
info->regmap_pull =
|
||||
devm_regmap_init_mmio(dev, base, &rockchip_regmap_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2834,7 +2824,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
|||
|
||||
ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register gpio device\n");
|
||||
dev_err(dev, "failed to register gpio device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче