* [PATCH v2 0/3] diverse at91 related fixes @ 2017-07-05 18:27 Sam Ravnborg 2017-07-05 18:32 ` [PATCH 1/3] clk: fix clk_get error handling Sam Ravnborg ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Sam Ravnborg @ 2017-07-05 18:27 UTC (permalink / raw) To: barebox, Alexander Kurz, Uwe Kleine-König 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] clk: fix clk_get error handling 2017-07-05 18:27 [PATCH v2 0/3] diverse at91 related fixes Sam Ravnborg @ 2017-07-05 18:32 ` Sam Ravnborg 2017-07-05 18:33 ` [PATCH 2/3] gpio: fix null pointer exception when there is no oftree Sam Ravnborg 2017-07-05 18:34 ` [PATCH 3/3] arm: at91 bootstrap: declare local function static Sam Ravnborg 2 siblings, 0 replies; 7+ messages in thread From: Sam Ravnborg @ 2017-07-05 18:32 UTC (permalink / raw) To: barebox, Alexander Kurz, Uwe Kleine-König From 20397009e13e6111c8b17e5cbaf0addf3aaf593a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <srn@skov.dk> 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. Fixes: 90f7eacb ("clk: let clk_get return errors from of_clk_get_by_name") Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 6b1666355..abdc41527 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -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; } -- 2.12.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] gpio: fix null pointer exception when there is no oftree 2017-07-05 18:27 [PATCH v2 0/3] diverse at91 related fixes Sam Ravnborg 2017-07-05 18:32 ` [PATCH 1/3] clk: fix clk_get error handling Sam Ravnborg @ 2017-07-05 18:33 ` Sam Ravnborg 2017-07-06 12:46 ` Lucas Stach 2017-07-05 18:34 ` [PATCH 3/3] arm: at91 bootstrap: declare local function static Sam Ravnborg 2 siblings, 1 reply; 7+ messages in thread From: Sam Ravnborg @ 2017-07-05 18:33 UTC (permalink / raw) To: barebox, Alexander Kurz, Uwe Kleine-König From d10f426e1b8cec7de257dabf59e7fe53a591b3c1 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <srn@skov.dk> 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. Fixes: 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes") Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a3e17ada0..2bd8ef2a8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -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) -- 2.12.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree 2017-07-05 18:33 ` [PATCH 2/3] gpio: fix null pointer exception when there is no oftree Sam Ravnborg @ 2017-07-06 12:46 ` Lucas Stach 2017-07-06 20:53 ` Alexander Kurz 0 siblings, 1 reply; 7+ messages in thread From: Lucas Stach @ 2017-07-06 12:46 UTC (permalink / raw) To: Sam Ravnborg; +Cc: barebox, Alexander Kurz, Uwe Kleine-König Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg: > From d10f426e1b8cec7de257dabf59e7fe53a591b3c1 Mon Sep 17 00:00:00 2001 > From: Sam Ravnborg <srn@skov.dk> > 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. > > Fixes: 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes") > Signed-off-by: Alexander Kurz <akurz@blala.de> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org> > --- > drivers/gpio/gpiolib.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index a3e17ada0..2bd8ef2a8 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -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) I think this can be simplified to: diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a3e17ada0d39..1a373ef149a5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree 2017-07-06 12:46 ` Lucas Stach @ 2017-07-06 20:53 ` Alexander Kurz 2017-07-07 12:42 ` Lucas Stach 0 siblings, 1 reply; 7+ messages in thread From: Alexander Kurz @ 2017-07-06 20:53 UTC (permalink / raw) To: Lucas Stach; +Cc: barebox, Sam Ravnborg, Uwe Kleine-König On Thu, 6 Jul 2017, Lucas Stach wrote: > Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg: > > From d10f426e1b8cec7de257dabf59e7fe53a591b3c1 Mon Sep 17 00:00:00 2001 > > From: Sam Ravnborg <srn@skov.dk> > > 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. > > > > Fixes: 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes") > > Signed-off-by: Alexander Kurz <akurz@blala.de> > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org> > > --- > > drivers/gpio/gpiolib.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > index a3e17ada0..2bd8ef2a8 100644 > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -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) > > I think this can be simplified to: > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index a3e17ada0d39..1a373ef149a5 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -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. This works perfecty fine with gcc-5.2 and gcc-4.6 (although gcc-4.6 compatibilty broke with commit 4ef026c3048) Thanks, Alexander > > Regards, > Lucas > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] gpio: fix null pointer exception when there is no oftree 2017-07-06 20:53 ` Alexander Kurz @ 2017-07-07 12:42 ` Lucas Stach 0 siblings, 0 replies; 7+ messages in thread From: Lucas Stach @ 2017-07-07 12:42 UTC (permalink / raw) To: Alexander Kurz; +Cc: barebox, Sam Ravnborg, Uwe Kleine-König Am Donnerstag, den 06.07.2017, 22:53 +0200 schrieb Alexander Kurz: > > On Thu, 6 Jul 2017, Lucas Stach wrote: > > > Am Mittwoch, den 05.07.2017, 20:33 +0200 schrieb Sam Ravnborg: > > > From d10f426e1b8cec7de257dabf59e7fe53a591b3c1 Mon Sep 17 00:00:00 2001 > > > From: Sam Ravnborg <srn@skov.dk> > > > 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. > > > > > > Fixes: 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes") > > > Signed-off-by: Alexander Kurz <akurz@blala.de> > > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org> > > > --- > > > drivers/gpio/gpiolib.c | 8 +++++++- > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > > index a3e17ada0..2bd8ef2a8 100644 > > > --- a/drivers/gpio/gpiolib.c > > > +++ b/drivers/gpio/gpiolib.c > > > @@ -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) > > > > I think this can be simplified to: > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > index a3e17ada0d39..1a373ef149a5 100644 > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -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. > 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] arm: at91 bootstrap: declare local function static 2017-07-05 18:27 [PATCH v2 0/3] diverse at91 related fixes Sam Ravnborg 2017-07-05 18:32 ` [PATCH 1/3] clk: fix clk_get error handling Sam Ravnborg 2017-07-05 18:33 ` [PATCH 2/3] gpio: fix null pointer exception when there is no oftree Sam Ravnborg @ 2017-07-05 18:34 ` Sam Ravnborg 2 siblings, 0 replies; 7+ messages in thread From: Sam Ravnborg @ 2017-07-05 18:34 UTC (permalink / raw) To: barebox, Alexander Kurz, Uwe Kleine-König From 8eb65eccbdd304ba4fb06e8de2a958791e0077f0 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <srn@skov.dk> 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. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- arch/arm/mach-at91/bootstrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c index 9dd575b74..5d21b2d02 100644 --- a/arch/arm/mach-at91/bootstrap.c +++ b/arch/arm/mach-at91/bootstrap.c @@ -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; -- 2.12.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-07 12:43 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-07-05 18:27 [PATCH v2 0/3] diverse at91 related fixes Sam Ravnborg 2017-07-05 18:32 ` [PATCH 1/3] clk: fix clk_get error handling Sam Ravnborg 2017-07-05 18:33 ` [PATCH 2/3] gpio: fix null pointer exception when there is no oftree Sam Ravnborg 2017-07-06 12:46 ` Lucas Stach 2017-07-06 20:53 ` Alexander Kurz 2017-07-07 12:42 ` Lucas Stach 2017-07-05 18:34 ` [PATCH 3/3] arm: at91 bootstrap: declare local function static Sam Ravnborg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox