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>
This commit is contained in:
Guenter Roeck 2011-03-08 23:00:10 -08:00
Родитель b4ce237b7f
Коммит 2cfa6aedb3
4 изменённых файлов: 27 добавлений и 22 удалений

Просмотреть файл

@ -32,7 +32,7 @@ enum chips { max34440, max34441 };
#define MAX34440_STATUS_OT_FAULT (1 << 5)
#define MAX34440_STATUS_OT_WARN (1 << 6)
static int max34440_get_status(struct i2c_client *client, int page, int reg)
static int max34440_read_byte_data(struct i2c_client *client, int page, int reg)
{
int ret;
int mfg_status;
@ -108,7 +108,7 @@ static struct pmbus_driver_info max34440_info[] = {
.func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.func[12] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.func[13] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.get_status = max34440_get_status,
.read_byte_data = max34440_read_byte_data,
},
[max34441] = {
.pages = 12,
@ -149,7 +149,7 @@ static struct pmbus_driver_info max34440_info[] = {
.func[9] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.func[10] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.func[11] = PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
.get_status = max34440_get_status,
.read_byte_data = max34440_read_byte_data,
},
};

Просмотреть файл

@ -37,7 +37,7 @@
#define MAX8688_STATUS_OT_FAULT (1 << 13)
#define MAX8688_STATUS_OT_WARNING (1 << 14)
static int max8688_get_status(struct i2c_client *client, int page, int reg)
static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)
{
int ret = 0;
int mfg_status;
@ -110,7 +110,7 @@ static struct pmbus_driver_info max8688_info = {
.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT
| PMBUS_HAVE_STATUS_TEMP,
.get_status = max8688_get_status,
.read_byte_data = max8688_read_byte_data,
};
static int max8688_probe(struct i2c_client *client,

Просмотреть файл

@ -281,13 +281,11 @@ struct pmbus_driver_info {
u32 func[PMBUS_PAGES]; /* Functionality, per page */
/*
* The get_status function maps manufacturing specific status values
* into PMBus standard status values.
* This function is optional and only necessary if chip specific status
* register values have to be mapped into standard PMBus status register
* values.
* The following functions map manufacturing specific register values
* to PMBus standard register values. Specify only if mapping is
* necessary.
*/
int (*get_status)(struct i2c_client *client, int page, int reg);
int (*read_byte_data)(struct i2c_client *client, int page, int reg);
/*
* The identify function determines supported PMBus functionality.
* This function is only necessary if a chip driver supports multiple

Просмотреть файл

@ -270,18 +270,22 @@ const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client)
}
EXPORT_SYMBOL_GPL(pmbus_get_driver_info);
static int pmbus_get_status(struct i2c_client *client, int page, int reg)
/*
* _pmbus_read_byte_data() is similar to pmbus_read_byte_data(), but checks if
* a device specific mapping funcion exists and calls it if necessary.
*/
static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg)
{
struct pmbus_data *data = i2c_get_clientdata(client);
const struct pmbus_driver_info *info = data->info;
int status;
if (info->get_status) {
status = info->get_status(client, page, reg);
if (info->read_byte_data) {
status = info->read_byte_data(client, page, reg);
if (status != -ENODATA)
return status;
}
return pmbus_read_byte_data(client, page, reg);
return pmbus_read_byte_data(client, page, reg);
}
static struct pmbus_data *pmbus_update_device(struct device *dev)
@ -302,38 +306,41 @@ static struct pmbus_data *pmbus_update_device(struct device *dev)
if (!(info->func[i] & PMBUS_HAVE_STATUS_VOUT))
continue;
data->status[PB_STATUS_VOUT_BASE + i]
= pmbus_get_status(client, i, PMBUS_STATUS_VOUT);
= _pmbus_read_byte_data(client, i, PMBUS_STATUS_VOUT);
}
for (i = 0; i < info->pages; i++) {
if (!(info->func[i] & PMBUS_HAVE_STATUS_IOUT))
continue;
data->status[PB_STATUS_IOUT_BASE + i]
= pmbus_get_status(client, i, PMBUS_STATUS_IOUT);
= _pmbus_read_byte_data(client, i, PMBUS_STATUS_IOUT);
}
for (i = 0; i < info->pages; i++) {
if (!(info->func[i] & PMBUS_HAVE_STATUS_TEMP))
continue;
data->status[PB_STATUS_TEMP_BASE + i]
= pmbus_get_status(client, i,
PMBUS_STATUS_TEMPERATURE);
= _pmbus_read_byte_data(client, i,
PMBUS_STATUS_TEMPERATURE);
}
for (i = 0; i < info->pages; i++) {
if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN12))
continue;
data->status[PB_STATUS_FAN_BASE + i]
= pmbus_get_status(client, i, PMBUS_STATUS_FAN_12);
= _pmbus_read_byte_data(client, i,
PMBUS_STATUS_FAN_12);
}
for (i = 0; i < info->pages; i++) {
if (!(info->func[i] & PMBUS_HAVE_STATUS_FAN34))
continue;
data->status[PB_STATUS_FAN34_BASE + i]
= pmbus_get_status(client, i, PMBUS_STATUS_FAN_34);
= _pmbus_read_byte_data(client, i,
PMBUS_STATUS_FAN_34);
}
if (info->func[0] & PMBUS_HAVE_STATUS_INPUT)
data->status[PB_STATUS_INPUT_BASE]
= pmbus_get_status(client, 0, PMBUS_STATUS_INPUT);
= _pmbus_read_byte_data(client, 0,
PMBUS_STATUS_INPUT);
for (i = 0; i < data->num_sensors; i++) {
struct pmbus_sensor *sensor = &data->sensors[i];