[U-Boot] [u-boot RFC/RFT PATCH] usb: dwc3: remove linux-compat header file

Kishon Vijay Abraham I kishon at ti.com
Tue Feb 24 14:19:29 CET 2015


Removed linux compatibility header file that was added specifically
for dwc3. The macro definitions and other functions added in this
header file has been moved to more generic linux compatibility
header file thats used across u-boot.
Found an issue w.r.t duplicate definition in mtd.h so fixed it here.

Signed-off-by: Kishon Vijay Abraham I <kishon at ti.com>
---
Compile tested only with a few configs. Since I'm adding defintions to
linux/compat.h it requires more testing with all the configs.
 drivers/usb/dwc3/core.c             |    3 ---
 drivers/usb/dwc3/dwc3-omap.c        |    3 ---
 drivers/usb/dwc3/ep0.c              |    2 --
 drivers/usb/dwc3/gadget.c           |    2 --
 drivers/usb/dwc3/linux-compat.h     |   38 -----------------------------------
 drivers/usb/dwc3/ti_usb_phy.c       |    2 --
 drivers/usb/musb-new/linux-compat.h |    6 ------
 include/linux/compat.h              |   15 ++++++++++++++
 include/linux/mtd/mtd.h             |    2 --
 include/linux/string.h              |    1 +
 lib/linux_compat.c                  |    6 ++++++
 lib/string.c                        |    6 ++++++
 12 files changed, 28 insertions(+), 58 deletions(-)
 delete mode 100644 drivers/usb/dwc3/linux-compat.h

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 78fce1b..aebebb4 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -27,8 +27,6 @@
 #include "gadget.h"
 #include "io.h"
 
-#include "linux-compat.h"
-
 static LIST_HEAD(dwc3_list);
 /* -------------------------------------------------------------------------- */
 
@@ -613,7 +611,6 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
 int dwc3_uboot_init(struct dwc3_device *dwc3_dev)
 {
 	struct dwc3		*dwc;
-	struct device		*dev;
 	u8			lpm_nyet_threshold;
 	u8			tx_de_emphasis;
 	u8			hird_threshold;
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 46af109..c70447b 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -24,8 +24,6 @@
 #include <linux/usb/otg.h>
 #include <linux/compat.h>
 
-#include "linux-compat.h"
-
 /*
  * All these registers belong to OMAP's Wrapper around the
  * DesignWare USB3 Core.
@@ -364,7 +362,6 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap, int utmi_mode)
 int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev)
 {
 	u32			reg;
-	struct device		*dev;
 	struct dwc3_omap	*omap;
 
 	omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index aba614f..cf174f0 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -25,8 +25,6 @@
 #include "gadget.h"
 #include "io.h"
 
-#include "linux-compat.h"
-
 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep);
 static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
 		struct dwc3_ep *dep, struct dwc3_request *req);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c8b7499..4be4d99 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -28,8 +28,6 @@
 #include "gadget.h"
 #include "io.h"
 
-#include "linux-compat.h"
-
 /**
  * dwc3_gadget_set_test_mode - Enables USB2 Test Modes
  * @dwc: pointer to our context structure
diff --git a/drivers/usb/dwc3/linux-compat.h b/drivers/usb/dwc3/linux-compat.h
deleted file mode 100644
index b36f68f..0000000
--- a/drivers/usb/dwc3/linux-compat.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * linux-compat.h - DesignWare USB3 Linux Compatibiltiy Adapter  Header
- *
- * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
- *
- * Authors: Kishon Vijay Abraham I <kishon at ti.com>
- *
- * SPDX-License-Identifier:	GPL-2.0
- *
- */
-
-#ifndef __DWC3_LINUX_COMPAT__
-#define __DWC3_LINUX_COMPAT__
-
-#define pr_debug(format)                debug(format)
-#define WARN(val, format, arg...)	debug(format, ##arg)
-#define dev_WARN(dev, format, arg...)	debug(format, ##arg)
-#define WARN_ON_ONCE(val)		debug("Error %d\n", val)
-
-#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
-
-static inline size_t strlcat(char *dest, const char *src, size_t n)
-{
-	strcat(dest, src);
-	return strlen(dest) + strlen(src);
-}
-
-static inline void *devm_kzalloc(struct device *dev, unsigned int size,
-				 unsigned int flags)
-{
-	return kzalloc(size, flags);
-}
-
-static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
-{
-	return kzalloc(n * size, flags);
-}
-#endif
diff --git a/drivers/usb/dwc3/ti_usb_phy.c b/drivers/usb/dwc3/ti_usb_phy.c
index e6048eb..40dc620 100644
--- a/drivers/usb/dwc3/ti_usb_phy.c
+++ b/drivers/usb/dwc3/ti_usb_phy.c
@@ -25,8 +25,6 @@
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 
-#include "linux-compat.h"
-
 #define PLL_STATUS		0x00000004
 #define PLL_GO			0x00000008
 #define PLL_CONFIGURATION1	0x0000000C
diff --git a/drivers/usb/musb-new/linux-compat.h b/drivers/usb/musb-new/linux-compat.h
index 46f83d9..c4bdca1 100644
--- a/drivers/usb/musb-new/linux-compat.h
+++ b/drivers/usb/musb-new/linux-compat.h
@@ -7,12 +7,6 @@
 
 #define pr_debug(fmt, args...) debug(fmt, ##args)
 
-#define WARN(condition, fmt, args...) ({	\
-	int ret_warn = !!condition;		\
-	if (ret_warn)				\
-		printf(fmt, ##args);		\
-	ret_warn; })
-
 #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)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 904425a..a3feda9 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -27,6 +27,18 @@ extern struct p_current *current;
 #define printk	printf
 #define printk_once	printf
 
+#define pr_debug(fmt, args...)	debug(fmt, ##args)
+
+#define WARN(condition, fmt, args...) ({	\
+	int ret_warn = !!condition;		\
+	if (ret_warn)				\
+		printf(fmt, ##args);		\
+	ret_warn; })
+#define dev_WARN(dev, format, arg...)	debug(format, ##arg)
+#define WARN_ON_ONCE(val)		debug("Error %d\n", val)
+
+#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
+
 #define KERN_EMERG
 #define KERN_ALERT
 #define KERN_CRIT
@@ -38,11 +50,14 @@ extern struct p_current *current;
 
 void *kmalloc(size_t size, int flags);
 void *kzalloc(size_t size, int flags);
+void *kmalloc_array(size_t n, size_t size, int flags);
 #define vmalloc(size)	kmalloc(size, 0)
 #define __vmalloc(size, flags, pgsz)	kmalloc(size, flags)
 #define kfree(ptr)	free(ptr)
 #define vfree(ptr)	free(ptr)
 
+#define devm_kzalloc(dev, size, flags) kzalloc(size, flags)
+
 struct kmem_cache { int sz; };
 
 struct kmem_cache *get_mem(int element_sz);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8666413..9ae2ddb 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -442,14 +442,12 @@ static inline void mtd_erase_callback(struct erase_info *instr)
 #define MTD_DEBUG_LEVEL3	(3)	/* Noisy   */
 
 #ifdef CONFIG_MTD_DEBUG
-#define pr_debug(args...)	MTDDEBUG(MTD_DEBUG_LEVEL0, args)
 #define MTDDEBUG(n, args...)				\
 	do {						\
 		if (n <= CONFIG_MTD_DEBUG_VERBOSE)	\
 			printk(KERN_INFO args);		\
 	} while(0)
 #else /* CONFIG_MTD_DEBUG */
-#define pr_debug(args...)
 #define MTDDEBUG(n, args...)				\
 	do {						\
 		if (0)					\
diff --git a/include/linux/string.h b/include/linux/string.h
index c7047ba..a4d84dd 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -35,6 +35,7 @@ size_t strlcpy(char *, const char *, size_t);
 #endif
 #ifndef __HAVE_ARCH_STRCAT
 extern char * strcat(char *, const char *);
+extern size_t strlcat(char *dest, const char *src, size_t n);
 #endif
 #ifndef __HAVE_ARCH_STRNCAT
 extern char * strncat(char *, const char *, __kernel_size_t);
diff --git a/lib/linux_compat.c b/lib/linux_compat.c
index a3d4675..560a2a4 100644
--- a/lib/linux_compat.c
+++ b/lib/linux_compat.c
@@ -45,3 +45,9 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
 {
 	return memalign(ARCH_DMA_MINALIGN, obj->sz);
 }
+
+void *kmalloc_array(size_t n, size_t size, int flags)
+{
+	return kzalloc(n * size, flags);
+}
+
diff --git a/lib/string.c b/lib/string.c
index 87c9a40..9ce9064 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -144,6 +144,12 @@ char * strcat(char * dest, const char * src)
 
 	return tmp;
 }
+
+size_t strlcat(char *dest, const char *src, size_t n)
+{
+	strcat(dest, src);
+	return strlen(dest) + strlen(src);
+}
 #endif
 
 #ifndef __HAVE_ARCH_STRNCAT
-- 
1.7.9.5



More information about the U-Boot mailing list