forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treewide: gpio-export: add error handling
Check if the GPIO is valid (or set at all). If no GPIO is set in the devicetree, a gpiolib related kernel warning + stacktrace is shown during boot and gpio-export reports GPIOs as exported albeit none really is. Signed-off-by: Mathias Kresin <[email protected]>
- Loading branch information
Showing
3 changed files
with
9 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <[email protected]> | |
|
||
#include "gpiolib.h" | ||
|
||
@@ -506,3 +508,69 @@ void of_gpiochip_remove(struct gpio_chip | ||
@@ -506,3 +508,71 @@ void of_gpiochip_remove(struct gpio_chip | ||
gpiochip_remove_pin_ranges(chip); | ||
of_node_put(chip->of_node); | ||
} | ||
|
@@ -56,6 +56,8 @@ Signed-off-by: John Crispin <[email protected]> | |
+ enum of_gpio_flags of_flags; | ||
+ | ||
+ gpio = of_get_gpio_flags(cnp, i, &of_flags); | ||
+ if (!gpio_is_valid(gpio)) | ||
+ return gpio; | ||
+ | ||
+ if (of_flags == OF_GPIO_ACTIVE_LOW) | ||
+ flags |= GPIOF_ACTIVE_LOW; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <[email protected]> | |
|
||
#include "gpiolib.h" | ||
|
||
@@ -506,3 +508,73 @@ void of_gpiochip_remove(struct gpio_chip | ||
@@ -506,3 +508,75 @@ void of_gpiochip_remove(struct gpio_chip | ||
gpiochip_remove_pin_ranges(chip); | ||
of_node_put(chip->of_node); | ||
} | ||
|
@@ -58,6 +58,8 @@ Signed-off-by: John Crispin <[email protected]> | |
+ enum of_gpio_flags of_flags; | ||
+ | ||
+ gpio = of_get_gpio_flags(cnp, i, &of_flags); | ||
+ if (!gpio_is_valid(gpio)) | ||
+ return gpio; | ||
+ | ||
+ if (of_flags == OF_GPIO_ACTIVE_LOW) | ||
+ flags |= GPIOF_ACTIVE_LOW; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <[email protected]> | |
|
||
#include "gpiolib.h" | ||
|
||
@@ -506,3 +508,69 @@ void of_gpiochip_remove(struct gpio_chip | ||
@@ -506,3 +508,71 @@ void of_gpiochip_remove(struct gpio_chip | ||
gpiochip_remove_pin_ranges(chip); | ||
of_node_put(chip->of_node); | ||
} | ||
|
@@ -56,6 +56,8 @@ Signed-off-by: John Crispin <[email protected]> | |
+ enum of_gpio_flags of_flags; | ||
+ | ||
+ gpio = of_get_gpio_flags(cnp, i, &of_flags); | ||
+ if (!gpio_is_valid(gpio)) | ||
+ return gpio; | ||
+ | ||
+ if (of_flags == OF_GPIO_ACTIVE_LOW) | ||
+ flags |= GPIOF_ACTIVE_LOW; | ||
|