devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nicolas Saenz Julienne" <nsaenzjulienne@suse.de>
To: "Stefan Wahren" <stefan.wahren@i2se.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>
Cc: <linux-gpio@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<bcm-kernel-feedback-list@broadcom.com>,
	<devicetree@vger.kernel.org>,
	"Stefan Wahren" <stefan.wahren@i2se.com>
Subject: Re: [RFC PATCH 2/4] pinctrl: bcm2835: Refactor platform data
Date: Tue, 28 Jan 2020 10:44:23 +0100	[thread overview]
Message-ID: <C07BSWY2PTAT.1MNBWW503QTQ0@linux-9qgx> (raw)
In-Reply-To: <1580148908-4863-3-git-send-email-stefan.wahren@i2se.com>

Hi Stefan,
thanks for the series!

On Mon Jan 27, 2020 at 7:15 PM, Stefan Wahren wrote:
> This prepares the platform data to be easier to extend for more GPIOs.
> Except of this there is no functional change.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---

[...]

> @@ -1083,6 +1112,7 @@ static int bcm2835_pinctrl_probe(struct
> platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct device_node *np = dev->of_node;
> struct bcm2835_pinctrl *pc;
> + struct bcm_plat_data *pdata;

You could define pdata as const here...

> struct gpio_irq_chip *girq;
> struct resource iomem;
> int err, i;
> @@ -1108,7 +1138,13 @@ static int bcm2835_pinctrl_probe(struct
> platform_device *pdev)
> if (IS_ERR(pc->base))
> return PTR_ERR(pc->base);
>  
> - pc->gpio_chip = bcm2835_gpio_chip;
> + match = of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node);
> + if (!match)
> + return -EINVAL;
> +
> + pdata = (struct bcm_plat_data *)match->data;

...And avoid this cast.

> +
> + memcpy(&pc->gpio_chip, pdata->gpio_chip, sizeof(pc->gpio_chip));

Here (and below) you could do:

	pc->gpio_chip = *pdata->gpio_chip;

IMO it's nicer, but it's a matter of taste.

> pc->gpio_chip.parent = dev;
> pc->gpio_chip.of_node = np;
>  
> @@ -1159,19 +1195,14 @@ static int bcm2835_pinctrl_probe(struct
> platform_device *pdev)
> return err;
> }
>  
> - match = of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node);
> - if (match) {
> - bcm2835_pinctrl_desc.confops =
> - (const struct pinconf_ops *)match->data;
> - }
> -
> - pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc);
> + memcpy(&pc->pctl_desc, pdata->pctl_desc, sizeof(pc->pctl_desc));
> + pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
> if (IS_ERR(pc->pctl_dev)) {
> gpiochip_remove(&pc->gpio_chip);
> return PTR_ERR(pc->pctl_dev);
> }
>  
> - pc->gpio_range = bcm2835_pinctrl_gpio_range;
> + memcpy(&pc->gpio_range, pdata->gpio_range, sizeof(pc->gpio_range));
> pc->gpio_range.base = pc->gpio_chip.base;
> pc->gpio_range.gc = &pc->gpio_chip;
> pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
> --
> 2.7.4


  reply	other threads:[~2020-01-28 10:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 18:15 [RFC PATCH 0/4] pinctrl: bcm2835: Add support for all BCM2711 GPIOs Stefan Wahren
2020-01-27 18:15 ` [RFC PATCH 1/4] pinctrl: bcm2835: Drop unused define Stefan Wahren
2020-02-14 10:46   ` Linus Walleij
2020-01-27 18:15 ` [RFC PATCH 2/4] pinctrl: bcm2835: Refactor platform data Stefan Wahren
2020-01-28  9:44   ` Nicolas Saenz Julienne [this message]
2020-01-29 13:52   ` Nicolas Saenz Julienne
2020-01-27 18:15 ` [RFC PATCH 3/4] pinctrl: bcm2835: Add support for all GPIOs on BCM2711 Stefan Wahren
2020-01-27 18:15 ` [RFC PATCH 4/4] ARM: dts: bcm2711-rpi-4-b: Add SoC GPIO labels Stefan Wahren
2020-01-28 10:05   ` Nicolas Saenz Julienne
2020-01-29 13:53   ` Nicolas Saenz Julienne
2020-01-28 10:17 ` [RFC PATCH 0/4] pinctrl: bcm2835: Add support for all BCM2711 GPIOs Nicolas Saenz Julienne
2020-01-29 13:56 ` Nicolas Saenz Julienne

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=C07BSWY2PTAT.1MNBWW503QTQ0@linux-9qgx \
    --to=nsaenzjulienne@suse.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=stefan.wahren@i2se.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).