usb, g_dnl: generalize DFU detach functions

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]
This commit is contained in:
Rob Herring 2014-12-10 14:43:03 -06:00 committed by Lukasz Majewski
parent 68ae882596
commit fe1b28c9f0
6 changed files with 25 additions and 23 deletions

View File

@ -38,10 +38,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
@ -74,7 +74,7 @@ done:
if (dfu_reset)
run_command("reset", 0);
dfu_clear_detach();
g_dnl_clear_detach();
return ret;
}

View File

@ -17,7 +17,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;
@ -39,21 +38,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;

View File

@ -366,7 +366,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;

View File

@ -163,6 +163,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;

View File

@ -150,9 +150,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);

View File

@ -39,4 +39,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_ */