Commit 662bda28328b983f842f008a81a5fd4e6de6c5fe

Authored by Guenter Roeck
Committed by Jean Delvare
1 parent 012f3b9118

hwmon: (lm63) Fix checkpatch errors

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Tested-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>

Showing 1 changed file with 53 additions and 21 deletions Side-by-side Diff

drivers/hwmon/lm63.c
... ... @@ -204,8 +204,13 @@
204 204 {
205 205 struct i2c_client *client = to_i2c_client(dev);
206 206 struct lm63_data *data = i2c_get_clientdata(client);
207   - unsigned long val = simple_strtoul(buf, NULL, 10);
  207 + unsigned long val;
  208 + int err;
208 209  
  210 + err = kstrtoul(buf, 10, &val);
  211 + if (err)
  212 + return err;
  213 +
209 214 mutex_lock(&data->update_lock);
210 215 data->fan[1] = FAN_TO_REG(val);
211 216 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
212 217  
... ... @@ -231,11 +236,15 @@
231 236 struct i2c_client *client = to_i2c_client(dev);
232 237 struct lm63_data *data = i2c_get_clientdata(client);
233 238 unsigned long val;
234   -
  239 + int err;
  240 +
235 241 if (!(data->config_fan & 0x20)) /* register is read-only */
236 242 return -EPERM;
237 243  
238   - val = simple_strtoul(buf, NULL, 10);
  244 + err = kstrtoul(buf, 10, &val);
  245 + if (err)
  246 + return err;
  247 +
239 248 mutex_lock(&data->update_lock);
240 249 data->pwm1_value = val <= 0 ? 0 :
241 250 val >= 255 ? 2 * data->pwm1_freq :
... ... @@ -245,8 +254,8 @@
245 254 return count;
246 255 }
247 256  
248   -static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy,
249   - char *buf)
  257 +static ssize_t show_pwm1_enable(struct device *dev,
  258 + struct device_attribute *dummy, char *buf)
250 259 {
251 260 struct lm63_data *data = lm63_update_device(dev);
252 261 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
253 262  
... ... @@ -283,8 +292,13 @@
283 292 {
284 293 struct i2c_client *client = to_i2c_client(dev);
285 294 struct lm63_data *data = i2c_get_clientdata(client);
286   - long val = simple_strtol(buf, NULL, 10);
  295 + long val;
  296 + int err;
287 297  
  298 + err = kstrtol(buf, 10, &val);
  299 + if (err)
  300 + return err;
  301 +
288 302 mutex_lock(&data->update_lock);
289 303 data->temp8[1] = TEMP8_TO_REG(val);
290 304 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
291 305  
... ... @@ -314,9 +328,14 @@
314 328 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
315 329 struct i2c_client *client = to_i2c_client(dev);
316 330 struct lm63_data *data = i2c_get_clientdata(client);
317   - long val = simple_strtol(buf, NULL, 10);
  331 + long val;
  332 + int err;
318 333 int nr = attr->index;
319 334  
  335 + err = kstrtol(buf, 10, &val);
  336 + if (err)
  337 + return err;
  338 +
320 339 mutex_lock(&data->update_lock);
321 340 data->temp11[nr] = TEMP11_TO_REG(val - data->temp2_offset);
322 341 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
... ... @@ -327,10 +346,12 @@
327 346 return count;
328 347 }
329 348  
330   -/* Hysteresis register holds a relative value, while we want to present
331   - an absolute to user-space */
332   -static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy,
333   - char *buf)
  349 +/*
  350 + * Hysteresis register holds a relative value, while we want to present
  351 + * an absolute to user-space
  352 + */
  353 +static ssize_t show_temp2_crit_hyst(struct device *dev,
  354 + struct device_attribute *dummy, char *buf)
334 355 {
335 356 struct lm63_data *data = lm63_update_device(dev);
336 357 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2])
337 358  
338 359  
... ... @@ -338,16 +359,24 @@
338 359 - TEMP8_FROM_REG(data->temp2_crit_hyst));
339 360 }
340 361  
341   -/* And now the other way around, user-space provides an absolute
342   - hysteresis value and we have to store a relative one */
343   -static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy,
  362 +/*
  363 + * And now the other way around, user-space provides an absolute
  364 + * hysteresis value and we have to store a relative one
  365 + */
  366 +static ssize_t set_temp2_crit_hyst(struct device *dev,
  367 + struct device_attribute *dummy,
344 368 const char *buf, size_t count)
345 369 {
346 370 struct i2c_client *client = to_i2c_client(dev);
347 371 struct lm63_data *data = i2c_get_clientdata(client);
348   - long val = simple_strtol(buf, NULL, 10);
  372 + long val;
  373 + int err;
349 374 long hyst;
350 375  
  376 + err = kstrtol(buf, 10, &val);
  377 + if (err)
  378 + return err;
  379 +
351 380 mutex_lock(&data->update_lock);
352 381 hyst = TEMP8_FROM_REG(data->temp8[2]) + data->temp2_offset - val;
353 382 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
354 383  
... ... @@ -518,12 +547,13 @@
518 547 lm63_init_client(new_client);
519 548  
520 549 /* Register sysfs hooks */
521   - if ((err = sysfs_create_group(&new_client->dev.kobj,
522   - &lm63_group)))
  550 + err = sysfs_create_group(&new_client->dev.kobj, &lm63_group);
  551 + if (err)
523 552 goto exit_free;
524 553 if (data->config & 0x04) { /* tachometer enabled */
525   - if ((err = sysfs_create_group(&new_client->dev.kobj,
526   - &lm63_group_fan1)))
  554 + err = sysfs_create_group(&new_client->dev.kobj,
  555 + &lm63_group_fan1);
  556 + if (err)
527 557 goto exit_remove_files;
528 558 }
529 559  
... ... @@ -544,8 +574,10 @@
544 574 return err;
545 575 }
546 576  
547   -/* Idealy we shouldn't have to initialize anything, since the BIOS
548   - should have taken care of everything */
  577 +/*
  578 + * Ideally we shouldn't have to initialize anything, since the BIOS
  579 + * should have taken care of everything
  580 + */
549 581 static void lm63_init_client(struct i2c_client *client)
550 582 {
551 583 struct lm63_data *data = i2c_get_clientdata(client);