Before using the cs_gpio, check if the GPIO is valid or not.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
u32 cs = slave_plat->cs;
+ if (!dm_gpio_is_valid(&priv->cs_gpios[cs]))
+ return;
+
dm_gpio_set_value(&priv->cs_gpios[cs], 0);
}
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
u32 cs = slave_plat->cs;
+ if (!dm_gpio_is_valid(&priv->cs_gpios[cs]))
+ return;
+
dm_gpio_set_value(&priv->cs_gpios[cs], 1);
}
}
for(i = 0; i < ARRAY_SIZE(priv->cs_gpios); i++) {
+ if (!dm_gpio_is_valid(&priv->cs_gpios[i]))
+ continue;
+
dm_gpio_set_dir_flags(&priv->cs_gpios[i],
GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
}