diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-30 01:19:39 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-10-24 14:09:40 -0400 |
commit | da8e48ab483e1f54c1099bed91bfd2c302bc7ddf (patch) | |
tree | 10a2c76781ef0b1c51515d4feb71c7fa5ae6e29f /drivers/hwmon | |
parent | 179144a0d4128e7588b3d613a14807402f5e7c37 (diff) |
hwmon: (pmbus) Always call _pmbus_read_byte in core driver
Always call _pmbus_read_byte() instead of pmbus_read_byte() in PMBus core
driver. With this change, device specific read functions can be implemented for
all registers.
Since the device specific read_byte function is now always called, we need to be
more careful with page validations. Only fail if the passed page number is larger
than 0, since -1 means "current page".
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/pmbus/adm1275.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/lm25066.c | 4 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/max34440.c | 10 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/max8688.c | 2 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 10 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/ucd9000.c | 4 |
6 files changed, 17 insertions, 15 deletions
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index fa1811274c27..980a4d9d5028 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c | |||
@@ -144,7 +144,7 @@ static int adm1275_read_byte_data(struct i2c_client *client, int page, int reg) | |||
144 | const struct adm1275_data *data = to_adm1275_data(info); | 144 | const struct adm1275_data *data = to_adm1275_data(info); |
145 | int mfr_status, ret; | 145 | int mfr_status, ret; |
146 | 146 | ||
147 | if (page) | 147 | if (page > 0) |
148 | return -ENXIO; | 148 | return -ENXIO; |
149 | 149 | ||
150 | switch (reg) { | 150 | switch (reg) { |
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index a72bb9f51dec..84a37f0c8db6 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c | |||
@@ -166,8 +166,8 @@ static int lm25066_write_byte(struct i2c_client *client, int page, u8 value) | |||
166 | if (page > 1) | 166 | if (page > 1) |
167 | return -ENXIO; | 167 | return -ENXIO; |
168 | 168 | ||
169 | if (page == 0) | 169 | if (page <= 0) |
170 | return pmbus_write_byte(client, 0, value); | 170 | return pmbus_write_byte(client, page, value); |
171 | 171 | ||
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c index c824365e4aa4..beaf5a8d9c45 100644 --- a/drivers/hwmon/pmbus/max34440.c +++ b/drivers/hwmon/pmbus/max34440.c | |||
@@ -93,12 +93,14 @@ static int max34440_write_word_data(struct i2c_client *client, int page, | |||
93 | 93 | ||
94 | static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) | 94 | static int max34440_read_byte_data(struct i2c_client *client, int page, int reg) |
95 | { | 95 | { |
96 | int ret; | 96 | int ret = 0; |
97 | int mfg_status; | 97 | int mfg_status; |
98 | 98 | ||
99 | ret = pmbus_set_page(client, page); | 99 | if (page >= 0) { |
100 | if (ret < 0) | 100 | ret = pmbus_set_page(client, page); |
101 | return ret; | 101 | if (ret < 0) |
102 | return ret; | ||
103 | } | ||
102 | 104 | ||
103 | switch (reg) { | 105 | switch (reg) { |
104 | case PMBUS_STATUS_IOUT: | 106 | case PMBUS_STATUS_IOUT: |
diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c index 7113f1131e4a..e2b74bb399ba 100644 --- a/drivers/hwmon/pmbus/max8688.c +++ b/drivers/hwmon/pmbus/max8688.c | |||
@@ -101,7 +101,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) | |||
101 | int ret = 0; | 101 | int ret = 0; |
102 | int mfg_status; | 102 | int mfg_status; |
103 | 103 | ||
104 | if (page) | 104 | if (page > 0) |
105 | return -ENXIO; | 105 | return -ENXIO; |
106 | 106 | ||
107 | switch (reg) { | 107 | switch (reg) { |
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 7841ea0c10a3..f241a4d2cf8f 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
@@ -316,9 +316,9 @@ static int pmbus_check_status_cml(struct i2c_client *client) | |||
316 | { | 316 | { |
317 | int status, status2; | 317 | int status, status2; |
318 | 318 | ||
319 | status = pmbus_read_byte_data(client, -1, PMBUS_STATUS_BYTE); | 319 | status = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_BYTE); |
320 | if (status < 0 || (status & PB_STATUS_CML)) { | 320 | if (status < 0 || (status & PB_STATUS_CML)) { |
321 | status2 = pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); | 321 | status2 = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); |
322 | if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) | 322 | if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) |
323 | return -EIO; | 323 | return -EIO; |
324 | } | 324 | } |
@@ -371,8 +371,8 @@ static struct pmbus_data *pmbus_update_device(struct device *dev) | |||
371 | 371 | ||
372 | for (i = 0; i < info->pages; i++) | 372 | for (i = 0; i < info->pages; i++) |
373 | data->status[PB_STATUS_BASE + i] | 373 | data->status[PB_STATUS_BASE + i] |
374 | = pmbus_read_byte_data(client, i, | 374 | = _pmbus_read_byte_data(client, i, |
375 | PMBUS_STATUS_BYTE); | 375 | PMBUS_STATUS_BYTE); |
376 | for (i = 0; i < info->pages; i++) { | 376 | for (i = 0; i < info->pages; i++) { |
377 | if (!(info->func[i] & PMBUS_HAVE_STATUS_VOUT)) | 377 | if (!(info->func[i] & PMBUS_HAVE_STATUS_VOUT)) |
378 | continue; | 378 | continue; |
@@ -1596,7 +1596,7 @@ static int pmbus_identify_common(struct i2c_client *client, | |||
1596 | int vout_mode = -1, exponent; | 1596 | int vout_mode = -1, exponent; |
1597 | 1597 | ||
1598 | if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) | 1598 | if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) |
1599 | vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); | 1599 | vout_mode = _pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); |
1600 | if (vout_mode >= 0 && vout_mode != 0xff) { | 1600 | if (vout_mode >= 0 && vout_mode != 0xff) { |
1601 | /* | 1601 | /* |
1602 | * Not all chips support the VOUT_MODE command, | 1602 | * Not all chips support the VOUT_MODE command, |
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index 1536db6543f0..4ff6cf289f85 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c | |||
@@ -74,7 +74,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) | |||
74 | 74 | ||
75 | switch (reg) { | 75 | switch (reg) { |
76 | case PMBUS_FAN_CONFIG_12: | 76 | case PMBUS_FAN_CONFIG_12: |
77 | if (page) | 77 | if (page > 0) |
78 | return -ENXIO; | 78 | return -ENXIO; |
79 | 79 | ||
80 | ret = ucd9000_get_fan_config(client, 0); | 80 | ret = ucd9000_get_fan_config(client, 0); |
@@ -88,7 +88,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) | |||
88 | ret = fan_config; | 88 | ret = fan_config; |
89 | break; | 89 | break; |
90 | case PMBUS_FAN_CONFIG_34: | 90 | case PMBUS_FAN_CONFIG_34: |
91 | if (page) | 91 | if (page > 0) |
92 | return -ENXIO; | 92 | return -ENXIO; |
93 | 93 | ||
94 | ret = ucd9000_get_fan_config(client, 2); | 94 | ret = ucd9000_get_fan_config(client, 2); |