mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
dm: gpio: Check a GPIO is valid before using it
Since a gpio_desc is allowed to be invalid we should return an error indicating that the operation cannot be completed. This can happen if the GPIO is optional - e.g. some devices may have a reset line and some may not. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
71db6341c5
commit
eca4866586
1 changed files with 5 additions and 1 deletions
|
@ -250,8 +250,12 @@ int gpio_free(unsigned gpio)
|
|||
|
||||
static int check_reserved(struct gpio_desc *desc, const char *func)
|
||||
{
|
||||
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(desc->dev);
|
||||
struct gpio_dev_priv *uc_priv;
|
||||
|
||||
if (!dm_gpio_is_valid(desc))
|
||||
return -ENOENT;
|
||||
|
||||
uc_priv = dev_get_uclass_priv(desc->dev);
|
||||
if (!uc_priv->name[desc->offset]) {
|
||||
printf("%s: %s: error: gpio %s%d not reserved\n",
|
||||
desc->dev->name, func,
|
||||
|
|
Loading…
Reference in a new issue