mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 10:46:33 +00:00
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>
This commit is contained in:
parent
41e71f9717
commit
2bfe814826
@ -174,10 +174,9 @@ static int __wait_status(u8 val)
|
|||||||
|
|
||||||
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
||||||
udelay(us);
|
udelay(us);
|
||||||
if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) {
|
if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -779,14 +778,12 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
|
|||||||
const char *sysfsbuf, size_t count)
|
const char *sysfsbuf, size_t count)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u32 speed;
|
unsigned long speed;
|
||||||
char newkey[5];
|
char newkey[5];
|
||||||
u8 buffer[2];
|
u8 buffer[2];
|
||||||
|
|
||||||
speed = simple_strtoul(sysfsbuf, NULL, 10);
|
if (strict_strtoul(sysfsbuf, 10, &speed) < 0 || speed >= 0x4000)
|
||||||
|
return -EINVAL; /* Bigger than a 14-bit value */
|
||||||
if (speed > 0x4000) /* Bigger than a 14-bit value */
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr));
|
sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr));
|
||||||
|
|
||||||
@ -822,10 +819,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u8 buffer[2];
|
u8 buffer[2];
|
||||||
u32 input;
|
unsigned long input;
|
||||||
u16 val;
|
u16 val;
|
||||||
|
|
||||||
input = simple_strtoul(sysfsbuf, NULL, 10);
|
if (strict_strtoul(sysfsbuf, 10, &input) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
|
ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
|
||||||
val = (buffer[0] << 8 | buffer[1]);
|
val = (buffer[0] << 8 | buffer[1]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user