kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] regulator: max77802: precedence error in max77802_set_suspend_mode()
@ 2014-10-24  8:16 Dan Carpenter
  2014-10-24  9:04 ` Javier Martinez Canillas
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-10-24  8:16 UTC (permalink / raw)
  To: Liam Girdwood, Javier Martinez Canillas
  Cc: Mark Brown, linux-kernel, kernel-janitors

The "!" operation has higher precedence that the comparison.

Fixes: 2e0eaa1aa008 ('regulator: max77802: Add set suspend mode for BUCKs and simplify code')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 5839c45..57e37fd 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -179,7 +179,7 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,
 	 * If the regulator has been disabled for suspend
 	 * then is invalid to try setting a suspend mode.
 	 */
-	if (!max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
+	if (max77802->opmode[id] != MAX77802_OFF_PWRREQ) {
 		dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n",
 			 rdev->desc->name, mode);
 		return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] regulator: max77802: precedence error in max77802_set_suspend_mode()
  2014-10-24  8:16 [patch] regulator: max77802: precedence error in max77802_set_suspend_mode() Dan Carpenter
@ 2014-10-24  9:04 ` Javier Martinez Canillas
  2014-10-27 10:45   ` [patch v2] regulator: max77802: fix a test " Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Javier Martinez Canillas @ 2014-10-24  9:04 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Mark Brown, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org

Hello Dan,

> On 24/10/2014, at 10:16, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> The "!" operation has higher precedence that the comparison.
> 
> Fixes: 2e0eaa1aa008 ('regulator: max77802: Add set suspend mode for BUCKs and simplify code')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
> index 5839c45..57e37fd 100644
> --- a/drivers/regulator/max77802.c
> +++ b/drivers/regulator/max77802.c
> @@ -179,7 +179,7 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,
>     * If the regulator has been disabled for suspend
>     * then is invalid to try setting a suspend mode.
>     */
> -    if (!max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
> +    if (max77802->opmode[id] != MAX77802_OFF_PWRREQ) {
>        dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n",
>             rdev->desc->name, mode);
>        return 0;

Thanks for the patch, there is indeed a typo error but $subject is not the correct fix.

The problem is that the "!" operator should not be in the expression so it has be removed and only compare if opmode is equal to MAX72802_OFF_PWRREQ.

With that change feel free to add my Reviewed-by.

Best regards,
Javier

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch v2] regulator: max77802: fix a test in max77802_set_suspend_mode()
  2014-10-24  9:04 ` Javier Martinez Canillas
@ 2014-10-27 10:45   ` Dan Carpenter
  2014-10-27 13:21     ` Javier Martinez Canillas
  2014-10-27 18:18     ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2014-10-27 10:45 UTC (permalink / raw)
  To: Liam Girdwood, Javier Martinez Canillas
  Cc: Mark Brown, linux-kernel, kernel-janitors

The original test triggers a static checker warning.  Javier Martinez
Canillas says that the "!" is a typo and should be removed.

Fixes: 2e0eaa1aa008 ('regulator: max77802: Add set suspend mode for BUCKs and simplify code')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2:  The first version of this patch was buggy.  Thanks Javier for
your review.

diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 5839c45..7718c8a 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -179,7 +179,7 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,
 	 * If the regulator has been disabled for suspend
 	 * then is invalid to try setting a suspend mode.
 	 */
-	if (!max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
+	if (max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
 		dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n",
 			 rdev->desc->name, mode);
 		return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch v2] regulator: max77802: fix a test in max77802_set_suspend_mode()
  2014-10-27 10:45   ` [patch v2] regulator: max77802: fix a test " Dan Carpenter
@ 2014-10-27 13:21     ` Javier Martinez Canillas
  2014-10-27 18:18     ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Javier Martinez Canillas @ 2014-10-27 13:21 UTC (permalink / raw)
  To: Dan Carpenter, Liam Girdwood; +Cc: Mark Brown, linux-kernel, kernel-janitors

Hello Dan,

On 10/27/2014 11:45 AM, Dan Carpenter wrote:
> The original test triggers a static checker warning.  Javier Martinez
> Canillas says that the "!" is a typo and should be removed.
> 
> Fixes: 2e0eaa1aa008 ('regulator: max77802: Add set suspend mode for BUCKs and simplify code')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2:  The first version of this patch was buggy.  Thanks Javier for
> your review.
> 
> diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
> index 5839c45..7718c8a 100644
> --- a/drivers/regulator/max77802.c
> +++ b/drivers/regulator/max77802.c
> @@ -179,7 +179,7 @@ static int max77802_set_suspend_mode(struct regulator_dev *rdev,
>  	 * If the regulator has been disabled for suspend
>  	 * then is invalid to try setting a suspend mode.
>  	 */
> -	if (!max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
> +	if (max77802->opmode[id] = MAX77802_OFF_PWRREQ) {
>  		dev_warn(&rdev->dev, "%s: is disabled, mode: 0x%x not set\n",
>  			 rdev->desc->name, mode);
>  		return 0;
> 

The typo was not found during testing because the expression always evaluated
to 0 which was expected since a regulator marked to be disabled for suspend
shouldn't have a suspend mode to be set.

But when trying to trigger that specific case the test was indeed failing and
the regulator mode was changed even when the regulator was marked as disabled.

This patch solves the issue by making max77802_set_suspend_mode() to return
early if the regulator was marked as disabled

Thanks a lot for finding this bug.

Acked-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>

Best regards,
Javier

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch v2] regulator: max77802: fix a test in max77802_set_suspend_mode()
  2014-10-27 10:45   ` [patch v2] regulator: max77802: fix a test " Dan Carpenter
  2014-10-27 13:21     ` Javier Martinez Canillas
@ 2014-10-27 18:18     ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2014-10-27 18:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Liam Girdwood, Javier Martinez Canillas, linux-kernel,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]

On Mon, Oct 27, 2014 at 01:45:06PM +0300, Dan Carpenter wrote:
> The original test triggers a static checker warning.  Javier Martinez
> Canillas says that the "!" is a typo and should be removed.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-27 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-24  8:16 [patch] regulator: max77802: precedence error in max77802_set_suspend_mode() Dan Carpenter
2014-10-24  9:04 ` Javier Martinez Canillas
2014-10-27 10:45   ` [patch v2] regulator: max77802: fix a test " Dan Carpenter
2014-10-27 13:21     ` Javier Martinez Canillas
2014-10-27 18:18     ` Mark Brown

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).