9
0
Fork 0

Merge branch 'for-next/gpio'

This commit is contained in:
Sascha Hauer 2014-02-03 09:52:34 +01:00
commit 3cbd92bf6e
1 changed files with 19 additions and 7 deletions

View File

@ -50,22 +50,33 @@ int gpio_request(unsigned gpio, const char *label)
struct gpio_info *gi = gpio_to_desc(gpio);
int ret;
if (!gi)
return -ENODEV;
if (!gi) {
ret = -ENODEV;
goto done;
}
if (gi->requested)
return -EBUSY;
if (gi->requested) {
ret = -EBUSY;
goto done;
}
ret = 0;
if (gi->chip->ops->request) {
ret = gi->chip->ops->request(gi->chip, gpio - gi->chip->base);
if (ret)
return ret;
goto done;
}
gi->requested = true;
gi->label = xstrdup(label);
return 0;
done:
if (ret)
pr_err("_gpio_request: gpio-%d (%s) status %d\n",
gpio, label ? : "?", ret);
return ret;
}
void gpio_free(unsigned gpio)
@ -83,6 +94,7 @@ void gpio_free(unsigned gpio)
gi->requested = false;
free(gi->label);
gi->label = NULL;
}
/**
@ -322,7 +334,7 @@ static int do_gpiolib(int argc, char *argv[])
3, (dir < 0) ? "unk" : ((dir == GPIOF_DIR_IN) ? "in" : "out"),
3, (val < 0) ? "unk" : ((val == 0) ? "lo" : "hi"),
9, gi->requested ? "true" : "false",
gi->label ? gi->label : "");
(gi->requested && gi->label) ? gi->label : "");
}
return 0;