aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@us.ibm.com>2007-10-26 14:55:11 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-11-08 08:42:47 -0500
commit59a030a9b7a1bab5bdae57d469583e611759e90b (patch)
tree31e1e0dfbf820b8d4eb33f3a38a875ea763777cd
parent7768aa76966f06c4add6ac2b0ef397ff34f3dab0 (diff)
hwmon: (i5k_amb) Convert macros to C functions
akpm objected to some of the macros, so convert them into functions. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
-rw-r--r--drivers/hwmon/i5k_amb.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index 7fdbe810e8e2..6ac5c6f53585 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -47,16 +47,35 @@
47#define AMB_CONFIG_SIZE 2048 47#define AMB_CONFIG_SIZE 2048
48#define AMB_FUNC_3_OFFSET 768 48#define AMB_FUNC_3_OFFSET 768
49 49
50#define AMB_REG_TEMP_STATUS(amb) ((amb) * AMB_CONFIG_SIZE + \ 50static unsigned long amb_reg_temp_status(unsigned int amb)
51 AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR) 51{
52#define AMB_REG_TEMP_MIN(amb) ((amb) * AMB_CONFIG_SIZE + \ 52 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR +
53 AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR) 53 AMB_CONFIG_SIZE * amb;
54#define AMB_REG_TEMP_MID(amb) ((amb) * AMB_CONFIG_SIZE + \ 54}
55 AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR) 55
56#define AMB_REG_TEMP_MAX(amb) ((amb) * AMB_CONFIG_SIZE + \ 56static unsigned long amb_reg_temp_min(unsigned int amb)
57 AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR) 57{
58#define AMB_REG_TEMP(amb) ((amb) * AMB_CONFIG_SIZE + \ 58 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR +
59 AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR) 59 AMB_CONFIG_SIZE * amb;
60}
61
62static unsigned long amb_reg_temp_mid(unsigned int amb)
63{
64 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR +
65 AMB_CONFIG_SIZE * amb;
66}
67
68static unsigned long amb_reg_temp_max(unsigned int amb)
69{
70 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR +
71 AMB_CONFIG_SIZE * amb;
72}
73
74static unsigned long amb_reg_temp(unsigned int amb)
75{
76 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR +
77 AMB_CONFIG_SIZE * amb;
78}
60 79
61#define MAX_MEM_CHANNELS 4 80#define MAX_MEM_CHANNELS 4
62#define MAX_AMBS_PER_CHANNEL 16 81#define MAX_AMBS_PER_CHANNEL 16
@@ -72,8 +91,10 @@
72#define REAL_MAX_AMBS_PER_CHANNEL 15 91#define REAL_MAX_AMBS_PER_CHANNEL 15
73#define KNOBS_PER_AMB 5 92#define KNOBS_PER_AMB 5
74 93
75#define AMB_NUM_FROM_REG(byte_num, bit_num) ((byte_num) * \ 94static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit)
76 MAX_AMBS_PER_CHANNEL) + (bit_num) 95{
96 return byte_num * MAX_AMBS_PER_CHANNEL + bit;
97}
77 98
78#define AMB_SYSFS_NAME_LEN 16 99#define AMB_SYSFS_NAME_LEN 16
79struct i5k_device_attribute { 100struct i5k_device_attribute {
@@ -121,8 +142,8 @@ static ssize_t show_amb_alarm(struct device *dev,
121 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 142 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
122 struct i5k_amb_data *data = dev_get_drvdata(dev); 143 struct i5k_amb_data *data = dev_get_drvdata(dev);
123 144
124 if (!(amb_read_byte(data, AMB_REG_TEMP_STATUS(attr->index)) & 0x20) && 145 if (!(amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x20) &&
125 (amb_read_byte(data, AMB_REG_TEMP_STATUS(attr->index)) & 0x8)) 146 (amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x8))
126 return sprintf(buf, "1\n"); 147 return sprintf(buf, "1\n");
127 else 148 else
128 return sprintf(buf, "0\n"); 149 return sprintf(buf, "0\n");
@@ -140,7 +161,7 @@ static ssize_t store_amb_min(struct device *dev,
140 if (temp > 255) 161 if (temp > 255)
141 temp = 255; 162 temp = 255;
142 163
143 amb_write_byte(data, AMB_REG_TEMP_MIN(attr->index), temp); 164 amb_write_byte(data, amb_reg_temp_min(attr->index), temp);
144 return count; 165 return count;
145} 166}
146 167
@@ -156,7 +177,7 @@ static ssize_t store_amb_mid(struct device *dev,
156 if (temp > 255) 177 if (temp > 255)
157 temp = 255; 178 temp = 255;
158 179
159 amb_write_byte(data, AMB_REG_TEMP_MID(attr->index), temp); 180 amb_write_byte(data, amb_reg_temp_mid(attr->index), temp);
160 return count; 181 return count;
161} 182}
162 183
@@ -172,7 +193,7 @@ static ssize_t store_amb_max(struct device *dev,
172 if (temp > 255) 193 if (temp > 255)
173 temp = 255; 194 temp = 255;
174 195
175 amb_write_byte(data, AMB_REG_TEMP_MAX(attr->index), temp); 196 amb_write_byte(data, amb_reg_temp_max(attr->index), temp);
176 return count; 197 return count;
177} 198}
178 199
@@ -183,7 +204,7 @@ static ssize_t show_amb_min(struct device *dev,
183 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 204 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
184 struct i5k_amb_data *data = dev_get_drvdata(dev); 205 struct i5k_amb_data *data = dev_get_drvdata(dev);
185 return sprintf(buf, "%d\n", 206 return sprintf(buf, "%d\n",
186 500 * amb_read_byte(data, AMB_REG_TEMP_MIN(attr->index))); 207 500 * amb_read_byte(data, amb_reg_temp_min(attr->index)));
187} 208}
188 209
189static ssize_t show_amb_mid(struct device *dev, 210static ssize_t show_amb_mid(struct device *dev,
@@ -193,7 +214,7 @@ static ssize_t show_amb_mid(struct device *dev,
193 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 214 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
194 struct i5k_amb_data *data = dev_get_drvdata(dev); 215 struct i5k_amb_data *data = dev_get_drvdata(dev);
195 return sprintf(buf, "%d\n", 216 return sprintf(buf, "%d\n",
196 500 * amb_read_byte(data, AMB_REG_TEMP_MID(attr->index))); 217 500 * amb_read_byte(data, amb_reg_temp_mid(attr->index)));
197} 218}
198 219
199static ssize_t show_amb_max(struct device *dev, 220static ssize_t show_amb_max(struct device *dev,
@@ -203,7 +224,7 @@ static ssize_t show_amb_max(struct device *dev,
203 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 224 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
204 struct i5k_amb_data *data = dev_get_drvdata(dev); 225 struct i5k_amb_data *data = dev_get_drvdata(dev);
205 return sprintf(buf, "%d\n", 226 return sprintf(buf, "%d\n",
206 500 * amb_read_byte(data, AMB_REG_TEMP_MAX(attr->index))); 227 500 * amb_read_byte(data, amb_reg_temp_max(attr->index)));
207} 228}
208 229
209static ssize_t show_amb_temp(struct device *dev, 230static ssize_t show_amb_temp(struct device *dev,
@@ -213,7 +234,7 @@ static ssize_t show_amb_temp(struct device *dev,
213 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 234 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
214 struct i5k_amb_data *data = dev_get_drvdata(dev); 235 struct i5k_amb_data *data = dev_get_drvdata(dev);
215 return sprintf(buf, "%d\n", 236 return sprintf(buf, "%d\n",
216 500 * amb_read_byte(data, AMB_REG_TEMP(attr->index))); 237 500 * amb_read_byte(data, amb_reg_temp(attr->index)));
217} 238}
218 239
219static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev) 240static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
@@ -241,7 +262,7 @@ static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
241 for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) { 262 for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) {
242 struct i5k_device_attribute *iattr; 263 struct i5k_device_attribute *iattr;
243 264
244 k = AMB_NUM_FROM_REG(i, j); 265 k = amb_num_from_reg(i, j);
245 if (!(c & 0x1)) 266 if (!(c & 0x1))
246 continue; 267 continue;
247 d++; 268 d++;