aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/asb100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/asb100.c')
-rw-r--r--drivers/i2c/chips/asb100.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c
index 7f899002bc54..70d996d6fe0a 100644
--- a/drivers/i2c/chips/asb100.c
+++ b/drivers/i2c/chips/asb100.c
@@ -42,6 +42,7 @@
42#include <linux/i2c-sensor.h> 42#include <linux/i2c-sensor.h>
43#include <linux/i2c-vid.h> 43#include <linux/i2c-vid.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/jiffies.h>
45#include "lm75.h" 46#include "lm75.h"
46 47
47/* 48/*
@@ -168,8 +169,6 @@ static int ASB100_PWM_FROM_REG(u8 reg)
168 return reg * 16; 169 return reg * 16;
169} 170}
170 171
171#define ALARMS_FROM_REG(val) (val)
172
173#define DIV_FROM_REG(val) (1 << (val)) 172#define DIV_FROM_REG(val) (1 << (val))
174 173
175/* FAN DIV: 1, 2, 4, or 8 (defaults to 2) 174/* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
@@ -260,28 +259,28 @@ set_in_reg(MAX, max)
260 259
261#define sysfs_in(offset) \ 260#define sysfs_in(offset) \
262static ssize_t \ 261static ssize_t \
263 show_in##offset (struct device *dev, char *buf) \ 262 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
264{ \ 263{ \
265 return show_in(dev, buf, offset); \ 264 return show_in(dev, buf, offset); \
266} \ 265} \
267static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 266static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
268 show_in##offset, NULL); \ 267 show_in##offset, NULL); \
269static ssize_t \ 268static ssize_t \
270 show_in##offset##_min (struct device *dev, char *buf) \ 269 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
271{ \ 270{ \
272 return show_in_min(dev, buf, offset); \ 271 return show_in_min(dev, buf, offset); \
273} \ 272} \
274static ssize_t \ 273static ssize_t \
275 show_in##offset##_max (struct device *dev, char *buf) \ 274 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
276{ \ 275{ \
277 return show_in_max(dev, buf, offset); \ 276 return show_in_max(dev, buf, offset); \
278} \ 277} \
279static ssize_t set_in##offset##_min (struct device *dev, \ 278static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
280 const char *buf, size_t count) \ 279 const char *buf, size_t count) \
281{ \ 280{ \
282 return set_in_min(dev, buf, count, offset); \ 281 return set_in_min(dev, buf, count, offset); \
283} \ 282} \
284static ssize_t set_in##offset##_max (struct device *dev, \ 283static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
285 const char *buf, size_t count) \ 284 const char *buf, size_t count) \
286{ \ 285{ \
287 return set_in_max(dev, buf, count, offset); \ 286 return set_in_max(dev, buf, count, offset); \
@@ -389,24 +388,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
389} 388}
390 389
391#define sysfs_fan(offset) \ 390#define sysfs_fan(offset) \
392static ssize_t show_fan##offset(struct device *dev, char *buf) \ 391static ssize_t show_fan##offset(struct device *dev, struct device_attribute *attr, char *buf) \
393{ \ 392{ \
394 return show_fan(dev, buf, offset - 1); \ 393 return show_fan(dev, buf, offset - 1); \
395} \ 394} \
396static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ 395static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
397{ \ 396{ \
398 return show_fan_min(dev, buf, offset - 1); \ 397 return show_fan_min(dev, buf, offset - 1); \
399} \ 398} \
400static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ 399static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
401{ \ 400{ \
402 return show_fan_div(dev, buf, offset - 1); \ 401 return show_fan_div(dev, buf, offset - 1); \
403} \ 402} \
404static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ 403static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
405 size_t count) \ 404 size_t count) \
406{ \ 405{ \
407 return set_fan_min(dev, buf, count, offset - 1); \ 406 return set_fan_min(dev, buf, count, offset - 1); \
408} \ 407} \
409static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \ 408static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \
410 size_t count) \ 409 size_t count) \
411{ \ 410{ \
412 return set_fan_div(dev, buf, count, offset - 1); \ 411 return set_fan_div(dev, buf, count, offset - 1); \
@@ -482,27 +481,27 @@ set_temp_reg(MAX, temp_max);
482set_temp_reg(HYST, temp_hyst); 481set_temp_reg(HYST, temp_hyst);
483 482
484#define sysfs_temp(num) \ 483#define sysfs_temp(num) \
485static ssize_t show_temp##num(struct device *dev, char *buf) \ 484static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \
486{ \ 485{ \
487 return show_temp(dev, buf, num-1); \ 486 return show_temp(dev, buf, num-1); \
488} \ 487} \
489static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \ 488static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \
490static ssize_t show_temp_max##num(struct device *dev, char *buf) \ 489static ssize_t show_temp_max##num(struct device *dev, struct device_attribute *attr, char *buf) \
491{ \ 490{ \
492 return show_temp_max(dev, buf, num-1); \ 491 return show_temp_max(dev, buf, num-1); \
493} \ 492} \
494static ssize_t set_temp_max##num(struct device *dev, const char *buf, \ 493static ssize_t set_temp_max##num(struct device *dev, struct device_attribute *attr, const char *buf, \
495 size_t count) \ 494 size_t count) \
496{ \ 495{ \
497 return set_temp_max(dev, buf, count, num-1); \ 496 return set_temp_max(dev, buf, count, num-1); \
498} \ 497} \
499static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ 498static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \
500 show_temp_max##num, set_temp_max##num); \ 499 show_temp_max##num, set_temp_max##num); \
501static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \ 500static ssize_t show_temp_hyst##num(struct device *dev, struct device_attribute *attr, char *buf) \
502{ \ 501{ \
503 return show_temp_hyst(dev, buf, num-1); \ 502 return show_temp_hyst(dev, buf, num-1); \
504} \ 503} \
505static ssize_t set_temp_hyst##num(struct device *dev, const char *buf, \ 504static ssize_t set_temp_hyst##num(struct device *dev, struct device_attribute *attr, const char *buf, \
506 size_t count) \ 505 size_t count) \
507{ \ 506{ \
508 return set_temp_hyst(dev, buf, count, num-1); \ 507 return set_temp_hyst(dev, buf, count, num-1); \
@@ -522,7 +521,7 @@ sysfs_temp(4);
522 device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \ 521 device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \
523} while (0) 522} while (0)
524 523
525static ssize_t show_vid(struct device *dev, char *buf) 524static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
526{ 525{
527 struct asb100_data *data = asb100_update_device(dev); 526 struct asb100_data *data = asb100_update_device(dev);
528 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); 527 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
@@ -533,13 +532,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
533device_create_file(&client->dev, &dev_attr_cpu0_vid) 532device_create_file(&client->dev, &dev_attr_cpu0_vid)
534 533
535/* VRM */ 534/* VRM */
536static ssize_t show_vrm(struct device *dev, char *buf) 535static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
537{ 536{
538 struct asb100_data *data = asb100_update_device(dev); 537 struct asb100_data *data = asb100_update_device(dev);
539 return sprintf(buf, "%d\n", data->vrm); 538 return sprintf(buf, "%d\n", data->vrm);
540} 539}
541 540
542static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) 541static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
543{ 542{
544 struct i2c_client *client = to_i2c_client(dev); 543 struct i2c_client *client = to_i2c_client(dev);
545 struct asb100_data *data = i2c_get_clientdata(client); 544 struct asb100_data *data = i2c_get_clientdata(client);
@@ -553,10 +552,10 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
553#define device_create_file_vrm(client) \ 552#define device_create_file_vrm(client) \
554device_create_file(&client->dev, &dev_attr_vrm); 553device_create_file(&client->dev, &dev_attr_vrm);
555 554
556static ssize_t show_alarms(struct device *dev, char *buf) 555static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
557{ 556{
558 struct asb100_data *data = asb100_update_device(dev); 557 struct asb100_data *data = asb100_update_device(dev);
559 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); 558 return sprintf(buf, "%u\n", data->alarms);
560} 559}
561 560
562static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 561static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
@@ -564,13 +563,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
564device_create_file(&client->dev, &dev_attr_alarms) 563device_create_file(&client->dev, &dev_attr_alarms)
565 564
566/* 1 PWM */ 565/* 1 PWM */
567static ssize_t show_pwm1(struct device *dev, char *buf) 566static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf)
568{ 567{
569 struct asb100_data *data = asb100_update_device(dev); 568 struct asb100_data *data = asb100_update_device(dev);
570 return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); 569 return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f));
571} 570}
572 571
573static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) 572static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
574{ 573{
575 struct i2c_client *client = to_i2c_client(dev); 574 struct i2c_client *client = to_i2c_client(dev);
576 struct asb100_data *data = i2c_get_clientdata(client); 575 struct asb100_data *data = i2c_get_clientdata(client);
@@ -584,13 +583,13 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
584 return count; 583 return count;
585} 584}
586 585
587static ssize_t show_pwm_enable1(struct device *dev, char *buf) 586static ssize_t show_pwm_enable1(struct device *dev, struct device_attribute *attr, char *buf)
588{ 587{
589 struct asb100_data *data = asb100_update_device(dev); 588 struct asb100_data *data = asb100_update_device(dev);
590 return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); 589 return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0);
591} 590}
592 591
593static ssize_t set_pwm_enable1(struct device *dev, const char *buf, 592static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr, const char *buf,
594 size_t count) 593 size_t count)
595{ 594{
596 struct i2c_client *client = to_i2c_client(dev); 595 struct i2c_client *client = to_i2c_client(dev);