diff options
author | Guenter Roeck <linux@roeck-us.net> | 2016-06-19 20:11:13 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2016-07-09 11:33:46 -0400 |
commit | 38aefb41b3803873dc366918a2e22f22dca78eac (patch) | |
tree | b1c76584a5971b2db7558aa7fa5fb409c839d736 /drivers/hwmon/lm75.c | |
parent | 9e37d3e2298e7ca2a9d210532c77a325d07816fe (diff) |
hwmon: (lm75) Drop lm75_read_value and lm75_write_value
lm75_read_value and lm75_write_value don't really add any value.
Replace with direct smbus access functions.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 0df745501a1f..7b18cbd4a5ec 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -89,8 +89,6 @@ struct lm75_data { | |||
89 | 2 = hyst */ | 89 | 2 = hyst */ |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static int lm75_read_value(struct i2c_client *client, u8 reg); | ||
93 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); | ||
94 | static struct lm75_data *lm75_update_device(struct device *dev); | 92 | static struct lm75_data *lm75_update_device(struct device *dev); |
95 | 93 | ||
96 | 94 | ||
@@ -156,7 +154,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, | |||
156 | temp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX); | 154 | temp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX); |
157 | data->temp[nr] = DIV_ROUND_CLOSEST(temp << (resolution - 8), | 155 | data->temp[nr] = DIV_ROUND_CLOSEST(temp << (resolution - 8), |
158 | 1000) << (16 - resolution); | 156 | 1000) << (16 - resolution); |
159 | lm75_write_value(client, LM75_REG_TEMP[nr], data->temp[nr]); | 157 | i2c_smbus_write_word_swapped(client, LM75_REG_TEMP[nr], data->temp[nr]); |
160 | mutex_unlock(&data->update_lock); | 158 | mutex_unlock(&data->update_lock); |
161 | return count; | 159 | return count; |
162 | } | 160 | } |
@@ -296,7 +294,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
296 | } | 294 | } |
297 | 295 | ||
298 | /* configure as specified */ | 296 | /* configure as specified */ |
299 | status = lm75_read_value(client, LM75_REG_CONF); | 297 | status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); |
300 | if (status < 0) { | 298 | if (status < 0) { |
301 | dev_dbg(dev, "Can't read config? %d\n", status); | 299 | dev_dbg(dev, "Can't read config? %d\n", status); |
302 | return status; | 300 | return status; |
@@ -305,7 +303,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
305 | new = status & ~clr_mask; | 303 | new = status & ~clr_mask; |
306 | new |= set_mask; | 304 | new |= set_mask; |
307 | if (status != new) | 305 | if (status != new) |
308 | lm75_write_value(client, LM75_REG_CONF, new); | 306 | i2c_smbus_write_byte_data(client, LM75_REG_CONF, new); |
309 | 307 | ||
310 | devm_add_action(dev, lm75_remove, data); | 308 | devm_add_action(dev, lm75_remove, data); |
311 | 309 | ||
@@ -450,13 +448,13 @@ static int lm75_suspend(struct device *dev) | |||
450 | { | 448 | { |
451 | int status; | 449 | int status; |
452 | struct i2c_client *client = to_i2c_client(dev); | 450 | struct i2c_client *client = to_i2c_client(dev); |
453 | status = lm75_read_value(client, LM75_REG_CONF); | 451 | status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); |
454 | if (status < 0) { | 452 | if (status < 0) { |
455 | dev_dbg(&client->dev, "Can't read config? %d\n", status); | 453 | dev_dbg(&client->dev, "Can't read config? %d\n", status); |
456 | return status; | 454 | return status; |
457 | } | 455 | } |
458 | status = status | LM75_SHUTDOWN; | 456 | status = status | LM75_SHUTDOWN; |
459 | lm75_write_value(client, LM75_REG_CONF, status); | 457 | i2c_smbus_write_byte_data(client, LM75_REG_CONF, status); |
460 | return 0; | 458 | return 0; |
461 | } | 459 | } |
462 | 460 | ||
@@ -464,13 +462,13 @@ static int lm75_resume(struct device *dev) | |||
464 | { | 462 | { |
465 | int status; | 463 | int status; |
466 | struct i2c_client *client = to_i2c_client(dev); | 464 | struct i2c_client *client = to_i2c_client(dev); |
467 | status = lm75_read_value(client, LM75_REG_CONF); | 465 | status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); |
468 | if (status < 0) { | 466 | if (status < 0) { |
469 | dev_dbg(&client->dev, "Can't read config? %d\n", status); | 467 | dev_dbg(&client->dev, "Can't read config? %d\n", status); |
470 | return status; | 468 | return status; |
471 | } | 469 | } |
472 | status = status & ~LM75_SHUTDOWN; | 470 | status = status & ~LM75_SHUTDOWN; |
473 | lm75_write_value(client, LM75_REG_CONF, status); | 471 | i2c_smbus_write_byte_data(client, LM75_REG_CONF, status); |
474 | return 0; | 472 | return 0; |
475 | } | 473 | } |
476 | 474 | ||
@@ -497,29 +495,6 @@ static struct i2c_driver lm75_driver = { | |||
497 | 495 | ||
498 | /*-----------------------------------------------------------------------*/ | 496 | /*-----------------------------------------------------------------------*/ |
499 | 497 | ||
500 | /* register access */ | ||
501 | |||
502 | /* | ||
503 | * All registers are word-sized, except for the configuration register. | ||
504 | * LM75 uses a high-byte first convention, which is exactly opposite to | ||
505 | * the SMBus standard. | ||
506 | */ | ||
507 | static int lm75_read_value(struct i2c_client *client, u8 reg) | ||
508 | { | ||
509 | if (reg == LM75_REG_CONF) | ||
510 | return i2c_smbus_read_byte_data(client, reg); | ||
511 | else | ||
512 | return i2c_smbus_read_word_swapped(client, reg); | ||
513 | } | ||
514 | |||
515 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) | ||
516 | { | ||
517 | if (reg == LM75_REG_CONF) | ||
518 | return i2c_smbus_write_byte_data(client, reg, value); | ||
519 | else | ||
520 | return i2c_smbus_write_word_swapped(client, reg, value); | ||
521 | } | ||
522 | |||
523 | static struct lm75_data *lm75_update_device(struct device *dev) | 498 | static struct lm75_data *lm75_update_device(struct device *dev) |
524 | { | 499 | { |
525 | struct lm75_data *data = dev_get_drvdata(dev); | 500 | struct lm75_data *data = dev_get_drvdata(dev); |
@@ -536,7 +511,8 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
536 | for (i = 0; i < ARRAY_SIZE(data->temp); i++) { | 511 | for (i = 0; i < ARRAY_SIZE(data->temp); i++) { |
537 | int status; | 512 | int status; |
538 | 513 | ||
539 | status = lm75_read_value(client, LM75_REG_TEMP[i]); | 514 | status = i2c_smbus_read_word_swapped(client, |
515 | LM75_REG_TEMP[i]); | ||
540 | if (unlikely(status < 0)) { | 516 | if (unlikely(status < 0)) { |
541 | dev_dbg(dev, | 517 | dev_dbg(dev, |
542 | "LM75: Failed to read value: reg %d, error %d\n", | 518 | "LM75: Failed to read value: reg %d, error %d\n", |