Add mmc control logic 13/14713/1
authorsh.pi <sh.pi@samsung.com>
Tue, 16 Apr 2013 08:51:51 +0000 (17:51 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Fri, 10 Jan 2014 08:55:45 +0000 (09:55 +0100)
Change-Id: I724d6cdab3955c3f84b468c4d91d929d9311a3b6
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
src/control/control.c
src/deviced/dd-control.h
src/mmc/mmc-handler.c
src/shared/control.c

index 455ca20..54cf3d3 100644 (file)
@@ -34,6 +34,7 @@ static const struct control_device {
         * { DEVICE_CONTROL_DISPLAY,       &display_device_ops },
         */
        /* Add id & ops to provide start/stop control */
+       { DEVICE_CONTROL_MMC,   &mmc_device_ops },
 };
 
 static int control_handler(int argc, char **argv)
index 563499d..5900222 100644 (file)
@@ -36,17 +36,14 @@ extern "C" {
 enum control_device_type {
        /* Add device define here  */
        /* DEVICE_CONTROL_DISPLAY, */
+       DEVICE_CONTROL_MMC,
        DEVICE_CONTROL_MAX,
 };
 
 /*
  * Add new function to control in library.
  */
-/*
- * exmaple code
- * int deviced_display_control(bool enable);
- */
-
+int deviced_mmc_control(bool enable);
 
 #ifdef __cplusplus
 }
index 79f65cb..1c5c6d7 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/statfs.h>
 #include <bundle.h>
 #include <signal.h>
+#include <stdbool.h>
 
 #include "core/log.h"
 #include "core/common.h"
@@ -136,12 +137,19 @@ static const char *ext4_check_arg[] = {
 static int smack;
 static int mmc_popup_pid;
 static mmc_fs_type inserted_type;
+static bool mmc_disabled = false;
 
 static void __attribute__ ((constructor)) smack_check(void)
 {
        struct statfs sfs;
        int ret;
 
+       if (mmc_disabled) {
+               PRT_TRACE("mmc is blocked!");
+               vconf_set_int(VCONFKEY_SYSMAN_MMC_UNMOUNT, VCONFKEY_SYSMAN_MMC_UNMOUNT_COMPLETED);
+               return -ENODEV;
+       }
+
        do {
                ret = statfs(SMACKFS_MNT, &sfs);
        } while (ret < 0 && errno == EINTR);
@@ -798,6 +806,22 @@ static void mmc_init(void *data)
                _E("failed to check mmc");
 }
 
+static void mmc_start(void)
+{
+       mmc_disabled = false;
+       PRT_TRACE("start");
+}
+
+static void mmc_stop(void)
+{
+       mmc_disabled = true;
+       vconf_set_int(VCONFKEY_SYSMAN_MMC_UNMOUNT, VCONFKEY_SYSMAN_MMC_UNMOUNT_COMPLETED);
+
+       PRT_TRACE("stop");
+}
+
 const struct device_ops mmc_device_ops = {
        .init = mmc_init,
+       .start = mmc_start,
+       .stop = mmc_stop,
 };
index cfc7331..8951c9a 100644 (file)
@@ -38,6 +38,11 @@ static int deviced_control_common(int device, bool enable)
                    buf_dev, buf_enable);
 }
 
+API int deviced_mmc_control(bool enable)
+{
+       return deviced_control_common(DEVICE_CONTROL_MMC, enable);
+}
+
 /*
  * example of control api
  * API int deviced_display_control(bool enable)