* Client data (each client gets its own)
*/
-struct max6650_data
-{
+struct max6650_data {
struct device *hwmon_dev;
struct mutex update_lock;
int nr_fans;
{
struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client);
- int rpm = simple_strtoul(buf, NULL, 10);
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);
{
struct i2c_client *client = to_i2c_client(dev);
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);
{
struct i2c_client *client = to_i2c_client(dev);
struct max6650_data *data = i2c_get_clientdata(client);
- int mode = simple_strtoul(buf, NULL, 10);
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)) {
- dev_err(&client->dev,
- "illegal value for pwm1_enable (%d)\n", mode);
+ if (mode > 2)
return -EINVAL;
- }
mutex_lock(&data->update_lock);
{
struct i2c_client *client = to_i2c_client(dev);
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);
switch (div) {
break;
default:
mutex_unlock(&data->update_lock);
- dev_err(&client->dev,
- "illegal value for fan divider (%d)\n", div);
return -EINVAL;
}
struct max6650_data *data;
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");
return -ENOMEM;
}
}
switch (fan_voltage) {
- case 0:
- break;
- case 5:
- config &= ~MAX6650_CFG_V12;
- break;
- case 12:
- config |= MAX6650_CFG_V12;
- break;
- default:
- dev_err(&client->dev,
- "illegal value for fan_voltage (%d)\n",
- fan_voltage);
+ case 0:
+ break;
+ case 5:
+ config &= ~MAX6650_CFG_V12;
+ break;
+ case 12:
+ config |= MAX6650_CFG_V12;
+ break;
+ default:
+ dev_err(&client->dev, "illegal value for fan_voltage (%d)\n",
+ fan_voltage);
}
dev_info(&client->dev, "Fan voltage is set to %dV.\n",
(config & MAX6650_CFG_V12) ? 12 : 5);
switch (prescaler) {
- case 0:
- break;
- case 1:
- config &= ~MAX6650_CFG_PRESCALER_MASK;
- break;
- case 2:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_2;
- break;
- case 4:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_4;
- break;
- case 8:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_8;
- break;
- case 16:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_16;
- break;
- default:
- dev_err(&client->dev,
- "illegal value for prescaler (%d)\n",
- prescaler);
+ case 0:
+ break;
+ case 1:
+ config &= ~MAX6650_CFG_PRESCALER_MASK;
+ break;
+ case 2:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_2;
+ break;
+ case 4:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_4;
+ break;
+ case 8:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_8;
+ break;
+ case 16:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_16;
+ break;
+ default:
+ dev_err(&client->dev, "illegal value for prescaler (%d)\n",
+ prescaler);
}
dev_info(&client->dev, "Prescaler is set to %d.\n",