Skip to contentSkip to conversation

mfd: fix check on unsigned in twl4030_configure_resource()

PATCH In review Roel Kluin 2 participants 2 messages Oct 21, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 mfd: fix check on unsigned in twl4030_configure_resource()

struct twl4030_resconfig members devgroup, type and type2 are unsigned.

---
`git grep devgroup' and notice that these are initialized to -1 in arch/arm/mach-omap2/board-rx51-peripherals.c:383-397

Is this the right fix?

drivers/mfd/twl4030-power.c +3 -3
index d423e0c..cc984a5 100644
@@ -335,7 +335,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
 		return err;
 	}
 
-	if (rconfig->devgroup >= 0) {
+	if (rconfig->devgroup != -1) {
 		grp &= ~DEVGROUP_MASK;
 		grp |= rconfig->devgroup << DEVGROUP_SHIFT;
 		err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
@@ -355,12 +355,12 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
 		return err;
 	}
 
-	if (rconfig->type >= 0) {
+	if (rconfig->type != -1) {
 		type &= ~TYPE_MASK;
 		type |= rconfig->type << TYPE_SHIFT;
 	}
 
-	if (rconfig->type2 >= 0) {
+	if (rconfig->type2 != -1) {
 		type &= ~TYPE2_MASK;
 		type |= rconfig->type2 << TYPE2_SHIFT;
 	}
#1 lore raw
Quoted 9 lines · Roel Kluin

struct twl4030_resconfig members devgroup, type and type2 are unsigned.

---
`git grep devgroup' and notice that these are initialized to -1 in arch/arm/mach-omap2/board-rx51-peripherals.c:383-397

Is this the right fix?

Yes it is. Aaro beat you to it though [1] :)

Regards,
Amit

[1]. http://git.kernel.org/?p=linux/kernel/git/sameo/mfd-2.6.git;a=commitdiff;h=86db38dffd5903e2fbb4268e46fd8a07a5ceb8ac

Quoted 29 lines
drivers/mfd/twl4030-power.c +3 -3
index d423e0c..cc984a5 100644
@@ -335,7 +335,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
                return err;
        }
 
-       if (rconfig->devgroup >= 0) {
+       if (rconfig->devgroup != -1) {
                grp &= ~DEVGROUP_MASK;
                grp |= rconfig->devgroup << DEVGROUP_SHIFT;
                err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
@@ -355,12 +355,12 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
                return err;
        }
 
-       if (rconfig->type >= 0) {
+       if (rconfig->type != -1) {
                type &= ~TYPE_MASK;
                type |= rconfig->type << TYPE_SHIFT;
        }
 
-       if (rconfig->type2 >= 0) {
+       if (rconfig->type2 != -1) {
                type &= ~TYPE2_MASK;
                type |= rconfig->type2 << TYPE2_SHIFT;
        }