提交 bafda5d0 编写于 作者: G Guenter Roeck 提交者: Guenter Roeck

hwmon: (max6650) Fix checkpatch issues

Fixed:
ERROR: do not use assignment in if condition
ERROR: open brace '{' following struct go on the same line
ERROR: spaces required around that '||' (ctx:VxV)
ERROR: switch and case should be at the same indent
WARNING: simple_strtoul is obsolete, use kstrtoul instead

Cc: Hans J. Koch <hjk@hansjkoch.de>
Acked-by: NHans J. Koch <hjk@hansjkoch.de>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 0117c3f2
...@@ -135,8 +135,7 @@ static struct i2c_driver max6650_driver = { ...@@ -135,8 +135,7 @@ static struct i2c_driver max6650_driver = {
* Client data (each client gets its own) * Client data (each client gets its own)
*/ */
struct max6650_data struct max6650_data {
{
struct device *hwmon_dev; struct device *hwmon_dev;
struct mutex update_lock; struct mutex update_lock;
int nr_fans; int nr_fans;
...@@ -238,8 +237,13 @@ static ssize_t set_target(struct device *dev, struct device_attribute *devattr, ...@@ -238,8 +237,13 @@ static ssize_t set_target(struct device *dev, struct device_attribute *devattr,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client); struct max6650_data *data = i2c_get_clientdata(client);
int rpm = simple_strtoul(buf, NULL, 10);
int kscale, ktach; int kscale, ktach;
unsigned long rpm;
int err;
err = kstrtoul(buf, 10, &rpm);
if (err)
return err;
rpm = SENSORS_LIMIT(rpm, FAN_RPM_MIN, FAN_RPM_MAX); rpm = SENSORS_LIMIT(rpm, FAN_RPM_MIN, FAN_RPM_MAX);
...@@ -300,7 +304,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, ...@@ -300,7 +304,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client); struct max6650_data *data = i2c_get_clientdata(client);
int pwm = simple_strtoul(buf, NULL, 10); unsigned long pwm;
int err;
err = kstrtoul(buf, 10, &pwm);
if (err)
return err;
pwm = SENSORS_LIMIT(pwm, 0, 255); pwm = SENSORS_LIMIT(pwm, 0, 255);
...@@ -341,14 +350,16 @@ static ssize_t set_enable(struct device *dev, struct device_attribute *devattr, ...@@ -341,14 +350,16 @@ static ssize_t set_enable(struct device *dev, struct device_attribute *devattr,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client); struct max6650_data *data = i2c_get_clientdata(client);
int mode = simple_strtoul(buf, NULL, 10);
int max6650_modes[3] = {0, 3, 2}; int max6650_modes[3] = {0, 3, 2};
unsigned long mode;
int err;
err = kstrtoul(buf, 10, &mode);
if (err)
return err;
if ((mode < 0)||(mode > 2)) { if (mode > 2)
dev_err(&client->dev,
"illegal value for pwm1_enable (%d)\n", mode);
return -EINVAL; return -EINVAL;
}
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -389,7 +400,12 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr, ...@@ -389,7 +400,12 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client); struct max6650_data *data = i2c_get_clientdata(client);
int div = simple_strtoul(buf, NULL, 10); unsigned long div;
int err;
err = kstrtoul(buf, 10, &div);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
switch (div) { switch (div) {
...@@ -407,8 +423,6 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr, ...@@ -407,8 +423,6 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr,
break; break;
default: default:
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
dev_err(&client->dev,
"illegal value for fan divider (%d)\n", div);
return -EINVAL; return -EINVAL;
} }
...@@ -529,7 +543,8 @@ static int max6650_probe(struct i2c_client *client, ...@@ -529,7 +543,8 @@ static int max6650_probe(struct i2c_client *client,
struct max6650_data *data; struct max6650_data *data;
int err; int err;
if (!(data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL))) { data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL);
if (!data) {
dev_err(&client->dev, "out of memory.\n"); dev_err(&client->dev, "out of memory.\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -596,49 +611,47 @@ static int max6650_init_client(struct i2c_client *client) ...@@ -596,49 +611,47 @@ static int max6650_init_client(struct i2c_client *client)
} }
switch (fan_voltage) { switch (fan_voltage) {
case 0: case 0:
break; break;
case 5: case 5:
config &= ~MAX6650_CFG_V12; config &= ~MAX6650_CFG_V12;
break; break;
case 12: case 12:
config |= MAX6650_CFG_V12; config |= MAX6650_CFG_V12;
break; break;
default: default:
dev_err(&client->dev, dev_err(&client->dev, "illegal value for fan_voltage (%d)\n",
"illegal value for fan_voltage (%d)\n", fan_voltage);
fan_voltage);
} }
dev_info(&client->dev, "Fan voltage is set to %dV.\n", dev_info(&client->dev, "Fan voltage is set to %dV.\n",
(config & MAX6650_CFG_V12) ? 12 : 5); (config & MAX6650_CFG_V12) ? 12 : 5);
switch (prescaler) { switch (prescaler) {
case 0: case 0:
break; break;
case 1: case 1:
config &= ~MAX6650_CFG_PRESCALER_MASK; config &= ~MAX6650_CFG_PRESCALER_MASK;
break; break;
case 2: case 2:
config = (config & ~MAX6650_CFG_PRESCALER_MASK) config = (config & ~MAX6650_CFG_PRESCALER_MASK)
| MAX6650_CFG_PRESCALER_2; | MAX6650_CFG_PRESCALER_2;
break; break;
case 4: case 4:
config = (config & ~MAX6650_CFG_PRESCALER_MASK) config = (config & ~MAX6650_CFG_PRESCALER_MASK)
| MAX6650_CFG_PRESCALER_4; | MAX6650_CFG_PRESCALER_4;
break; break;
case 8: case 8:
config = (config & ~MAX6650_CFG_PRESCALER_MASK) config = (config & ~MAX6650_CFG_PRESCALER_MASK)
| MAX6650_CFG_PRESCALER_8; | MAX6650_CFG_PRESCALER_8;
break; break;
case 16: case 16:
config = (config & ~MAX6650_CFG_PRESCALER_MASK) config = (config & ~MAX6650_CFG_PRESCALER_MASK)
| MAX6650_CFG_PRESCALER_16; | MAX6650_CFG_PRESCALER_16;
break; break;
default: default:
dev_err(&client->dev, dev_err(&client->dev, "illegal value for prescaler (%d)\n",
"illegal value for prescaler (%d)\n", prescaler);
prescaler);
} }
dev_info(&client->dev, "Prescaler is set to %d.\n", dev_info(&client->dev, "Prescaler is set to %d.\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册