test-power: add testpower dts-config
author许盛飞 <xsf@rock-chips.com>
Mon, 24 Nov 2014 04:00:21 +0000 (12:00 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 19 Aug 2016 03:06:11 +0000 (11:06 +0800)
Change-Id: Ib2c78602f604d610a648397cbf08c56cdbd77eab
Signed-off-by: Shengfei Xu <xsf@rock-chips.com>
drivers/power/test_power.c

index 83c42ea88f2b252b0c77a65cfe1bab12135e9dca..328ddd8bb77357b3a6f34d8990c891e640402d02 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/vermagic.h>
+#include <linux/of.h>
 
 enum test_power_id {
        TEST_AC,
@@ -197,6 +198,19 @@ static int __init test_power_init(void)
 {
        int i;
        int ret;
+       struct device_node *dev_node;
+
+       dev_node = of_find_node_by_name(NULL, "test-power");
+
+       if (!dev_node) {
+               pr_info("%s: could not find dev node\n", __func__);
+               return 0;
+       }
+       if (!of_device_is_available(dev_node)) {
+               pr_info("%s: test power disabled\n", __func__);
+               return 0;
+       }
+       of_node_put(dev_node);
 
        BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies));
        BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_configs));