All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] miscellaneous cleanup patches
@ 2007-02-14 19:29 Grant Likely
  2007-02-14 19:29 ` [U-Boot-Users] [PATCH 1/4] Merge common get_dev() routines for block devices Grant Likely
  0 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2007-02-14 19:29 UTC (permalink / raw)
  To: u-boot

Here's a bunch of cleanup patches from my local tree.  I've cherry-picked
the ones that I think are ready to be merged.  I've got a bunch more
in the works; but I figure it will be less painless if I send them in
smaller chunks.

I've tested these changes on my xilinx ppc405 platform, and on a lite5200b.

Can someone who has a Dataflash part test the print_buffer patch for me?
There shouldn't be any functional changes, but I don't have the board to test
it.

These patches can also be pulled from the merge branch of my git tree:

git://git.secretlab.ca/srv/git-trees/public/git/u-boot.git#merge
--or--
http://git.secretlab.ca/git/u-boot.git#merge

Thanks,
g.

board/esd/common/auto_update.c          |    3 +-
board/mcc200/auto_update.c              |    3 +-
board/mpl/mip405/mip405.c               |    3 -
board/trab/auto_update.c                |    1 -
board/xilinx/ml300/Makefile             |    2 +-
board/xilinx/ml300/ml300.c              |    2 +-
board/xilinx/ml300/serial.c             |    3 +-
board/xilinx/xilinx_enet/emac_adapter.c |    2 +-
board/xilinx/xilinx_enet/xemac.h        |    2 +-
board/xilinx/xilinx_enet/xemac_g.c      |    2 +-
board/xilinx/xilinx_iic/iic_adapter.c   |    2 +-
common/cmd_ext2.c                       |   40 +----------------
common/cmd_fat.c                        |   37 +----------------
common/cmd_ide.c                        |    8 +++-
common/cmd_mem.c                        |   64 ++++++----------------------
common/cmd_reiser.c                     |   40 +----------------
common/cmd_scsi.c                       |    2 +-
common/cmd_usb.c                        |    1 +
common/ft_build.c                       |    6 +--
common/usb_storage.c                    |    3 +-
cpu/pxa/mmc.c                           |    2 +-
disk/part.c                             |   49 +++++++++++++++++++++
include/common.h                        |    2 +
include/ide.h                           |    6 +-
include/part.h                          |    9 ++++
lib_generic/display_options.c           |   70 +++++++++++++++++++++++++++++++
26 files changed, 176 insertions(+), 188 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 1/4] Merge common get_dev() routines for block devices
  2007-02-14 19:29 [U-Boot-Users] miscellaneous cleanup patches Grant Likely
@ 2007-02-14 19:29 ` Grant Likely
  2007-02-14 19:29   ` [U-Boot-Users] [PATCH 2/4] Use config.h, not xparameters.h, for xilinx targets Grant Likely
  0 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2007-02-14 19:29 UTC (permalink / raw)
  To: u-boot

Each of the filesystem drivers duplicate the get_dev routine.  This change
merges them into a single function in part.c

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 board/esd/common/auto_update.c |    3 +-
 board/mcc200/auto_update.c     |    3 +-
 board/mpl/mip405/mip405.c      |    3 --
 board/trab/auto_update.c       |    1 -
 common/cmd_ext2.c              |   40 ++------------------------------
 common/cmd_fat.c               |   37 +-----------------------------
 common/cmd_ide.c               |    8 +++++-
 common/cmd_reiser.c            |   40 ++------------------------------
 common/cmd_scsi.c              |    2 +-
 common/cmd_usb.c               |    1 +
 common/usb_storage.c           |    3 +-
 cpu/pxa/mmc.c                  |    2 +-
 disk/part.c                    |   49 ++++++++++++++++++++++++++++++++++++++++
 include/ide.h                  |    6 ++--
 include/part.h                 |    9 +++++++
 15 files changed, 82 insertions(+), 125 deletions(-)

diff --git a/board/esd/common/auto_update.c b/board/esd/common/auto_update.c
index 5cd3423..001fd68 100644
--- a/board/esd/common/auto_update.c
+++ b/board/esd/common/auto_update.c
@@ -33,6 +33,7 @@ #include <image.h>
 #include <asm/byteorder.h>
 #include <linux/mtd/nand_legacy.h>
 #include <fat.h>
+#include <part.h>
 
 #include "auto_update.h"
 
@@ -71,8 +72,6 @@ #endif
 extern int flash_sect_erase(ulong, ulong);
 extern int flash_sect_protect (int, ulong, ulong);
 extern int flash_write (char *, ulong, ulong);
-/* change char* to void* to shutup the compiler */
-extern block_dev_desc_t *get_dev (char*, int);
 
 #if (CONFIG_COMMANDS & CFG_CMD_NAND) && defined(CFG_NAND_LEGACY)
 /* references to names in cmd_nand.c */
diff --git a/board/mcc200/auto_update.c b/board/mcc200/auto_update.c
index f1bb721..d67ad83 100644
--- a/board/mcc200/auto_update.c
+++ b/board/mcc200/auto_update.c
@@ -23,6 +23,7 @@ #include <malloc.h>
 #include <image.h>
 #include <asm/byteorder.h>
 #include <usb.h>
+#include <part.h>
 
 #ifdef CFG_HUSH_PARSER
 #include <hush.h>
@@ -134,8 +135,6 @@ extern int i2c_read (unsigned char, unsi
 extern int flash_sect_erase(ulong, ulong);
 extern int flash_sect_protect (int, ulong, ulong);
 extern int flash_write (char *, ulong, ulong);
-/* change char* to void* to shutup the compiler */
-extern block_dev_desc_t *get_dev (char*, int);
 extern int u_boot_hush_start(void);
 
 int au_check_cksum_valid(int idx, long nbytes)
diff --git a/board/mpl/mip405/mip405.c b/board/mpl/mip405/mip405.c
index 34f3289..1324978 100644
--- a/board/mpl/mip405/mip405.c
+++ b/board/mpl/mip405/mip405.c
@@ -73,9 +73,6 @@ #include <rtc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern block_dev_desc_t * scsi_get_dev(int dev);
-extern block_dev_desc_t * ide_get_dev(int dev);
-
 #undef SDRAM_DEBUG
 #define ENABLE_ECC /* for ecc boards */
 #define FALSE           0
diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
index d2c8d44..f4074ae 100644
--- a/board/trab/auto_update.c
+++ b/board/trab/auto_update.c
@@ -203,7 +203,6 @@ extern int flash_write (char *, ulong, u
 /* change char* to void* to shutup the compiler */
 extern int i2c_write_multiple (uchar, uint, int, void *, int);
 extern int i2c_read_multiple (uchar, uint, int, void *, int);
-extern block_dev_desc_t *get_dev (char*, int);
 extern int u_boot_hush_start(void);
 
 int
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index 5db42f2..94bd9b6 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -33,6 +33,7 @@
  * Ext2fs support
  */
 #include <common.h>
+#include <part.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_EXT2)
 #include <config.h>
@@ -57,41 +58,6 @@ #else
 #define PRINTF(fmt,args...)
 #endif
 
-static block_dev_desc_t *get_dev (char* ifname, int dev)
-{
-#if (CONFIG_COMMANDS & CFG_CMD_IDE)
-	if (strncmp(ifname,"ide",3)==0) {
-		extern block_dev_desc_t * ide_get_dev(int dev);
-		return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev));
-	}
-#endif
-#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
-	if (strncmp(ifname,"scsi",4)==0) {
-		extern block_dev_desc_t * scsi_get_dev(int dev);
-		return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev));
-	}
-#endif
-#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
-	if (strncmp(ifname,"usb",3)==0) {
-		extern block_dev_desc_t * usb_stor_get_dev(int dev);
-		return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_MMC)
-	if (strncmp(ifname,"mmc",3)==0) {
-		extern block_dev_desc_t *  mmc_get_dev(int dev);
-		return((dev >= 1) ? NULL : mmc_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_SYSTEMACE)
-	if (strcmp(ifname,"ace")==0) {
-		extern block_dev_desc_t *  systemace_get_dev(int dev);
-		return((dev >= 1) ? NULL : systemace_get_dev(dev));
-	}
-#endif
-	return(NULL);
-}
-
 int do_ext2ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	char *filename = "/";
@@ -106,7 +72,7 @@ int do_ext2ls (cmd_tbl_t *cmdtp, int fla
 		return(1);
 	}
 	dev = (int)simple_strtoul (argv[2], &ep, 16);
-	dev_desc=get_dev(argv[1],dev);
+	dev_desc = get_dev(argv[1],dev);
 
 	if (dev_desc == NULL) {
 		printf ("\n** Block device %s %d not supported\n", argv[1], dev);
@@ -210,7 +176,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int f
 	}
 
 	dev = (int)simple_strtoul (argv[2], &ep, 16);
-	dev_desc=get_dev(argv[1],dev);
+	dev_desc = get_dev(argv[1],dev);
 	if (dev_desc==NULL) {
 		printf ("\n** Block device %s %d not supported\n", argv[1], dev);
 		return(1);
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index 6844c10..afaf299 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -29,6 +29,7 @@ #include <command.h>
 #include <s_record.h>
 #include <net.h>
 #include <ata.h>
+#include <part.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_FAT)
 
@@ -37,42 +38,6 @@ #undef	DEBUG
 #include <fat.h>
 
 
-block_dev_desc_t *get_dev (char* ifname, int dev)
-{
-#if (CONFIG_COMMANDS & CFG_CMD_IDE)
-	if (strncmp(ifname,"ide",3)==0) {
-		extern block_dev_desc_t * ide_get_dev(int dev);
-		return(ide_get_dev(dev));
-	}
-#endif
-#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
-	if (strncmp(ifname,"scsi",4)==0) {
-		extern block_dev_desc_t * scsi_get_dev(int dev);
-		return(scsi_get_dev(dev));
-	}
-#endif
-#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
-	if (strncmp(ifname,"usb",3)==0) {
-		extern block_dev_desc_t * usb_stor_get_dev(int dev);
-		return(usb_stor_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_MMC)
-	if (strncmp(ifname,"mmc",3)==0) {
-		extern block_dev_desc_t *  mmc_get_dev(int dev);
-		return(mmc_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_SYSTEMACE)
-	if (strcmp(ifname,"ace")==0) {
-		extern block_dev_desc_t *  systemace_get_dev(int dev);
-		return(systemace_get_dev(dev));
-	}
-#endif
-	return NULL;
-}
-
-
 int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	long size;
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index a415502..ebc080c 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -31,20 +31,26 @@ #include <watchdog.h>
 #include <command.h>
 #include <image.h>
 #include <asm/byteorder.h>
+
 #if defined(CONFIG_IDE_8xx_DIRECT) || defined(CONFIG_IDE_PCMCIA)
 # include <pcmcia.h>
 #endif
+
 #ifdef CONFIG_8xx
 # include <mpc8xx.h>
 #endif
+
 #ifdef CONFIG_MPC5xxx
 #include <mpc5xxx.h>
 #endif
+
 #include <ide.h>
 #include <ata.h>
+
 #ifdef CONFIG_STATUS_LED
 # include <status_led.h>
 #endif
+
 #ifndef __PPC__
 #include <asm/io.h>
 #ifdef __MIPS__
@@ -697,7 +703,7 @@ #endif
 
 block_dev_desc_t * ide_get_dev(int dev)
 {
-	return ((block_dev_desc_t *)&ide_dev_desc[dev]);
+	return (dev < CFG_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
 }
 
 
diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c
index 508ffcb..09c86e6 100644
--- a/common/cmd_reiser.c
+++ b/common/cmd_reiser.c
@@ -35,6 +35,7 @@ #include <image.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <reiserfs.h>
+#include <part.h>
 
 #ifndef CONFIG_DOS_PARTITION
 #error DOS partition support must be selected
@@ -48,41 +49,6 @@ #else
 #define PRINTF(fmt,args...)
 #endif
 
-static block_dev_desc_t *get_dev (char* ifname, int dev)
-{
-#if (CONFIG_COMMANDS & CFG_CMD_IDE)
-	if (strncmp(ifname,"ide",3)==0) {
-		extern block_dev_desc_t * ide_get_dev(int dev);
-		return((dev >= CFG_IDE_MAXDEVICE) ? NULL : ide_get_dev(dev));
-	}
-#endif
-#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
-	if (strncmp(ifname,"scsi",4)==0) {
-		extern block_dev_desc_t * scsi_get_dev(int dev);
-		return((dev >= CFG_SCSI_MAXDEVICE) ? NULL : scsi_get_dev(dev));
-	}
-#endif
-#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
-	if (strncmp(ifname,"usb",3)==0) {
-		extern block_dev_desc_t * usb_stor_get_dev(int dev);
-		return((dev >= USB_MAX_STOR_DEV) ? NULL : usb_stor_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_MMC)
-	if (strncmp(ifname,"mmc",3)==0) {
-		extern block_dev_desc_t *  mmc_get_dev(int dev);
-		return((dev >= 1) ? NULL : mmc_get_dev(dev));
-	}
-#endif
-#if defined(CONFIG_SYSTEMACE)
-	if (strcmp(ifname,"ace")==0) {
-		extern block_dev_desc_t *  systemace_get_dev(int dev);
-		return((dev >= 1) ? NULL : systemace_get_dev(dev));
-	}
-#endif
-	return NULL;
-}
-
 int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	char *filename = "/";
@@ -97,7 +63,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int f
 		return 1;
 	}
 	dev = (int)simple_strtoul (argv[2], &ep, 16);
-	dev_desc=get_dev(argv[1],dev);
+	dev_desc = get_dev(argv[1],dev);
 
 	if (dev_desc == NULL) {
 		printf ("\n** Block device %s %d not supported\n", argv[1], dev);
@@ -196,7 +162,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int
 	}
 
 	dev = (int)simple_strtoul (argv[2], &ep, 16);
-	dev_desc=get_dev(argv[1],dev);
+	dev_desc = get_dev(argv[1],dev);
 	if (dev_desc==NULL) {
 		printf ("\n** Block device %s %d not supported\n", argv[1], dev);
 		return 1;
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index cc08743..b17bebb 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -194,7 +194,7 @@ #endif
 
 block_dev_desc_t * scsi_get_dev(int dev)
 {
-	return((block_dev_desc_t *)&scsi_dev_desc[dev]);
+	return (dev < CFG_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL;
 }
 
 
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 28c05aa..904df71 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/byteorder.h>
+#include <part.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_USB)
 
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 06ea99b..b4b7914 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -56,6 +56,7 @@ #include <asm/processor.h>
 
 
 #if (CONFIG_COMMANDS & CFG_CMD_USB)
+#include <part.h>
 #include <usb.h>
 
 #ifdef CONFIG_USB_STORAGE
@@ -174,7 +175,7 @@ void uhci_show_temp_int_td(void);
 
 block_dev_desc_t *usb_stor_get_dev(int index)
 {
-	return &usb_dev_desc[index];
+	return (index < USB_MAX_STOR_DEV) ? &usb_dev_desc[index] : NULL;
 }
 
 
diff --git a/cpu/pxa/mmc.c b/cpu/pxa/mmc.c
index f7020ee..c57d0d5 100644
--- a/cpu/pxa/mmc.c
+++ b/cpu/pxa/mmc.c
@@ -37,7 +37,7 @@ static block_dev_desc_t mmc_dev;
 
 block_dev_desc_t * mmc_get_dev(int dev)
 {
-	return ((block_dev_desc_t *)&mmc_dev);
+	return (dev == 0) ? &mmc_dev : NULL;
 }
 
 /*
diff --git a/disk/part.c b/disk/part.c
index 2255e72..f1026c5 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <ide.h>
+#include <part.h>
 
 #undef	PART_DEBUG
 
@@ -39,6 +40,54 @@ #if ((CONFIG_COMMANDS & CFG_CMD_IDE)	|| 
      defined(CONFIG_MMC) || \
      defined(CONFIG_SYSTEMACE) )
 
+struct block_drvr {
+	char *name;
+	block_dev_desc_t* (*get_dev)(int dev);
+};
+
+static const struct block_drvr block_drvr[] = {
+#if (CONFIG_COMMANDS & CFG_CMD_IDE)
+	{ .name = "ide", .get_dev = ide_get_dev, },
+#endif
+#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
+	{ .name = "scsi", .get_dev = scsi_get_dev, },
+#endif
+#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
+	{ .name = "usb", .get_dev = usb_stor_get_dev, },
+#endif
+#if defined(CONFIG_MMC)
+	{ .name = "mmc", .get_dev = mmc_get_dev, },
+#endif
+#if defined(CONFIG_SYSTEMACE)
+	{ .name = "ace", .get_dev = systemace_get_dev, },
+#endif
+	{ },
+};
+
+block_dev_desc_t *get_dev(char* ifname, int dev)
+{
+	const struct block_drvr *drvr = block_drvr;
+
+	while (drvr->name) {
+		if (strncmp(ifname, drvr->name, strlen(drvr->name)) == 0)
+			return drvr->get_dev(dev);
+		drvr++;
+	}
+	return NULL;
+}
+#else
+block_dev_desc_t *get_dev(char* ifname, int dev)
+{
+	return NULL;
+}
+#endif
+
+#if ((CONFIG_COMMANDS & CFG_CMD_IDE)	|| \
+     (CONFIG_COMMANDS & CFG_CMD_SCSI)	|| \
+     (CONFIG_COMMANDS & CFG_CMD_USB)	|| \
+     defined(CONFIG_MMC) || \
+     defined(CONFIG_SYSTEMACE) )
+
 /* ------------------------------------------------------------------------- */
 /*
  * reports device info to the user
diff --git a/include/ide.h b/include/ide.h
index dfef32f..e29ed36 100644
--- a/include/ide.h
+++ b/include/ide.h
@@ -48,8 +48,8 @@ #endif
  * Function Prototypes
  */
 
-void  ide_init  (void);
-ulong ide_read	(int device, lbaint_t blknr, ulong blkcnt, ulong *buffer);
-ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, ulong *buffer);
+void ide_init(void);
+ulong ide_read(int device, lbaint_t blknr, ulong blkcnt, ulong *buffer);
+ulong ide_write(int device, lbaint_t blknr, ulong blkcnt, ulong *buffer);
 
 #endif /* _IDE_H */
diff --git a/include/part.h b/include/part.h
index 318aa3c..f89ebc6 100644
--- a/include/part.h
+++ b/include/part.h
@@ -22,6 +22,7 @@
  */
 #ifndef _PART_H
 #define _PART_H
+
 #include <ide.h>
 
 typedef struct block_dev_desc {
@@ -83,6 +84,14 @@ typedef struct disk_partition {
 	uchar	type[32];	/* string type description		*/
 } disk_partition_t;
 
+/* Misc _get_dev functions */
+block_dev_desc_t* get_dev(char* ifname, int dev);
+block_dev_desc_t* ide_get_dev(int dev);
+block_dev_desc_t* scsi_get_dev(int dev);
+block_dev_desc_t* usb_stor_get_dev(int dev);
+block_dev_desc_t* mmc_get_dev(int dev);
+block_dev_desc_t* systemace_get_dev(int dev);
+
 /* disk/part.c */
 int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
 void print_part (block_dev_desc_t *dev_desc);
-- 
1.4.3.rc2.g0503

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 2/4] Use config.h, not xparameters.h, for xilinx targets
  2007-02-14 19:29 ` [U-Boot-Users] [PATCH 1/4] Merge common get_dev() routines for block devices Grant Likely
@ 2007-02-14 19:29   ` Grant Likely
  2007-02-14 19:29     ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md command to common function Grant Likely
  0 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2007-02-14 19:29 UTC (permalink / raw)
  To: u-boot

Change the xilinx device drivers and board code to include config.h
instead of xparameters.h directly.  config.h always includes the
correct xparameters file.  This change reduces the posibility of
including the wrong file when adding a new xilinx board port

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 board/xilinx/ml300/Makefile             |    2 +-
 board/xilinx/ml300/ml300.c              |    2 +-
 board/xilinx/ml300/serial.c             |    3 +--
 board/xilinx/xilinx_enet/emac_adapter.c |    2 +-
 board/xilinx/xilinx_enet/xemac.h        |    2 +-
 board/xilinx/xilinx_enet/xemac_g.c      |    2 +-
 board/xilinx/xilinx_iic/iic_adapter.c   |    2 +-
 7 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/board/xilinx/ml300/Makefile b/board/xilinx/ml300/Makefile
index 02c22fb..05ad235 100644
--- a/board/xilinx/ml300/Makefile
+++ b/board/xilinx/ml300/Makefile
@@ -28,7 +28,7 @@ ifneq ($(OBJTREE),$(SRCTREE))
 $(shell mkdir -p $(obj)../xilinx_iic)
 endif
 
-INCS		:= -I../ml300 -I../common -I../xilinx_enet -I../xilinx_iic
+INCS		:= -I../common -I../xilinx_enet -I../xilinx_iic
 CFLAGS		+= $(INCS)
 HOST_CFLAGS	+= $(INCS)
 
diff --git a/board/xilinx/ml300/ml300.c b/board/xilinx/ml300/ml300.c
index dad562f..60f0bc2 100644
--- a/board/xilinx/ml300/ml300.c
+++ b/board/xilinx/ml300/ml300.c
@@ -38,9 +38,9 @@
  *
  */
 
+#include <config.h>
 #include <common.h>
 #include <asm/processor.h>
-#include "xparameters.h"
 
 #ifdef CFG_ENV_IS_IN_EEPROM
 extern void convert_env(void);
diff --git a/board/xilinx/ml300/serial.c b/board/xilinx/ml300/serial.c
index c204b88..9b03f89 100644
--- a/board/xilinx/ml300/serial.c
+++ b/board/xilinx/ml300/serial.c
@@ -40,8 +40,7 @@ #include <asm/u-boot.h>
 #include <asm/processor.h>
 #include <common.h>
 #include <command.h>
-#include <configs/ml300.h>
-#include "xparameters.h"
+#include <config.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/board/xilinx/xilinx_enet/emac_adapter.c b/board/xilinx/xilinx_enet/emac_adapter.c
index b30e897..f159cb6 100644
--- a/board/xilinx/xilinx_enet/emac_adapter.c
+++ b/board/xilinx/xilinx_enet/emac_adapter.c
@@ -37,9 +37,9 @@
 *
 ******************************************************************************/
 
+#include <config.h>
 #include <common.h>
 #include <net.h>
-#include "xparameters.h"
 #include "xemac.h"
 
 #if defined(XPAR_EMAC_0_DEVICE_ID)
diff --git a/board/xilinx/xilinx_enet/xemac.h b/board/xilinx/xilinx_enet/xemac.h
index ed704bf..584cb7a 100644
--- a/board/xilinx/xilinx_enet/xemac.h
+++ b/board/xilinx/xilinx_enet/xemac.h
@@ -257,9 +257,9 @@ #define XEMAC_H			/* by using protection
 
 /***************************** Include Files *********************************/
 
+#include <config.h>
 #include "xbasic_types.h"
 #include "xstatus.h"
-#include "xparameters.h"
 #include "xpacket_fifo_v1_00_b.h"	/* Uses v1.00b of Packet Fifo */
 #include "xdma_channel.h"
 
diff --git a/board/xilinx/xilinx_enet/xemac_g.c b/board/xilinx/xilinx_enet/xemac_g.c
index 9340f91..d985157 100644
--- a/board/xilinx/xilinx_enet/xemac_g.c
+++ b/board/xilinx/xilinx_enet/xemac_g.c
@@ -43,7 +43,7 @@
 *
 *******************************************************************/
 
-#include "xparameters.h"
+#include <config.h>
 #include "xemac.h"
 
 /*
diff --git a/board/xilinx/xilinx_iic/iic_adapter.c b/board/xilinx/xilinx_iic/iic_adapter.c
index 163fe15..37dce03 100644
--- a/board/xilinx/xilinx_iic/iic_adapter.c
+++ b/board/xilinx/xilinx_iic/iic_adapter.c
@@ -37,10 +37,10 @@
 *
 ******************************************************************************/
 
+#include <config.h>
 #include <common.h>
 #include <environment.h>
 #include <net.h>
-#include "xparameters.h"
 
 #ifdef CFG_ENV_IS_IN_EEPROM
 #include <i2c.h>
-- 
1.4.3.rc2.g0503

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 3/4] Move buffer print code from md command to common function
  2007-02-14 19:29   ` [U-Boot-Users] [PATCH 2/4] Use config.h, not xparameters.h, for xilinx targets Grant Likely
@ 2007-02-14 19:29     ` Grant Likely
  2007-02-14 19:29       ` [U-Boot-Users] [PATCH 4/4] Remove local implementation of isprint() in ft_build.c Grant Likely
  2007-02-14 19:52       ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function Ulf Samuelsson
  0 siblings, 2 replies; 7+ messages in thread
From: Grant Likely @ 2007-02-14 19:29 UTC (permalink / raw)
  To: u-boot

Printing a buffer is a darn useful thing.  Move the buffer print code
into print_buffer() in lib_generic/

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 common/cmd_mem.c              |   64 ++++++++-----------------------------
 include/common.h              |    2 +
 lib_generic/display_options.c |   70 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 50 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index d0fae6b..9fc3d1e 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -92,8 +92,9 @@ #define DISP_LINE_LEN	16
 int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong	addr, length;
-	ulong	i, nbytes, linebytes;
-	u_char	*cp;
+#if defined(CONFIG_HAS_DATAFLASH)
+	ulong	nbytes, linebytes;
+#endif
 	int	size;
 	int rc = 0;
 
@@ -128,6 +129,7 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int fl
 			length = simple_strtoul(argv[2], NULL, 16);
 	}
 
+#if defined(CONFIG_HAS_DATAFLASH)
 	/* Print the lines.
 	 *
 	 * We buffer all read data, so we can make sure data is read only
@@ -136,64 +138,26 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int fl
 	nbytes = length * size;
 	do {
 		char	linebuf[DISP_LINE_LEN];
-		uint	*uip = (uint   *)linebuf;
-		ushort	*usp = (ushort *)linebuf;
-		u_char	*ucp = (u_char *)linebuf;
-#ifdef CONFIG_HAS_DATAFLASH
-		int rc;
-#endif
-		printf("%08lx:", addr);
 		linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
-
-#ifdef CONFIG_HAS_DATAFLASH
 		if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){
-			/* if outside dataflash */
-			/*if (rc != 1) {
-				dataflash_perror (rc);
-				return (1);
-			}*/
-			for (i=0; i<linebytes; i+= size) {
-				if (size == 4) {
-					printf(" %08x", *uip++);
-				} else if (size == 2) {
-					printf(" %04x", *usp++);
-				} else {
-					printf(" %02x", *ucp++);
-				}
-				addr += size;
-			}
-
+			print_buffer(addr, linebuf, size, linebytes/size,
+			             DISP_LINE_LEN/size);
 		} else {	/* addr does not correspond to DataFlash */
-#endif
-		for (i=0; i<linebytes; i+= size) {
-			if (size == 4) {
-				printf(" %08x", (*uip++ = *((uint *)addr)));
-			} else if (size == 2) {
-				printf(" %04x", (*usp++ = *((ushort *)addr)));
-			} else {
-				printf(" %02x", (*ucp++ = *((u_char *)addr)));
-			}
-			addr += size;
-		}
-#ifdef CONFIG_HAS_DATAFLASH
+			print_buffer(addr, (void*)addr, size, linebytes/size,
+			             DISP_LINE_LEN/size);
 		}
-#endif
-		puts ("    ");
-		cp = (u_char *)linebuf;
-		for (i=0; i<linebytes; i++) {
-			if ((*cp < 0x20) || (*cp > 0x7e))
-				putc ('.');
-			else
-				printf("%c", *cp);
-			cp++;
-		}
-		putc ('\n');
 		nbytes -= linebytes;
+		addr += linebytes;
 		if (ctrlc()) {
 			rc = 1;
 			break;
 		}
 	} while (nbytes > 0);
+#else
+	/* Print the lines. */
+	print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size);
+	addr += size*length;
+#endif
 
 	dp_last_addr = addr;
 	dp_last_length = length;
diff --git a/include/common.h b/include/common.h
index 982d6a8..5b2e71c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -187,6 +187,8 @@ void	hang		(void) __attribute__ ((noretu
 long int initdram (int);
 int	display_options (void);
 void	print_size (ulong, const char *);
+int	print_buffer (ulong addr, void* data, uint width, uint count,
+                      uint linelen);
 
 /* common/main.c */
 void	main_loop	(void);
diff --git a/lib_generic/display_options.c b/lib_generic/display_options.c
index 512e898..5ddd94f 100644
--- a/lib_generic/display_options.c
+++ b/lib_generic/display_options.c
@@ -21,7 +21,10 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
 #include <common.h>
+#include <linux/ctype.h>
+#include <asm/io.h>
 
 int display_options (void)
 {
@@ -65,3 +68,70 @@ void print_size (ulong size, const char 
 	}
 	printf (" %cB%s", c, s);
 }
+
+/*
+ * Print data buffer in hex and ascii form to the terminal.
+ *
+ * data reads are buffered so that each memory address is only read once.
+ * Useful when displaying the contents of volatile registers.
+ *
+ * parameters:
+ *    addr: Starting address to display at start of line
+ *    data: pointer to data buffer
+ *    width: data value width.  May be 1, 2, or 4.
+ *    count: number of values to display
+ *    linelen: Number of values to print per line; specify 0 for default length
+ */
+#define MAX_LINE_LENGTH_BYTES (64)
+#define DEFAULT_LINE_LENGTH_BYTES (16)
+int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
+{
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES];
+	uint32_t *uip = (void*)linebuf;
+	uint16_t *usp = (void*)linebuf;
+	uint8_t *ucp = (void*)linebuf;
+	int i;
+
+	if (linelen*width > MAX_LINE_LENGTH_BYTES)
+		linelen = MAX_LINE_LENGTH_BYTES / width;
+	if (linelen < 1)
+		linelen = DEFAULT_LINE_LENGTH_BYTES / width;
+
+	while (count) {
+		printf("%08lx:", addr);
+
+		/* check for overflow condition */
+		if (count < linelen)
+			linelen = count;
+
+		/* Copy from memory into linebuf and print hex values */
+		for (i = 0; i < linelen; i++) {
+			if (width == 4) {
+				uip[i] = *(volatile uint32_t *)data;
+				printf(" %08x", uip[i]);
+			} else if (width == 2) {
+				usp[i] = *(volatile uint16_t *)data;
+				printf(" %04x", usp[i]);
+			} else {
+				ucp[i] = *(volatile uint8_t *)data;
+				printf(" %02x", ucp[i]);
+			}
+			data += width;
+		}
+
+		/* Print data in ASCII characters */
+		puts("    ");
+		for (i = 0; i < linelen * width; i++)
+			putc(isprint(ucp[i]) && (ucp[i] < 0x80) ? ucp[i] : '.');
+		putc ('\n');
+
+		/* update references */
+		addr += linelen * width;
+		count -= linelen;
+
+		if (ctrlc())
+			return -1;
+	}
+
+	return 0;
+}
-- 
1.4.3.rc2.g0503

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 4/4] Remove local implementation of isprint() in ft_build.c
  2007-02-14 19:29     ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md command to common function Grant Likely
@ 2007-02-14 19:29       ` Grant Likely
  2007-02-14 19:52       ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function Ulf Samuelsson
  1 sibling, 0 replies; 7+ messages in thread
From: Grant Likely @ 2007-02-14 19:29 UTC (permalink / raw)
  To: u-boot

isprint is already defined in ctype.c

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 common/ft_build.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/common/ft_build.c b/common/ft_build.c
index 980e40f..5a0575e 100644
--- a/common/ft_build.c
+++ b/common/ft_build.c
@@ -29,6 +29,7 @@ #include <asm/errno.h>
 #include <stddef.h>
 
 #include <ft_build.h>
+#include <linux/ctype.h>
 
 #undef DEBUG
 
@@ -180,11 +181,6 @@ void ft_finalize_tree(struct ft_cxt *cxt
 	bph->dt_strings_size = cxt->p_end - cxt->p;
 }
 
-static inline int isprint(int c)
-{
-	return c >= 0x20 && c <= 0x7e;
-}
-
 static int is_printable_string(const void *data, int len)
 {
 	const char *s = data;
-- 
1.4.3.rc2.g0503

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function
  2007-02-14 19:29     ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md command to common function Grant Likely
  2007-02-14 19:29       ` [U-Boot-Users] [PATCH 4/4] Remove local implementation of isprint() in ft_build.c Grant Likely
@ 2007-02-14 19:52       ` Ulf Samuelsson
  2007-02-14 20:01         ` Grant Likely
  1 sibling, 1 reply; 7+ messages in thread
From: Ulf Samuelsson @ 2007-02-14 19:52 UTC (permalink / raw)
  To: u-boot

Looks like your code boils down to:

if ((rc = read_dataflash(addr, (linebytes/size)*size, linebuf)) == DATAFLASH_OK){
             print_buffer(addr, linebuf, size, linebytes/size,
              DISP_LINE_LEN/size);
} else { /* addr does not correspond to DataFlash */
            print_buffer(addr, (void*)addr, size, linebytes/size,
             DISP_LINE_LEN/size);
}

Would it not generate less (better) code if you do something like:

rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
p = (rc == DATAFLASH_OK)? linebuf : (void*)addr;    /* or an if statement */
print_buffer(addr, p, size, linebytes/size,DISP_LINE_LEN/size);

Best Regards
Ulf Samuelsson

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function
  2007-02-14 19:52       ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function Ulf Samuelsson
@ 2007-02-14 20:01         ` Grant Likely
  0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2007-02-14 20:01 UTC (permalink / raw)
  To: u-boot

On 2/14/07, Ulf Samuelsson <ulf@atmel.com> wrote:
>
> Would it not generate less (better) code if you do something like:
>
> rc = read_dataflash(addr, (linebytes/size)*size, linebuf);
> p = (rc == DATAFLASH_OK)? linebuf : (void*)addr;    /* or an if statement */
> print_buffer(addr, p, size, linebytes/size,DISP_LINE_LEN/size);

Yep, that would work.  I can make that change.

g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-02-14 20:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 19:29 [U-Boot-Users] miscellaneous cleanup patches Grant Likely
2007-02-14 19:29 ` [U-Boot-Users] [PATCH 1/4] Merge common get_dev() routines for block devices Grant Likely
2007-02-14 19:29   ` [U-Boot-Users] [PATCH 2/4] Use config.h, not xparameters.h, for xilinx targets Grant Likely
2007-02-14 19:29     ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md command to common function Grant Likely
2007-02-14 19:29       ` [U-Boot-Users] [PATCH 4/4] Remove local implementation of isprint() in ft_build.c Grant Likely
2007-02-14 19:52       ` [U-Boot-Users] [PATCH 3/4] Move buffer print code from md commandto common function Ulf Samuelsson
2007-02-14 20:01         ` Grant Likely

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.