usb, g_dnl: generalize DFU detach functions
authorRob Herring <robh@kernel.org>
Wed, 10 Dec 2014 20:43:03 +0000 (14:43 -0600)
committerChanho Park <chanho61.park@samsung.com>
Fri, 24 Jul 2015 07:30:03 +0000 (16:30 +0900)
In order to add detach functions for fastboot, make the DFU detach related
functions common so they can be shared.

Signed-off-by: Rob Herring <robh@kernel.org>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
[TestHW: Exynos4412-Trats2]

common/cmd_dfu.c
drivers/dfu/dfu.c
drivers/usb/gadget/f_dfu.c
drivers/usb/gadget/g_dnl.c
include/dfu.h
include/g_dnl.h

index db3d74add83cb3c20b0270bdb78ebc8a5ed8b3d1..74a86a00da45bc582418c3a0869729eb438f8d5a 100644 (file)
@@ -50,10 +50,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        int controller_index = simple_strtoul(usb_controller, NULL, 0);
        board_usb_init(controller_index, USB_INIT_DEVICE);
-       dfu_clear_detach();
+       g_dnl_clear_detach();
        g_dnl_register("usb_dnl_dfu");
        while (1) {
-               if (dfu_detach()) {
+               if (g_dnl_detach()) {
                        /*
                         * Check if USB bus reset is performed after detach,
                         * which indicates that -R switch has been passed to
@@ -86,7 +86,7 @@ done:
        if (dfu_reset)
                run_command("reset", 0);
 
-       dfu_clear_detach();
+       g_dnl_clear_detach();
 
        return ret;
 }
index a712f1e8ba7a6155bc2f57fec86922563ad3d7a3..10cb395cf9634fb9a393d0277f908adf20baa253 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/list.h>
 #include <linux/compiler.h>
 
-static bool dfu_detach_request;
 static LIST_HEAD(dfu_list);
 static int dfu_alt_num;
 static int alt_num_cnt;
@@ -51,21 +50,6 @@ __weak bool dfu_usb_get_reset(void)
        return true;
 }
 
-bool dfu_detach(void)
-{
-       return dfu_detach_request;
-}
-
-void dfu_trigger_detach(void)
-{
-       dfu_detach_request = true;
-}
-
-void dfu_clear_detach(void)
-{
-       dfu_detach_request = false;
-}
-
 static int dfu_find_alt_num(const char *s)
 {
        int i = 0;
index 1218e463b7dbf4422b86d2efd959c1654b4577e7..4f1c07bab90d181b9e9f8edce1d39afad48b9d77 100644 (file)
@@ -370,7 +370,7 @@ static int state_dfu_idle(struct f_dfu *f_dfu,
                to_runtime_mode(f_dfu);
                f_dfu->dfu_state = DFU_STATE_appIDLE;
 
-               dfu_trigger_detach();
+               g_dnl_trigger_detach();
                break;
        default:
                f_dfu->dfu_state = DFU_STATE_dfuERROR;
index 2c09413c451c11164c34d2f4b9fe9722f8f079bc..babaad363ed5c75a93c54d775e7eff3003ac63d6 100644 (file)
@@ -175,6 +175,23 @@ __weak int g_dnl_board_usb_cable_connected(void)
        return -EOPNOTSUPP;
 }
 
+static bool g_dnl_detach_request;
+
+bool g_dnl_detach(void)
+{
+       return g_dnl_detach_request;
+}
+
+void g_dnl_trigger_detach(void)
+{
+       g_dnl_detach_request = true;
+}
+
+void g_dnl_clear_detach(void)
+{
+       g_dnl_detach_request = false;
+}
+
 static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
 {
        struct usb_gadget *gadget = cdev->gadget;
index c9a4197026b8aa28c00b60f601bfe0735435c02b..570134832d74c66e66b4cd02ca0c21e521f5658a 100644 (file)
@@ -161,9 +161,6 @@ struct dfu_entity *dfu_get_entity(int alt);
 char *dfu_extract_token(char** e, int *n);
 void dfu_trigger_reset(void);
 int dfu_get_alt(char *name);
-bool dfu_detach(void);
-void dfu_trigger_detach(void);
-void dfu_clear_detach(void);
 int dfu_init_env_entities(char *interface, char *devstr);
 unsigned char *dfu_get_buf(struct dfu_entity *dfu);
 unsigned char *dfu_free_buf(void);
index ea8865df69957e020b39e228170ebb0c5cd4b883..eb9ce50e6cb5519c9dd0722a1178e9e749728884 100644 (file)
@@ -52,4 +52,8 @@ int g_dnl_register(const char *s);
 void g_dnl_unregister(void);
 void g_dnl_set_serialnumber(char *);
 
+bool g_dnl_detach(void);
+void g_dnl_trigger_detach(void);
+void g_dnl_clear_detach(void);
+
 #endif /* __G_DOWNLOAD_H_ */