Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73645
b: refs/heads/master
c: 59a030a
h: refs/heads/master
i:
  73643: 276174b
v: v3
  • Loading branch information
Darrick J. Wong authored and Mark M. Hoffman committed Nov 8, 2007
1 parent f630d9e commit fe5ae98
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 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: 7768aa76966f06c4add6ac2b0ef397ff34f3dab0
refs/heads/master: 59a030a9b7a1bab5bdae57d469583e611759e90b
65 changes: 43 additions & 22 deletions trunk/drivers/hwmon/i5k_amb.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,35 @@
#define AMB_CONFIG_SIZE 2048
#define AMB_FUNC_3_OFFSET 768

#define AMB_REG_TEMP_STATUS(amb) ((amb) * AMB_CONFIG_SIZE + \
AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR)
#define AMB_REG_TEMP_MIN(amb) ((amb) * AMB_CONFIG_SIZE + \
AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR)
#define AMB_REG_TEMP_MID(amb) ((amb) * AMB_CONFIG_SIZE + \
AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR)
#define AMB_REG_TEMP_MAX(amb) ((amb) * AMB_CONFIG_SIZE + \
AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR)
#define AMB_REG_TEMP(amb) ((amb) * AMB_CONFIG_SIZE + \
AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR)
static unsigned long amb_reg_temp_status(unsigned int amb)
{
return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR +
AMB_CONFIG_SIZE * amb;
}

static unsigned long amb_reg_temp_min(unsigned int amb)
{
return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR +
AMB_CONFIG_SIZE * amb;
}

static unsigned long amb_reg_temp_mid(unsigned int amb)
{
return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR +
AMB_CONFIG_SIZE * amb;
}

static unsigned long amb_reg_temp_max(unsigned int amb)
{
return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR +
AMB_CONFIG_SIZE * amb;
}

static unsigned long amb_reg_temp(unsigned int amb)
{
return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR +
AMB_CONFIG_SIZE * amb;
}

#define MAX_MEM_CHANNELS 4
#define MAX_AMBS_PER_CHANNEL 16
Expand All @@ -72,8 +91,10 @@
#define REAL_MAX_AMBS_PER_CHANNEL 15
#define KNOBS_PER_AMB 5

#define AMB_NUM_FROM_REG(byte_num, bit_num) ((byte_num) * \
MAX_AMBS_PER_CHANNEL) + (bit_num)
static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit)
{
return byte_num * MAX_AMBS_PER_CHANNEL + bit;
}

#define AMB_SYSFS_NAME_LEN 16
struct i5k_device_attribute {
Expand Down Expand Up @@ -121,8 +142,8 @@ static ssize_t show_amb_alarm(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i5k_amb_data *data = dev_get_drvdata(dev);

if (!(amb_read_byte(data, AMB_REG_TEMP_STATUS(attr->index)) & 0x20) &&
(amb_read_byte(data, AMB_REG_TEMP_STATUS(attr->index)) & 0x8))
if (!(amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x20) &&
(amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x8))
return sprintf(buf, "1\n");
else
return sprintf(buf, "0\n");
Expand All @@ -140,7 +161,7 @@ static ssize_t store_amb_min(struct device *dev,
if (temp > 255)
temp = 255;

amb_write_byte(data, AMB_REG_TEMP_MIN(attr->index), temp);
amb_write_byte(data, amb_reg_temp_min(attr->index), temp);
return count;
}

Expand All @@ -156,7 +177,7 @@ static ssize_t store_amb_mid(struct device *dev,
if (temp > 255)
temp = 255;

amb_write_byte(data, AMB_REG_TEMP_MID(attr->index), temp);
amb_write_byte(data, amb_reg_temp_mid(attr->index), temp);
return count;
}

Expand All @@ -172,7 +193,7 @@ static ssize_t store_amb_max(struct device *dev,
if (temp > 255)
temp = 255;

amb_write_byte(data, AMB_REG_TEMP_MAX(attr->index), temp);
amb_write_byte(data, amb_reg_temp_max(attr->index), temp);
return count;
}

Expand All @@ -183,7 +204,7 @@ static ssize_t show_amb_min(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i5k_amb_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%d\n",
500 * amb_read_byte(data, AMB_REG_TEMP_MIN(attr->index)));
500 * amb_read_byte(data, amb_reg_temp_min(attr->index)));
}

static ssize_t show_amb_mid(struct device *dev,
Expand All @@ -193,7 +214,7 @@ static ssize_t show_amb_mid(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i5k_amb_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%d\n",
500 * amb_read_byte(data, AMB_REG_TEMP_MID(attr->index)));
500 * amb_read_byte(data, amb_reg_temp_mid(attr->index)));
}

static ssize_t show_amb_max(struct device *dev,
Expand All @@ -203,7 +224,7 @@ static ssize_t show_amb_max(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i5k_amb_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%d\n",
500 * amb_read_byte(data, AMB_REG_TEMP_MAX(attr->index)));
500 * amb_read_byte(data, amb_reg_temp_max(attr->index)));
}

static ssize_t show_amb_temp(struct device *dev,
Expand All @@ -213,7 +234,7 @@ static ssize_t show_amb_temp(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i5k_amb_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%d\n",
500 * amb_read_byte(data, AMB_REG_TEMP(attr->index)));
500 * amb_read_byte(data, amb_reg_temp(attr->index)));
}

static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
Expand Down Expand Up @@ -241,7 +262,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) {
struct i5k_device_attribute *iattr;

k = AMB_NUM_FROM_REG(i, j);
k = amb_num_from_reg(i, j);
if (!(c & 0x1))
continue;
d++;
Expand Down

0 comments on commit fe5ae98

Please sign in to comment.