From: Gregory CLEMENT <gregory.clement@bootlin.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Jianqun Xu <jay.xu@rock-chips.com>,
Linus Walleij <linus.walleij@linaro.org>,
Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org
Cc: Bamvor Jian Zhang <bamv2005@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Heiko Stuebner <heiko@sntech.de>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Michal Simek <michal.simek@xilinx.com>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v1 09/19] pinctrl: armada-37xx: Use temporary variable for struct device
Date: Mon, 08 Nov 2021 11:49:03 +0100 [thread overview]
Message-ID: <8735o6udls.fsf@BL-laptop> (raw)
In-Reply-To: <20211105124242.27288-9-andriy.shevchenko@linux.intel.com>
Hello Andy,
> Use temporary variable for struct device to make code neater.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Thanks,
Gregory
> ---
> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 56 +++++++++------------
> 1 file changed, 23 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> index 5615cb7a1209..37f92dc54d7a 100644
> --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> @@ -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_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
> + struct device *dev = info->dev;
> unsigned int reg = SELECTION;
> unsigned int mask = grp->reg_mask;
> int func, val;
>
> - dev_dbg(info->dev, "enable function %s group %s\n",
> - name, grp->name);
> + dev_dbg(dev, "enable function %s group %s\n", name, grp->name);
>
> func = match_string(grp->funcs, NB_FUNCS, name);
> if (func < 0)
> @@ -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,
> struct armada_37xx_pinctrl *info)
> {
> - struct device_node *np = info->dev->of_node;
> struct gpio_chip *gc = &info->gpio_chip;
> struct irq_chip *irqchip = &info->irq_chip;
> struct gpio_irq_chip *girq = &gc->irq;
> struct device *dev = &pdev->dev;
> + struct device_node *np;
> struct resource res;
> int ret = -ENODEV, i, nr_irq_parent;
>
> /* 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")) {
> ret = 0;
> break;
> @@ -750,12 +750,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
> 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");
> return -ENOENT;
> }
>
> - info->base = devm_ioremap_resource(info->dev, &res);
> + info->base = devm_ioremap_resource(dev, &res);
> if (IS_ERR(info->base))
> return PTR_ERR(info->base);
>
> @@ -774,8 +774,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
> * the chained irq with all of them.
> */
> girq->num_parents = nr_irq_parent;
> - girq->parents = devm_kcalloc(&pdev->dev, nr_irq_parent,
> - sizeof(*girq->parents), GFP_KERNEL);
> + girq->parents = devm_kcalloc(dev, nr_irq_parent, sizeof(*girq->parents), GFP_KERNEL);
> if (!girq->parents)
> return -ENOMEM;
> for (i = 0; i < nr_irq_parent; i++) {
> @@ -794,11 +793,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
> static int armada_37xx_gpiochip_register(struct platform_device *pdev,
> struct armada_37xx_pinctrl *info)
> {
> + struct device *dev = &pdev->dev;
> struct device_node *np;
> struct gpio_chip *gc;
> 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)) {
> ret = 0;
> break;
> @@ -811,19 +811,16 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
>
> gc = &info->gpio_chip;
> gc->ngpio = info->data->nr_pins;
> - gc->parent = &pdev->dev;
> + gc->parent = dev;
> gc->base = -1;
> gc->of_node = np;
> gc->label = info->data->name;
>
> ret = armada_37xx_irqchip_register(pdev, info);
> - if (ret)
> - return ret;
> - ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
> if (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,
> static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
> {
> int n, num = 0, funcsize = info->data->nr_pins;
> + struct device *dev = info->dev;
>
> for (n = 0; n < info->ngroups; n++) {
> struct armada_37xx_pin_group *grp = &info->groups[n];
> int i, j, f;
>
> - grp->pins = devm_kcalloc(info->dev,
> - grp->npins + grp->extra_npins,
> + grp->pins = devm_kcalloc(dev, grp->npins + grp->extra_npins,
> sizeof(*grp->pins),
> GFP_KERNEL);
> if (!grp->pins)
> @@ -898,8 +895,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
> ret = armada_37xx_add_function(info->funcs, &funcsize,
> grp->funcs[f]);
> if (ret == -EOVERFLOW)
> - dev_err(info->dev,
> - "More functions than pins(%d)\n",
> + dev_err(dev, "More functions than pins(%d)\n",
> info->data->nr_pins);
> if (ret < 0)
> continue;
> @@ -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)
> {
> struct armada_37xx_pmx_func *funcs = info->funcs;
> + struct device *dev = info->dev;
> int n;
>
> for (n = 0; n < info->nfuncs; n++) {
> @@ -932,8 +929,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
> const char **groups;
> int g;
>
> - funcs[n].groups = devm_kcalloc(info->dev,
> - funcs[n].ngroups,
> + funcs[n].groups = devm_kcalloc(dev, funcs[n].ngroups,
> sizeof(*(funcs[n].groups)),
> GFP_KERNEL);
> if (!funcs[n].groups)
> @@ -962,6 +958,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
> const struct armada_37xx_pin_data *pin_data = info->data;
> struct pinctrl_desc *ctrldesc = &info->pctl;
> struct pinctrl_pin_desc *pindesc, *pdesc;
> + struct device *dev = &pdev->dev;
> int pin, ret;
>
> info->groups = pin_data->groups;
> @@ -973,9 +970,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
> ctrldesc->pmxops = &armada_37xx_pmx_ops;
> ctrldesc->confops = &armada_37xx_pinconf_ops;
>
> - pindesc = devm_kcalloc(&pdev->dev,
> - pin_data->nr_pins, sizeof(*pindesc),
> - GFP_KERNEL);
> + pindesc = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*pindesc), GFP_KERNEL);
> if (!pindesc)
> return -ENOMEM;
>
> @@ -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
> * fewer unique functions than pins available
> */
> - info->funcs = devm_kcalloc(&pdev->dev,
> - pin_data->nr_pins,
> - sizeof(struct armada_37xx_pmx_func),
> - GFP_KERNEL);
> + info->funcs = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*info->funcs), GFP_KERNEL);
> if (!info->funcs)
> return -ENOMEM;
>
> -
> ret = armada_37xx_fill_group(info);
> if (ret)
> return ret;
> @@ -1010,9 +1001,9 @@ static int armada_37xx_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);
> }
>
> @@ -1143,8 +1134,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev)
> struct regmap *regmap;
> int ret;
>
> - info = devm_kzalloc(dev, sizeof(struct armada_37xx_pinctrl),
> - GFP_KERNEL);
> + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> if (!info)
> return -ENOMEM;
>
> @@ -1152,7 +1142,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev)
>
> regmap = syscon_node_to_regmap(np);
> if (IS_ERR(regmap)) {
> - dev_err(&pdev->dev, "cannot get regmap\n");
> + dev_err(dev, "cannot get regmap\n");
> return PTR_ERR(regmap);
> }
> info->regmap = regmap;
> --
> 2.33.0
>
--
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com
next prev parent reply other threads:[~2021-11-08 10:49 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 12:42 [PATCH v1 01/19] lib/string_helpers: Introduce kasprintf_strarray() Andy Shevchenko
2021-11-05 12:42 ` [PATCH v1 02/19] lib/string_helpers: Introduce managed variant of kasprintf_strarray() Andy Shevchenko
2021-11-05 12:42 ` [PATCH v1 03/19] pinctrl/rockchip: Drop wrong kernel doc annotation Andy Shevchenko
2021-11-06 16:32 ` Heiko Stübner
2021-11-05 12:42 ` [PATCH v1 04/19] pinctrl/rockchip: Use temporary variable for struct device Andy Shevchenko
2021-11-08 12:46 ` Heiko Stübner
2021-11-05 12:42 ` [PATCH v1 05/19] pinctrl/rockchip: Make use of the devm_platform_get_and_ioremap_resource() Andy Shevchenko
2021-11-08 12:48 ` Heiko Stübner
2021-11-05 12:42 ` [PATCH v1 06/19] pinctrl/rockchip: Convert to use dev_err_probe() Andy Shevchenko
2021-11-08 12:49 ` Heiko Stübner
2021-11-05 12:42 ` [PATCH v1 07/19] pinctrl/rockchip: Switch to use devm_kasprintf_strarray() Andy Shevchenko
2021-11-08 12:51 ` Heiko Stübner
2021-11-05 12:42 ` [PATCH v1 08/19] pinctrl: armada-37xx: Fix function name in the kernel doc Andy Shevchenko
2021-11-08 10:37 ` Gregory CLEMENT
2021-11-05 12:42 ` [PATCH v1 09/19] pinctrl: armada-37xx: Use temporary variable for struct device Andy Shevchenko
2021-11-08 10:49 ` Gregory CLEMENT [this message]
2021-11-05 12:42 ` [PATCH v1 10/19] pinctrl: armada-37xx: Make use of the devm_platform_ioremap_resource() Andy Shevchenko
2021-11-08 10:56 ` Gregory CLEMENT
2021-11-05 12:42 ` [PATCH v1 11/19] pinctrl: armada-37xx: Convert to use dev_err_probe() Andy Shevchenko
2021-11-08 10:59 ` Gregory CLEMENT
2021-11-05 12:42 ` [PATCH v1 12/19] pinctrl: armada-37xx: Switch to use devm_kasprintf_strarray() Andy Shevchenko
2021-11-08 11:09 ` Gregory CLEMENT
2021-11-05 12:42 ` [PATCH v1 13/19] pinctrl: st: Drop wrong kernel doc annotations Andy Shevchenko
2021-11-09 11:32 ` Linus Walleij
2021-11-09 12:04 ` Andy Shevchenko
2021-11-05 12:42 ` [PATCH v1 14/19] pinctrl: st: Use temporary variable for struct device Andy Shevchenko
2021-11-06 7:50 ` Joe Perches
[not found] ` <CAHp75Ve0Bv9VsWFFZxL9wYk=Z_Mm7nat-vf7g8HHTiROi7EY=Q@mail.gmail.com>
2021-11-06 8:28 ` Joe Perches
2021-11-08 9:26 ` Andy Shevchenko
2021-11-09 11:55 ` Linus Walleij
2021-11-09 12:07 ` Andy Shevchenko
2021-11-09 12:09 ` Andy Shevchenko
2021-11-05 12:42 ` [PATCH v1 15/19] pinctrl: st: Make use of the devm_platform_ioremap_resource_byname() Andy Shevchenko
2021-11-09 11:33 ` Linus Walleij
2021-11-05 12:42 ` [PATCH v1 16/19] pinctrl: st: Convert to use dev_err_probe() Andy Shevchenko
2021-11-09 11:34 ` Linus Walleij
2021-11-05 12:42 ` [PATCH v1 17/19] pinctrl: st: Switch to use devm_kasprintf_strarray() Andy Shevchenko
2021-11-09 11:34 ` Linus Walleij
2021-11-05 12:42 ` [PATCH v1 18/19] pinctrl: zynqmp: Unify pin naming Andy Shevchenko
2021-11-09 11:34 ` Linus Walleij
2021-11-05 12:42 ` [PATCH v1 19/19] gpio: mockup: Switch to use kasprintf_strarray() Andy Shevchenko
2021-11-09 11:35 ` Linus Walleij
2021-11-16 9:12 ` Bartosz Golaszewski
2021-11-06 7:34 ` [PATCH v1 01/19] lib/string_helpers: Introduce kasprintf_strarray() Joe Perches
2021-11-09 11:42 ` Linus Walleij
2021-11-15 11:23 ` Andy Shevchenko
2021-11-18 16:56 ` Andy Shevchenko
2021-11-18 20:30 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735o6udls.fsf@BL-laptop \
--to=gregory.clement@bootlin.com \
--cc=akpm@linux-foundation.org \
--cc=andrew@lunn.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=bamv2005@gmail.com \
--cc=brgl@bgdev.pl \
--cc=heiko@sntech.de \
--cc=jay.xu@rock-chips.com \
--cc=lakshmi.sai.krishna.potthuri@xilinx.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=michal.simek@xilinx.com \
--cc=patrice.chotard@foss.st.com \
--cc=sebastian.hesselbarth@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).