Skip to contentSkip to conversation

gunzip: rename z{alloc, free} to gz{alloc, free}

PATCH New Mike Frysinger 3 participants 15 messages Apr 9, 2012 – Apr 30, 2012

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 gunzip: rename z{alloc, free} to gz{alloc, free}

This allows us to add a proper zalloc() func (one that does a zeroing alloc), and removes duplicate prototypes.

---
 fs/cramfs/uncompress.c |    7 ++-----
 include/u-boot/zlib.h  |    3 +++
 lib/gunzip.c           |   11 ++++-------
 3 files changed, 9 insertions(+), 12 deletions(-)
fs/cramfs/uncompress.c +2 -5
index 228fe68..f431cc4 100644
@@ -27,9 +27,6 @@
 
 static z_stream stream;
 
-void *zalloc(void *, unsigned, unsigned);
-void zfree(void *, void *, unsigned);
-
 /* Returns length of decompressed data. */
 int cramfs_uncompress_block (void *dst, void *src, int srclen)
 {
@@ -59,8 +56,8 @@ int cramfs_uncompress_init (void)
 {
 	int err;
 
-	stream.zalloc = zalloc;
-	stream.zfree = zfree;
+	stream.zalloc = gzalloc;
+	stream.zfree = gzfree;
 	stream.next_in = 0;
 	stream.avail_in = 0;
 
include/u-boot/zlib.h +3 -0
index fb27081..fbb08a3 100644
@@ -691,6 +691,9 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
 	struct internal_state {int dummy;}; /* hack for buggy compilers */
 #endif
 
+extern void *gzalloc(void *, unsigned, unsigned);
+extern void gzfree(void *, void *, unsigned);
+
 #ifdef __cplusplus
 }
 #endif
lib/gunzip.c +4 -7
index 8b16b24..99a8ab0 100644
@@ -36,10 +36,7 @@
 #define RESERVED		0xe0
 #define DEFLATED		8
 
-void *zalloc(void *, unsigned, unsigned);
-void zfree(void *, void *, unsigned);
-
-void *zalloc(void *x, unsigned items, unsigned size)
+void *gzalloc(void *x, unsigned items, unsigned size)
 {
 	void *p;
 
@@ -51,7 +48,7 @@ void *zalloc(void *x, unsigned items, unsigned size)
 	return (p);
 }
 
-void zfree(void *x, void *addr, unsigned nb)
+void gzfree(void *x, void *addr, unsigned nb)
 {
 	free (addr);
 }
@@ -94,8 +91,8 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
 	z_stream s;
 	int r;
 
-	s.zalloc = zalloc;
-	s.zfree = zfree;
+	s.zalloc = gzalloc;
+	s.zfree = gzfree;
 
 	r = inflateInit2(&s, -MAX_WBITS);
 	if (r != Z_OK) {
Signature · 1 line
1.7.8.5
#1 lore raw

PATCH 2/4 lin_gadget: use common mdelay

No need to provide our own mdelay() macro when we have a func for it.

---
 include/usb/lin_gadget_compat.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
include/usb/lin_gadget_compat.h +0 -1
index fce3be7..1b937e4 100644
@@ -52,7 +52,6 @@
 
 #define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)
 #define kfree(addr) free(addr)
-#define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
 
 #define __iomem
 #define min_t min
Signature · 1 line
1.7.8.5
#2 lore raw

PATCH 2/4 lin_gadget: use common mdelay

Quoted 6 lines · On Mon, 9 Apr 2012 19:39:54 -0400 Mike Frysinger <[email protected]> wrote:

No need to provide our own mdelay() macro when we have a func for it.

---
 include/usb/lin_gadget_compat.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

Applied to u-boot-staging/agust at denx.de, thanks.

Anatolij

#3 lore raw

PATCH 3/4 linux/compat.h: rename from linux/mtd/compat.h

In reply to Mike Frysinger

This lets us use it in more places than just mtd code.

---
 board/samsung/smdkc100/onenand.c    |    2 +-
 common/cmd_onenand.c                |    2 +-
 common/env_onenand.c                |    2 +-
 drivers/mtd/mtdconcat.c             |    2 +-
 drivers/mtd/mtdcore.c               |    2 +-
 drivers/mtd/mtdpart.c               |    2 +-
 drivers/mtd/nand/mpc5121_nfc.c      |    2 +-
 drivers/mtd/nand/nand_base.c        |    2 +-
 drivers/mtd/nand/nand_bbt.c         |    2 +-
 drivers/mtd/onenand/onenand_base.c  |    2 +-
 drivers/mtd/onenand/onenand_bbt.c   |    2 +-
 drivers/mtd/onenand/onenand_uboot.c |    2 +-
 drivers/mtd/onenand/samsung.c       |    2 +-
 fs/jffs2/jffs2_1pass.c              |    2 +-
 include/linux/{mtd => }/compat.h    |    0
 include/linux/err.h                 |    2 +-
 include/linux/mtd/mtd-abi.h         |    2 +-
 include/linux/mtd/nand.h            |    2 +-
 include/linux/mtd/onenand.h         |    2 +-
 include/nand.h                      |    2 +-
 20 files changed, 19 insertions(+), 19 deletions(-)
 rename include/linux/{mtd => }/compat.h (100%)
board/samsung/smdkc100/onenand.c +1 -1
index 501855e..e34cd31 100644
@@ -22,7 +22,7 @@
  */
 
 #include <common.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 #include <linux/mtd/samsung_onenand.h>
common/cmd_onenand.c +1 -1
index 0f2e208..a0d25e5 100644
@@ -13,7 +13,7 @@
 #include <command.h>
 #include <malloc.h>
 
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
common/env_onenand.c +1 -1
index 652665a..7197ab6 100644
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <onenand_uboot.h>
 
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
drivers/mtd/mtdconcat.c +1 -1
index fc22701..e6d9384 100644
@@ -9,7 +9,7 @@
  */
 
 #include <linux/mtd/mtd.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/concat.h>
 #include <ubi_uboot.h>
 
drivers/mtd/mtdcore.c +1 -1
index a195dda..3a81ada 100644
@@ -8,7 +8,7 @@
  */
 
 #include <linux/mtd/mtd.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <ubi_uboot.h>
 
 struct mtd_info *mtd_table[MAX_MTD_DEVICES];
drivers/mtd/mtdpart.c +1 -1
index f647e43..96dcda2 100644
@@ -17,7 +17,7 @@
 #include <linux/list.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 
 /* Our partition linked list */
 struct list_head mtd_partitions;
drivers/mtd/nand/mpc5121_nfc.c +1 -1
index 7fd8a35..e6b7a70 100644
@@ -29,7 +29,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand_ecc.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 
 #include <asm/errno.h>
 #include <asm/io.h>
drivers/mtd/nand/nand_base.c +1 -1
index 44f7b91..bef79be 100644
@@ -39,7 +39,7 @@
 #include <malloc.h>
 #include <watchdog.h>
 #include <linux/err.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand_ecc.h>
drivers/mtd/nand/nand_bbt.c +1 -1
index 2b730e0..dc6c648 100644
@@ -61,7 +61,7 @@
 
 #include <common.h>
 #include <malloc.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand_ecc.h>
drivers/mtd/onenand/onenand_base.c +1 -1
index 480ae7a..96a5b08 100644
@@ -20,7 +20,7 @@
  */
 
 #include <common.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
drivers/mtd/onenand/onenand_bbt.c +1 -1
index 1354877..9d5da54 100644
@@ -15,7 +15,7 @@
  */
 
 #include <common.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 #include <malloc.h>
drivers/mtd/onenand/onenand_uboot.c +1 -1
index c642016..ae60c3b 100644
@@ -14,7 +14,7 @@
  */
 
 #include <common.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
drivers/mtd/onenand/samsung.c +1 -1
index c9d33ec..0d94ea5 100644
@@ -28,7 +28,7 @@
 
 #include <common.h>
 #include <malloc.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 #include <linux/mtd/samsung_onenand.h>
fs/jffs2/jffs2_1pass.c +1 -1
index a0b02e4..c856983 100644
@@ -119,7 +119,7 @@
 #include <watchdog.h>
 #include <jffs2/jffs2.h>
 #include <jffs2/jffs2_1pass.h>
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <asm/errno.h>
 
 #include "jffs2_private.h"
include/linux/compat.h renamed from include/linux/mtd/compat.h +0 -0
similarity index 100%
rename from include/linux/mtd/compat.h
rename to include/linux/compat.h
include/linux/err.h +1 -1
index 4e08c4f..96c0c72 100644
@@ -5,7 +5,7 @@
 #if 0
 #include <linux/compiler.h>
 #else
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #endif
 
 #include <asm/errno.h>
include/linux/mtd/mtd-abi.h +1 -1
index 8d5f60c..5991157 100644
@@ -8,7 +8,7 @@
 #define __MTD_ABI_H__
 
 #if 1
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #endif
 
 struct erase_info_user {
include/linux/mtd/nand.h +1 -1
index da6fa18..82704de 100644
@@ -20,7 +20,7 @@
 
 #include "config.h"
 
-#include "linux/mtd/compat.h"
+#include "linux/compat.h"
 #include "linux/mtd/mtd.h"
 #include "linux/mtd/bbm.h"
 
include/linux/mtd/onenand.h +1 -1
index bb4a4a6..e7b63dd 100644
@@ -17,7 +17,7 @@
 /* Note: The header order is impoertant */
 #include <onenand_uboot.h>
 
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/bbm.h>
 
 #define MAX_DIES		2
include/nand.h +1 -1
index 8b3a1a7..a48b1b8 100644
@@ -37,7 +37,7 @@
 
 extern void nand_init(void);
 
-#include <linux/mtd/compat.h>
+#include <linux/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 
Signature · 1 line
1.7.8.5
#4 lore raw

PATCH 3/4 linux/compat.h: rename from linux/mtd/compat.h

Quoted 18 lines · On Mon, 9 Apr 2012 19:39:55 -0400 Mike Frysinger <[email protected]> wrote:

This lets us use it in more places than just mtd code.

---
 board/samsung/smdkc100/onenand.c    |    2 +-
 common/cmd_onenand.c                |    2 +-
 common/env_onenand.c                |    2 +-
 drivers/mtd/mtdconcat.c             |    2 +-
 drivers/mtd/mtdcore.c               |    2 +-
 drivers/mtd/mtdpart.c               |    2 +-
 drivers/mtd/nand/mpc5121_nfc.c      |    2 +-
 drivers/mtd/nand/nand_base.c        |    2 +-
 drivers/mtd/nand/nand_bbt.c         |    2 +-
 drivers/mtd/onenand/onenand_base.c  |    2 +-
 drivers/mtd/onenand/onenand_bbt.c   |    2 +-
 drivers/mtd/onenand/onenand_uboot.c |    2 +-
 drivers/mtd/onenand/samsung.c       |    2 +-
 fs/jffs2/jffs2_1pass.c              |    2 +-
Quoted 8 lines
 include/linux/{mtd => }/compat.h    |    0
 include/linux/err.h                 |    2 +-
 include/linux/mtd/mtd-abi.h         |    2 +-
 include/linux/mtd/nand.h            |    2 +-
 include/linux/mtd/onenand.h         |    2 +-
 include/nand.h                      |    2 +-
 20 files changed, 19 insertions(+), 19 deletions(-)
 rename include/linux/{mtd => }/compat.h (100%)

Applied to u-boot-staging/agust at denx.de, thanks.

Anatolij

#5 lore raw

PATCH 4/4 lin_gadget: use common linux/compat.h

In reply to Mike Frysinger

Merge our duplicate definitions with the common header.

---
 include/linux/compat.h          |    3 +++
 include/usb/lin_gadget_compat.h |   15 ++-------------
 2 files changed, 5 insertions(+), 13 deletions(-)
include/linux/compat.h +3 -0
index 39c693f..593b07f 100644
@@ -48,5 +48,8 @@
 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
 #endif /* BUG */
 
+#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
+				  , __FILE__, __LINE__); }
+
 #define PAGE_SIZE	4096
 #endif
include/usb/lin_gadget_compat.h +2 -13
index 1b937e4..8287b9d 100644
@@ -23,6 +23,8 @@
 #ifndef __LIN_COMPAT_H__
 #define __LIN_COMPAT_H__
 
+#include <linux/compat.h>
+
 /* common */
 #define spin_lock_init(...)
 #define spin_lock(...)
@@ -36,25 +38,12 @@
 #define mutex_lock(...)
 #define mutex_unlock(...)
 
-#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
-				  , __FILE__, __LINE__); }
-
-#define KERN_WARNING
-#define KERN_ERR
-#define KERN_NOTICE
-#define KERN_DEBUG
-
 #define GFP_KERNEL	0
 
 #define IRQ_HANDLED	1
 
 #define ENOTSUPP	524	/* Operation is not supported */
 
-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)
-#define kfree(addr) free(addr)
-
-#define __iomem
-#define min_t min
 #define dma_cache_maint(addr, size, mode) cache_flush()
 void cache_flush(void);
 
Signature · 1 line
1.7.8.5
#6 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header. Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

---
v2:
- fix build breakage:
In file included from s3c_udc_otg.c:212:0:
s3c_udc_otg_xfer_dma.c: In function 'setdma_tx':
s3c_udc_otg_xfer_dma.c:171:47: error: macro "min_t" requires 3 arguments, but only 2 given s3c_udc_otg_xfer_dma.c:171:12: error: 'min_t' undeclared (first use in this function)

 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |    2 +-
 include/linux/compat.h                    |    3 +++
 include/usb/lin_gadget_compat.h           |   15 ++-------------
 3 files changed, 6 insertions(+), 14 deletions(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1 -1
index afd4931..56e6e53 100644
@@ -168,7 +168,7 @@ int setdma_tx(struct s3c_ep *ep, struct s3c_request *req)
 	length = req->req.length - req->req.actual;
 
 	if (ep_num == EP0_CON)
-		length = min_t(length, (u32)ep_maxpacket(ep));
+		length = min(length, (u32)ep_maxpacket(ep));
 
 	ep->len = length;
 	ep->dma_buf = buf;
include/linux/compat.h +3 -0
index 39c693f..593b07f 100644
@@ -48,5 +48,8 @@
 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
 #endif /* BUG */
 
+#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
+				  , __FILE__, __LINE__); }
+
 #define PAGE_SIZE	4096
 #endif
include/usb/lin_gadget_compat.h +2 -13
index 1b937e4..8287b9d 100644
@@ -23,6 +23,8 @@
 #ifndef __LIN_COMPAT_H__
 #define __LIN_COMPAT_H__
 
+#include <linux/compat.h>
+
 /* common */
 #define spin_lock_init(...)
 #define spin_lock(...)
@@ -36,25 +38,12 @@
 #define mutex_lock(...)
 #define mutex_unlock(...)
 
-#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
-				  , __FILE__, __LINE__); }
-
-#define KERN_WARNING
-#define KERN_ERR
-#define KERN_NOTICE
-#define KERN_DEBUG
-
 #define GFP_KERNEL	0
 
 #define IRQ_HANDLED	1
 
 #define ENOTSUPP	524	/* Operation is not supported */
 
-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)
-#define kfree(addr) free(addr)
-
-#define __iomem
-#define min_t min
 #define dma_cache_maint(addr, size, mode) cache_flush()
 void cache_flush(void);
 
Signature · 1 line
1.7.7.6
#7 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

Quoted 9 lines · On Wednesday 25 April 2012 04:11:41 Anatolij Gustschin wrote:

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header. Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Quoted 8 lines

---
v2:
- fix build breakage:

   In file included from s3c_udc_otg.c:212:0:
   s3c_udc_otg_xfer_dma.c: In function 'setdma_tx':
   s3c_udc_otg_xfer_dma.c:171:47: error: macro "min_t" requires 3

arguments, but only 2 given s3c_udc_otg_xfer_dma.c:171:12: error: 'min_t' undeclared (first use in this function)

we'll prob want to merge the mtd/compat.h stuff in to linux/compat.h, like the min_t() macro
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120425/899f6046/attachment.pgp>

#8 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

In reply to Anatolij Gustschin

Hi Anatolij,

Quoted 6 lines

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header. Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Yes. the include/usb/lin_gadget_compat.h layer.
Good idea to provide one compat file (as fair as I remember similar problem is with mtd/compat.h).

I'll look into the include/linux.h file.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#9 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

Hi Lukasz,

Quoted 9 lines · On Wed, 25 Apr 2012 17:58:51 +0200 Lukasz Majewski <[email protected]>…

Hi Anatolij,

Quoted 6 lines

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header. Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Quoted 5 lines

Yes. the include/usb/lin_gadget_compat.h layer.
Good idea to provide one compat file (as fair as I remember similar problem is with mtd/compat.h).

I'll look into the include/linux.h file.

Mike already moved mtd/compat.h to linux/compat.h, please see this patch http://patchwork.ozlabs.org/patch/151500/

Now I see another issue. In this 4/4 patch we are removing kmalloc:

-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)

linux/compat.h defines kmalloc() to be malloc(), so the gadget driver should probably use memalign() directly where it is needed?

Thanks,
Anatolij

#10 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

Hi Anatolij,

Quoted 18 lines
Quoted 9 lines

Hi Anatolij,

Quoted 6 lines

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header. Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Quoted 5 lines

Yes. the include/usb/lin_gadget_compat.h layer.
Good idea to provide one compat file (as fair as I remember similar problem is with mtd/compat.h).

I'll look into the include/linux.h file.

Mike already moved mtd/compat.h to linux/compat.h, please see this patch http://patchwork.ozlabs.org/patch/151500/

Quoted 6 lines

Now I see another issue. In this 4/4 patch we are removing kmalloc:

-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)

linux/compat.h defines kmalloc() to be malloc(), so the gadget driver should probably use memalign() directly where it is needed?

In the include/usb/lin_gadget_compat.h the

#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size) line is defined.

I think that memalign can be used directly, no problem.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
#11 lore raw

PATCH v2 4/4 lin_gadget: use common linux/compat.h

Hi Lukasz,

On Thu, 26 Apr 2012 12:32:40 +0200
Lukasz Majewski <[email protected]> wrote:
...

Quoted 7 lines
Quoted 6 lines

Now I see another issue. In this 4/4 patch we are removing kmalloc:

-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)

linux/compat.h defines kmalloc() to be malloc(), so the gadget driver should probably use memalign() directly where it is needed?

Quoted 6 lines

In the include/usb/lin_gadget_compat.h the

#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size) line is defined.

I think that memalign can be used directly, no problem.

Okay, I'll change this patch accordingly and will resubmit v3 then.

Thanks,
Anatolij

#12 lore raw

PATCH v3 4/4 lin_gadget: use common linux/compat.h

In reply to Anatolij Gustschin

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header.

Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Additionally use memalign() directly as the lin_gadget specific kmalloc() macro is removed from lin_gadget_compat.h by this patch.

---
v3:
- use memalign() in the s3c_udc_otg driver directly

v2:
- fix build breakage:
In file included from s3c_udc_otg.c:212:0:
s3c_udc_otg_xfer_dma.c: In function 'setdma_tx':
s3c_udc_otg_xfer_dma.c:171:47: error: macro "min_t" requires 3 arguments, but only 2 given s3c_udc_otg_xfer_dma.c:171:12: error: 'min_t' undeclared (first use in this function)

 drivers/usb/gadget/s3c_udc_otg.c          |    5 +++--
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |    2 +-
 include/linux/compat.h                    |    3 +++
 include/usb/lin_gadget_compat.h           |   15 ++-------------
 4 files changed, 9 insertions(+), 16 deletions(-)
drivers/usb/gadget/s3c_udc_otg.c +3 -2
index 1050a98..9d11aea 100644
@@ -671,7 +671,7 @@ static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
 
 	debug("%s: %s %p\n", __func__, ep->name, ep);
 
-	req = kmalloc(sizeof *req, gfp_flags);
+	req = memalign(CONFIG_SYS_CACHELINE_SIZE, sizeof(*req));
 	if (!req)
 		return 0;
 
@@ -865,7 +865,8 @@ int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
 	the_controller = dev;
 
 	for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
-		dev->dma_buf[i] = kmalloc(DMA_BUFFER_SIZE, GFP_KERNEL);
+		dev->dma_buf[i] = memalign(CONFIG_SYS_CACHELINE_SIZE,
+					   DMA_BUFFER_SIZE);
 		dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
 		invalidate_dcache_range((unsigned long) dev->dma_buf[i],
 					(unsigned long) (dev->dma_buf[i]
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +1 -1
index afd4931..56e6e53 100644
@@ -168,7 +168,7 @@ int setdma_tx(struct s3c_ep *ep, struct s3c_request *req)
 	length = req->req.length - req->req.actual;
 
 	if (ep_num == EP0_CON)
-		length = min_t(length, (u32)ep_maxpacket(ep));
+		length = min(length, (u32)ep_maxpacket(ep));
 
 	ep->len = length;
 	ep->dma_buf = buf;
include/linux/compat.h +3 -0
index 39c693f..593b07f 100644
@@ -48,5 +48,8 @@
 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
 #endif /* BUG */
 
+#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
+				  , __FILE__, __LINE__); }
+
 #define PAGE_SIZE	4096
 #endif
include/usb/lin_gadget_compat.h +2 -13
index 1b937e4..8287b9d 100644
@@ -23,6 +23,8 @@
 #ifndef __LIN_COMPAT_H__
 #define __LIN_COMPAT_H__
 
+#include <linux/compat.h>
+
 /* common */
 #define spin_lock_init(...)
 #define spin_lock(...)
@@ -36,25 +38,12 @@
 #define mutex_lock(...)
 #define mutex_unlock(...)
 
-#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
-				  , __FILE__, __LINE__); }
-
-#define KERN_WARNING
-#define KERN_ERR
-#define KERN_NOTICE
-#define KERN_DEBUG
-
 #define GFP_KERNEL	0
 
 #define IRQ_HANDLED	1
 
 #define ENOTSUPP	524	/* Operation is not supported */
 
-#define kmalloc(size, type) memalign(CONFIG_SYS_CACHELINE_SIZE, size)
-#define kfree(addr) free(addr)
-
-#define __iomem
-#define min_t min
 #define dma_cache_maint(addr, size, mode) cache_flush()
 void cache_flush(void);
 
Signature · 1 line
1.7.7.6
#13 lore raw

PATCH v3 4/4 lin_gadget: use common linux/compat.h

Quoted 26 lines · On Thu, 26 Apr 2012 14:34:44 +0200 Anatolij Gustschin <[email protected]> wrote:

From: Mike Frysinger <[email protected]>

Merge our duplicate definitions with the common header.

Also fix drivers/usb/gadget/s3c_udc_otg_xfer_dma.c to use min() instead of min_t() since we remove the latter from compat.h.

Additionally use memalign() directly as the lin_gadget specific kmalloc() macro is removed from lin_gadget_compat.h by this patch.

---
v3:
- use memalign() in the s3c_udc_otg driver directly

v2:
- fix build breakage:
In file included from s3c_udc_otg.c:212:0:
s3c_udc_otg_xfer_dma.c: In function 'setdma_tx':
s3c_udc_otg_xfer_dma.c:171:47: error: macro "min_t" requires 3 arguments, but only 2 given s3c_udc_otg_xfer_dma.c:171:12: error: 'min_t' undeclared (first use in this function)

Quoted 5 lines
 drivers/usb/gadget/s3c_udc_otg.c          |    5 +++--
 drivers/usb/gadget/s3c_udc_otg_xfer_dma.c |    2 +-
 include/linux/compat.h                    |    3 +++
 include/usb/lin_gadget_compat.h           |   15 ++-------------
 4 files changed, 9 insertions(+), 16 deletions(-)

Applied to u-boot-staging/agust at denx.de. Thanks!

Anatolij

#14 lore raw

PATCH 1/4 gunzip: rename z{alloc, free} to gz{alloc, free}

In reply to Mike Frysinger
Quoted 9 lines · On Mon, 9 Apr 2012 19:39:53 -0400 Mike Frysinger <[email protected]> wrote:

This allows us to add a proper zalloc() func (one that does a zeroing alloc), and removes duplicate prototypes.

---
 fs/cramfs/uncompress.c |    7 ++-----
 include/u-boot/zlib.h  |    3 +++
 lib/gunzip.c           |   11 ++++-------
 3 files changed, 9 insertions(+), 12 deletions(-)

Applied to u-boot-staging/agust at denx.de, thanks.

Anatolij