diff options
author | Rui Miguel Silva | 2022-06-29 11:06:14 +0100 |
---|---|---|
committer | Marek Vasut | 2022-07-12 21:59:54 +0200 |
commit | b2d2b7872249e6816487e95bd9197a9417aa62bb (patch) | |
tree | 8ff4d1d1bfad6aabf51c25a0df61f4ad99f2088f /drivers/usb/musb-new | |
parent | b252d79b0936d60b0c6c69e71b0233e58f9c961e (diff) |
usb: common: move urb code to common
Move urb code from musb only use to a more common scope, so other
drivers in the future can use the handling of urb in usb.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Diffstat (limited to 'drivers/usb/musb-new')
-rw-r--r-- | drivers/usb/musb-new/musb_core.c | 2 | ||||
-rw-r--r-- | drivers/usb/musb-new/musb_host.c | 2 | ||||
-rw-r--r-- | drivers/usb/musb-new/musb_host.h | 2 | ||||
-rw-r--r-- | drivers/usb/musb-new/musb_uboot.c | 38 | ||||
-rw-r--r-- | drivers/usb/musb-new/musb_uboot.h | 2 | ||||
-rw-r--r-- | drivers/usb/musb-new/usb-compat.h | 79 |
6 files changed, 5 insertions, 120 deletions
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c index 18d9bc805f8..fc7af7484e4 100644 --- a/drivers/usb/musb-new/musb_core.c +++ b/drivers/usb/musb-new/musb_core.c @@ -89,9 +89,9 @@ #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/musb.h> +#include <linux/usb/usb_urb_compat.h> #include <asm/io.h> #include "linux-compat.h" -#include "usb-compat.h" #endif #include "musb_core.h" diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c index acb2d40f3b5..e5905d90d66 100644 --- a/drivers/usb/musb-new/musb_host.c +++ b/drivers/usb/musb-new/musb_host.c @@ -26,8 +26,8 @@ #include <dm/device_compat.h> #include <usb.h> #include <linux/bug.h> +#include <linux/usb/usb_urb_compat.h> #include "linux-compat.h" -#include "usb-compat.h" #endif #include "musb_core.h" diff --git a/drivers/usb/musb-new/musb_host.h b/drivers/usb/musb-new/musb_host.h index afc8fa35a73..5a604bdb0cf 100644 --- a/drivers/usb/musb-new/musb_host.h +++ b/drivers/usb/musb-new/musb_host.h @@ -10,7 +10,7 @@ #ifndef _MUSB_HOST_H #define _MUSB_HOST_H #ifdef __UBOOT__ -#include "usb-compat.h" +#include <linux/usb/usb_urb_compat.h> #endif static inline struct usb_hcd *musb_to_hcd(struct musb *musb) diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 61ff68def2f..d186facc7e0 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -8,10 +8,10 @@ #include <linux/errno.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> +#include <linux/usb/usb_urb_compat.h> #include <usb.h> #include "linux-compat.h" -#include "usb-compat.h" #include "musb_core.h" #include "musb_host.h" #include "musb_gadget.h" @@ -453,39 +453,3 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, return *musbp; } - -#if CONFIG_IS_ENABLED(DM_USB) -struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - struct udevice *parent = udev->dev->parent; - - /* - * When called from usb-uclass.c: usb_scan_device() udev->dev points - * to the parent udevice, not the actual udevice belonging to the - * udev as the device is not instantiated yet. - * - * If dev is an usb-bus, then we are called from usb_scan_device() for - * an usb-device plugged directly into the root port, return NULL. - */ - if (device_get_uclass_id(udev->dev) == UCLASS_USB) - return NULL; - - /* - * If these 2 are not the same we are being called from - * usb_scan_device() and udev itself is the parent. - */ - if (dev_get_parent_priv(udev->dev) != udev) - return udev; - - /* We are being called normally, use the parent pointer */ - if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parent_priv(parent); - - return NULL; -} -#else -struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - return udev->parent; -} -#endif diff --git a/drivers/usb/musb-new/musb_uboot.h b/drivers/usb/musb-new/musb_uboot.h index 18282efccc9..6b162f03b19 100644 --- a/drivers/usb/musb-new/musb_uboot.h +++ b/drivers/usb/musb-new/musb_uboot.h @@ -8,8 +8,8 @@ #define __MUSB_UBOOT_H__ #include <usb.h> +#include <linux/usb/usb_urb_compat.h> #include "linux-compat.h" -#include "usb-compat.h" #include "musb_core.h" struct musb_host_data { diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h deleted file mode 100644 index df68c9220a7..00000000000 --- a/drivers/usb/musb-new/usb-compat.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __USB_COMPAT_H__ -#define __USB_COMPAT_H__ - -#include "usb.h" - -struct udevice; - -struct usb_hcd { - void *hcd_priv; -}; - -struct usb_host_endpoint { - struct usb_endpoint_descriptor desc; - struct list_head urb_list; - void *hcpriv; -}; - -/* - * urb->transfer_flags: - * - * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb(). - */ -#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ -#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ - -struct urb; - -typedef void (*usb_complete_t)(struct urb *); - -struct urb { - void *hcpriv; /* private data for host controller */ - struct list_head urb_list; /* list head for use by the urb's - * current owner */ - struct usb_device *dev; /* (in) pointer to associated device */ - struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */ - unsigned int pipe; /* (in) pipe information */ - int status; /* (return) non-ISO status */ - unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ - void *transfer_buffer; /* (in) associated data buffer */ - dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ - u32 transfer_buffer_length; /* (in) data buffer length */ - u32 actual_length; /* (return) actual transfer length */ - unsigned char *setup_packet; /* (in) setup packet (control only) */ - int start_frame; /* (modify) start frame (ISO) */ - usb_complete_t complete; /* (in) completion routine */ -}; - -#define usb_hcd_link_urb_to_ep(hcd, urb) ({ \ - int ret = 0; \ - list_add_tail(&urb->urb_list, &urb->ep->urb_list); \ - ret; }) -#define usb_hcd_unlink_urb_from_ep(hcd, urb) list_del_init(&urb->urb_list) -#define usb_hcd_check_unlink_urb(hdc, urb, status) 0 - -static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd, - struct urb *urb, - int status) -{ - urb->status = status; - if (urb->complete) - urb->complete(urb); -} - -static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, - struct urb *urb) -{ - /* TODO: add cache invalidation here */ - return 0; -} - -/** - * usb_dev_get_parent() - Get the parent of a USB device - * - * @udev: USB struct containing information about the device - * Return: associated device for which udev == dev_get_parent_priv(dev) - */ -struct usb_device *usb_dev_get_parent(struct usb_device *udev); - -#endif /* __USB_COMPAT_H__ */ |