Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 261751
b: refs/heads/master
c: 9c1ed89
h: refs/heads/master
i:
  261749: 9c6445d
  261747: 7be91fc
  261743: dc54c44
v: v3
  • Loading branch information
Guenter Roeck committed Jul 29, 2011
1 parent a29feb9 commit df05ee1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 46243f3ab44ad0d2e9ca62e6485ca433659f3881
refs/heads/master: 9c1ed8941d30fd6252e84a9941e6507e497d242b
2 changes: 1 addition & 1 deletion trunk/drivers/hwmon/pmbus/pmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ struct pmbus_driver_info {
int pmbus_set_page(struct i2c_client *client, u8 page);
int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg);
int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word);
int pmbus_read_byte_data(struct i2c_client *client, u8 page, u8 reg);
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
void pmbus_clear_faults(struct i2c_client *client);
bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
Expand Down
46 changes: 19 additions & 27 deletions trunk/drivers/hwmon/pmbus/pmbus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ int pmbus_set_page(struct i2c_client *client, u8 page)
}
EXPORT_SYMBOL_GPL(pmbus_set_page);

static int pmbus_write_byte(struct i2c_client *client, u8 page, u8 value)
static int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
{
int rv;

rv = pmbus_set_page(client, page);
if (rv < 0)
return rv;
if (page >= 0) {
rv = pmbus_set_page(client, page);
if (rv < 0)
return rv;
}

return i2c_smbus_write_byte(client, value);
}
Expand Down Expand Up @@ -238,13 +240,15 @@ static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg)
return pmbus_read_word_data(client, page, reg);
}

int pmbus_read_byte_data(struct i2c_client *client, u8 page, u8 reg)
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg)
{
int rv;

rv = pmbus_set_page(client, page);
if (rv < 0)
return rv;
if (page >= 0) {
rv = pmbus_set_page(client, page);
if (rv < 0)
return rv;
}

return i2c_smbus_read_byte_data(client, reg);
}
Expand All @@ -265,13 +269,13 @@ void pmbus_clear_faults(struct i2c_client *client)
}
EXPORT_SYMBOL_GPL(pmbus_clear_faults);

static int pmbus_check_status_cml(struct i2c_client *client, int page)
static int pmbus_check_status_cml(struct i2c_client *client)
{
int status, status2;

status = pmbus_read_byte_data(client, page, PMBUS_STATUS_BYTE);
status = pmbus_read_byte_data(client, -1, PMBUS_STATUS_BYTE);
if (status < 0 || (status & PB_STATUS_CML)) {
status2 = pmbus_read_byte_data(client, page, PMBUS_STATUS_CML);
status2 = pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML);
if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND))
return -EINVAL;
}
Expand All @@ -285,8 +289,8 @@ bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg)

rv = pmbus_read_byte_data(client, page, reg);
if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK))
rv = pmbus_check_status_cml(client, page);
pmbus_clear_fault_page(client, page);
rv = pmbus_check_status_cml(client);
pmbus_clear_fault_page(client, -1);
return rv >= 0;
}
EXPORT_SYMBOL_GPL(pmbus_check_byte_register);
Expand All @@ -298,8 +302,8 @@ bool pmbus_check_word_register(struct i2c_client *client, int page, int reg)

rv = pmbus_read_word_data(client, page, reg);
if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK))
rv = pmbus_check_status_cml(client, page);
pmbus_clear_fault_page(client, page);
rv = pmbus_check_status_cml(client);
pmbus_clear_fault_page(client, -1);
return rv >= 0;
}
EXPORT_SYMBOL_GPL(pmbus_check_word_register);
Expand Down Expand Up @@ -1541,18 +1545,6 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
ret = -EINVAL;
goto out_data;
}
/*
* Bail out if more than one page was configured, but we can not
* select the highest page. This is an indication that the wrong
* chip type was selected. Better bail out now than keep
* returning errors later on.
*/
if (info->pages > 1 && pmbus_set_page(client, info->pages - 1) < 0) {
dev_err(&client->dev, "Failed to select page %d\n",
info->pages - 1);
ret = -EINVAL;
goto out_data;
}

ret = pmbus_identify_common(client, data);
if (ret < 0) {
Expand Down

0 comments on commit df05ee1

Please sign in to comment.