Skip to content

Commit

Permalink
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/groeck/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging:
  hwmon: (ibmaem) add missing kfree
  hwmon: (pmbus/lm25066) Ignore byte writes to non-zero pages
  hwmon: (pmbus) Virtualize pmbus_write_byte
  • Loading branch information
Linus Torvalds committed Aug 14, 2011
2 parents 1798778 + 66a89b2 commit 91d85ea
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
15 changes: 10 additions & 5 deletions drivers/hwmon/ibmaem.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,15 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
aem_send_message(ipmi);

res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
if (!res)
return -ETIMEDOUT;
if (!res) {
res = -ETIMEDOUT;
goto out;
}

if (ipmi->rx_result || ipmi->rx_msg_len != rs_size ||
memcmp(&rs_resp->id, &system_x_id, sizeof(system_x_id))) {
kfree(rs_resp);
return -ENOENT;
res = -ENOENT;
goto out;
}

switch (size) {
Expand All @@ -463,8 +465,11 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
break;
}
}
res = 0;

return 0;
out:
kfree(rs_resp);
return res;
}

/* Update AEM energy registers */
Expand Down
12 changes: 12 additions & 0 deletions drivers/hwmon/pmbus/lm25066.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
return ret;
}

static int lm25066_write_byte(struct i2c_client *client, int page, u8 value)
{
if (page > 1)
return -EINVAL;

if (page == 0)
return pmbus_write_byte(client, 0, value);

return 0;
}

static int lm25066_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
Expand Down Expand Up @@ -204,6 +215,7 @@ static int lm25066_probe(struct i2c_client *client,

info->read_word_data = lm25066_read_word_data;
info->write_word_data = lm25066_write_word_data;
info->write_byte = lm25066_write_byte;

switch (id->driver_data) {
case lm25066:
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/pmbus/pmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ struct pmbus_driver_info {
int (*read_word_data)(struct i2c_client *client, int page, int reg);
int (*write_word_data)(struct i2c_client *client, int page, int reg,
u16 word);
int (*write_byte)(struct i2c_client *client, int page, u8 value);
/*
* The identify function determines supported PMBus functionality.
* This function is only necessary if a chip driver supports multiple
Expand Down
20 changes: 19 additions & 1 deletion drivers/hwmon/pmbus/pmbus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
}
EXPORT_SYMBOL_GPL(pmbus_write_byte);

/*
* _pmbus_write_byte() is similar to pmbus_write_byte(), but checks if
* a device specific mapping funcion exists and calls it if necessary.
*/
static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value)
{
struct pmbus_data *data = i2c_get_clientdata(client);
const struct pmbus_driver_info *info = data->info;
int status;

if (info->write_byte) {
status = info->write_byte(client, page, value);
if (status != -ENODATA)
return status;
}
return pmbus_write_byte(client, page, value);
}

int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word)
{
int rv;
Expand Down Expand Up @@ -281,7 +299,7 @@ static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg)

static void pmbus_clear_fault_page(struct i2c_client *client, int page)
{
pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS);
_pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS);
}

void pmbus_clear_faults(struct i2c_client *client)
Expand Down

0 comments on commit 91d85ea

Please sign in to comment.