diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2015-02-04 22:43:27 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2015-02-04 22:43:27 -0800 |
commit | 333e55e8d99b71ccf4917aaebd23dd4e0d318bbb (patch) | |
tree | 5c825fa2e3333a7ba070dd2d0b05800dda134001 | |
parent | bd4791d0c2a32c570d85eeec2c6d7f2ccc1ddb5c (diff) | |
parent | d990889448c6a72e012ed93322ff9c5c1b66eed0 (diff) | |
download | deviced-333e55e8d99b71ccf4917aaebd23dd4e0d318bbb.tar.gz deviced-333e55e8d99b71ccf4917aaebd23dd4e0d318bbb.tar.bz2 deviced-333e55e8d99b71ccf4917aaebd23dd4e0d318bbb.zip |
Merge "deviced: Enable battery module and check whether it is available at runtime" into tizen
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | packaging/deviced.spec | 4 | ||||
-rw-r--r-- | src/battery/lowbat-handler.c | 51 | ||||
-rw-r--r-- | src/battery/power-supply.c | 13 |
4 files changed, 41 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d8db63f1..7a6f0183 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,14 +45,12 @@ SET(SRCS ${SRCS} src/gpio/buzzer.c) ENDIF(TIZEN_BUZZER) -IF(TIZEN_BATTERY) SET(SRCS ${SRCS} src/battery/battery-time.c src/battery/config.c src/battery/lowbat-handler.c src/battery/power-supply.c ) -ENDIF(TIZEN_BATTERY) IF(TIZEN_EXTCON) SET(SRCS ${SRCS} diff --git a/packaging/deviced.spec b/packaging/deviced.spec index 0b87fe37..fc0397fd 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -4,7 +4,6 @@ #These options are DEACTIVATED by default. %bcond_with x -%bcond_with battery %bcond_with buzzer %bcond_with camera_led %bcond_with extcon @@ -188,9 +187,6 @@ export CFLAGS+=" -DX11_SUPPORT" -DTZ_SYS_ETC=%TZ_SYS_ETC \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DARCH=%{ARCH} \ -%if %{with battery} - -DTIZEN_BATTERY:BOOL=ON \ -%endif %if %{with buzzer} -DTIZEN_BUZZER:BOOL=ON \ %endif diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index bb67d123..3cfaaa18 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -32,6 +32,7 @@ #include "core/device-notifier.h" #include "core/common.h" #include "core/list.h" +#include "core/udev.h" #include "device-node.h" #include "display/setting.h" #include "display/poll.h" @@ -154,6 +155,23 @@ static int power_execute(void) return ops->execute(INTERNAL_PWROFF); } +static int booting_done(void *data) +{ + static int done = 0; + + if (data == NULL) + goto out; + done = *(int*)data; + if (!done) + goto out; + _I("booting done"); + + power_supply_timer_stop(); + power_supply_init(NULL); +out: + return done; +} + static int lowbat_popup(char *option) { int ret, state=0; @@ -495,23 +513,6 @@ static int check_power_save_mode(void) return ret; } -static int booting_done(void *data) -{ - static int done = 0; - - if (data == NULL) - goto out; - done = *(int*)data; - if (!done) - goto out; - _I("booting done"); - - power_supply_timer_stop(); - power_supply_init(NULL); -out: - return done; -} - static int lowbat_monitor_init(void *data) { int status = 1; @@ -536,6 +537,21 @@ static int display_changed(void *data) return 0; } +static int lowbat_probe(void *data) +{ + /** + * find power-supply class. + * if there is no power-supply class, + * deviced does not activate a battery module. + */ + if (access(POWER_PATH, R_OK) != 0) { + _E("there is no power-supply class"); + return -ENODEV; + } + + return 0; +} + static void lowbat_init(void *data) { /* process check battery timer until booting done */ @@ -561,6 +577,7 @@ static void lowbat_exit(void *data) static const struct device_ops lowbat_device_ops = { .priority = DEVICE_PRIORITY_NORMAL, .name = "lowbat", + .probe = lowbat_probe, .init = lowbat_init, .exit = lowbat_exit, }; diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index ffc5fbff..8f25fc26 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -22,15 +22,15 @@ #include <vconf.h> #include <Ecore.h> #include <device-node.h> -#include "devices.h" -#include "device-handler.h" -#include "device-notifier.h" -#include "udev.h" -#include "log.h" +#include "core/devices.h" +#include "core/device-handler.h" +#include "core/device-notifier.h" +#include "core/udev.h" +#include "core/log.h" #include "display/poll.h" #include "display/setting.h" #include "proc/proc-handler.h" -#include "config-parser.h" +#include "core/config-parser.h" #include "power-supply.h" #define BUFF_MAX 255 @@ -69,6 +69,7 @@ enum power_supply_init_type { POWER_SUPPLY_INITIALIZED = 1, }; +static void uevent_power_handler(struct udev_device *dev); static struct uevent_handler uh = { .subsystem = POWER_SUBSYSTEM, .uevent_func = uevent_power_handler, |