aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max6650.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-01-15 00:32:21 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:26:44 -0400
commitbafda5d0f5eeef6f80a9030b23d824fd16dcd827 (patch)
treeba3c8f45d0f16b8caf903a0c7ffc440a3224dc6a /drivers/hwmon/max6650.c
parent0117c3f24523166ca764575c0e486887b7e33c2b (diff)
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: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/max6650.c')
-rw-r--r--drivers/hwmon/max6650.c113
1 files changed, 63 insertions, 50 deletions
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 2fc034aeca0..159ce027532 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -135,8 +135,7 @@ static struct i2c_driver max6650_driver = {
135 * Client data (each client gets its own) 135 * Client data (each client gets its own)
136 */ 136 */
137 137
138struct max6650_data 138struct max6650_data {
139{
140 struct device *hwmon_dev; 139 struct device *hwmon_dev;
141 struct mutex update_lock; 140 struct mutex update_lock;
142 int nr_fans; 141 int nr_fans;
@@ -238,8 +237,13 @@ static ssize_t set_target(struct device *dev, struct device_attribute *devattr,
238{ 237{
239 struct i2c_client *client = to_i2c_client(dev); 238 struct i2c_client *client = to_i2c_client(dev);
240 struct max6650_data *data = i2c_get_clientdata(client); 239 struct max6650_data *data = i2c_get_clientdata(client);
241 int rpm = simple_strtoul(buf, NULL, 10);
242 int kscale, ktach; 240 int kscale, ktach;
241 unsigned long rpm;
242 int err;
243
244 err = kstrtoul(buf, 10, &rpm);
245 if (err)
246 return err;
243 247
244 rpm = SENSORS_LIMIT(rpm, FAN_RPM_MIN, FAN_RPM_MAX); 248 rpm = SENSORS_LIMIT(rpm, FAN_RPM_MIN, FAN_RPM_MAX);
245 249
@@ -300,7 +304,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
300{ 304{
301 struct i2c_client *client = to_i2c_client(dev); 305 struct i2c_client *client = to_i2c_client(dev);
302 struct max6650_data *data = i2c_get_clientdata(client); 306 struct max6650_data *data = i2c_get_clientdata(client);
303 int pwm = simple_strtoul(buf, NULL, 10); 307 unsigned long pwm;
308 int err;
309
310 err = kstrtoul(buf, 10, &pwm);
311 if (err)
312 return err;
304 313
305 pwm = SENSORS_LIMIT(pwm, 0, 255); 314 pwm = SENSORS_LIMIT(pwm, 0, 255);
306 315
@@ -341,14 +350,16 @@ static ssize_t set_enable(struct device *dev, struct device_attribute *devattr,
341{ 350{
342 struct i2c_client *client = to_i2c_client(dev); 351 struct i2c_client *client = to_i2c_client(dev);
343 struct max6650_data *data = i2c_get_clientdata(client); 352 struct max6650_data *data = i2c_get_clientdata(client);
344 int mode = simple_strtoul(buf, NULL, 10);
345 int max6650_modes[3] = {0, 3, 2}; 353 int max6650_modes[3] = {0, 3, 2};
354 unsigned long mode;
355 int err;
356
357 err = kstrtoul(buf, 10, &mode);
358 if (err)
359 return err;
346 360
347 if ((mode < 0)||(mode > 2)) { 361 if (mode > 2)
348 dev_err(&client->dev,
349 "illegal value for pwm1_enable (%d)\n", mode);
350 return -EINVAL; 362 return -EINVAL;
351 }
352 363
353 mutex_lock(&data->update_lock); 364 mutex_lock(&data->update_lock);
354 365
@@ -389,7 +400,12 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr,
389{ 400{
390 struct i2c_client *client = to_i2c_client(dev); 401 struct i2c_client *client = to_i2c_client(dev);
391 struct max6650_data *data = i2c_get_clientdata(client); 402 struct max6650_data *data = i2c_get_clientdata(client);
392 int div = simple_strtoul(buf, NULL, 10); 403 unsigned long div;
404 int err;
405
406 err = kstrtoul(buf, 10, &div);
407 if (err)
408 return err;
393 409
394 mutex_lock(&data->update_lock); 410 mutex_lock(&data->update_lock);
395 switch (div) { 411 switch (div) {
@@ -407,8 +423,6 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr,
407 break; 423 break;
408 default: 424 default:
409 mutex_unlock(&data->update_lock); 425 mutex_unlock(&data->update_lock);
410 dev_err(&client->dev,
411 "illegal value for fan divider (%d)\n", div);
412 return -EINVAL; 426 return -EINVAL;
413 } 427 }
414 428
@@ -529,7 +543,8 @@ static int max6650_probe(struct i2c_client *client,
529 struct max6650_data *data; 543 struct max6650_data *data;
530 int err; 544 int err;
531 545
532 if (!(data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL))) { 546 data = kzalloc(sizeof(struct max6650_data), GFP_KERNEL);
547 if (!data) {
533 dev_err(&client->dev, "out of memory.\n"); 548 dev_err(&client->dev, "out of memory.\n");
534 return -ENOMEM; 549 return -ENOMEM;
535 } 550 }
@@ -596,49 +611,47 @@ static int max6650_init_client(struct i2c_client *client)
596 } 611 }
597 612
598 switch (fan_voltage) { 613 switch (fan_voltage) {
599 case 0: 614 case 0:
600 break; 615 break;
601 case 5: 616 case 5:
602 config &= ~MAX6650_CFG_V12; 617 config &= ~MAX6650_CFG_V12;
603 break; 618 break;
604 case 12: 619 case 12:
605 config |= MAX6650_CFG_V12; 620 config |= MAX6650_CFG_V12;
606 break; 621 break;
607 default: 622 default:
608 dev_err(&client->dev, 623 dev_err(&client->dev, "illegal value for fan_voltage (%d)\n",
609 "illegal value for fan_voltage (%d)\n", 624 fan_voltage);
610 fan_voltage);
611 } 625 }
612 626
613 dev_info(&client->dev, "Fan voltage is set to %dV.\n", 627 dev_info(&client->dev, "Fan voltage is set to %dV.\n",
614 (config & MAX6650_CFG_V12) ? 12 : 5); 628 (config & MAX6650_CFG_V12) ? 12 : 5);
615 629
616 switch (prescaler) { 630 switch (prescaler) {
617 case 0: 631 case 0:
618 break; 632 break;
619 case 1: 633 case 1:
620 config &= ~MAX6650_CFG_PRESCALER_MASK; 634 config &= ~MAX6650_CFG_PRESCALER_MASK;
621 break; 635 break;
622 case 2: 636 case 2:
623 config = (config & ~MAX6650_CFG_PRESCALER_MASK) 637 config = (config & ~MAX6650_CFG_PRESCALER_MASK)
624 | MAX6650_CFG_PRESCALER_2; 638 | MAX6650_CFG_PRESCALER_2;
625 break; 639 break;
626 case 4: 640 case 4:
627 config = (config & ~MAX6650_CFG_PRESCALER_MASK) 641 config = (config & ~MAX6650_CFG_PRESCALER_MASK)
628 | MAX6650_CFG_PRESCALER_4; 642 | MAX6650_CFG_PRESCALER_4;
629 break; 643 break;
630 case 8: 644 case 8:
631 config = (config & ~MAX6650_CFG_PRESCALER_MASK) 645 config = (config & ~MAX6650_CFG_PRESCALER_MASK)
632 | MAX6650_CFG_PRESCALER_8; 646 | MAX6650_CFG_PRESCALER_8;
633 break; 647 break;
634 case 16: 648 case 16:
635 config = (config & ~MAX6650_CFG_PRESCALER_MASK) 649 config = (config & ~MAX6650_CFG_PRESCALER_MASK)
636 | MAX6650_CFG_PRESCALER_16; 650 | MAX6650_CFG_PRESCALER_16;
637 break; 651 break;
638 default: 652 default:
639 dev_err(&client->dev, 653 dev_err(&client->dev, "illegal value for prescaler (%d)\n",
640 "illegal value for prescaler (%d)\n", 654 prescaler);
641 prescaler);
642 } 655 }
643 656
644 dev_info(&client->dev, "Prescaler is set to %d.\n", 657 dev_info(&client->dev, "Prescaler is set to %d.\n",