[U-Boot] [PATCH] musb: Move linux and usb compat files to include/linux/usb

Dan Murphy dmurphy at ti.com
Thu Jun 13 19:55:09 CEST 2013


Move the linux and usb compat files to the
include/linux/usb directory in order for the files to be
reused.

Added GPLv2 license to the linux and usb compat as well.

Signed-off-by: Dan Murphy <dmurphy at ti.com>
---
 drivers/usb/musb-new/linux-compat.h    |  114 --------------------------
 drivers/usb/musb-new/musb_core.c       |    4 +-
 drivers/usb/musb-new/musb_dsps.c       |    2 +-
 drivers/usb/musb-new/musb_gadget.c     |    2 +-
 drivers/usb/musb-new/musb_gadget_ep0.c |    2 +-
 drivers/usb/musb-new/musb_host.c       |    4 +-
 drivers/usb/musb-new/musb_host.h       |    2 +-
 drivers/usb/musb-new/musb_uboot.c      |    4 +-
 drivers/usb/musb-new/usb-compat.h      |   88 --------------------
 include/linux/usb/linux-compat.h       |  136 ++++++++++++++++++++++++++++++++
 include/linux/usb/usb-compat.h         |  110 ++++++++++++++++++++++++++
 11 files changed, 256 insertions(+), 212 deletions(-)
 delete mode 100644 drivers/usb/musb-new/linux-compat.h
 delete mode 100644 drivers/usb/musb-new/usb-compat.h
 create mode 100644 include/linux/usb/linux-compat.h
 create mode 100644 include/linux/usb/usb-compat.h

diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h
deleted file mode 100644
index 72c8c2b..0000000
--- a/drivers/usb/musb-new/linux-compat.h
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef __LINUX_COMPAT_H__
-#define __LINUX_COMPAT_H__
-
-#include <malloc.h>
-#include <linux/list.h>
-#include <linux/compat.h>
-
-#define __init
-#define __devinit
-#define __devinitdata
-#define __devinitconst
-#define __iomem
-#define __deprecated
-
-struct unused {};
-typedef struct unused unused_t;
-
-typedef int irqreturn_t;
-typedef unused_t spinlock_t;
-
-struct work_struct {};
-
-struct timer_list {};
-struct notifier_block {};
-
-typedef unsigned long dmaaddr_t;
-
-#define spin_lock_init(lock) do {} while (0)
-#define spin_lock(lock) do {} while (0)
-#define spin_unlock(lock) do {} while (0)
-#define spin_lock_irqsave(lock, flags) do {} while (0)
-#define spin_unlock_irqrestore(lock, flags) do {} while (0)
-
-#define setup_timer(timer, func, data) do {} while (0)
-#define del_timer_sync(timer) do {} while (0)
-#define schedule_work(work) do {} while (0)
-#define INIT_WORK(work, fun) do {} while (0)
-
-#define cpu_relax() do {} while (0)
-
-#define pr_debug(fmt, args...) debug(fmt, ##args)
-#define dev_dbg(dev, fmt, args...)		\
-	debug(fmt, ##args)
-#define dev_vdbg(dev, fmt, args...)		\
-	debug(fmt, ##args)
-#define dev_info(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define dev_err(dev, fmt, args...)		\
-	printf(fmt, ##args)
-#define printk printf
-
-#define WARN(condition, fmt, args...) ({	\
-	int ret_warn = !!condition;		\
-	if (ret_warn)				\
-		printf(fmt, ##args);		\
-	ret_warn; })
-
-#define KERN_DEBUG
-#define KERN_NOTICE
-#define KERN_WARNING
-#define KERN_ERR
-
-#define kfree(ptr) free(ptr)
-
-#define pm_runtime_get_sync(dev) do {} while (0)
-#define pm_runtime_put(dev) do {} while (0)
-#define pm_runtime_put_sync(dev) do {} while (0)
-#define pm_runtime_use_autosuspend(dev) do {} while (0)
-#define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
-#define pm_runtime_enable(dev) do {} while (0)
-
-#define MODULE_DESCRIPTION(desc)
-#define MODULE_AUTHOR(author)
-#define MODULE_LICENSE(license)
-#define MODULE_ALIAS(alias)
-#define module_param(name, type, perm)
-#define MODULE_PARM_DESC(name, desc)
-#define EXPORT_SYMBOL_GPL(name)
-
-#define writesl(a, d, s) __raw_writesl((unsigned long)a, d, s)
-#define readsl(a, d, s) __raw_readsl((unsigned long)a, d, s)
-#define writesw(a, d, s) __raw_writesw((unsigned long)a, d, s)
-#define readsw(a, d, s) __raw_readsw((unsigned long)a, d, s)
-#define writesb(a, d, s) __raw_writesb((unsigned long)a, d, s)
-#define readsb(a, d, s) __raw_readsb((unsigned long)a, d, s)
-
-#define IRQ_NONE 0
-#define IRQ_HANDLED 0
-
-#define dev_set_drvdata(dev, data) do {} while (0)
-
-#define disable_irq_wake(irq) do {} while (0)
-#define enable_irq_wake(irq) -EINVAL
-#define free_irq(irq, data) do {} while (0)
-#define request_irq(nr, f, flags, nm, data) 0
-
-#define device_init_wakeup(dev, a) do {} while (0)
-
-#define platform_data device_data
-
-#ifndef wmb
-#define wmb()			asm volatile (""   : : : "memory")
-#endif
-
-#define msleep(a)	udelay(a * 1000)
-
-/*
- * Map U-Boot config options to Linux ones
- */
-#ifdef CONFIG_OMAP34XX
-#define CONFIG_SOC_OMAP3430
-#endif
-
-#endif /* __LINUX_COMPAT_H__ */
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index da93571..2cb3181 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -109,8 +109,8 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/musb.h>
 #include <asm/io.h>
-#include "linux-compat.h"
-#include "usb-compat.h"
+#include <linux/usb/linux-compat.h>
+#include <linux/usb/usb-compat.h>
 #endif
 
 #include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c
index 9a03917..aa5f8aa 100644
--- a/drivers/usb/musb-new/musb_dsps.c
+++ b/drivers/usb/musb-new/musb_dsps.c
@@ -47,7 +47,7 @@
 #else
 #include <common.h>
 #include <asm/omap_musb.h>
-#include "linux-compat.h"
+#include <linux/usb/linux-compat.h>
 #endif
 
 #include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_gadget.c b/drivers/usb/musb-new/musb_gadget.c
index d2cb91a..0186b57 100644
--- a/drivers/usb/musb-new/musb_gadget.c
+++ b/drivers/usb/musb-new/musb_gadget.c
@@ -47,7 +47,7 @@
 #else
 #include <common.h>
 #include <linux/usb/ch9.h>
-#include "linux-compat.h"
+#include <linux/usb/linux-compat.h>
 #endif
 
 #include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_gadget_ep0.c b/drivers/usb/musb-new/musb_gadget_ep0.c
index 6599d38..bbc67b0 100644
--- a/drivers/usb/musb-new/musb_gadget_ep0.c
+++ b/drivers/usb/musb-new/musb_gadget_ep0.c
@@ -43,7 +43,7 @@
 #include <linux/interrupt.h>
 #else
 #include <common.h>
-#include "linux-compat.h"
+#include <linux/usb/linux-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 9a2cf59..7bc19bf 100644
--- a/drivers/usb/musb-new/musb_host.c
+++ b/drivers/usb/musb-new/musb_host.c
@@ -47,8 +47,8 @@
 #else
 #include <common.h>
 #include <usb.h>
-#include "linux-compat.h"
-#include "usb-compat.h"
+#include <linux/usb/linux-compat.h>
+#include <linux/usb/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 ebebe0c..1be9206 100644
--- a/drivers/usb/musb-new/musb_host.h
+++ b/drivers/usb/musb-new/musb_host.h
@@ -35,7 +35,7 @@
 #ifndef _MUSB_HOST_H
 #define _MUSB_HOST_H
 #ifdef __UBOOT__
-#include "usb-compat.h"
+#include <linux/usb/usb-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 15d2ec0..bebf4c6 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -5,8 +5,8 @@
 
 #define __UBOOT__
 #include <usb.h>
-#include "linux-compat.h"
-#include "usb-compat.h"
+#include <linux/usb/linux-compat.h>
+#include <linux/usb/usb-compat.h>
 #include "musb_core.h"
 #include "musb_host.h"
 #include "musb_gadget.h"
diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h
deleted file mode 100644
index 27f656f..0000000
--- a/drivers/usb/musb-new/usb-compat.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef __USB_COMPAT_H__
-#define __USB_COMPAT_H__
-
-#include "usb.h"
-
-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)
-
-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;
-}
-
-static inline u16 find_tt(struct usb_device *dev)
-{
-	u8 chid;
-	u8 hub;
-
-	/* Find out the nearest parent which is high speed */
-	while (dev->parent->parent != NULL)
-		if (dev->parent->speed != USB_SPEED_HIGH)
-			dev = dev->parent;
-		else
-			break;
-
-	/* determine the port address at that hub */
-	hub = dev->parent->devnum;
-	for (chid = 0; chid < USB_MAXCHILDREN; chid++)
-		if (dev->parent->children[chid] == dev)
-			break;
-
-	return (hub << 8) | chid;
-}
-#endif /* __USB_COMPAT_H__ */
diff --git a/include/linux/usb/linux-compat.h b/include/linux/usb/linux-compat.h
new file mode 100644
index 0000000..a93dec7
--- /dev/null
+++ b/include/linux/usb/linux-compat.h
@@ -0,0 +1,136 @@
+/*
+ * linux_compat.h -- linux compatibility header file
+ *
+ * Copyright (C) 2012-2013
+ * Texas Instruments Incorporated.
+ * Cogent Embedded.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LINUX_COMPAT_H__
+#define __LINUX_COMPAT_H__
+
+#include <malloc.h>
+#include <linux/list.h>
+#include <linux/compat.h>
+
+#define __init
+#define __devinit
+#define __devinitdata
+#define __devinitconst
+#define __iomem
+#define __deprecated
+
+struct unused {};
+typedef struct unused unused_t;
+
+typedef int irqreturn_t;
+typedef unused_t spinlock_t;
+
+struct work_struct {};
+
+struct timer_list {};
+struct notifier_block {};
+
+typedef unsigned long dmaaddr_t;
+
+#define spin_lock_init(lock) do {} while (0)
+#define spin_lock(lock) do {} while (0)
+#define spin_unlock(lock) do {} while (0)
+#define spin_lock_irqsave(lock, flags) do {} while (0)
+#define spin_unlock_irqrestore(lock, flags) do {} while (0)
+
+#define setup_timer(timer, func, data) do {} while (0)
+#define del_timer_sync(timer) do {} while (0)
+#define schedule_work(work) do {} while (0)
+#define INIT_WORK(work, fun) do {} while (0)
+
+#define cpu_relax() do {} while (0)
+
+#define pr_debug(fmt, args...) debug(fmt, ##args)
+#define dev_dbg(dev, fmt, args...)		\
+	debug(fmt, ##args)
+#define dev_vdbg(dev, fmt, args...)		\
+	debug(fmt, ##args)
+#define dev_info(dev, fmt, args...)		\
+	printf(fmt, ##args)
+#define dev_err(dev, fmt, args...)		\
+	printf(fmt, ##args)
+#define printk printf
+
+#define WARN(condition, fmt, args...) ({	\
+	int ret_warn = !!condition;		\
+	if (ret_warn)				\
+		printf(fmt, ##args);		\
+	ret_warn; })
+
+#define KERN_DEBUG
+#define KERN_NOTICE
+#define KERN_WARNING
+#define KERN_ERR
+
+#define kfree(ptr) free(ptr)
+
+#define pm_runtime_get_sync(dev) do {} while (0)
+#define pm_runtime_put(dev) do {} while (0)
+#define pm_runtime_put_sync(dev) do {} while (0)
+#define pm_runtime_use_autosuspend(dev) do {} while (0)
+#define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
+#define pm_runtime_enable(dev) do {} while (0)
+
+#define MODULE_DESCRIPTION(desc)
+#define MODULE_AUTHOR(author)
+#define MODULE_LICENSE(license)
+#define MODULE_ALIAS(alias)
+#define module_param(name, type, perm)
+#define MODULE_PARM_DESC(name, desc)
+#define EXPORT_SYMBOL_GPL(name)
+
+#define writesl(a, d, s) __raw_writesl((unsigned long)a, d, s)
+#define readsl(a, d, s) __raw_readsl((unsigned long)a, d, s)
+#define writesw(a, d, s) __raw_writesw((unsigned long)a, d, s)
+#define readsw(a, d, s) __raw_readsw((unsigned long)a, d, s)
+#define writesb(a, d, s) __raw_writesb((unsigned long)a, d, s)
+#define readsb(a, d, s) __raw_readsb((unsigned long)a, d, s)
+
+#define IRQ_NONE 0
+#define IRQ_HANDLED 0
+
+#define dev_set_drvdata(dev, data) do {} while (0)
+
+#define disable_irq_wake(irq) do {} while (0)
+#define enable_irq_wake(irq) -EINVAL
+#define free_irq(irq, data) do {} while (0)
+#define request_irq(nr, f, flags, nm, data) 0
+
+#define device_init_wakeup(dev, a) do {} while (0)
+
+#define platform_data device_data
+
+#ifndef wmb
+#define wmb()			asm volatile (""   : : : "memory")
+#endif
+
+#define msleep(a)	udelay(a * 1000)
+
+/*
+ * Map U-Boot config options to Linux ones
+ */
+#ifdef CONFIG_OMAP34XX
+#define CONFIG_SOC_OMAP3430
+#endif
+
+#endif /* __LINUX_COMPAT_H__ */
diff --git a/include/linux/usb/usb-compat.h b/include/linux/usb/usb-compat.h
new file mode 100644
index 0000000..067bc79
--- /dev/null
+++ b/include/linux/usb/usb-compat.h
@@ -0,0 +1,110 @@
+/*
+ * usb_compat.h -- usb compatibility header file
+ *
+ * Copyright (C) 2012-2013
+ * Texas Instruments Incorporated.
+ * Cogent Embedded. 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+ 
+#ifndef __USB_COMPAT_H__
+#define __USB_COMPAT_H__
+
+#include "usb.h"
+
+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)
+
+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;
+}
+
+static inline u16 find_tt(struct usb_device *dev)
+{
+	u8 chid;
+	u8 hub;
+
+	/* Find out the nearest parent which is high speed */
+	while (dev->parent->parent != NULL)
+		if (dev->parent->speed != USB_SPEED_HIGH)
+			dev = dev->parent;
+		else
+			break;
+
+	/* determine the port address at that hub */
+	hub = dev->parent->devnum;
+	for (chid = 0; chid < USB_MAXCHILDREN; chid++)
+		if (dev->parent->children[chid] == dev)
+			break;
+
+	return (hub << 8) | chid;
+}
+#endif /* __USB_COMPAT_H__ */
-- 
1.7.5.4



More information about the U-Boot mailing list