diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-09 02:00:10 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-05-19 11:19:38 -0400 |
commit | 2cfa6aedb32c9c1226094ed383dc3c9b3e2ecddb (patch) | |
tree | 75f7a7d3c90d8416370300f5bec2ee45bcc2b44b /drivers/hwmon | |
parent | b4ce237b7f7d31abe9c5b0c443a64573ace4933d (diff) |
hwmon: (pmbus) Expand scope of device specific get_status function
Some devices use non-standard registers to access various functionality.
This does not only affect status registers, but other registers as well.
Rename local get_status function to get_byte_data to reflect this requirement.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Tom Grennan <tom.grennan@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/max34440.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/max8688.c | 4 | ||||
-rw-r--r-- | drivers/hwmon/pmbus.h | 10 | ||||
-rw-r--r-- | drivers/hwmon/pmbus_core.c | 29 |
4 files changed, 27 insertions, 22 deletions
diff --git a/drivers/hwmon/max34440.c b/drivers/hwmon/max34440.c index 992b701b4c5e..db11e1a175b2 100644 --- a/drivers/hwmon/max34440.c +++ b/drivers/hwmon/max34440.c | |||
@@ -32,7 +32,7 @@ enum chips { max34440, max34441 }; | |||
32 | #define MAX34440_STATUS_OT_FAULT (1 << 5) | 32 | #define MAX34440_STATUS_OT_FAULT (1 << 5) |
33 | #define MAX34440_STATUS_OT_WARN (1 << 6) | 33 | #define MAX34440_STATUS_OT_WARN (1 << 6) |
34 | 34 | ||
35 | static int max34440_get_status(struct i2c_client *client, int page, int reg) | 35 | static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) |
36 | { | 36 | { |
37 | int ret; | 37 | int ret; |
38 | int mfg_status; | 38 | int mfg_status; |
@@ -108,7 +108,7 @@ static struct pmbus_driver_info max34440_info[] = { | |||
108 | .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 108 | .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
109 | .func[12] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 109 | .func[12] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
110 | .func[13] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 110 | .func[13] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
111 | .get_status = max34440_get_status, | 111 | .read_byte_data = max34440_read_byte_data, |
112 | }, | 112 | }, |
113 | [max34441] = { | 113 | [max34441] = { |
114 | .pages = 12, | 114 | .pages = 12, |
@@ -149,7 +149,7 @@ static struct pmbus_driver_info max34440_info[] = { | |||
149 | .func[9] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 149 | .func[9] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
150 | .func[10] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 150 | .func[10] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
151 | .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, | 151 | .func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP, |
152 | .get_status = max34440_get_status, | 152 | .read_byte_data = max34440_read_byte_data, |
153 | }, | 153 | }, |
154 | }; | 154 | }; |
155 | 155 | ||
diff --git a/drivers/hwmon/max8688.c b/drivers/hwmon/max8688.c index 8ebfef2ecf26..7fb93f4e9f21 100644 --- a/drivers/hwmon/max8688.c +++ b/drivers/hwmon/max8688.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #define MAX8688_STATUS_OT_FAULT (1 << 13) | 37 | #define MAX8688_STATUS_OT_FAULT (1 << 13) |
38 | #define MAX8688_STATUS_OT_WARNING (1 << 14) | 38 | #define MAX8688_STATUS_OT_WARNING (1 << 14) |
39 | 39 | ||
40 | static int max8688_get_status(struct i2c_client *client, int page, int reg) | 40 | static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) |
41 | { | 41 | { |
42 | int ret = 0; | 42 | int ret = 0; |
43 | int mfg_status; | 43 | int mfg_status; |
@@ -110,7 +110,7 @@ static struct pmbus_driver_info max8688_info = { | |||
110 | .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP | 110 | .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP |
111 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT | 111 | | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
112 | | PMBUS_HAVE_STATUS_TEMP, | 112 | | PMBUS_HAVE_STATUS_TEMP, |
113 | .get_status = max8688_get_status, | 113 | .read_byte_data = max8688_read_byte_data, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static int max8688_probe(struct i2c_client *client, | 116 | static int max8688_probe(struct i2c_client *client, |
diff --git a/drivers/hwmon/pmbus.h b/drivers/hwmon/pmbus.h index a81f7f228762..50647ab7235a 100644 --- a/drivers/hwmon/pmbus.h +++ b/drivers/hwmon/pmbus.h | |||
@@ -281,13 +281,11 @@ struct pmbus_driver_info { | |||
281 | 281 | ||
282 | u32 func[PMBUS_PAGES]; /* Functionality, per page */ | 282 | u32 func[PMBUS_PAGES]; /* Functionality, per page */ |
283 | /* | 283 | /* |
284 | * The get_status function maps manufacturing specific status values | 284 | * The following functions map manufacturing specific register values |
285 | * into PMBus standard status values. | 285 | * to PMBus standard register values. Specify only if mapping is |
286 | * This function is optional and only necessary if chip specific status | 286 | * necessary. |
287 | * register values have to be mapped into standard PMBus status register | ||
288 | * values. | ||
289 | */ | 287 | */ |
290 | int (*get_status)(struct i2c_client *client, int page, int reg); | 288 | int (*read_byte_data)(struct i2c_client *client, int page, int reg); |
291 | /* | 289 | /* |
292 | * The identify function determines supported PMBus functionality. | 290 | * The identify function determines supported PMBus functionality. |
293 | * This function is only necessary if a chip driver supports multiple | 291 | * This function is only necessary if a chip driver supports multiple |
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c index 4e42a2994644..43ec1057c1f7 100644 --- a/drivers/hwmon/pmbus_core.c +++ b/drivers/hwmon/pmbus_core.c | |||
@@ -270,18 +270,22 @@ const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client) | |||
270 | } | 270 | } |
271 | EXPORT_SYMBOL_GPL(pmbus_get_driver_info); | 271 | EXPORT_SYMBOL_GPL(pmbus_get_driver_info); |
272 | 272 | ||
273 | static int pmbus_get_status(struct i2c_client *client, int page, int reg) | 273 | /* |
274 | * _pmbus_read_byte_data() is similar to pmbus_read_byte_data(), but checks if | ||
275 | * a device specific mapping funcion exists and calls it if necessary. | ||
276 | */ | ||
277 | static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg) | ||
274 | { | 278 | { |
275 | struct pmbus_data *data = i2c_get_clientdata(client); | 279 | struct pmbus_data *data = i2c_get_clientdata(client); |
276 | const struct pmbus_driver_info *info = data->info; | 280 | const struct pmbus_driver_info *info = data->info; |
277 | int status; | 281 | int status; |
278 | 282 | ||
279 | if (info->get_status) { | 283 | if (info->read_byte_data) { |
280 | status = info->get_status(client, page, reg); | 284 | status = info->read_byte_data(client, page, reg); |
281 | if (status != -ENODATA) | 285 | if (status != -ENODATA) |
282 | return status; | 286 | return status; |
283 | } | 287 | } |
284 | return pmbus_read_byte_data(client, page, reg); | 288 | return pmbus_read_byte_data(client, page, reg); |
285 | } | 289 | } |
286 | 290 | ||
287 | static struct pmbus_data *pmbus_update_device(struct device *dev) | 291 | static struct pmbus_data *pmbus_update_device(struct device *dev) |
@@ -302,38 +306,41 @@ static struct pmbus_data *pmbus_update_device(struct device *dev) | |||
302 | if (!(info->func[i] & PMBUS_HAVE_STATUS_VOUT)) | 306 | if (!(info->func[i] & PMBUS_HAVE_STATUS_VOUT)) |
303 | continue; | 307 | continue; |
304 | data->status[PB_STATUS_VOUT_BASE + i] | 308 | data->status[PB_STATUS_VOUT_BASE + i] |
305 | = pmbus_get_status(client, i, PMBUS_STATUS_VOUT); | 309 | = _pmbus_read_byte_data(client, i, PMBUS_STATUS_VOUT); |
306 | } | 310 | } |
307 | for (i = 0; i < info->pages; i++) { | 311 | for (i = 0; i < info->pages; i++) { |
308 | if (!(info->func[i] & PMBUS_HAVE_STATUS_IOUT)) | 312 | if (!(info->func[i] & PMBUS_HAVE_STATUS_IOUT)) |
309 | continue; | 313 | continue; |
310 | data->status[PB_STATUS_IOUT_BASE + i] | 314 | data->status[PB_STATUS_IOUT_BASE + i] |
311 | = pmbus_get_status(client, i, PMBUS_STATUS_IOUT); | 315 | = _pmbus_read_byte_data(client, i, PMBUS_STATUS_IOUT); |
312 | } | 316 | } |
313 | for (i = 0; i < info->pages; i++) { | 317 | for (i = 0; i < info->pages; i++) { |
314 | if (!(info->func[i] & PMBUS_HAVE_STATUS_TEMP)) | 318 | if (!(info->func[i] & PMBUS_HAVE_STATUS_TEMP)) |
315 | continue; | 319 | continue; |
316 | data->status[PB_STATUS_TEMP_BASE + i] | 320 | data->status[PB_STATUS_TEMP_BASE + i] |
317 | = pmbus_get_status(client, i, | 321 | = _pmbus_read_byte_data(client, i, |
318 | PMBUS_STATUS_TEMPERATURE); | 322 | PMBUS_STATUS_TEMPERATURE); |
319 | } | 323 | } |
320 | for (i = 0; i < info->pages; i++) { | 324 | for (i = 0; i < info->pages; i++) { |
321 | if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN12)) | 325 | if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN12)) |
322 | continue; | 326 | continue; |
323 | data->status[PB_STATUS_FAN_BASE + i] | 327 | data->status[PB_STATUS_FAN_BASE + i] |
324 | = pmbus_get_status(client, i, PMBUS_STATUS_FAN_12); | 328 | = _pmbus_read_byte_data(client, i, |
329 | PMBUS_STATUS_FAN_12); | ||
325 | } | 330 | } |
326 | 331 | ||
327 | for (i = 0; i < info->pages; i++) { | 332 | for (i = 0; i < info->pages; i++) { |
328 | if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN34)) | 333 | if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN34)) |
329 | continue; | 334 | continue; |
330 | data->status[PB_STATUS_FAN34_BASE + i] | 335 | data->status[PB_STATUS_FAN34_BASE + i] |
331 | = pmbus_get_status(client, i, PMBUS_STATUS_FAN_34); | 336 | = _pmbus_read_byte_data(client, i, |
337 | PMBUS_STATUS_FAN_34); | ||
332 | } | 338 | } |
333 | 339 | ||
334 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) | 340 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) |
335 | data->status[PB_STATUS_INPUT_BASE] | 341 | data->status[PB_STATUS_INPUT_BASE] |
336 | = pmbus_get_status(client, 0, PMBUS_STATUS_INPUT); | 342 | = _pmbus_read_byte_data(client, 0, |
343 | PMBUS_STATUS_INPUT); | ||
337 | 344 | ||
338 | for (i = 0; i < data->num_sensors; i++) { | 345 | for (i = 0; i < data->num_sensors; i++) { |
339 | struct pmbus_sensor *sensor = &data->sensors[i]; | 346 | struct pmbus_sensor *sensor = &data->sensors[i]; |