Skip to content

Commit 91d85ea

Browse files
committed
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/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
2 parents 1798778 + 66a89b2 commit 91d85ea

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

drivers/hwmon/ibmaem.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,15 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
432432
aem_send_message(ipmi);
433433

434434
res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
435-
if (!res)
436-
return -ETIMEDOUT;
435+
if (!res) {
436+
res = -ETIMEDOUT;
437+
goto out;
438+
}
437439

438440
if (ipmi->rx_result || ipmi->rx_msg_len != rs_size ||
439441
memcmp(&rs_resp->id, &system_x_id, sizeof(system_x_id))) {
440-
kfree(rs_resp);
441-
return -ENOENT;
442+
res = -ENOENT;
443+
goto out;
442444
}
443445

444446
switch (size) {
@@ -463,8 +465,11 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
463465
break;
464466
}
465467
}
468+
res = 0;
466469

467-
return 0;
470+
out:
471+
kfree(rs_resp);
472+
return res;
468473
}
469474

470475
/* Update AEM energy registers */

drivers/hwmon/pmbus/lm25066.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
161161
return ret;
162162
}
163163

164+
static int lm25066_write_byte(struct i2c_client *client, int page, u8 value)
165+
{
166+
if (page > 1)
167+
return -EINVAL;
168+
169+
if (page == 0)
170+
return pmbus_write_byte(client, 0, value);
171+
172+
return 0;
173+
}
174+
164175
static int lm25066_probe(struct i2c_client *client,
165176
const struct i2c_device_id *id)
166177
{
@@ -204,6 +215,7 @@ static int lm25066_probe(struct i2c_client *client,
204215

205216
info->read_word_data = lm25066_read_word_data;
206217
info->write_word_data = lm25066_write_word_data;
218+
info->write_byte = lm25066_write_byte;
207219

208220
switch (id->driver_data) {
209221
case lm25066:

drivers/hwmon/pmbus/pmbus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ struct pmbus_driver_info {
325325
int (*read_word_data)(struct i2c_client *client, int page, int reg);
326326
int (*write_word_data)(struct i2c_client *client, int page, int reg,
327327
u16 word);
328+
int (*write_byte)(struct i2c_client *client, int page, u8 value);
328329
/*
329330
* The identify function determines supported PMBus functionality.
330331
* This function is only necessary if a chip driver supports multiple

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,24 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value)
182182
}
183183
EXPORT_SYMBOL_GPL(pmbus_write_byte);
184184

185+
/*
186+
* _pmbus_write_byte() is similar to pmbus_write_byte(), but checks if
187+
* a device specific mapping funcion exists and calls it if necessary.
188+
*/
189+
static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value)
190+
{
191+
struct pmbus_data *data = i2c_get_clientdata(client);
192+
const struct pmbus_driver_info *info = data->info;
193+
int status;
194+
195+
if (info->write_byte) {
196+
status = info->write_byte(client, page, value);
197+
if (status != -ENODATA)
198+
return status;
199+
}
200+
return pmbus_write_byte(client, page, value);
201+
}
202+
185203
int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word)
186204
{
187205
int rv;
@@ -281,7 +299,7 @@ static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg)
281299

282300
static void pmbus_clear_fault_page(struct i2c_client *client, int page)
283301
{
284-
pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS);
302+
_pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS);
285303
}
286304

287305
void pmbus_clear_faults(struct i2c_client *client)

0 commit comments

Comments
 (0)