[U-Boot] [PATCH v2] spi: atmel: check GPIO validity before using cs_gpios
Jagan Teki
jagannadh.teki at gmail.com
Mon Mar 27 16:57:29 UTC 2017
On Thu, Mar 23, 2017 at 10:19 AM, Wenyou Yang <wenyou.yang at atmel.com> wrote:
> Before using the cs_gpio, check if the GPIO is valid or not.
>
> Signed-off-by: Wenyou Yang <wenyou.yang at atmel.com>
> ---
>
> Changes in v2:
> - Rebase on v2017.03.
>
> drivers/spi/atmel_spi.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
> index 7649114231..8d29f7c4eb 100644
> --- a/drivers/spi/atmel_spi.c
> +++ b/drivers/spi/atmel_spi.c
> @@ -296,7 +296,8 @@ static void atmel_spi_cs_activate(struct udevice *dev)
> struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
> u32 cs = slave_plat->cs;
>
> - dm_gpio_set_value(&priv->cs_gpios[cs], 0);
> + if (dm_gpio_is_valid(&priv->cs_gpios[cs]))
> + dm_gpio_set_value(&priv->cs_gpios[cs], 0);
> }
Can rearrange like below, this look more reasonable.
if (!dm_gpio_is_valid(&priv->cs_gpios[cs]))
return;
dm_gpio_set_value(&priv->cs_gpios[cs], 0);
thanks!
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
More information about the U-Boot
mailing list