From: Aaro Koskinen <aaro.koskinen@nokia.com>
To: sameo@linux.intel.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] mfd: twl4030-power: fix undefined resconfig value checks
Date: Wed, 14 Oct 2009 15:15:50 +0300 [thread overview]
Message-ID: <1255522550-15199-2-git-send-email-aaro.koskinen@nokia.com> (raw)
In-Reply-To: <1255522550-15199-1-git-send-email-aaro.koskinen@nokia.com>
The code tries to skip values initialized with -1, but since the values
are unsigned the comparison is always true.
The patch eliminates the following compiler warnings:
drivers/mfd/twl4030-power.c: In function 'twl4030_configure_resource':
drivers/mfd/twl4030-power.c:338: warning: comparison is always true due to limited range of data type
drivers/mfd/twl4030-power.c:358: warning: comparison is always true due to limited range of data type
drivers/mfd/twl4030-power.c:363: warning: comparison is always true due to limited range of data type
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
drivers/mfd/twl4030-power.c | 6 +++---
include/linux/i2c/twl4030.h | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index eae6cda..2f7c805 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -335,7 +335,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
return err;
}
- if (rconfig->devgroup >= 0) {
+ if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) {
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 != TWL4030_RESCONFIG_UNDEF) {
type &= ~TYPE_MASK;
type |= rconfig->type << TYPE_SHIFT;
}
- if (rconfig->type2 >= 0) {
+ if (rconfig->type2 != TWL4030_RESCONFIG_UNDEF) {
type &= ~TYPE2_MASK;
type |= rconfig->type2 << TYPE2_SHIFT;
}
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 508824e..99e5d7b 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -391,6 +391,7 @@ struct twl4030_resconfig {
u8 devgroup; /* Processor group that Power resource belongs to */
u8 type; /* Power resource addressed, 6 / broadcast message */
u8 type2; /* Power resource addressed, 3 / broadcast message */
+#define TWL4030_RESCONFIG_UNDEF ((u8)-1)
};
struct twl4030_power_data {
--
1.6.0.4
next prev parent reply other threads:[~2009-10-14 12:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 12:15 [PATCH 1/2] mfd: twl4030-power: do not allow negative or zero length script Aaro Koskinen
2009-10-14 12:15 ` Aaro Koskinen [this message]
2009-10-19 16:37 ` Samuel Ortiz
2009-10-20 10:21 ` Aaro Koskinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1255522550-15199-2-git-send-email-aaro.koskinen@nokia.com \
--to=aaro.koskinen@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®