diverse at91 related fixes
Subsystems (5)
v2 cover diverse at91 related fixes
This is a rework of the two patches sent earlier + an extra patch. With these patches my AT91SAM9263EK board boots barebox.
clk: fix clk_get error handling
- changed based on feedback from Uwe, test for -ENOENT
gpiolib: fix: do not access oftree on non-OFDEVICE boards
- rebased on top of Alexenaders original fix
And a third patch that just adds a missing static (found while browsing code)
diffstat:
arch/arm/mach-at91/bootstrap.c | 2 +- drivers/clk/clkdev.c | 2 +- drivers/gpio/gpiolib.c | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-)
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/3 clk: fix clk_get error handling
From 20397009e13e6111c8b17e5cbaf0addf3aaf593a Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Mon, 3 Jul 2017 21:21:02 +0200
Subject: [PATCH 1/3] clk: fix clk_get error handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If there is no OFTREE support of_clk_get_by_name failed with -ENOENT, which caused clk_get to bail out.
This had the effect that nothing was printed on the serial console with at91sam9263-ek.
There are no error paths that will return -ENODEV as we test for today, so change this to -ENOENT which is in use.
This allows us to contine with clk_get_sys() in case of other errors as was the intention of the original fix.
--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clkdev.c +1 -1
@@ -181,7 +181,7 @@ struct clk *clk_get(struct device_d *dev, const char *con_id)if (dev) { clk =of_clk_get_by_name (dev->device_node, con_id); -if (!IS_ERR (clk) ||PTR_ERR (clk) != -ENODEV ) +if (!IS_ERR (clk) ||PTR_ERR (clk) != -ENOENT )return clk; }
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 gpio: fix null pointer exception when there is no oftree
In reply to Sam RavnborgFrom d10f426e1b8cec7de257dabf59e7fe53a591b3c1 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Mon, 3 Jul 2017 22:07:41 +0200
Subject: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree
In a system with oftree support enabled but with no oftree the of_gpiochip_scan_hogs() would fail due to device_node equals NULL.
Check device_node and return with 0 in this situation, as this mirrors what would have happened before we added support for gpio-hogs.
Use IS_ENABLED(CONFIG_OFDEVICE) to teach compiler to leave out the of_* specific functions if not needed.
--- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib.c +7 -1
@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue ;
@@ -416,7 +419,10 @@ int gpiochip_add(struct gpio_chip *chip)for (i = chip->base; i < chip->base + chip->ngpio; i++) gpio_desc[i].chip = chip; -return of_gpiochip_scan_hogs (chip); +if (IS_ENABLED (CONFIG_OFDEVICE )) +return of_gpiochip_scan_hogs (chip); +else +return 0 ; }void gpiochip_remove (struct gpio_chip *chip)
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree
Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg:
Quoted 37 lines
From
d10f426e1b8cec7de257dabf59e7fe53a591b3c1Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Mon, 3 Jul 2017 22:07:41 +0200
Subject: [PATCH 2/3] gpio: fix null pointer exception when there is no oftreeIn a system with oftree support enabled but with no oftree the
of_gpiochip_scan_hogs()would fail due todevice_nodeequals NULL.Check
device_nodeand return with 0 in this situation, as this mirrors what would have happened before we added support for gpio-hogs.Use
IS_ENABLED(CONFIG_OFDEVICE)to teach compiler to leave out the of_* specific functions if not needed.Fixes 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes")Signed-off-by Alexander Kurz <[email protected]>Signed-off-by Sam Ravnborg <[email protected]>--- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/gpio/gpiolib.c +3
-0@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue ;@@ -416,7 +419,10 @@ int gpiochip_add(struct gpio_chip *chip)for (i = chip->base; i < chip->base + chip->ngpio; i++)
drivers/gpio/gpiolib.c int gpiochip_add(struct gpio_chip *chip) · line 428
Quoted 10 lines
drivers/gpio/gpiolib.c +4
-1gpio_desc[i].chip = chip; -return of_gpiochip_scan_hogs (chip); +if (IS_ENABLED (CONFIG_OFDEVICE )) +return of_gpiochip_scan_hogs (chip); +else +return 0 ; }void gpiochip_remove (struct gpio_chip *chip)
I think this can be simplified to:
drivers/gpio/gpiolib.c +0 -0
@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip
*chip)
struct device_node *np;
int ret, i;+ if (!IS_ENABLED(CONFIG_OFDEVICE) || !chip->dev->device_node)
+ return 0;
+
for_each_available_child_of_node(chip->dev->device_node, np) {
if (!of_property_read_bool(np, "gpio-hog"))
continue;The optimizer should be able to work this out. Can you check that this works for you? No need to resend, if it works I'll just commit this.
Regards,
Lucas
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree
Quoted 67 lines · Lucas Stach
Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg:
Quoted 37 lines
From
d10f426e1b8cec7de257dabf59e7fe53a591b3c1Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Mon, 3 Jul 2017 22:07:41 +0200
Subject: [PATCH 2/3] gpio: fix null pointer exception when there is no oftreeIn a system with oftree support enabled but with no oftree the
of_gpiochip_scan_hogs()would fail due todevice_nodeequals NULL.Check
device_nodeand return with 0 in this situation, as this mirrors what would have happened before we added support for gpio-hogs.Use
IS_ENABLED(CONFIG_OFDEVICE)to teach compiler to leave out the of_* specific functions if not needed.Fixes 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes")Signed-off-by Alexander Kurz <[email protected]>Signed-off-by Sam Ravnborg <[email protected]>--- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/gpio/gpiolib.c +3
-0@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue ;@@ -416,7 +419,10 @@ int gpiochip_add(struct gpio_chip *chip)for (i = chip->base; i < chip->base + chip->ngpio; i++)drivers/gpio/gpiolib.c int gpiochip_add(struct gpio_chip *chip) · line 428
Quoted 10 lines
drivers/gpio/gpiolib.c +4
-1gpio_desc[i].chip = chip; -return of_gpiochip_scan_hogs (chip); +if (IS_ENABLED (CONFIG_OFDEVICE )) +return of_gpiochip_scan_hogs (chip); +else +return 0 ; }void gpiochip_remove (struct gpio_chip *chip)I think this can be simplified to:
drivers/gpio/gpiolib.c +3
-0@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!IS_ENABLED (CONFIG_OFDEVICE ) || !chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue;
Quoted 2 lines
The optimizer should be able to work this out. Can you check that this works for you? No need to resend, if it works I'll just commit this.
This works perfecty fine with gcc-5.2 and gcc-4.6 (although gcc-4.6 compatibilty broke with commit 4ef026c3048)
Thanks, Alexander
Quoted 4 lines
Regards,
Lucas
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree
Am Donnerstag, den 06.07.2017, 22:53 +0200 schrieb Alexander Kurz:
Quoted 70 lines · Lucas Stach
Quoted 68 lines
Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg:
Quoted 37 lines
From
d10f426e1b8cec7de257dabf59e7fe53a591b3c1Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Mon, 3 Jul 2017 22:07:41 +0200
Subject: [PATCH 2/3] gpio: fix null pointer exception when there is no oftreeIn a system with oftree support enabled but with no oftree the
of_gpiochip_scan_hogs()would fail due todevice_nodeequals NULL.Check
device_nodeand return with 0 in this situation, as this mirrors what would have happened before we added support for gpio-hogs.Use
IS_ENABLED(CONFIG_OFDEVICE)to teach compiler to leave out the of_* specific functions if not needed.Fixes 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes")Signed-off-by Alexander Kurz <[email protected]>Signed-off-by Sam Ravnborg <[email protected]>--- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/gpio/gpiolib.c +3
-0@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue ;@@ -416,7 +419,10 @@ int gpiochip_add(struct gpio_chip *chip)for (i = chip->base; i < chip->base + chip->ngpio; i++)drivers/gpio/gpiolib.c int gpiochip_add(struct gpio_chip *chip) · line 428
Quoted 10 lines
drivers/gpio/gpiolib.c +4
-1gpio_desc[i].chip = chip; -return of_gpiochip_scan_hogs (chip); +if (IS_ENABLED (CONFIG_OFDEVICE )) +return of_gpiochip_scan_hogs (chip); +else +return 0 ; }void gpiochip_remove (struct gpio_chip *chip)I think this can be simplified to:
drivers/gpio/gpiolib.c +3
-0@@ -379,6 +379,9 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)struct device_node *np;int ret, i; +if (!IS_ENABLED (CONFIG_OFDEVICE ) || !chip->dev->device_node) +return 0 ; +for_each_available_child_of_node (chip->dev->device_node, np) {if (!of_property_read_bool (np,"gpio-hog" ))continue;
Quoted 4 lines
Quoted 2 lines
The optimizer should be able to work this out. Can you check that this works for you? No need to resend, if it works I'll just commit this.
This works perfecty fine with gcc-5.2 and gcc-4.6 (although gcc-4.6 compatibilty broke with commit
4ef026c3048)
Thanks, all. I've pushed the reworked patch together with 1/3 to master. Patch 3/3 is applied for -next.
Regards,
Lucas
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/3 arm: at91 bootstrap: declare local function static
In reply to Sam RavnborgFrom 8eb65eccbdd304ba4fb06e8de2a958791e0077f0 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Wed, 5 Jul 2017 08:52:19 +0200
Subject: [PATCH 3/3] arm: at91 bootstrap: declare local function static
Function is only used in this file and no prototype exist in any header.
--- arch/arm/mach-at91/bootstrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-at91/bootstrap.c +1 -1
@@ -149,7 +149,7 @@ static void boot_reset_action(struct menu *m, struct menu_entry *me)restart_machine (); } -void at91_bootstrap_menu (void ) +static void at91_bootstrap_menu (void ) {struct menu *m;struct menu_entry *me;
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox