diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-02-10 12:57:36 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-02-11 22:29:46 +0300 |
commit | fdeb8e1547cb9dd39d5d7223b33f3565cf86c28e (patch) | |
tree | 65016a6cdaaa86565803c77f662c4b298c7b19f1 /sound | |
parent | 6cee3821e4e4bd6e6cdf0870b6c72d455460bd39 (diff) | |
download | linux-fdeb8e1547cb9dd39d5d7223b33f3565cf86c28e.tar.xz |
gpio: reflect base and ngpio into gpio_device
Some information about the GPIO chip need to stay around also
after the gpio_chip has been removed and only the gpio_device
persist. The base and ngpio are such things, for example we
don't want a new chip arriving to overlap the number space
of a dangling gpio_device, and the chardev may still query
the device for the number of lines etc.
Note that the code that assigns base and insert gpio_device
into the global list no longer check for a missing gpio_chip:
we respect the number space allocated by any other gpio_device.
As a consequence of the gdev being referenced directly from
the gpio_desc, we need to verify it differently from all
in-kernel API calls that fall through to direct queries to
the gpio_chip vtable: we first check that desc is !NULL, then
that desc->gdev is !NULL, then, if desc->gdev->chip is NULL,
we *BAIL OUT* without any error, so as to manage the case
where operations are requested on a device that is gone.
These checks were non-uniform and partly missing in the past:
so to simplify: create the macros VALIDATE_DESC() that will
return -EINVAL if the desc or desc->gdev is missing and just
0 if the chip is gone, and conversely VALIDATE_DESC_VOID()
for the case where the function does not return an error.
By using these macros, we get warning messages about missing
gdev with reference to the right function in the kernel log.
Despite the macro business this simplifies the code and make
it more readable than if we copy/paste the same descriptor
checking code into all code ABI call sites (IMHO).
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'sound')
0 files changed, 0 insertions, 0 deletions