diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/i5k_amb.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index f9e2ed621f7b..2ede9388096b 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c | |||
@@ -81,6 +81,8 @@ static unsigned long amb_reg_temp(unsigned int amb) | |||
81 | #define MAX_AMBS_PER_CHANNEL 16 | 81 | #define MAX_AMBS_PER_CHANNEL 16 |
82 | #define MAX_AMBS (MAX_MEM_CHANNELS * \ | 82 | #define MAX_AMBS (MAX_MEM_CHANNELS * \ |
83 | MAX_AMBS_PER_CHANNEL) | 83 | MAX_AMBS_PER_CHANNEL) |
84 | #define CHANNEL_SHIFT 4 | ||
85 | #define DIMM_MASK 0xF | ||
84 | /* | 86 | /* |
85 | * Ugly hack: For some reason the highest bit is set if there | 87 | * Ugly hack: For some reason the highest bit is set if there |
86 | * are _any_ DIMMs in the channel. Attempting to read from | 88 | * are _any_ DIMMs in the channel. Attempting to read from |
@@ -89,7 +91,7 @@ static unsigned long amb_reg_temp(unsigned int amb) | |||
89 | * might prevent us from seeing the 16th DIMM in the channel. | 91 | * might prevent us from seeing the 16th DIMM in the channel. |
90 | */ | 92 | */ |
91 | #define REAL_MAX_AMBS_PER_CHANNEL 15 | 93 | #define REAL_MAX_AMBS_PER_CHANNEL 15 |
92 | #define KNOBS_PER_AMB 5 | 94 | #define KNOBS_PER_AMB 6 |
93 | 95 | ||
94 | static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit) | 96 | static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit) |
95 | { | 97 | { |
@@ -238,6 +240,16 @@ static ssize_t show_amb_temp(struct device *dev, | |||
238 | 500 * amb_read_byte(data, amb_reg_temp(attr->index))); | 240 | 500 * amb_read_byte(data, amb_reg_temp(attr->index))); |
239 | } | 241 | } |
240 | 242 | ||
243 | static ssize_t show_label(struct device *dev, | ||
244 | struct device_attribute *devattr, | ||
245 | char *buf) | ||
246 | { | ||
247 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
248 | |||
249 | return sprintf(buf, "Ch. %d DIMM %d\n", attr->index >> CHANNEL_SHIFT, | ||
250 | attr->index & DIMM_MASK); | ||
251 | } | ||
252 | |||
241 | static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev) | 253 | static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev) |
242 | { | 254 | { |
243 | int i, j, k, d = 0; | 255 | int i, j, k, d = 0; |
@@ -268,6 +280,20 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev) | |||
268 | continue; | 280 | continue; |
269 | d++; | 281 | d++; |
270 | 282 | ||
283 | /* sysfs label */ | ||
284 | iattr = data->attrs + data->num_attrs; | ||
285 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, | ||
286 | "temp%d_label", d); | ||
287 | iattr->s_attr.dev_attr.attr.name = iattr->name; | ||
288 | iattr->s_attr.dev_attr.attr.mode = S_IRUGO; | ||
289 | iattr->s_attr.dev_attr.show = show_label; | ||
290 | iattr->s_attr.index = k; | ||
291 | res = device_create_file(&pdev->dev, | ||
292 | &iattr->s_attr.dev_attr); | ||
293 | if (res) | ||
294 | goto exit_remove; | ||
295 | data->num_attrs++; | ||
296 | |||
271 | /* Temperature sysfs knob */ | 297 | /* Temperature sysfs knob */ |
272 | iattr = data->attrs + data->num_attrs; | 298 | iattr = data->attrs + data->num_attrs; |
273 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, | 299 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |