aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus_core.c
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-03-09 02:00:10 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-05-19 11:19:38 -0400
commit2cfa6aedb32c9c1226094ed383dc3c9b3e2ecddb (patch)
tree75f7a7d3c90d8416370300f5bec2ee45bcc2b44b /drivers/hwmon/pmbus_core.c
parentb4ce237b7f7d31abe9c5b0c443a64573ace4933d (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/pmbus_core.c')
-rw-r--r--drivers/hwmon/pmbus_core.c29
1 files changed, 18 insertions, 11 deletions
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}
271EXPORT_SYMBOL_GPL(pmbus_get_driver_info); 271EXPORT_SYMBOL_GPL(pmbus_get_driver_info);
272 272
273static 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 */
277static 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
287static struct pmbus_data *pmbus_update_device(struct device *dev) 291static 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];