diff options
author | Tang Yuantian <yuantian.tang@freescale.com> | 2013-06-19 02:50:20 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-06-27 13:31:42 -0400 |
commit | 31e7ad74f6044ffec112fd4975c07b797589d89c (patch) | |
tree | 220cacb4384d156c3fc723ce043974aecc36e442 /drivers/hwmon | |
parent | 87438c2c5483a7ab445c14a8855fd309ae79b4e6 (diff) |
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 <Yuantian.Tang@freescale.com>
[Guenter Roeck: Added missing of.h include]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ina2xx.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 4958b2f89dce..d917a2d8c30f 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/jiffies.h> | 36 | #include <linux/jiffies.h> |
37 | #include <linux/of.h> | ||
37 | 38 | ||
38 | #include <linux/platform_data/ina2xx.h> | 39 | #include <linux/platform_data/ina2xx.h> |
39 | 40 | ||
@@ -221,6 +222,7 @@ static int ina2xx_probe(struct i2c_client *client, | |||
221 | struct ina2xx_data *data; | 222 | struct ina2xx_data *data; |
222 | struct ina2xx_platform_data *pdata; | 223 | struct ina2xx_platform_data *pdata; |
223 | int ret; | 224 | int ret; |
225 | u32 val; | ||
224 | long shunt = 10000; /* default shunt value 10mOhms */ | 226 | long shunt = 10000; /* default shunt value 10mOhms */ |
225 | 227 | ||
226 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) | 228 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -234,6 +236,9 @@ static int ina2xx_probe(struct i2c_client *client, | |||
234 | pdata = | 236 | pdata = |
235 | (struct ina2xx_platform_data *)client->dev.platform_data; | 237 | (struct ina2xx_platform_data *)client->dev.platform_data; |
236 | shunt = pdata->shunt_uohms; | 238 | shunt = pdata->shunt_uohms; |
239 | } else if (!of_property_read_u32(client->dev.of_node, | ||
240 | "shunt-resistor", &val)) { | ||
241 | shunt = val; | ||
237 | } | 242 | } |
238 | 243 | ||
239 | if (shunt <= 0) | 244 | if (shunt <= 0) |