All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] gpio: xilinx: Add support for using label property
Date: Sun, 5 Aug 2018 09:56:54 +0200	[thread overview]
Message-ID: <930d4fc3-0fba-345c-dba6-90d8f758d136@herbrechtsmeier.net> (raw)
In-Reply-To: <92fe83f57d380fab5b5c194d5d602d59112023e1.1533209515.git.michal.simek@xilinx.com>

Am 02.08.2018 um 13:31 schrieb Michal Simek:
> Add support for reading label property from DT and set up bank name
> based on that. If label property is not present full device node name is
> used.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>   drivers/gpio/xilinx_gpio.c | 14 ++++++++++++--
>   drivers/gpio/zynq_gpio.c   | 14 ++++++++++++--
>   2 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
> index cccfa7561739..da50d1634570 100644
> --- a/drivers/gpio/xilinx_gpio.c
> +++ b/drivers/gpio/xilinx_gpio.c
> @@ -224,8 +224,18 @@ static int xilinx_gpio_probe(struct udevice *dev)
>   {
>   	struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev);
>   	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> -
> -	uc_priv->bank_name = dev->name;
> +	const void *label_ptr;
> +	void *label_c;
> +	int size;
> +
> +	label_ptr = dev_read_prop(dev, "label", &size);
> +	if (label_ptr) {
> +		label_c = calloc(1, size);
> +		memcpy(label_c, label_ptr, size);
> +		uc_priv->bank_name = label_c;

This could be simplified by the function strdup.

> +	} else {
> +		uc_priv->bank_name = dev->name;
> +	}
>   
>   	uc_priv->gpio_count = platdata->bank_max[0] + platdata->bank_max[1];
>   
> diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c
> index 6fbaafb3fa3c..aa8d51e2f709 100644
> --- a/drivers/gpio/zynq_gpio.c
> +++ b/drivers/gpio/zynq_gpio.c
> @@ -336,8 +336,18 @@ static int zynq_gpio_probe(struct udevice *dev)
>   {
>   	struct zynq_gpio_platdata *platdata = dev_get_platdata(dev);
>   	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> -
> -	uc_priv->bank_name = dev->name;
> +	const void *label_ptr;
> +	void *label_c;
> +	int size;
> +
> +	label_ptr = dev_read_prop(dev, "label", &size);
> +	if (label_ptr) {
> +		label_c = calloc(1, size);
> +		memcpy(label_c, label_ptr, size);
> +		uc_priv->bank_name = label_c;
> +	} else {
> +		uc_priv->bank_name = dev->name;
> +	}
>   
>   	if (platdata->p_data)
>   		uc_priv->gpio_count = platdata->p_data->ngpio;

Reviewed-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>

  reply	other threads:[~2018-08-05  7:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 11:31 [U-Boot] [PATCH] gpio: xilinx: Add support for using label property Michal Simek
2018-08-05  7:56 ` Stefan Herbrechtsmeier [this message]
2018-08-06  6:43   ` Michal Simek

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=930d4fc3-0fba-345c-dba6-90d8f758d136@herbrechtsmeier.net \
    --to=stefan@herbrechtsmeier.net \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.