diff for duplicates of <1469896245.3998.113.camel@perches.com> diff --git a/a/1.txt b/N1/1.txt index b9d79d4..53b8b29 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -2,17 +2,17 @@ On Sat, 2016-07-30 at 13:22 +0200, Robert Jarzmik wrote: > The commit 9bf448c66d4b ("ARM: pxa: use generic gpio operation instead of > gpio register") from Oct 17, 2011, leads to the following static checker > warning: -> ? arch/arm/mach-pxa/spitz_pm.c:172 spitz_charger_wakeup() -> ? warn: double left shift '!gpio_get_value(SPITZ_GPIO_KEY_INT) -> ????????<< (1 << ((SPITZ_GPIO_KEY_INT) & 31))' +> arch/arm/mach-pxa/spitz_pm.c:172 spitz_charger_wakeup() +> warn: double left shift '!gpio_get_value(SPITZ_GPIO_KEY_INT) +> << (1 << ((SPITZ_GPIO_KEY_INT) & 31))' > > As Dan reported, the value is shifted three times : -> ?- once by gpio_get_value(), which returns either 0 or BIT(gpio) -> ?- once by the shift operation '<<' -> ?- a last time by GPIO_bit(gpio) which is BIT(gpio) +> - once by gpio_get_value(), which returns either 0 or BIT(gpio) +> - once by the shift operation '<<' +> - a last time by GPIO_bit(gpio) which is BIT(gpio) > > Therefore the calculation lead to a chained or operator of : -> ?- (1 << gpio) << (1 << gpio) = (2^gpio)^gpio = 2 ^ (gpio * gpio) +> - (1 << gpio) << (1 << gpio) = (2^gpio)^gpio = 2 ^ (gpio * gpio) > > It is be sheer luck the former statement works, only because each gpio > used is strictly smaller than 6, and therefore 2^(gpio^2) never @@ -21,14 +21,14 @@ On Sat, 2016-07-30 at 13:22 +0200, Robert Jarzmik wrote: It may be better to change the charger_wakeup callback return value from unsigned long to bool and modify the other use in -spitz_pm.c? +spitz_pm.c $ git grep -w charger_wakeup -arch/arm/mach-pxa/corgi_pm.c:???.charger_wakeup??= corgi_charger_wakeup, -arch/arm/mach-pxa/sharpsl_pm.c:?????????????????if (sharpsl_pm.machinfo->charger_wakeup() != 0) -arch/arm/mach-pxa/sharpsl_pm.c:?????????if (sharpsl_pm.machinfo->charger_wakeup()) +arch/arm/mach-pxa/corgi_pm.c: .charger_wakeup = corgi_charger_wakeup, +arch/arm/mach-pxa/sharpsl_pm.c: if (sharpsl_pm.machinfo->charger_wakeup() != 0) +arch/arm/mach-pxa/sharpsl_pm.c: if (sharpsl_pm.machinfo->charger_wakeup()) arch/arm/mach-pxa/sharpsl_pm.h: unsigned long (*charger_wakeup)(void); -arch/arm/mach-pxa/spitz_pm.c:???.charger_wakeup???= spitz_charger_wakeup, +arch/arm/mach-pxa/spitz_pm.c: .charger_wakeup = spitz_charger_wakeup, > Fixes: 9bf448c66d4b ("ARM: pxa: use generic gpio operation instead of > gpio register") @@ -37,18 +37,18 @@ arch/arm/mach-pxa/spitz_pm.c:???.charger_wakeup???= spitz_charger_wakeup, > --- > Since v1: replaced binary ORs with logical ORs after assembly comparison > --- -> ?arch/arm/mach-pxa/corgi_pm.c | 8 +++----- -> ?arch/arm/mach-pxa/spitz_pm.c | 5 ++--- -> ?2 files changed, 5 insertions(+), 8 deletions(-) +> arch/arm/mach-pxa/corgi_pm.c | 8 +++----- +> arch/arm/mach-pxa/spitz_pm.c | 5 ++--- +> 2 files changed, 5 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c > index d9206811be9b..8dc39d602884 100644 > --- a/arch/arm/mach-pxa/corgi_pm.c > +++ b/arch/arm/mach-pxa/corgi_pm.c > @@ -135,11 +135,9 @@ static unsigned long corgi_charger_wakeup(void) -> ?{ -> ? unsigned long ret; -> ? +> { +> unsigned long ret; +> > - ret = (!gpio_get_value(CORGI_GPIO_AC_IN) << GPIO_bit(CORGI_GPIO_AC_IN)) > - | (!gpio_get_value(CORGI_GPIO_KEY_INT) > - << GPIO_bit(CORGI_GPIO_KEY_INT)) @@ -57,22 +57,22 @@ arch/arm/mach-pxa/spitz_pm.c:???.charger_wakeup???= spitz_charger_wakeup, > + ret = !gpio_get_value(CORGI_GPIO_AC_IN) > + || !gpio_get_value(CORGI_GPIO_KEY_INT) > + || !gpio_get_value(CORGI_GPIO_WAKEUP); -> ? return ret; -> ?} -> ? +> return ret; +> } +> > diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c > index ea9f9034cb54..dd85869f6f99 100644 > --- a/arch/arm/mach-pxa/spitz_pm.c > +++ b/arch/arm/mach-pxa/spitz_pm.c > @@ -168,9 +168,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm) -> ?static unsigned long spitz_charger_wakeup(void) -> ?{ -> ? unsigned long ret; +> static unsigned long spitz_charger_wakeup(void) +> { +> unsigned long ret; > - ret = ((!gpio_get_value(SPITZ_GPIO_KEY_INT) > - << GPIO_bit(SPITZ_GPIO_KEY_INT)) > - | gpio_get_value(SPITZ_GPIO_SYNC)); > + ret = !gpio_get_value(SPITZ_GPIO_KEY_INT) > + || gpio_get_value(SPITZ_GPIO_SYNC); -> ? return ret; -> ?} -> ? +> return ret; +> } +> diff --git a/a/content_digest b/N1/content_digest index 7a9c7ec..52620ec 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,25 +1,30 @@ "ref\01469877735-30127-1-git-send-email-robert.jarzmik@free.fr\0" - "From\0joe@perches.com (Joe Perches)\0" - "Subject\0[PATCH v2] ARM: pxa: fix GPIO double shifts\0" + "From\0Joe Perches <joe@perches.com>\0" + "Subject\0Re: [PATCH v2] ARM: pxa: fix GPIO double shifts\0" "Date\0Sat, 30 Jul 2016 09:30:45 -0700\0" - "To\0linux-arm-kernel@lists.infradead.org\0" + "To\0Robert Jarzmik <robert.jarzmik@free.fr>" + Daniel Mack <daniel@zonque.org> + Haojian Zhuang <haojian.zhuang@gmail.com> + " Russell King <linux@armlinux.org.uk>\0" + "Cc\0linux-arm-kernel@lists.infradead.org" + " linux-kernel@vger.kernel.org\0" "\00:1\0" "b\0" "On Sat, 2016-07-30 at 13:22 +0200, Robert Jarzmik wrote:\n" "> The commit 9bf448c66d4b (\"ARM: pxa: use generic gpio operation instead of\n" "> gpio register\") from Oct 17, 2011, leads to the following static checker\n" "> warning:\n" - "> ? arch/arm/mach-pxa/spitz_pm.c:172 spitz_charger_wakeup()\n" - "> ? warn: double left shift '!gpio_get_value(SPITZ_GPIO_KEY_INT)\n" - "> ????????<< (1 << ((SPITZ_GPIO_KEY_INT) & 31))'\n" + "> \302\240 arch/arm/mach-pxa/spitz_pm.c:172 spitz_charger_wakeup()\n" + "> \302\240 warn: double left shift '!gpio_get_value(SPITZ_GPIO_KEY_INT)\n" + "> \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240<< (1 << ((SPITZ_GPIO_KEY_INT) & 31))'\n" "> \n" "> As Dan reported, the value is shifted three times :\n" - "> ?- once by gpio_get_value(), which returns either 0 or BIT(gpio)\n" - "> ?- once by the shift operation '<<'\n" - "> ?- a last time by GPIO_bit(gpio) which is BIT(gpio)\n" + "> \302\240- once by gpio_get_value(), which returns either 0 or BIT(gpio)\n" + "> \302\240- once by the shift operation '<<'\n" + "> \302\240- a last time by GPIO_bit(gpio) which is BIT(gpio)\n" "> \n" "> Therefore the calculation lead to a chained or operator of :\n" - "> ?- (1 << gpio) << (1 << gpio) = (2^gpio)^gpio = 2 ^ (gpio * gpio)\n" + "> \302\240- (1 << gpio) << (1 << gpio) = (2^gpio)^gpio = 2 ^ (gpio * gpio)\n" "> \n" "> It is be sheer luck the former statement works, only because each gpio\n" "> used is strictly smaller than 6, and therefore 2^(gpio^2) never\n" @@ -28,14 +33,14 @@ "\n" "It may be better to change the charger_wakeup callback return\n" "value from unsigned long to bool and modify the other use in\n" - "spitz_pm.c?\n" + "spitz_pm.c\302\240\n" "\n" "$ git grep -w charger_wakeup\n" - "arch/arm/mach-pxa/corgi_pm.c:???.charger_wakeup??= corgi_charger_wakeup,\n" - "arch/arm/mach-pxa/sharpsl_pm.c:?????????????????if (sharpsl_pm.machinfo->charger_wakeup() != 0)\n" - "arch/arm/mach-pxa/sharpsl_pm.c:?????????if (sharpsl_pm.machinfo->charger_wakeup())\n" + "arch/arm/mach-pxa/corgi_pm.c:\302\240\302\240\302\240.charger_wakeup\302\240\302\240= corgi_charger_wakeup,\n" + "arch/arm/mach-pxa/sharpsl_pm.c:\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (sharpsl_pm.machinfo->charger_wakeup() != 0)\n" + "arch/arm/mach-pxa/sharpsl_pm.c:\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (sharpsl_pm.machinfo->charger_wakeup())\n" "arch/arm/mach-pxa/sharpsl_pm.h: unsigned long (*charger_wakeup)(void);\n" - "arch/arm/mach-pxa/spitz_pm.c:???.charger_wakeup???= spitz_charger_wakeup,\n" + "arch/arm/mach-pxa/spitz_pm.c:\302\240\302\240\302\240.charger_wakeup\302\240\302\240\302\240= spitz_charger_wakeup,\n" "\n" "> Fixes: 9bf448c66d4b (\"ARM: pxa: use generic gpio operation instead of\n" "> gpio register\")\n" @@ -44,18 +49,18 @@ "> ---\n" "> Since v1: replaced binary ORs with logical ORs after assembly comparison\n" "> ---\n" - "> ?arch/arm/mach-pxa/corgi_pm.c | 8 +++-----\n" - "> ?arch/arm/mach-pxa/spitz_pm.c | 5 ++---\n" - "> ?2 files changed, 5 insertions(+), 8 deletions(-)\n" + "> \302\240arch/arm/mach-pxa/corgi_pm.c | 8 +++-----\n" + "> \302\240arch/arm/mach-pxa/spitz_pm.c | 5 ++---\n" + "> \302\2402 files changed, 5 insertions(+), 8 deletions(-)\n" "> \n" "> diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c\n" "> index d9206811be9b..8dc39d602884 100644\n" "> --- a/arch/arm/mach-pxa/corgi_pm.c\n" "> +++ b/arch/arm/mach-pxa/corgi_pm.c\n" "> @@ -135,11 +135,9 @@ static unsigned long corgi_charger_wakeup(void)\n" - "> ?{\n" - "> ?\tunsigned long ret;\n" - "> ?\n" + "> \302\240{\n" + "> \302\240\tunsigned long ret;\n" + "> \302\240\n" "> -\tret = (!gpio_get_value(CORGI_GPIO_AC_IN) << GPIO_bit(CORGI_GPIO_AC_IN))\n" "> -\t\t| (!gpio_get_value(CORGI_GPIO_KEY_INT)\n" "> -\t\t<< GPIO_bit(CORGI_GPIO_KEY_INT))\n" @@ -64,24 +69,24 @@ "> +\tret = !gpio_get_value(CORGI_GPIO_AC_IN)\n" "> +\t\t|| !gpio_get_value(CORGI_GPIO_KEY_INT)\n" "> +\t\t|| !gpio_get_value(CORGI_GPIO_WAKEUP);\n" - "> ?\treturn ret;\n" - "> ?}\n" - "> ?\n" + "> \302\240\treturn ret;\n" + "> \302\240}\n" + "> \302\240\n" "> diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c\n" "> index ea9f9034cb54..dd85869f6f99 100644\n" "> --- a/arch/arm/mach-pxa/spitz_pm.c\n" "> +++ b/arch/arm/mach-pxa/spitz_pm.c\n" "> @@ -168,9 +168,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm)\n" - "> ?static unsigned long spitz_charger_wakeup(void)\n" - "> ?{\n" - "> ?\tunsigned long ret;\n" + "> \302\240static unsigned long spitz_charger_wakeup(void)\n" + "> \302\240{\n" + "> \302\240\tunsigned long ret;\n" "> -\tret = ((!gpio_get_value(SPITZ_GPIO_KEY_INT)\n" "> -\t\t<< GPIO_bit(SPITZ_GPIO_KEY_INT))\n" "> -\t\t| gpio_get_value(SPITZ_GPIO_SYNC));\n" "> +\tret = !gpio_get_value(SPITZ_GPIO_KEY_INT)\n" "> +\t\t|| gpio_get_value(SPITZ_GPIO_SYNC);\n" - "> ?\treturn ret;\n" - "> ?}\n" - > ? + "> \302\240\treturn ret;\n" + "> \302\240}\n" + > -fb65a1c0db94ce4a62baf5e43b72edfcbc008a785f779c1371594c9872b4977f +dd1d0db68203c63ffb66902e78402e644b28f5b5063374324130b87b368a1d8d
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.