Commit 3e59f59015e39ceb870fa8a7a12e0464e775512b
Committed by
Marek Vasut
1 parent
7489d22a3c
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
dm: usb: Add a new USB controller operation 'get_max_xfer_size'
The HCD may have limitation on the maximum bytes to be transferred in a USB transfer. USB class driver needs to be aware of this. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Showing 2 changed files with 32 additions and 1 deletions Side-by-side Diff
drivers/usb/host/usb-uclass.c
... | ... | @@ -150,6 +150,17 @@ |
150 | 150 | return ops->update_hub_device(bus, udev); |
151 | 151 | } |
152 | 152 | |
153 | +int usb_get_max_xfer_size(struct usb_device *udev, size_t *size) | |
154 | +{ | |
155 | + struct udevice *bus = udev->controller_dev; | |
156 | + struct dm_usb_ops *ops = usb_get_ops(bus); | |
157 | + | |
158 | + if (!ops->get_max_xfer_size) | |
159 | + return -ENOSYS; | |
160 | + | |
161 | + return ops->get_max_xfer_size(bus, size); | |
162 | +} | |
163 | + | |
153 | 164 | int usb_stop(void) |
154 | 165 | { |
155 | 166 | struct udevice *bus; |
include/usb.h
... | ... | @@ -766,6 +766,14 @@ |
766 | 766 | * representation of this hub can be updated (xHCI) |
767 | 767 | */ |
768 | 768 | int (*update_hub_device)(struct udevice *bus, struct usb_device *udev); |
769 | + | |
770 | + /** | |
771 | + * get_max_xfer_size() - Get HCD's maximum transfer bytes | |
772 | + * | |
773 | + * The HCD may have limitation on the maximum bytes to be transferred | |
774 | + * in a USB transfer. USB class driver needs to be aware of this. | |
775 | + */ | |
776 | + int (*get_max_xfer_size)(struct udevice *bus, size_t *size); | |
769 | 777 | }; |
770 | 778 | |
771 | 779 | #define usb_get_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops) |
... | ... | @@ -939,7 +947,7 @@ |
939 | 947 | int usb_alloc_device(struct usb_device *dev); |
940 | 948 | |
941 | 949 | /** |
942 | - * update_hub_device() - Update HCD's internal representation of hub | |
950 | + * usb_update_hub_device() - Update HCD's internal representation of hub | |
943 | 951 | * |
944 | 952 | * After a hub descriptor is fetched, notify HCD so that its internal |
945 | 953 | * representation of this hub can be updated. |
... | ... | @@ -948,6 +956,18 @@ |
948 | 956 | * @return 0 if OK, -ve on error |
949 | 957 | */ |
950 | 958 | int usb_update_hub_device(struct usb_device *dev); |
959 | + | |
960 | +/** | |
961 | + * usb_get_max_xfer_size() - Get HCD's maximum transfer bytes | |
962 | + * | |
963 | + * The HCD may have limitation on the maximum bytes to be transferred | |
964 | + * in a USB transfer. USB class driver needs to be aware of this. | |
965 | + * | |
966 | + * @dev: USB device | |
967 | + * @size: maximum transfer bytes | |
968 | + * @return 0 if OK, -ve on error | |
969 | + */ | |
970 | +int usb_get_max_xfer_size(struct usb_device *dev, size_t *size); | |
951 | 971 | |
952 | 972 | /** |
953 | 973 | * usb_emul_setup_device() - Set up a new USB device emulation |