diff options
-rw-r--r-- | drivers/hwmon/pmbus/pmbus.h | 4 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index fa9beb3eb60c..3ae79a7d1b00 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h | |||
@@ -375,6 +375,10 @@ int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg); | |||
375 | int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word); | 375 | int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word); |
376 | int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); | 376 | int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); |
377 | int pmbus_write_byte(struct i2c_client *client, int page, u8 value); | 377 | int pmbus_write_byte(struct i2c_client *client, int page, u8 value); |
378 | int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, | ||
379 | u8 value); | ||
380 | int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, | ||
381 | u8 mask, u8 value); | ||
378 | void pmbus_clear_faults(struct i2c_client *client); | 382 | void pmbus_clear_faults(struct i2c_client *client); |
379 | bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); | 383 | bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); |
380 | bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); | 384 | bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); |
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 291d11fe93e7..d6c3701eb7f9 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
@@ -253,6 +253,37 @@ int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg) | |||
253 | } | 253 | } |
254 | EXPORT_SYMBOL_GPL(pmbus_read_byte_data); | 254 | EXPORT_SYMBOL_GPL(pmbus_read_byte_data); |
255 | 255 | ||
256 | int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value) | ||
257 | { | ||
258 | int rv; | ||
259 | |||
260 | rv = pmbus_set_page(client, page); | ||
261 | if (rv < 0) | ||
262 | return rv; | ||
263 | |||
264 | return i2c_smbus_write_byte_data(client, reg, value); | ||
265 | } | ||
266 | EXPORT_SYMBOL_GPL(pmbus_write_byte_data); | ||
267 | |||
268 | int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, | ||
269 | u8 mask, u8 value) | ||
270 | { | ||
271 | unsigned int tmp; | ||
272 | int rv; | ||
273 | |||
274 | rv = pmbus_read_byte_data(client, page, reg); | ||
275 | if (rv < 0) | ||
276 | return rv; | ||
277 | |||
278 | tmp = (rv & ~mask) | (value & mask); | ||
279 | |||
280 | if (tmp != rv) | ||
281 | rv = pmbus_write_byte_data(client, page, reg, tmp); | ||
282 | |||
283 | return rv; | ||
284 | } | ||
285 | EXPORT_SYMBOL_GPL(pmbus_update_byte_data); | ||
286 | |||
256 | /* | 287 | /* |
257 | * _pmbus_read_byte_data() is similar to pmbus_read_byte_data(), but checks if | 288 | * _pmbus_read_byte_data() is similar to pmbus_read_byte_data(), but checks if |
258 | * a device specific mapping function exists and calls it if necessary. | 289 | * a device specific mapping function exists and calls it if necessary. |