diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-16 10:58:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-16 10:58:58 -0400 |
commit | d1291ebd85770299857b355160864cd1a9f6e5e9 (patch) | |
tree | eb966cdb29f46cee6a6b77da6b6ea0f10327f272 | |
parent | aa57e0b281453334267e836d15cfdb933f6d6f97 (diff) | |
parent | 46d4f7c25e1bb59b1663878b843a7ec06eaf5806 (diff) |
Merge tag 'gpio-v4.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij:
"This is the first round of GPIO fixes for v4.3. Quite a lot of
patches, but the influx of new stuff in the merge window was equally
big, so I'm not surprised.
- Return value checks and thus nicer errorpath for two drivers.
- Make GPIO_RCAR arch neutral.
- Propagate errors from GPIO chip ->get() vtable call. It turned out
these can actually fail sometimes, especially on slowpath
controllers doing I2C traffic and similar.
- Update documentation to be in sync with the massive changes in the
v4.3 merge window, phew.
- Handle deferred probe properly in the OMAP driver.
- Get rid of surplus MODULE_ALIAS() from sx150x"
* tag 'gpio-v4.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: omap: Fix GPIO numbering for deferred probe
Documentation: gpio: Explain that <function>-gpio is also supported
gpio: omap: Fix gpiochip_add() handling for deferred probe
gpio: sx150x: Remove unnecessary MODULE_ALIAS()
Documentation: gpio: board: describe the con_id parameter
Documentation: gpio: board: add flags parameter to gpiod_get*() functions
gpio: Propagate errors from chip->get()
gpio: rcar: GPIO_RCAR doesn't relate to ARM
gpio: mxs: need to check return value of irq_alloc_generic_chip
gpio: mxc: need to check return value of irq_alloc_generic_chip
-rw-r--r-- | Documentation/gpio/board.txt | 40 | ||||
-rw-r--r-- | Documentation/gpio/consumer.txt | 3 | ||||
-rw-r--r-- | drivers/gpio/Kconfig | 2 | ||||
-rw-r--r-- | drivers/gpio/gpio-mxc.c | 12 | ||||
-rw-r--r-- | drivers/gpio/gpio-mxs.c | 13 | ||||
-rw-r--r-- | drivers/gpio/gpio-omap.c | 9 | ||||
-rw-r--r-- | drivers/gpio/gpio-sx150x.c | 1 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 21 |
8 files changed, 71 insertions, 30 deletions
diff --git a/Documentation/gpio/board.txt b/Documentation/gpio/board.txt index b80606de545a..f59c43b6411b 100644 --- a/Documentation/gpio/board.txt +++ b/Documentation/gpio/board.txt | |||
@@ -21,8 +21,8 @@ exact way to do it depends on the GPIO controller providing the GPIOs, see the | |||
21 | device tree bindings for your controller. | 21 | device tree bindings for your controller. |
22 | 22 | ||
23 | GPIOs mappings are defined in the consumer device's node, in a property named | 23 | GPIOs mappings are defined in the consumer device's node, in a property named |
24 | <function>-gpios, where <function> is the function the driver will request | 24 | either <function>-gpios or <function>-gpio, where <function> is the function |
25 | through gpiod_get(). For example: | 25 | the driver will request through gpiod_get(). For example: |
26 | 26 | ||
27 | foo_device { | 27 | foo_device { |
28 | compatible = "acme,foo"; | 28 | compatible = "acme,foo"; |
@@ -31,7 +31,7 @@ through gpiod_get(). For example: | |||
31 | <&gpio 16 GPIO_ACTIVE_HIGH>, /* green */ | 31 | <&gpio 16 GPIO_ACTIVE_HIGH>, /* green */ |
32 | <&gpio 17 GPIO_ACTIVE_HIGH>; /* blue */ | 32 | <&gpio 17 GPIO_ACTIVE_HIGH>; /* blue */ |
33 | 33 | ||
34 | power-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; | 34 | power-gpio = <&gpio 1 GPIO_ACTIVE_LOW>; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | This property will make GPIOs 15, 16 and 17 available to the driver under the | 37 | This property will make GPIOs 15, 16 and 17 available to the driver under the |
@@ -39,15 +39,24 @@ This property will make GPIOs 15, 16 and 17 available to the driver under the | |||
39 | 39 | ||
40 | struct gpio_desc *red, *green, *blue, *power; | 40 | struct gpio_desc *red, *green, *blue, *power; |
41 | 41 | ||
42 | red = gpiod_get_index(dev, "led", 0); | 42 | red = gpiod_get_index(dev, "led", 0, GPIOD_OUT_HIGH); |
43 | green = gpiod_get_index(dev, "led", 1); | 43 | green = gpiod_get_index(dev, "led", 1, GPIOD_OUT_HIGH); |
44 | blue = gpiod_get_index(dev, "led", 2); | 44 | blue = gpiod_get_index(dev, "led", 2, GPIOD_OUT_HIGH); |
45 | 45 | ||
46 | power = gpiod_get(dev, "power"); | 46 | power = gpiod_get(dev, "power", GPIOD_OUT_HIGH); |
47 | 47 | ||
48 | The led GPIOs will be active-high, while the power GPIO will be active-low (i.e. | 48 | The led GPIOs will be active-high, while the power GPIO will be active-low (i.e. |
49 | gpiod_is_active_low(power) will be true). | 49 | gpiod_is_active_low(power) will be true). |
50 | 50 | ||
51 | The second parameter of the gpiod_get() functions, the con_id string, has to be | ||
52 | the <function>-prefix of the GPIO suffixes ("gpios" or "gpio", automatically | ||
53 | looked up by the gpiod functions internally) used in the device tree. With above | ||
54 | "led-gpios" example, use the prefix without the "-" as con_id parameter: "led". | ||
55 | |||
56 | Internally, the GPIO subsystem prefixes the GPIO suffix ("gpios" or "gpio") | ||
57 | with the string passed in con_id to get the resulting string | ||
58 | (snprintf(... "%s-%s", con_id, gpio_suffixes[]). | ||
59 | |||
51 | ACPI | 60 | ACPI |
52 | ---- | 61 | ---- |
53 | ACPI also supports function names for GPIOs in a similar fashion to DT. | 62 | ACPI also supports function names for GPIOs in a similar fashion to DT. |
@@ -142,13 +151,14 @@ The driver controlling "foo.0" will then be able to obtain its GPIOs as follows: | |||
142 | 151 | ||
143 | struct gpio_desc *red, *green, *blue, *power; | 152 | struct gpio_desc *red, *green, *blue, *power; |
144 | 153 | ||
145 | red = gpiod_get_index(dev, "led", 0); | 154 | red = gpiod_get_index(dev, "led", 0, GPIOD_OUT_HIGH); |
146 | green = gpiod_get_index(dev, "led", 1); | 155 | green = gpiod_get_index(dev, "led", 1, GPIOD_OUT_HIGH); |
147 | blue = gpiod_get_index(dev, "led", 2); | 156 | blue = gpiod_get_index(dev, "led", 2, GPIOD_OUT_HIGH); |
148 | 157 | ||
149 | power = gpiod_get(dev, "power"); | 158 | power = gpiod_get(dev, "power", GPIOD_OUT_HIGH); |
150 | gpiod_direction_output(power, 1); | ||
151 | 159 | ||
152 | Since the "power" GPIO is mapped as active-low, its actual signal will be 0 | 160 | Since the "led" GPIOs are mapped as active-high, this example will switch their |
153 | after this code. Contrary to the legacy integer GPIO interface, the active-low | 161 | signals to 1, i.e. enabling the LEDs. And for the "power" GPIO, which is mapped |
154 | property is handled during mapping and is thus transparent to GPIO consumers. | 162 | as active-low, its actual signal will be 0 after this code. Contrary to the legacy |
163 | integer GPIO interface, the active-low property is handled during mapping and is | ||
164 | thus transparent to GPIO consumers. | ||
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt index a206639454ab..e000502fde20 100644 --- a/Documentation/gpio/consumer.txt +++ b/Documentation/gpio/consumer.txt | |||
@@ -39,6 +39,9 @@ device that displays digits), an additional index argument can be specified: | |||
39 | const char *con_id, unsigned int idx, | 39 | const char *con_id, unsigned int idx, |
40 | enum gpiod_flags flags) | 40 | enum gpiod_flags flags) |
41 | 41 | ||
42 | For a more detailed description of the con_id parameter in the DeviceTree case | ||
43 | see Documentation/gpio/board.txt | ||
44 | |||
42 | The flags parameter is used to optionally specify a direction and initial value | 45 | The flags parameter is used to optionally specify a direction and initial value |
43 | for the GPIO. Values can be: | 46 | for the GPIO. Values can be: |
44 | 47 | ||
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b4fc9e4d24c6..8949b3f6f74d 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -356,7 +356,7 @@ config GPIO_PXA | |||
356 | 356 | ||
357 | config GPIO_RCAR | 357 | config GPIO_RCAR |
358 | tristate "Renesas R-Car GPIO" | 358 | tristate "Renesas R-Car GPIO" |
359 | depends on ARM && (ARCH_SHMOBILE || COMPILE_TEST) | 359 | depends on ARCH_SHMOBILE || COMPILE_TEST |
360 | select GPIOLIB_IRQCHIP | 360 | select GPIOLIB_IRQCHIP |
361 | help | 361 | help |
362 | Say yes here to support GPIO on Renesas R-Car SoCs. | 362 | Say yes here to support GPIO on Renesas R-Car SoCs. |
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index b752b560126e..8813abab9736 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -339,13 +339,15 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable) | |||
339 | return 0; | 339 | return 0; |
340 | } | 340 | } |
341 | 341 | ||
342 | static void mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) | 342 | static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) |
343 | { | 343 | { |
344 | struct irq_chip_generic *gc; | 344 | struct irq_chip_generic *gc; |
345 | struct irq_chip_type *ct; | 345 | struct irq_chip_type *ct; |
346 | 346 | ||
347 | gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, | 347 | gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, |
348 | port->base, handle_level_irq); | 348 | port->base, handle_level_irq); |
349 | if (!gc) | ||
350 | return -ENOMEM; | ||
349 | gc->private = port; | 351 | gc->private = port; |
350 | 352 | ||
351 | ct = gc->chip_types; | 353 | ct = gc->chip_types; |
@@ -360,6 +362,8 @@ static void mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) | |||
360 | 362 | ||
361 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, | 363 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, |
362 | IRQ_NOREQUEST, 0); | 364 | IRQ_NOREQUEST, 0); |
365 | |||
366 | return 0; | ||
363 | } | 367 | } |
364 | 368 | ||
365 | static void mxc_gpio_get_hw(struct platform_device *pdev) | 369 | static void mxc_gpio_get_hw(struct platform_device *pdev) |
@@ -477,12 +481,16 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
477 | } | 481 | } |
478 | 482 | ||
479 | /* gpio-mxc can be a generic irq chip */ | 483 | /* gpio-mxc can be a generic irq chip */ |
480 | mxc_gpio_init_gc(port, irq_base); | 484 | err = mxc_gpio_init_gc(port, irq_base); |
485 | if (err < 0) | ||
486 | goto out_irqdomain_remove; | ||
481 | 487 | ||
482 | list_add_tail(&port->node, &mxc_gpio_ports); | 488 | list_add_tail(&port->node, &mxc_gpio_ports); |
483 | 489 | ||
484 | return 0; | 490 | return 0; |
485 | 491 | ||
492 | out_irqdomain_remove: | ||
493 | irq_domain_remove(port->domain); | ||
486 | out_irqdesc_free: | 494 | out_irqdesc_free: |
487 | irq_free_descs(irq_base, 32); | 495 | irq_free_descs(irq_base, 32); |
488 | out_gpiochip_remove: | 496 | out_gpiochip_remove: |
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index b7f383eb18d9..1387385e6697 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c | |||
@@ -196,13 +196,16 @@ static int mxs_gpio_set_wake_irq(struct irq_data *d, unsigned int enable) | |||
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
198 | 198 | ||
199 | static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) | 199 | static int __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) |
200 | { | 200 | { |
201 | struct irq_chip_generic *gc; | 201 | struct irq_chip_generic *gc; |
202 | struct irq_chip_type *ct; | 202 | struct irq_chip_type *ct; |
203 | 203 | ||
204 | gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base, | 204 | gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base, |
205 | port->base, handle_level_irq); | 205 | port->base, handle_level_irq); |
206 | if (!gc) | ||
207 | return -ENOMEM; | ||
208 | |||
206 | gc->private = port; | 209 | gc->private = port; |
207 | 210 | ||
208 | ct = gc->chip_types; | 211 | ct = gc->chip_types; |
@@ -216,6 +219,8 @@ static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) | |||
216 | 219 | ||
217 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, | 220 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, |
218 | IRQ_NOREQUEST, 0); | 221 | IRQ_NOREQUEST, 0); |
222 | |||
223 | return 0; | ||
219 | } | 224 | } |
220 | 225 | ||
221 | static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | 226 | static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) |
@@ -317,7 +322,9 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
317 | } | 322 | } |
318 | 323 | ||
319 | /* gpio-mxs can be a generic irq chip */ | 324 | /* gpio-mxs can be a generic irq chip */ |
320 | mxs_gpio_init_gc(port, irq_base); | 325 | err = mxs_gpio_init_gc(port, irq_base); |
326 | if (err < 0) | ||
327 | goto out_irqdomain_remove; | ||
321 | 328 | ||
322 | /* setup one handler for each entry */ | 329 | /* setup one handler for each entry */ |
323 | irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, | 330 | irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, |
@@ -343,6 +350,8 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
343 | 350 | ||
344 | out_bgpio_remove: | 351 | out_bgpio_remove: |
345 | bgpio_remove(&port->bgc); | 352 | bgpio_remove(&port->bgc); |
353 | out_irqdomain_remove: | ||
354 | irq_domain_remove(port->domain); | ||
346 | out_irqdesc_free: | 355 | out_irqdesc_free: |
347 | irq_free_descs(irq_base, 32); | 356 | irq_free_descs(irq_base, 32); |
348 | return err; | 357 | return err; |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 2ae0d47e9554..072af5239bc1 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -1098,7 +1098,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1098 | } else { | 1098 | } else { |
1099 | bank->chip.label = "gpio"; | 1099 | bank->chip.label = "gpio"; |
1100 | bank->chip.base = gpio; | 1100 | bank->chip.base = gpio; |
1101 | gpio += bank->width; | ||
1102 | } | 1101 | } |
1103 | bank->chip.ngpio = bank->width; | 1102 | bank->chip.ngpio = bank->width; |
1104 | 1103 | ||
@@ -1108,6 +1107,9 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1108 | return ret; | 1107 | return ret; |
1109 | } | 1108 | } |
1110 | 1109 | ||
1110 | if (!bank->is_mpuio) | ||
1111 | gpio += bank->width; | ||
1112 | |||
1111 | #ifdef CONFIG_ARCH_OMAP1 | 1113 | #ifdef CONFIG_ARCH_OMAP1 |
1112 | /* | 1114 | /* |
1113 | * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop | 1115 | * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop |
@@ -1253,8 +1255,11 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1253 | omap_gpio_mod_init(bank); | 1255 | omap_gpio_mod_init(bank); |
1254 | 1256 | ||
1255 | ret = omap_gpio_chip_init(bank, irqc); | 1257 | ret = omap_gpio_chip_init(bank, irqc); |
1256 | if (ret) | 1258 | if (ret) { |
1259 | pm_runtime_put_sync(bank->dev); | ||
1260 | pm_runtime_disable(bank->dev); | ||
1257 | return ret; | 1261 | return ret; |
1262 | } | ||
1258 | 1263 | ||
1259 | omap_gpio_show_rev(bank); | 1264 | omap_gpio_show_rev(bank); |
1260 | 1265 | ||
diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index 458d9d7952b8..9c6b96707c9f 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c | |||
@@ -706,4 +706,3 @@ module_exit(sx150x_exit); | |||
706 | MODULE_AUTHOR("Gregory Bean <gbean@codeaurora.org>"); | 706 | MODULE_AUTHOR("Gregory Bean <gbean@codeaurora.org>"); |
707 | MODULE_DESCRIPTION("Driver for Semtech SX150X I2C GPIO Expanders"); | 707 | MODULE_DESCRIPTION("Driver for Semtech SX150X I2C GPIO Expanders"); |
708 | MODULE_LICENSE("GPL v2"); | 708 | MODULE_LICENSE("GPL v2"); |
709 | MODULE_ALIAS("i2c:sx150x"); | ||
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 980c1f87866a..5db3445552b1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1174,15 +1174,16 @@ EXPORT_SYMBOL_GPL(gpiod_is_active_low); | |||
1174 | * that the GPIO was actually requested. | 1174 | * that the GPIO was actually requested. |
1175 | */ | 1175 | */ |
1176 | 1176 | ||
1177 | static bool _gpiod_get_raw_value(const struct gpio_desc *desc) | 1177 | static int _gpiod_get_raw_value(const struct gpio_desc *desc) |
1178 | { | 1178 | { |
1179 | struct gpio_chip *chip; | 1179 | struct gpio_chip *chip; |
1180 | bool value; | ||
1181 | int offset; | 1180 | int offset; |
1181 | int value; | ||
1182 | 1182 | ||
1183 | chip = desc->chip; | 1183 | chip = desc->chip; |
1184 | offset = gpio_chip_hwgpio(desc); | 1184 | offset = gpio_chip_hwgpio(desc); |
1185 | value = chip->get ? chip->get(chip, offset) : false; | 1185 | value = chip->get ? chip->get(chip, offset) : -EIO; |
1186 | value = value < 0 ? value : !!value; | ||
1186 | trace_gpio_value(desc_to_gpio(desc), 1, value); | 1187 | trace_gpio_value(desc_to_gpio(desc), 1, value); |
1187 | return value; | 1188 | return value; |
1188 | } | 1189 | } |
@@ -1192,7 +1193,7 @@ static bool _gpiod_get_raw_value(const struct gpio_desc *desc) | |||
1192 | * @desc: gpio whose value will be returned | 1193 | * @desc: gpio whose value will be returned |
1193 | * | 1194 | * |
1194 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding | 1195 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding |
1195 | * its ACTIVE_LOW status. | 1196 | * its ACTIVE_LOW status, or negative errno on failure. |
1196 | * | 1197 | * |
1197 | * This function should be called from contexts where we cannot sleep, and will | 1198 | * This function should be called from contexts where we cannot sleep, and will |
1198 | * complain if the GPIO chip functions potentially sleep. | 1199 | * complain if the GPIO chip functions potentially sleep. |
@@ -1212,7 +1213,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_value); | |||
1212 | * @desc: gpio whose value will be returned | 1213 | * @desc: gpio whose value will be returned |
1213 | * | 1214 | * |
1214 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into | 1215 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into |
1215 | * account. | 1216 | * account, or negative errno on failure. |
1216 | * | 1217 | * |
1217 | * This function should be called from contexts where we cannot sleep, and will | 1218 | * This function should be called from contexts where we cannot sleep, and will |
1218 | * complain if the GPIO chip functions potentially sleep. | 1219 | * complain if the GPIO chip functions potentially sleep. |
@@ -1226,6 +1227,9 @@ int gpiod_get_value(const struct gpio_desc *desc) | |||
1226 | WARN_ON(desc->chip->can_sleep); | 1227 | WARN_ON(desc->chip->can_sleep); |
1227 | 1228 | ||
1228 | value = _gpiod_get_raw_value(desc); | 1229 | value = _gpiod_get_raw_value(desc); |
1230 | if (value < 0) | ||
1231 | return value; | ||
1232 | |||
1229 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | 1233 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
1230 | value = !value; | 1234 | value = !value; |
1231 | 1235 | ||
@@ -1548,7 +1552,7 @@ EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); | |||
1548 | * @desc: gpio whose value will be returned | 1552 | * @desc: gpio whose value will be returned |
1549 | * | 1553 | * |
1550 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding | 1554 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding |
1551 | * its ACTIVE_LOW status. | 1555 | * its ACTIVE_LOW status, or negative errno on failure. |
1552 | * | 1556 | * |
1553 | * This function is to be called from contexts that can sleep. | 1557 | * This function is to be called from contexts that can sleep. |
1554 | */ | 1558 | */ |
@@ -1566,7 +1570,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_value_cansleep); | |||
1566 | * @desc: gpio whose value will be returned | 1570 | * @desc: gpio whose value will be returned |
1567 | * | 1571 | * |
1568 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into | 1572 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into |
1569 | * account. | 1573 | * account, or negative errno on failure. |
1570 | * | 1574 | * |
1571 | * This function is to be called from contexts that can sleep. | 1575 | * This function is to be called from contexts that can sleep. |
1572 | */ | 1576 | */ |
@@ -1579,6 +1583,9 @@ int gpiod_get_value_cansleep(const struct gpio_desc *desc) | |||
1579 | return 0; | 1583 | return 0; |
1580 | 1584 | ||
1581 | value = _gpiod_get_raw_value(desc); | 1585 | value = _gpiod_get_raw_value(desc); |
1586 | if (value < 0) | ||
1587 | return value; | ||
1588 | |||
1582 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | 1589 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
1583 | value = !value; | 1590 | value = !value; |
1584 | 1591 | ||