X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fusb%2Fgadget%2Ff_mass_storage.c;h=d1bc5efa9b39dfe48d03f7fe94d245f203d60caa;hb=72a38e06a20129209eaa0e5211cbf50b192de688;hp=b1fe8bd3a805df4a1d97d50395a128a30ad21eaa;hpb=351e9b206934c2d4a6a0acd1547caf077e4e675c;p=u-boot diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index b1fe8bd3a8..d1bc5efa9b 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -243,7 +243,7 @@ #include #include #include -#include +#include #include #include @@ -255,6 +255,7 @@ #include #include #include +#include /*------------------------------------------------------------------------*/ @@ -680,15 +681,15 @@ static int sleep_thread(struct fsg_common *common) /* Handle CTRL+C */ if (ctrlc()) return -EPIPE; -#ifdef CONFIG_USB_CABLE_CHECK + /* Check cable connection */ - if (!usb_cable_connected()) + if (!g_dnl_board_usb_cable_connected()) return -EIO; -#endif + k = 0; } - usb_gadget_handle_interrupts(); + usb_gadget_handle_interrupts(0); } common->thread_wakeup_needed = 0; return rc; @@ -972,7 +973,7 @@ static int do_write(struct fsg_common *common) /* If an error occurred, report it and its position */ if (nwritten < amount) { - printf("nwritten:%d amount:%d\n", nwritten, + printf("nwritten:%zd amount:%u\n", nwritten, amount); curlun->sense_data = SS_WRITE_ERROR; curlun->info_valid = 1; @@ -1109,6 +1110,7 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh) memset(buf, 0, 8); buf[0] = TYPE_DISK; + buf[1] = curlun->removable ? 0x80 : 0; buf[2] = 2; /* ANSI SCSI level 2 */ buf[3] = 2; /* SCSI-2 INQUIRY data format */ buf[4] = 31; /* Additional length */ @@ -2461,12 +2463,12 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, /* Allocate? */ if (!common) { - common = calloc(sizeof *common, 1); + common = calloc(sizeof(*common), 1); if (!common) return ERR_PTR(-ENOMEM); common->free_storage_on_release = 1; } else { - memset(common, 0, sizeof common); + memset(common, 0, sizeof(*common)); common->free_storage_on_release = 0; } @@ -2515,7 +2517,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy = 0; bh->outreq_busy = 0; - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN); if (unlikely(!bh->buf)) { rc = -ENOMEM; goto error_release; @@ -2622,7 +2624,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc + 1) * sizeof(*tmp); - mem = kmalloc(bytes, GFP_KERNEL); + mem = memalign(CONFIG_SYS_CACHELINE_SIZE, bytes); if (!mem) return NULL; @@ -2778,3 +2780,5 @@ int fsg_init(struct ums *ums_dev) return 0; } + +DECLARE_GADGET_BIND_CALLBACK(usb_dnl_ums, fsg_add);