X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=inline;f=common%2Fusb_storage.c;h=9cd64744f8ab9c5c4bf07ab08b4d1702e6cf4094;hb=7e16342bde9d56b5e2f7cd4eb51d128bfde45dd2;hp=957ccdb29730eafa9ad5aed456f82b555d47fbc4;hpb=6158d0b42411165d34635a2ddfea17e12dce3329;p=oweals%2Fu-boot.git diff --git a/common/usb_storage.c b/common/usb_storage.c index 957ccdb297..9cd64744f8 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Most of this source has been derived from the Linux USB * project: @@ -17,8 +18,6 @@ * * BBB support based on /sys/dev/usb/umass.c from * FreeBSD. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* Note: @@ -939,10 +938,14 @@ do_retry: return USB_STOR_TRANSPORT_FAILED; } -static void usb_stor_set_max_xfer_blk(struct us_data *us) +static void usb_stor_set_max_xfer_blk(struct usb_device *udev, + struct us_data *us) { unsigned short blk; + size_t __maybe_unused size; + int __maybe_unused ret; +#ifndef CONFIG_DM_USB #ifdef CONFIG_USB_EHCI_HCD /* * The U-Boot EHCI driver can handle any transfer length as long as @@ -953,6 +956,17 @@ static void usb_stor_set_max_xfer_blk(struct us_data *us) #else blk = 20; #endif +#else + ret = usb_get_max_xfer_size(udev, (size_t *)&size); + if (ret < 0) { + /* unimplemented, let's use default 20 */ + blk = 20; + } else { + if (size > USHRT_MAX * 512) + size = USHRT_MAX * 512; + blk = size / 512; + } +#endif us->max_xfer_blk = blk; } @@ -1393,7 +1407,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, } /* Set the maximum transfer size per host controller setting */ - usb_stor_set_max_xfer_blk(ss); + usb_stor_set_max_xfer_blk(dev, ss); dev->privptr = (void *)ss; return 1;