Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 55181
b: refs/heads/master
c: 3659a01
h: refs/heads/master
i:
  55179: 731261e
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed May 8, 2007
1 parent 322eece commit 1d24e51
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 292fc1a5ff44d477ff335a343a48d2b67bbc70e3
refs/heads/master: 3659a0178f76d13174e8924416e5d6805ea9bad1
64 changes: 26 additions & 38 deletions trunk/drivers/hwmon/smsc47b397.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/jiffies.h>
#include <linux/platform_device.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/mutex.h>
Expand Down Expand Up @@ -156,24 +157,18 @@ static int temp_from_reg(u8 reg)
return (s8)reg * 1000;
}

/* 0 <= nr <= 3 */
static ssize_t show_temp(struct device *dev, char *buf, int nr)
static ssize_t show_temp(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47b397_data *data = smsc47b397_update_device(dev);
return sprintf(buf, "%d\n", temp_from_reg(data->temp[nr]));
return sprintf(buf, "%d\n", temp_from_reg(data->temp[attr->index]));
}

#define sysfs_temp(num) \
static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
return show_temp(dev, buf, num-1); \
} \
static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL)

sysfs_temp(1);
sysfs_temp(2);
sysfs_temp(3);
sysfs_temp(4);
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);

/* FAN: 1 RPM/bit
REG: count of 90kHz pulses / revolution */
Expand All @@ -182,24 +177,17 @@ static int fan_from_reg(u16 reg)
return 90000 * 60 / reg;
}

/* 0 <= nr <= 3 */
static ssize_t show_fan(struct device *dev, char *buf, int nr)
static ssize_t show_fan(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct smsc47b397_data *data = smsc47b397_update_device(dev);
return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr]));
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47b397_data *data = smsc47b397_update_device(dev);
return sprintf(buf, "%d\n", fan_from_reg(data->fan[attr->index]));
}

#define sysfs_fan(num) \
static ssize_t show_fan##num(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
return show_fan(dev, buf, num-1); \
} \
static DEVICE_ATTR(fan##num##_input, S_IRUGO, show_fan##num, NULL)

sysfs_fan(1);
sysfs_fan(2);
sysfs_fan(3);
sysfs_fan(4);
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3);

static ssize_t show_name(struct device *dev, struct device_attribute
*devattr, char *buf)
Expand All @@ -210,14 +198,14 @@ static ssize_t show_name(struct device *dev, struct device_attribute
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);

static struct attribute *smsc47b397_attributes[] = {
&dev_attr_temp1_input.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp3_input.attr,
&dev_attr_temp4_input.attr,
&dev_attr_fan1_input.attr,
&dev_attr_fan2_input.attr,
&dev_attr_fan3_input.attr,
&dev_attr_fan4_input.attr,
&sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp2_input.dev_attr.attr,
&sensor_dev_attr_temp3_input.dev_attr.attr,
&sensor_dev_attr_temp4_input.dev_attr.attr,
&sensor_dev_attr_fan1_input.dev_attr.attr,
&sensor_dev_attr_fan2_input.dev_attr.attr,
&sensor_dev_attr_fan3_input.dev_attr.attr,
&sensor_dev_attr_fan4_input.dev_attr.attr,

&dev_attr_name.attr,
NULL
Expand Down

0 comments on commit 1d24e51

Please sign in to comment.