summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/ucd9200.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-08-31 17:53:41 +0200
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-09-06 17:56:07 +0200
commitf020b007d5dd24597f5e985a6309bcb8393797ed (patch)
tree17d7db505904c9cb57c79e586d31eb79376dd9b6 /drivers/hwmon/pmbus/ucd9200.c
parenthwmon: (max16065) Add chip access warning to documentation (diff)
downloadlinux-f020b007d5dd24597f5e985a6309bcb8393797ed.tar.xz
linux-f020b007d5dd24597f5e985a6309bcb8393797ed.zip
hwmon: (ucd9000/ucd9200) Optimize array walk
Rewrite the loop walking the id array during probe. The new code is better adapted to a null-terminated array, and is also clearer and more efficient than the original. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Axel Lin <axel.lin@gmail.com> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to '')
-rw-r--r--drivers/hwmon/pmbus/ucd9200.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c
index ffcc1cf3609d..c65e9da707cc 100644
--- a/drivers/hwmon/pmbus/ucd9200.c
+++ b/drivers/hwmon/pmbus/ucd9200.c
@@ -68,13 +68,11 @@ static int ucd9200_probe(struct i2c_client *client,
block_buffer[ret] = '\0';
dev_info(&client->dev, "Device ID %s\n", block_buffer);
- mid = NULL;
- for (i = 0; i < ARRAY_SIZE(ucd9200_id); i++) {
- mid = &ucd9200_id[i];
+ for (mid = ucd9200_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}
- if (!mid || !strlen(mid->name)) {
+ if (!mid->name[0]) {
dev_err(&client->dev, "Unsupported device\n");
return -ENODEV;
}