[U-Boot] [PATCH] gpio: xilinx: Add support for using label property

Stefan Herbrechtsmeier stefan at herbrechtsmeier.net
Sun Aug 5 07:56:54 UTC 2018


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 at 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 at herbrechtsmeier.net>



More information about the U-Boot mailing list