Commit 179144a0 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (pmbus) Replace EINVAL return codes with more appropriate errors

EINVAL was over-used in the code. Replace it with more appropriate errors.
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Reviewed-by: default avatarRobert Coulson <robert.coulson@ericsson.com>
parent ced29d42
...@@ -57,7 +57,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -57,7 +57,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg)
int ret; int ret;
if (page > 1) if (page > 1)
return -EINVAL; return -ENXIO;
/* Map READ_VAUX into READ_VOUT register on page 1 */ /* Map READ_VAUX into READ_VOUT register on page 1 */
if (page == 1) { if (page == 1) {
...@@ -85,7 +85,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -85,7 +85,7 @@ static int lm25066_read_word_data(struct i2c_client *client, int page, int reg)
break; break;
default: default:
/* No other valid registers on page 1 */ /* No other valid registers on page 1 */
ret = -EINVAL; ret = -ENXIO;
break; break;
} }
goto done; goto done;
...@@ -138,7 +138,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, ...@@ -138,7 +138,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
int ret; int ret;
if (page > 1) if (page > 1)
return -EINVAL; return -ENXIO;
switch (reg) { switch (reg) {
case PMBUS_IIN_OC_WARN_LIMIT: case PMBUS_IIN_OC_WARN_LIMIT:
...@@ -164,7 +164,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, ...@@ -164,7 +164,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
static int lm25066_write_byte(struct i2c_client *client, int page, u8 value) static int lm25066_write_byte(struct i2c_client *client, int page, u8 value)
{ {
if (page > 1) if (page > 1)
return -EINVAL; return -ENXIO;
if (page == 0) if (page == 0)
return pmbus_write_byte(client, 0, value); return pmbus_write_byte(client, 0, value);
......
...@@ -45,7 +45,7 @@ static int max8688_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -45,7 +45,7 @@ static int max8688_read_word_data(struct i2c_client *client, int page, int reg)
int ret; int ret;
if (page) if (page)
return -EINVAL; return -ENXIO;
switch (reg) { switch (reg) {
case PMBUS_VIRT_READ_VOUT_MAX: case PMBUS_VIRT_READ_VOUT_MAX:
...@@ -102,7 +102,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -102,7 +102,7 @@ static int max8688_read_byte_data(struct i2c_client *client, int page, int reg)
int mfg_status; int mfg_status;
if (page) if (page)
return -EINVAL; return -ENXIO;
switch (reg) { switch (reg) {
case PMBUS_STATUS_VOUT: case PMBUS_STATUS_VOUT:
......
...@@ -160,7 +160,7 @@ int pmbus_set_page(struct i2c_client *client, u8 page) ...@@ -160,7 +160,7 @@ int pmbus_set_page(struct i2c_client *client, u8 page)
rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE); newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
if (newpage != page) if (newpage != page)
rv = -EINVAL; rv = -EIO;
else else
data->currpage = page; data->currpage = page;
} }
...@@ -229,7 +229,7 @@ static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg, ...@@ -229,7 +229,7 @@ static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg,
return status; return status;
} }
if (reg >= PMBUS_VIRT_BASE) if (reg >= PMBUS_VIRT_BASE)
return -EINVAL; return -ENXIO;
return pmbus_write_word_data(client, page, reg, word); return pmbus_write_word_data(client, page, reg, word);
} }
...@@ -261,7 +261,7 @@ static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg) ...@@ -261,7 +261,7 @@ static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg)
return status; return status;
} }
if (reg >= PMBUS_VIRT_BASE) if (reg >= PMBUS_VIRT_BASE)
return -EINVAL; return -ENXIO;
return pmbus_read_word_data(client, page, reg); return pmbus_read_word_data(client, page, reg);
} }
...@@ -320,7 +320,7 @@ static int pmbus_check_status_cml(struct i2c_client *client) ...@@ -320,7 +320,7 @@ static int pmbus_check_status_cml(struct i2c_client *client)
if (status < 0 || (status & PB_STATUS_CML)) { if (status < 0 || (status & PB_STATUS_CML)) {
status2 = pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); status2 = pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML);
if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND))
return -EINVAL; return -EIO;
} }
return 0; return 0;
} }
...@@ -1682,7 +1682,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, ...@@ -1682,7 +1682,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
if (info->pages <= 0 || info->pages > PMBUS_PAGES) { if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
dev_err(&client->dev, "Bad number of PMBus pages: %d\n", dev_err(&client->dev, "Bad number of PMBus pages: %d\n",
info->pages); info->pages);
ret = -EINVAL; ret = -ENODEV;
goto out_data; goto out_data;
} }
......
...@@ -75,7 +75,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -75,7 +75,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg)
switch (reg) { switch (reg) {
case PMBUS_FAN_CONFIG_12: case PMBUS_FAN_CONFIG_12:
if (page) if (page)
return -EINVAL; return -ENXIO;
ret = ucd9000_get_fan_config(client, 0); ret = ucd9000_get_fan_config(client, 0);
if (ret < 0) if (ret < 0)
...@@ -89,7 +89,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) ...@@ -89,7 +89,7 @@ static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg)
break; break;
case PMBUS_FAN_CONFIG_34: case PMBUS_FAN_CONFIG_34:
if (page) if (page)
return -EINVAL; return -ENXIO;
ret = ucd9000_get_fan_config(client, 2); ret = ucd9000_get_fan_config(client, 2);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment