Commit 50cf2ed2 authored by Andy Shevchenko's avatar Andy Shevchenko

pinctrl: armada-37xx: Use temporary variable for struct device

Use temporary variable for struct device to make code neater.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
parent a6d93da4
...@@ -341,12 +341,12 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev, ...@@ -341,12 +341,12 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev,
struct armada_37xx_pin_group *grp) struct armada_37xx_pin_group *grp)
{ {
struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
struct device *dev = info->dev;
unsigned int reg = SELECTION; unsigned int reg = SELECTION;
unsigned int mask = grp->reg_mask; unsigned int mask = grp->reg_mask;
int func, val; int func, val;
dev_dbg(info->dev, "enable function %s group %s\n", dev_dbg(dev, "enable function %s group %s\n", name, grp->name);
name, grp->name);
func = match_string(grp->funcs, NB_FUNCS, name); func = match_string(grp->funcs, NB_FUNCS, name);
if (func < 0) if (func < 0)
...@@ -722,16 +722,16 @@ static unsigned int armada_37xx_irq_startup(struct irq_data *d) ...@@ -722,16 +722,16 @@ static unsigned int armada_37xx_irq_startup(struct irq_data *d)
static int armada_37xx_irqchip_register(struct platform_device *pdev, static int armada_37xx_irqchip_register(struct platform_device *pdev,
struct armada_37xx_pinctrl *info) struct armada_37xx_pinctrl *info)
{ {
struct device_node *np = info->dev->of_node;
struct gpio_chip *gc = &info->gpio_chip; struct gpio_chip *gc = &info->gpio_chip;
struct irq_chip *irqchip = &info->irq_chip; struct irq_chip *irqchip = &info->irq_chip;
struct gpio_irq_chip *girq = &gc->irq; struct gpio_irq_chip *girq = &gc->irq;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np;
struct resource res; struct resource res;
int ret = -ENODEV, i, nr_irq_parent; int ret = -ENODEV, i, nr_irq_parent;
/* Check if we have at least one gpio-controller child node */ /* Check if we have at least one gpio-controller child node */
for_each_child_of_node(info->dev->of_node, np) { for_each_child_of_node(dev->of_node, np) {
if (of_property_read_bool(np, "gpio-controller")) { if (of_property_read_bool(np, "gpio-controller")) {
ret = 0; ret = 0;
break; break;
...@@ -750,12 +750,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -750,12 +750,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
return 0; return 0;
} }
if (of_address_to_resource(info->dev->of_node, 1, &res)) { if (of_address_to_resource(dev->of_node, 1, &res)) {
dev_err(dev, "cannot find IO resource\n"); dev_err(dev, "cannot find IO resource\n");
return -ENOENT; return -ENOENT;
} }
info->base = devm_ioremap_resource(info->dev, &res); info->base = devm_ioremap_resource(dev, &res);
if (IS_ERR(info->base)) if (IS_ERR(info->base))
return PTR_ERR(info->base); return PTR_ERR(info->base);
...@@ -774,8 +774,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -774,8 +774,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
* the chained irq with all of them. * the chained irq with all of them.
*/ */
girq->num_parents = nr_irq_parent; girq->num_parents = nr_irq_parent;
girq->parents = devm_kcalloc(&pdev->dev, nr_irq_parent, girq->parents = devm_kcalloc(dev, nr_irq_parent, sizeof(*girq->parents), GFP_KERNEL);
sizeof(*girq->parents), GFP_KERNEL);
if (!girq->parents) if (!girq->parents)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < nr_irq_parent; i++) { for (i = 0; i < nr_irq_parent; i++) {
...@@ -794,11 +793,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, ...@@ -794,11 +793,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
static int armada_37xx_gpiochip_register(struct platform_device *pdev, static int armada_37xx_gpiochip_register(struct platform_device *pdev,
struct armada_37xx_pinctrl *info) struct armada_37xx_pinctrl *info)
{ {
struct device *dev = &pdev->dev;
struct device_node *np; struct device_node *np;
struct gpio_chip *gc; struct gpio_chip *gc;
int ret = -ENODEV; int ret = -ENODEV;
for_each_child_of_node(info->dev->of_node, np) { for_each_child_of_node(dev->of_node, np) {
if (of_find_property(np, "gpio-controller", NULL)) { if (of_find_property(np, "gpio-controller", NULL)) {
ret = 0; ret = 0;
break; break;
...@@ -811,19 +811,16 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev, ...@@ -811,19 +811,16 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
gc = &info->gpio_chip; gc = &info->gpio_chip;
gc->ngpio = info->data->nr_pins; gc->ngpio = info->data->nr_pins;
gc->parent = &pdev->dev; gc->parent = dev;
gc->base = -1; gc->base = -1;
gc->of_node = np; gc->of_node = np;
gc->label = info->data->name; gc->label = info->data->name;
ret = armada_37xx_irqchip_register(pdev, info); ret = armada_37xx_irqchip_register(pdev, info);
if (ret)
return ret;
ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
if (ret) if (ret)
return ret; return ret;
return 0; return devm_gpiochip_add_data(dev, gc, info);
} }
/** /**
...@@ -874,13 +871,13 @@ static int armada_37xx_add_function(struct armada_37xx_pmx_func *funcs, ...@@ -874,13 +871,13 @@ static int armada_37xx_add_function(struct armada_37xx_pmx_func *funcs,
static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
{ {
int n, num = 0, funcsize = info->data->nr_pins; int n, num = 0, funcsize = info->data->nr_pins;
struct device *dev = info->dev;
for (n = 0; n < info->ngroups; n++) { for (n = 0; n < info->ngroups; n++) {
struct armada_37xx_pin_group *grp = &info->groups[n]; struct armada_37xx_pin_group *grp = &info->groups[n];
int i, j, f; int i, j, f;
grp->pins = devm_kcalloc(info->dev, grp->pins = devm_kcalloc(dev, grp->npins + grp->extra_npins,
grp->npins + grp->extra_npins,
sizeof(*grp->pins), sizeof(*grp->pins),
GFP_KERNEL); GFP_KERNEL);
if (!grp->pins) if (!grp->pins)
...@@ -898,8 +895,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) ...@@ -898,8 +895,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
ret = armada_37xx_add_function(info->funcs, &funcsize, ret = armada_37xx_add_function(info->funcs, &funcsize,
grp->funcs[f]); grp->funcs[f]);
if (ret == -EOVERFLOW) if (ret == -EOVERFLOW)
dev_err(info->dev, dev_err(dev, "More functions than pins(%d)\n",
"More functions than pins(%d)\n",
info->data->nr_pins); info->data->nr_pins);
if (ret < 0) if (ret < 0)
continue; continue;
...@@ -925,6 +921,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) ...@@ -925,6 +921,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
{ {
struct armada_37xx_pmx_func *funcs = info->funcs; struct armada_37xx_pmx_func *funcs = info->funcs;
struct device *dev = info->dev;
int n; int n;
for (n = 0; n < info->nfuncs; n++) { for (n = 0; n < info->nfuncs; n++) {
...@@ -932,8 +929,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) ...@@ -932,8 +929,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
const char **groups; const char **groups;
int g; int g;
funcs[n].groups = devm_kcalloc(info->dev, funcs[n].groups = devm_kcalloc(dev, funcs[n].ngroups,
funcs[n].ngroups,
sizeof(*(funcs[n].groups)), sizeof(*(funcs[n].groups)),
GFP_KERNEL); GFP_KERNEL);
if (!funcs[n].groups) if (!funcs[n].groups)
...@@ -962,6 +958,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ...@@ -962,6 +958,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
const struct armada_37xx_pin_data *pin_data = info->data; const struct armada_37xx_pin_data *pin_data = info->data;
struct pinctrl_desc *ctrldesc = &info->pctl; struct pinctrl_desc *ctrldesc = &info->pctl;
struct pinctrl_pin_desc *pindesc, *pdesc; struct pinctrl_pin_desc *pindesc, *pdesc;
struct device *dev = &pdev->dev;
int pin, ret; int pin, ret;
info->groups = pin_data->groups; info->groups = pin_data->groups;
...@@ -973,9 +970,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ...@@ -973,9 +970,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
ctrldesc->pmxops = &armada_37xx_pmx_ops; ctrldesc->pmxops = &armada_37xx_pmx_ops;
ctrldesc->confops = &armada_37xx_pinconf_ops; ctrldesc->confops = &armada_37xx_pinconf_ops;
pindesc = devm_kcalloc(&pdev->dev, pindesc = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*pindesc), GFP_KERNEL);
pin_data->nr_pins, sizeof(*pindesc),
GFP_KERNEL);
if (!pindesc) if (!pindesc)
return -ENOMEM; return -ENOMEM;
...@@ -994,14 +989,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ...@@ -994,14 +989,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
* we allocate functions for number of pins and hope there are * we allocate functions for number of pins and hope there are
* fewer unique functions than pins available * fewer unique functions than pins available
*/ */
info->funcs = devm_kcalloc(&pdev->dev, info->funcs = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*info->funcs), GFP_KERNEL);
pin_data->nr_pins,
sizeof(struct armada_37xx_pmx_func),
GFP_KERNEL);
if (!info->funcs) if (!info->funcs)
return -ENOMEM; return -ENOMEM;
ret = armada_37xx_fill_group(info); ret = armada_37xx_fill_group(info);
if (ret) if (ret)
return ret; return ret;
...@@ -1010,9 +1001,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ...@@ -1010,9 +1001,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
if (ret) if (ret)
return 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)) { 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); return PTR_ERR(info->pctl_dev);
} }
...@@ -1143,8 +1134,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) ...@@ -1143,8 +1134,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev)
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
info = devm_kzalloc(dev, sizeof(struct armada_37xx_pinctrl), info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
...@@ -1152,7 +1142,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) ...@@ -1152,7 +1142,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev)
regmap = syscon_node_to_regmap(np); regmap = syscon_node_to_regmap(np);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
dev_err(&pdev->dev, "cannot get regmap\n"); dev_err(dev, "cannot get regmap\n");
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
info->regmap = regmap; info->regmap = regmap;
......
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