diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2010-11-10 13:42:21 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-01-08 13:55:46 -0500 |
commit | 2bfe814826b7266a489895f731a777f8cbe37963 (patch) | |
tree | 9d4398dded8637c45ac24e06d59538cbad48513e /drivers/hwmon | |
parent | 41e71f97174ba08fcca7f31bf448de92abc8862e (diff) |
hwmon: (applesmc) Fix checkpatch errors and fix value range checks
This patch fixes all checkpatch errors and most of the checkpatch warnings.
It also fixes the range check in applesmc_store_fan_speed().
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/applesmc.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 81792ca47175..ce0372f0615e 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -174,9 +174,8 @@ static int __wait_status(u8 val) | |||
174 | 174 | ||
175 | for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) { | 175 | for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) { |
176 | udelay(us); | 176 | udelay(us); |
177 | if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) { | 177 | if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) |
178 | return 0; | 178 | return 0; |
179 | } | ||
180 | } | 179 | } |
181 | 180 | ||
182 | return -EIO; | 181 | return -EIO; |
@@ -431,7 +430,7 @@ static int applesmc_has_key(const char *key, bool *value) | |||
431 | /* | 430 | /* |
432 | * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). | 431 | * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). |
433 | */ | 432 | */ |
434 | static int applesmc_read_motion_sensor(int index, s16* value) | 433 | static int applesmc_read_motion_sensor(int index, s16 *value) |
435 | { | 434 | { |
436 | u8 buffer[2]; | 435 | u8 buffer[2]; |
437 | int ret; | 436 | int ret; |
@@ -779,14 +778,12 @@ static ssize_t applesmc_store_fan_speed(struct device *dev, | |||
779 | const char *sysfsbuf, size_t count) | 778 | const char *sysfsbuf, size_t count) |
780 | { | 779 | { |
781 | int ret; | 780 | int ret; |
782 | u32 speed; | 781 | unsigned long speed; |
783 | char newkey[5]; | 782 | char newkey[5]; |
784 | u8 buffer[2]; | 783 | u8 buffer[2]; |
785 | 784 | ||
786 | speed = simple_strtoul(sysfsbuf, NULL, 10); | 785 | if (strict_strtoul(sysfsbuf, 10, &speed) < 0 || speed >= 0x4000) |
787 | 786 | return -EINVAL; /* Bigger than a 14-bit value */ | |
788 | if (speed > 0x4000) /* Bigger than a 14-bit value */ | ||
789 | return -EINVAL; | ||
790 | 787 | ||
791 | sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr)); | 788 | sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr)); |
792 | 789 | ||
@@ -822,10 +819,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev, | |||
822 | { | 819 | { |
823 | int ret; | 820 | int ret; |
824 | u8 buffer[2]; | 821 | u8 buffer[2]; |
825 | u32 input; | 822 | unsigned long input; |
826 | u16 val; | 823 | u16 val; |
827 | 824 | ||
828 | input = simple_strtoul(sysfsbuf, NULL, 10); | 825 | if (strict_strtoul(sysfsbuf, 10, &input) < 0) |
826 | return -EINVAL; | ||
829 | 827 | ||
830 | ret = applesmc_read_key(FANS_MANUAL, buffer, 2); | 828 | ret = applesmc_read_key(FANS_MANUAL, buffer, 2); |
831 | val = (buffer[0] << 8 | buffer[1]); | 829 | val = (buffer[0] << 8 | buffer[1]); |
@@ -1198,24 +1196,24 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { | |||
1198 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir") }, | 1196 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir") }, |
1199 | }, | 1197 | }, |
1200 | { applesmc_dmi_match, "Apple MacBook Pro", { | 1198 | { applesmc_dmi_match, "Apple MacBook Pro", { |
1201 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1199 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1202 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") }, | 1200 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro") }, |
1203 | }, | 1201 | }, |
1204 | { applesmc_dmi_match, "Apple MacBook", { | 1202 | { applesmc_dmi_match, "Apple MacBook", { |
1205 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1203 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1206 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") }, | 1204 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBook") }, |
1207 | }, | 1205 | }, |
1208 | { applesmc_dmi_match, "Apple Macmini", { | 1206 | { applesmc_dmi_match, "Apple Macmini", { |
1209 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1207 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1210 | DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") }, | 1208 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini") }, |
1211 | }, | 1209 | }, |
1212 | { applesmc_dmi_match, "Apple MacPro", { | 1210 | { applesmc_dmi_match, "Apple MacPro", { |
1213 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | 1211 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1214 | DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, | 1212 | DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, |
1215 | }, | 1213 | }, |
1216 | { applesmc_dmi_match, "Apple iMac", { | 1214 | { applesmc_dmi_match, "Apple iMac", { |
1217 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1215 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1218 | DMI_MATCH(DMI_PRODUCT_NAME,"iMac") }, | 1216 | DMI_MATCH(DMI_PRODUCT_NAME, "iMac") }, |
1219 | }, | 1217 | }, |
1220 | { .ident = NULL } | 1218 | { .ident = NULL } |
1221 | }; | 1219 | }; |