Add voltage and temperature in battery_info 51/178951/3 submit/tizen/20180706.105024
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 15 May 2018 05:01:21 +0000 (14:01 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 6 Jul 2018 10:42:03 +0000 (10:42 +0000)
Change-Id: I4b639801e472c20edb8302a841b55c15799b8865
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
hw/battery/battery.c [changed mode: 0644->0755]
hw/usb_cfs_client/usb_cfs_client.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index f0404bc..61af8ee
@@ -53,7 +53,7 @@ static int get_power_source(char **src)
 
        *src = POWER_SOURCE_NONE;
 
-       while(fgets(buf, sizeof(buf), fp)) {
+       while (fgets(buf, sizeof(buf), fp)) {
                if (strstr(buf, "USB=")) {
                        val = atoi(buf + 4); /* 4 == "USB=" */
                        if (val == 0)
@@ -155,6 +155,21 @@ static void uevent_delivered(struct udev_device *dev)
 
        info.current_average = info.current_now;
 
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_VOLTAGE_NOW");
+       if (!val)
+               return;
+       info.voltage_now = atoi(val); /* uV */
+
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_VOLTAGE_AVG");
+       if (!val)
+               return;
+       info.voltage_average = atoi(val); /* uV */
+
+       val = (char *)udev_device_get_property_value(dev, "POWER_SUPPLY_TEMP");
+       if (!val)
+               return;
+       info.temperature = atoi(val);
+
        adjust_current(&info);
 
        ret = get_power_source(&val);
@@ -278,6 +293,24 @@ static int battery_get_current_state(
 
        info.current_average = info.current_now;
 
+       path = BATTERY_ROOT_PATH"/battery/voltage_now";
+       ret = sys_get_int(path, &val);
+       if (ret < 0) {
+               _E("Failed to get value of (%s, %d)", path, ret);
+               return ret;
+       }
+       info.voltage_now = val;
+
+       info.voltage_average = info.voltage_now;
+
+       path = BATTERY_ROOT_PATH"/battery/temp";
+       ret = sys_get_int(path, &val);
+       if (ret < 0) {
+               _E("Failed to get value of (%s, %d)", path, ret);
+               return ret;
+       }
+       info.temperature = val;
+
        adjust_current(&info);
 
        updated_cb(&info, data);
old mode 100644 (file)
new mode 100755 (executable)
index 0e76f3b..adbc945
@@ -312,9 +312,9 @@ static int cfs_read_config(usbg_config *config, struct usb_gadget *gadget,
 
                usb_config->funcs[i] = cfs_find_func_in_gadget(gadget,
                                                               name, instance);
-               if (!usb_config->funcs[i]) {
+               if (!usb_config->funcs[i])
                        return -ENOTSUP;
-               }
+
                ++i;
        }