mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
hwmon: (ina2xx) Add device tree support to pass the shunt resistor
Adding another way that is device tree to pass the shunt resistor value to driver except for platform data. Signed-off-by: Tang Yuantian <[email protected]> [Guenter Roeck: Added missing of.h include] Signed-off-by: Guenter Roeck <[email protected]>
This commit is contained in:
parent
87438c2c54
commit
31e7ad74f6
3 changed files with 30 additions and 1 deletions
|
|
@ -34,6 +34,7 @@
|
|||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include <linux/platform_data/ina2xx.h>
|
||||
|
||||
|
|
@ -221,6 +222,7 @@ static int ina2xx_probe(struct i2c_client *client,
|
|||
struct ina2xx_data *data;
|
||||
struct ina2xx_platform_data *pdata;
|
||||
int ret;
|
||||
u32 val;
|
||||
long shunt = 10000; /* default shunt value 10mOhms */
|
||||
|
||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
|
||||
|
|
@ -234,6 +236,9 @@ static int ina2xx_probe(struct i2c_client *client,
|
|||
pdata =
|
||||
(struct ina2xx_platform_data *)client->dev.platform_data;
|
||||
shunt = pdata->shunt_uohms;
|
||||
} else if (!of_property_read_u32(client->dev.of_node,
|
||||
"shunt-resistor", &val)) {
|
||||
shunt = val;
|
||||
}
|
||||
|
||||
if (shunt <= 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue