OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 20... | Line 20... | |||
20 | +#include <linux/init.h> |
20 | +#include <linux/init.h> |
|
21 | +#include <linux/platform_device.h> |
21 | +#include <linux/platform_device.h> |
|
Line 22... | Line 22... | |||
22 | |
22 | |
|
Line 23... | Line 23... | |||
23 | #include "gpiolib.h" |
23 | #include "gpiolib.h" |
|
24 | |
24 | |
|
25 | @@ -507,3 +509,68 @@ void of_gpiochip_remove(struct gpio_chip |
25 | @@ -506,3 +508,69 @@ void of_gpiochip_remove(struct gpio_chip |
|
26 | gpiochip_remove_pin_ranges(chip); |
26 | gpiochip_remove_pin_ranges(chip); |
|
27 | of_node_put(chip->of_node); |
27 | of_node_put(chip->of_node); |
|
28 | } |
28 | } |
|
29 | + |
29 | + |
|
30 | +static struct of_device_id gpio_export_ids[] = { |
30 | +static struct of_device_id gpio_export_ids[] = { |
|
31 | + { .compatible = "gpio-export" }, |
31 | + { .compatible = "gpio-export" }, |
|
32 | + { /* sentinel */ } |
32 | + { /* sentinel */ } |
|
33 | +}; |
33 | +}; |
|
34 | + |
34 | + |
|
35 | +static int of_gpio_export_probe(struct platform_device *pdev) |
35 | +static int __init of_gpio_export_probe(struct platform_device *pdev) |
|
36 | +{ |
36 | +{ |
|
37 | + struct device_node *np = pdev->dev.of_node; |
37 | + struct device_node *np = pdev->dev.of_node; |
|
38 | + struct device_node *cnp; |
38 | + struct device_node *cnp; |
|
Line 54... | Line 54... | |||
54 | + for (i = 0; i < max_gpio; i++) { |
54 | + for (i = 0; i < max_gpio; i++) { |
|
55 | + unsigned flags = 0; |
55 | + unsigned flags = 0; |
|
56 | + enum of_gpio_flags of_flags; |
56 | + enum of_gpio_flags of_flags; |
|
57 | + |
57 | + |
|
58 | + gpio = of_get_gpio_flags(cnp, i, &of_flags); |
58 | + gpio = of_get_gpio_flags(cnp, i, &of_flags); |
|
59 | + if (!gpio_is_valid(gpio)) |
- | ||
60 | + return gpio; |
- | ||
61 | + |
59 | + |
|
62 | + if (of_flags == OF_GPIO_ACTIVE_LOW) |
60 | + if (of_flags == OF_GPIO_ACTIVE_LOW) |
|
63 | + flags |= GPIOF_ACTIVE_LOW; |
61 | + flags |= GPIOF_ACTIVE_LOW; |
|
64 | + |
62 | + |
|
65 | + if (!of_property_read_u32(cnp, "gpio-export,output", &val)) |
63 | + if (!of_property_read_u32(cnp, "gpio-export,output", &val)) |
|
Line 85... | Line 83... | |||
85 | + .driver = { |
83 | + .driver = { |
|
86 | + .name = "gpio-export", |
84 | + .name = "gpio-export", |
|
87 | + .owner = THIS_MODULE, |
85 | + .owner = THIS_MODULE, |
|
88 | + .of_match_table = of_match_ptr(gpio_export_ids), |
86 | + .of_match_table = of_match_ptr(gpio_export_ids), |
|
89 | + }, |
87 | + }, |
|
90 | + .probe = of_gpio_export_probe, |
- | ||
91 | +}; |
88 | +}; |
|
92 | + |
89 | + |
|
- | 90 | +static int __init of_gpio_export_init(void) |
||
- | 91 | +{ |
||
- | 92 | + return platform_driver_probe(&gpio_export_driver, of_gpio_export_probe); |
||
- | 93 | +} |
||
93 | +module_platform_driver(gpio_export_driver); |
94 | +device_initcall(of_gpio_export_init); |
|
94 | --- a/drivers/gpio/gpiolib-sysfs.c |
95 | --- a/drivers/gpio/gpiolib-sysfs.c |
|
95 | +++ b/drivers/gpio/gpiolib-sysfs.c |
96 | +++ b/drivers/gpio/gpiolib-sysfs.c |
|
96 | @@ -553,7 +553,7 @@ static struct class gpio_class = { |
97 | @@ -553,7 +553,7 @@ static struct class gpio_class = { |
|
97 | * |
98 | * |
|
98 | * Returns zero on success, else an error. |
99 | * Returns zero on success, else an error. |