* [PATCH] power/reset: at91-poweroff: Fix error handling and other compiler warnings
@ 2014-10-11 0:41 Guenter Roeck
2014-10-13 11:00 ` Maxime Ripard
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2014-10-11 0:41 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel,
Guenter Roeck, Maxime Ripard, Nicolas Ferre
at91_poweroff_get_wakeup_mode can return a negative error code and should
therefore not return an enum type. Similar, its result should not be
assigned to an enum type. Otherwise, the returned value is never negative,
resulting in a compiler warning and a missed error condition, which in turn
results in writing bad values into a chip register.
Also fix other compiler warnings which can be easily avoided.
drivers/power/reset/at91-poweroff.c:74:24:
warning: type qualifiers ignored on function return type
drivers/power/reset/at91-poweroff.c:74:24:
warning: no previous prototype for 'at91_poweroff_get_wakeup_mode'
drivers/power/reset/at91-poweroff.c:83:16:
warning: comparison between signed and unsigned integer expressions
drivers/power/reset/at91-poweroff.c:97:2:
warning: comparison of unsigned expression < 0 is always false
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/power/reset/at91-poweroff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c
index c610003..4b72ea5 100644
--- a/drivers/power/reset/at91-poweroff.c
+++ b/drivers/power/reset/at91-poweroff.c
@@ -71,10 +71,11 @@ static void at91_poweroff(void)
writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, at91_shdwc_base + AT91_SHDW_CR);
}
-const enum wakeup_type at91_poweroff_get_wakeup_mode(struct device_node *np)
+static int at91_poweroff_get_wakeup_mode(struct device_node *np)
{
const char *pm;
- int err, i;
+ unsigned int i;
+ int err;
err = of_property_read_string(np, "atmel,wakeup-mode", &pm);
if (err < 0)
@@ -90,7 +91,7 @@ const enum wakeup_type at91_poweroff_get_wakeup_mode(struct device_node *np)
static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
- enum wakeup_type wakeup_mode;
+ int wakeup_mode;
u32 mode = 0, tmp;
wakeup_mode = at91_poweroff_get_wakeup_mode(np);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power/reset: at91-poweroff: Fix error handling and other compiler warnings
2014-10-11 0:41 [PATCH] power/reset: at91-poweroff: Fix error handling and other compiler warnings Guenter Roeck
@ 2014-10-13 11:00 ` Maxime Ripard
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2014-10-13 11:00 UTC (permalink / raw)
To: Guenter Roeck
Cc: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
linux-pm, linux-kernel, Nicolas Ferre
[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]
On Fri, Oct 10, 2014 at 05:41:17PM -0700, Guenter Roeck wrote:
> at91_poweroff_get_wakeup_mode can return a negative error code and should
> therefore not return an enum type. Similar, its result should not be
> assigned to an enum type. Otherwise, the returned value is never negative,
> resulting in a compiler warning and a missed error condition, which in turn
> results in writing bad values into a chip register.
>
> Also fix other compiler warnings which can be easily avoided.
>
> drivers/power/reset/at91-poweroff.c:74:24:
> warning: type qualifiers ignored on function return type
> drivers/power/reset/at91-poweroff.c:74:24:
> warning: no previous prototype for 'at91_poweroff_get_wakeup_mode'
> drivers/power/reset/at91-poweroff.c:83:16:
> warning: comparison between signed and unsigned integer expressions
> drivers/power/reset/at91-poweroff.c:97:2:
> warning: comparison of unsigned expression < 0 is always false
>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-13 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-11 0:41 [PATCH] power/reset: at91-poweroff: Fix error handling and other compiler warnings Guenter Roeck
2014-10-13 11:00 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).