Source
476
476
show_temp_max, set_temp_max, num - 1); \
477
477
static SENSOR_DEVICE_ATTR(temp##num##_max_hyst, S_IRUGO | S_IWUSR, \
478
478
show_temp_hyst, set_temp_hyst, num - 1)
479
479
480
480
sysfs_temp(1);
481
481
sysfs_temp(2);
482
482
sysfs_temp(3);
483
483
sysfs_temp(4);
484
484
485
485
/* VID */
486
-
static ssize_t show_vid(struct device *dev, struct device_attribute *attr,
487
-
char *buf)
486
+
static ssize_t cpu0_vid_show(struct device *dev,
487
+
struct device_attribute *attr, char *buf)
488
488
{
489
489
struct asb100_data *data = asb100_update_device(dev);
490
490
return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
491
491
}
492
492
493
-
static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
493
+
static DEVICE_ATTR_RO(cpu0_vid);
494
494
495
495
/* VRM */
496
-
static ssize_t show_vrm(struct device *dev, struct device_attribute *attr,
496
+
static ssize_t vrm_show(struct device *dev, struct device_attribute *attr,
497
497
char *buf)
498
498
{
499
499
struct asb100_data *data = dev_get_drvdata(dev);
500
500
return sprintf(buf, "%d\n", data->vrm);
501
501
}
502
502
503
-
static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
504
-
const char *buf, size_t count)
503
+
static ssize_t vrm_store(struct device *dev, struct device_attribute *attr,
504
+
const char *buf, size_t count)
505
505
{
506
506
struct asb100_data *data = dev_get_drvdata(dev);
507
507
unsigned long val;
508
508
int err;
509
509
510
510
err = kstrtoul(buf, 10, &val);
511
511
if (err)
512
512
return err;
513
513
514
514
if (val > 255)
515
515
return -EINVAL;
516
516
517
517
data->vrm = val;
518
518
return count;
519
519
}
520
520
521
521
/* Alarms */
522
-
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
522
+
static DEVICE_ATTR_RW(vrm);
523
523
524
-
static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
524
+
static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
525
525
char *buf)
526
526
{
527
527
struct asb100_data *data = asb100_update_device(dev);
528
528
return sprintf(buf, "%u\n", data->alarms);
529
529
}
530
530
531
-
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
531
+
static DEVICE_ATTR_RO(alarms);
532
532
533
533
static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
534
534
char *buf)
535
535
{
536
536
int bitnr = to_sensor_dev_attr(attr)->index;
537
537
struct asb100_data *data = asb100_update_device(dev);
538
538
return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
539
539
}
540
540
static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
541
541
static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
543
543
static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
544
544
static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
545
545
static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
546
546
static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
547
547
static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11);
548
548
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
549
549
static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
550
550
static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
551
551
552
552
/* 1 PWM */
553
-
static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr,
553
+
static ssize_t pwm1_show(struct device *dev, struct device_attribute *attr,
554
554
char *buf)
555
555
{
556
556
struct asb100_data *data = asb100_update_device(dev);
557
557
return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f));
558
558
}
559
559
560
-
static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr,
561
-
const char *buf, size_t count)
560
+
static ssize_t pwm1_store(struct device *dev, struct device_attribute *attr,
561
+
const char *buf, size_t count)
562
562
{
563
563
struct i2c_client *client = to_i2c_client(dev);
564
564
struct asb100_data *data = i2c_get_clientdata(client);
565
565
unsigned long val;
566
566
int err;
567
567
568
568
err = kstrtoul(buf, 10, &val);
569
569
if (err)
570
570
return err;
571
571
572
572
mutex_lock(&data->update_lock);
573
573
data->pwm &= 0x80; /* keep the enable bit */
574
574
data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
575
575
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
576
576
mutex_unlock(&data->update_lock);
577
577
return count;
578
578
}
579
579
580
-
static ssize_t show_pwm_enable1(struct device *dev,
580
+
static ssize_t pwm1_enable_show(struct device *dev,
581
581
struct device_attribute *attr, char *buf)
582
582
{
583
583
struct asb100_data *data = asb100_update_device(dev);
584
584
return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0);
585
585
}
586
586
587
-
static ssize_t set_pwm_enable1(struct device *dev,
588
-
struct device_attribute *attr, const char *buf, size_t count)
587
+
static ssize_t pwm1_enable_store(struct device *dev,
588
+
struct device_attribute *attr,
589
+
const char *buf, size_t count)
589
590
{
590
591
struct i2c_client *client = to_i2c_client(dev);
591
592
struct asb100_data *data = i2c_get_clientdata(client);
592
593
unsigned long val;
593
594
int err;
594
595
595
596
err = kstrtoul(buf, 10, &val);
596
597
if (err)
597
598
return err;
598
599
599
600
mutex_lock(&data->update_lock);
600
601
data->pwm &= 0x0f; /* keep the duty cycle bits */
601
602
data->pwm |= (val ? 0x80 : 0x00);
602
603
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
603
604
mutex_unlock(&data->update_lock);
604
605
return count;
605
606
}
606
607
607
-
static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
608
-
static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
609
-
show_pwm_enable1, set_pwm_enable1);
608
+
static DEVICE_ATTR_RW(pwm1);
609
+
static DEVICE_ATTR_RW(pwm1_enable);
610
610
611
611
static struct attribute *asb100_attributes[] = {
612
612
&sensor_dev_attr_in0_input.dev_attr.attr,
613
613
&sensor_dev_attr_in0_min.dev_attr.attr,
614
614
&sensor_dev_attr_in0_max.dev_attr.attr,
615
615
&sensor_dev_attr_in1_input.dev_attr.attr,
616
616
&sensor_dev_attr_in1_min.dev_attr.attr,
617
617
&sensor_dev_attr_in1_max.dev_attr.attr,
618
618
&sensor_dev_attr_in2_input.dev_attr.attr,
619
619
&sensor_dev_attr_in2_min.dev_attr.attr,