-static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
-{
- char *cmd = req->buf;
- if (!strcmp_l1("reboot-bootloader", cmd)) {
- if (fastboot_set_reboot_flag()) {
- fastboot_tx_write_str("FAILCannot set reboot flag");
- return;
- }
- }
- fastboot_func->in_req->complete = compl_do_reset;
- fastboot_tx_write_str("OKAY");
-}
-
-static int strcmp_l1(const char *s1, const char *s2)
-{
- if (!s1 || !s2)
- return -1;
- return strncmp(s1, s2, strlen(s1));
-}
-
-static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
-{
- char *cmd = req->buf;
- char response[FASTBOOT_RESPONSE_LEN];
- const char *s;
- size_t chars_left;
-
- strcpy(response, "OKAY");
- chars_left = sizeof(response) - strlen(response) - 1;
-
- strsep(&cmd, ":");
- if (!cmd) {
- pr_err("missing variable");
- fastboot_tx_write_str("FAILmissing var");
- return;
- }
-
- if (!strcmp_l1("version", cmd)) {
- strncat(response, FASTBOOT_VERSION, chars_left);
- } else if (!strcmp_l1("bootloader-version", cmd)) {
- strncat(response, U_BOOT_VERSION, chars_left);
- } else if (!strcmp_l1("downloadsize", cmd) ||
- !strcmp_l1("max-download-size", cmd)) {
- char str_num[12];
-
- sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE);
- strncat(response, str_num, chars_left);
- } else if (!strcmp_l1("serialno", cmd)) {
- s = env_get("serial#");
- if (s)
- strncat(response, s, chars_left);
- else
- strcpy(response, "FAILValue not set");
- } else {
- char *envstr;
-
- envstr = malloc(strlen("fastboot.") + strlen(cmd) + 1);
- if (!envstr) {
- fastboot_tx_write_str("FAILmalloc error");
- return;
- }
-
- sprintf(envstr, "fastboot.%s", cmd);
- s = env_get(envstr);
- if (s) {
- strncat(response, s, chars_left);
- } else {
- printf("WARNING: unknown variable: %s\n", cmd);
- strcpy(response, "FAILVariable not implemented");
- }
-
- free(envstr);
- }
- fastboot_tx_write_str(response);
-}
-