summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-09-01 00:16:29 +0200
committerWolfgang Denk <wd@denx.de>2008-09-01 00:16:29 +0200
commite99e9575bbeba1b7c48e046547cae065ec0071de (patch)
treec08553c4d06725bd6013a46068df0059c5b49a00
parenta13b2d937941f6b525abfcfad96c034f94421188 (diff)
parent08ab4e1780fa63c88dd5a5ab52f4ff4ed1ee1878 (diff)
downloadu-boot-imx-e99e9575bbeba1b7c48e046547cae065ec0071de.zip
u-boot-imx-e99e9575bbeba1b7c48e046547cae065ec0071de.tar.gz
u-boot-imx-e99e9575bbeba1b7c48e046547cae065ec0071de.tar.bz2
Merge branch 'Makefile' of git://git.denx.de/u-boot-arm
-rw-r--r--Makefile1
-rw-r--r--common/Makefile79
-rw-r--r--common/cmd_autoscript.c4
-rw-r--r--common/cmd_console.c9
-rw-r--r--common/cmd_terminal.c14
-rw-r--r--common/console.c62
-rw-r--r--common/devices.c79
-rw-r--r--common/lists.c734
-rw-r--r--common/miiphyutil.c2
-rw-r--r--common/usb_kbd.c14
-rw-r--r--drivers/i2c/Makefile1
-rw-r--r--drivers/i2c/soft_i2c.c (renamed from common/soft_i2c.c)0
-rw-r--r--drivers/net/phy/Makefile46
-rw-r--r--drivers/net/phy/miiphybb.c (renamed from common/miiphybb.c)0
-rw-r--r--drivers/spi/Makefile3
-rw-r--r--drivers/spi/soft_spi.c (renamed from common/soft_spi.c)0
-rw-r--r--fs/Makefile10
-rw-r--r--fs/cramfs/Makefile7
-rw-r--r--fs/cramfs/cramfs.c5
-rw-r--r--fs/cramfs/uncompress.c4
-rw-r--r--fs/ext2/Makefile6
-rw-r--r--fs/ext2/dev.c3
-rw-r--r--fs/ext2/ext2fs.c4
-rw-r--r--fs/fat/Makefile6
-rw-r--r--fs/fat/fat.c4
-rw-r--r--fs/fat/file.c4
-rw-r--r--fs/fdos/Makefile6
-rw-r--r--fs/fdos/dev.c5
-rw-r--r--fs/fdos/fat.c4
-rw-r--r--fs/fdos/fdos.c5
-rw-r--r--fs/fdos/fs.c4
-rw-r--r--fs/fdos/subdir.c3
-rw-r--r--fs/fdos/vfat.c5
-rw-r--r--fs/jffs2/Makefile8
-rw-r--r--fs/jffs2/compr_lzari.c3
-rw-r--r--fs/jffs2/compr_lzo.c4
-rw-r--r--fs/jffs2/compr_rtime.c4
-rw-r--r--fs/jffs2/compr_rubin.c4
-rw-r--r--fs/jffs2/compr_zlib.c4
-rw-r--r--fs/jffs2/jffs2_1pass.c5
-rw-r--r--fs/jffs2/jffs2_nand_1pass.c2
-rw-r--r--fs/jffs2/mini_inflate.c5
-rw-r--r--fs/reiserfs/Makefile6
-rw-r--r--fs/reiserfs/dev.c4
-rw-r--r--fs/reiserfs/mode_string.c3
-rw-r--r--fs/reiserfs/reiserfs.c4
-rw-r--r--include/devices.h8
-rw-r--r--include/linux/list.h506
-rw-r--r--include/linux/poison.h11
-rw-r--r--include/lists.h77
-rw-r--r--lib_generic/Makefile2
-rw-r--r--lib_generic/crc16.c (renamed from common/crc16.c)0
-rw-r--r--lib_generic/gunzip.c (renamed from common/gunzip.c)0
53 files changed, 682 insertions, 1111 deletions
diff --git a/Makefile b/Makefile
index 18b851d..2d4b513 100644
--- a/Makefile
+++ b/Makefile
@@ -227,6 +227,7 @@ LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
LIBS += drivers/mtd/onenand/libonenand.a
LIBS += drivers/mtd/spi/libspi_flash.a
LIBS += drivers/net/libnet.a
+LIBS += drivers/net/phy/libphy.a
LIBS += drivers/net/sk98lin/libsk98lin.a
LIBS += drivers/pci/libpci.a
LIBS += drivers/pcmcia/libpcmcia.a
diff --git a/common/Makefile b/common/Makefile
index 944b1c0..0fe9c8b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -27,16 +27,39 @@ LIB = $(obj)libcommon.a
AOBJS =
+# core
COBJS-y += main.o
-COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o
COBJS-y += circbuf.o
+COBJS-y += console.o
+COBJS-y += command.o
+COBJS-y += devices.o
+COBJS-y += dlmalloc.o
+COBJS-y += exports.o
+COBJS-y += hush.o
+COBJS-y += image.o
+COBJS-y += memsize.o
+COBJS-y += s_record.o
+COBJS-y += serial.o
+COBJS-y += xyzModem.o
+
+# environment
+COBJS-y += environment.o
+COBJS-y += env_common.o
+COBJS-y += env_dataflash.o
+COBJS-y += env_eeprom.o
+COBJS-y += env_flash.o
+COBJS-y += env_nand.o
+COBJS-y += env_nvram.o
+COBJS-y += env_onenand.o
+COBJS-y += env_sf.o
+COBJS-y += env_nowhere.o
+
+# command
COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
-COBJS-y += cmd_autoscript.o
+COBJS-$(CONFIG_AUTOSCRIPT)$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o
COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o
-COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
+COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
-COBJS-y += image.o
-COBJS-y += gunzip.o
COBJS-y += cmd_boot.o
COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
COBJS-y += cmd_bootm.o
@@ -84,10 +107,14 @@ COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o
COBJS-y += cmd_load.o
COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
+COBJS-y += cmd_mac.o
COBJS-y += cmd_mem.o
+COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
+COBJS-$(CONFIG_MII)$(CONFIG_CMD_MII) += miiphyutil.o
COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
+COBJS-$(CONFIG_MP) += cmd_mp.o
COBJS-y += cmd_nand.o
COBJS-$(CONFIG_CMD_NET) += cmd_net.o
COBJS-y += cmd_nvedit.o
@@ -101,58 +128,30 @@ COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o
COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o
COBJS-$(CONFIG_CMD_SATA) += cmd_sata.o
+COBJS-$(CONFIG_CMD_SF) += cmd_sf.o
COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o
COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o
COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o
COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
-COBJS-$(CONFIG_CMD_USB) += cmd_usb.o
+ifdef CONFIG_CMD_USB
+COBJS-y += cmd_usb.o
+COBJS-y += usb.o
+COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
+endif
COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
COBJS-y += cmd_vfd.o
-COBJS-y += command.o
-COBJS-y += console.o
-COBJS-y += devices.o
-COBJS-y += dlmalloc.o
COBJS-$(CONFIG_CMD_DOC) += docecc.o
-COBJS-y += environment.o
-COBJS-y += env_common.o
-COBJS-y += env_nand.o
-COBJS-y += env_dataflash.o
-COBJS-y += env_flash.o
-COBJS-y += env_eeprom.o
-COBJS-y += env_onenand.o
-COBJS-y += env_sf.o
-COBJS-y += env_nvram.o
-COBJS-y += env_nowhere.o
-COBJS-y += exports.o
COBJS-y += flash.o
-COBJS-y += hush.o
COBJS-y += kgdb.o
COBJS-$(CONFIG_LCD) += lcd.o
-COBJS-y += lists.o
COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
-COBJS-y += memsize.o
-COBJS-$(CONFIG_BITBANGMII) += miiphybb.o
-COBJS-y += miiphyutil.o
-COBJS-y += s_record.o
-COBJS-y += serial.o
-COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
-COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
-ifdef CONFIG_CMD_USB
-COBJS-y += usb.o
-COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
-endif
COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
-COBJS-y += crc16.o
-COBJS-y += xyzModem.o
-COBJS-y += cmd_mac.o
-COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
-COBJS-$(CONFIG_MP) += cmd_mp.o
-COBJS-$(CONFIG_CMD_SF) += cmd_sf.o
COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o
+COBJS-y += $(COBJS-yy)
COBJS := $(COBJS-y)
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c
index 13af93e..c2e7e66 100644
--- a/common/cmd_autoscript.c
+++ b/common/cmd_autoscript.c
@@ -47,8 +47,6 @@
#include <hush.h>
#endif
-#if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT)
-
int
autoscript (ulong addr, const char *fit_uname)
{
@@ -200,8 +198,6 @@ autoscript (ulong addr, const char *fit_uname)
return rcode;
}
-#endif
-
/**************************************************/
#if defined(CONFIG_CMD_AUTOSCRIPT)
int
diff --git a/common/cmd_console.c b/common/cmd_console.c
index 50ddb01..e2bc2a3 100644
--- a/common/cmd_console.c
+++ b/common/cmd_console.c
@@ -31,14 +31,17 @@
extern void _do_coninfo (void);
int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
- int i, l;
+ int l;
+ struct list_head *list = device_get_list();
+ struct list_head *pos;
+ device_t *dev;
/* Scan for valid output and input devices */
puts ("List of available devices:\n");
- for (i = 1; i <= ListNumItems (devlist); i++) {
- device_t *dev = ListGetPtrToItem (devlist, i);
+ list_for_each(pos, list) {
+ dev = list_entry(pos, device_t, list);
printf ("%-8s %08x %c%c%c ",
dev->name,
diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c
index 8871607..67a2546 100644
--- a/common/cmd_terminal.c
+++ b/common/cmd_terminal.c
@@ -27,12 +27,10 @@
#include <common.h>
#include <command.h>
#include <devices.h>
-
-#if defined(CONFIG_CMD_TERMINAL)
+#include <serial.h>
int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
- int i, l;
int last_tilde = 0;
device_t *dev = NULL;
@@ -40,13 +38,7 @@ int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
return -1;
/* Scan for selected output/input device */
- for (i = 1; i <= ListNumItems (devlist); i++) {
- device_t *tmp = ListGetPtrToItem (devlist, i);
- if (!strcmp(tmp->name, argv[1])) {
- dev = tmp;
- break;
- }
- }
+ dev = device_get_by_name(argv[1]);
if (!dev)
return -1;
@@ -98,5 +90,3 @@ U_BOOT_CMD(
"terminal - start terminal emulator\n",
""
);
-
-#endif /* CONFIG_CMD_TERMINAL */
diff --git a/common/console.c b/common/console.c
index 1b095b1..cfcaeb8 100644
--- a/common/console.c
+++ b/common/console.c
@@ -325,9 +325,22 @@ inline void dbg(const char *fmt, ...)
/** U-Boot INIT FUNCTIONS *************************************************/
+device_t *search_device (int flags, char *name)
+{
+ device_t *dev;
+
+ dev = device_get_by_name(name);
+
+ if(dev && (dev->flags & flags))
+ return dev;
+
+ return NULL;
+}
+
int console_assign (int file, char *devname)
{
- int flag, i;
+ int flag;
+ device_t *dev;
/* Check for valid file */
switch (file) {
@@ -344,16 +357,10 @@ int console_assign (int file, char *devname)
/* Check for valid device name */
- for (i = 1; i <= ListNumItems (devlist); i++) {
- device_t *dev = ListGetPtrToItem (devlist, i);
-
- if (strcmp (devname, dev->name) == 0) {
- if (dev->flags & flag)
- return console_setfile (file, dev);
+ dev = search_device(flag, devname);
- return -1;
- }
- }
+ if(dev)
+ return console_setfile (file, dev);
return -1;
}
@@ -371,27 +378,6 @@ int console_init_f (void)
return (0);
}
-#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SPLASH_SCREEN) || defined(CONFIG_SILENT_CONSOLE)
-/* search a device */
-device_t *search_device (int flags, char *name)
-{
- int i, items;
- device_t *dev = NULL;
-
- items = ListNumItems (devlist);
- if (name == NULL)
- return dev;
-
- for (i = 1; i <= items; i++) {
- dev = ListGetPtrToItem (devlist, i);
- if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
- break;
- }
- }
- return dev;
-}
-#endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
-
#ifdef CFG_CONSOLE_IS_IN_ENV
/* Called after the relocation - use desired console functions */
int console_init_r (void)
@@ -488,7 +474,10 @@ int console_init_r (void)
int console_init_r (void)
{
device_t *inputdev = NULL, *outputdev = NULL;
- int i, items = ListNumItems (devlist);
+ int i;
+ struct list_head *list = device_get_list();
+ struct list_head *pos;
+ device_t *dev;
#ifdef CONFIG_SPLASH_SCREEN
/* suppress all output if splash screen is enabled and we have
@@ -498,11 +487,8 @@ int console_init_r (void)
#endif
/* Scan devices looking for input and output devices */
- for (i = 1;
- (i <= items) && ((inputdev == NULL) || (outputdev == NULL));
- i++
- ) {
- device_t *dev = ListGetPtrToItem (devlist, i);
+ list_for_each(pos, list) {
+ dev = list_entry(pos, device_t, list);
if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
inputdev = dev;
@@ -510,6 +496,8 @@ int console_init_r (void)
if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) {
outputdev = dev;
}
+ if(inputdev && outputdev)
+ break;
}
/* Initializes output console first */
diff --git a/common/devices.c b/common/devices.c
index 9cc963a..2977436 100644
--- a/common/devices.c
+++ b/common/devices.c
@@ -36,7 +36,7 @@
DECLARE_GLOBAL_DATA_PTR;
-list_t devlist = 0;
+static device_t devs;
device_t *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
@@ -48,18 +48,18 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#ifdef CFG_DEVICE_NULLDEV
void nulldev_putc(const char c)
{
- /* nulldev is empty! */
+ /* nulldev is empty! */
}
void nulldev_puts(const char *s)
{
- /* nulldev is empty! */
+ /* nulldev is empty! */
}
int nulldev_input(void)
{
- /* nulldev is empty! */
- return 0;
+ /* nulldev is empty! */
+ return 0;
}
#endif
@@ -108,10 +108,32 @@ static void drv_system_init (void)
* DEVICES
**************************************************************************
*/
+struct list_head* device_get_list(void)
+{
+ return &(devs.list);
+}
+
+device_t* device_get_by_name(char* name)
+{
+ struct list_head *pos;
+ device_t *dev;
+
+ if(!name)
+ return NULL;
+
+ list_for_each(pos, &(devs.list)) {
+ dev = list_entry(pos, device_t, list);
+ if(strcmp(dev->name, name) == 0)
+ return dev;
+ }
+
+ return NULL;
+}
+
int device_register (device_t * dev)
{
- ListInsertItem (devlist, dev, LIST_END);
+ list_add(&(dev->list), &(devs.list));
return 0;
}
@@ -121,20 +143,15 @@ int device_register (device_t * dev)
#ifdef CFG_DEVICE_DEREGISTER
int device_deregister(char *devname)
{
- int i,l,dev_index;
- device_t *dev = NULL;
+ int l;
+ struct list_head *pos;
+ device_t *dev;
char temp_names[3][8];
- dev_index = -1;
- for (i=1; i<=ListNumItems(devlist); i++) {
- dev = ListGetPtrToItem (devlist, i);
- if(strcmp(dev->name,devname)==0) {
- dev_index=i;
- break;
- }
- }
- if(dev_index<0) /* device not found */
- return 0;
+ dev = device_get_by_name(devname);
+
+ if(!dev) /* device not found */
+ return -1;
/* get stdio devices (ListRemoveItem changes the dev list) */
for (l=0 ; l< MAX_FILES; l++) {
if (stdio_devices[l] == dev) {
@@ -145,14 +162,15 @@ int device_deregister(char *devname)
stdio_devices[l]->name,
sizeof(stdio_devices[l]->name));
}
- ListRemoveItem(devlist,NULL,dev_index);
+
+ list_del(&(dev->list));
+
/* reassign Device list */
- for (i=1; i<=ListNumItems(devlist); i++) {
- dev = ListGetPtrToItem (devlist, i);
+ list_for_each(pos, &(devs.list)) {
+ dev = list_entry(pos, device_t, list);
for (l=0 ; l< MAX_FILES; l++) {
- if(strcmp(dev->name,temp_names[l])==0) {
+ if(strcmp(dev->name, temp_names[l]) == 0)
stdio_devices[l] = dev;
- }
}
}
return 0;
@@ -161,7 +179,7 @@ int device_deregister(char *devname)
int devices_init (void)
{
-#ifndef CONFIG_ARM /* already relocated for current ARM implementation */
+#ifndef CONFIG_ARM /* already relocated for current ARM implementation */
ulong relocation_offset = gd->reloc_off;
int i;
@@ -173,12 +191,8 @@ int devices_init (void)
#endif
/* Initialize the list */
- devlist = ListCreate (sizeof (device_t));
+ INIT_LIST_HEAD(&(devs.list));
- if (devlist == NULL) {
- eputs ("Cannot initialize the list of devices!\n");
- return -1;
- }
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
#endif
@@ -207,10 +221,3 @@ int devices_init (void)
return (0);
}
-
-int devices_done (void)
-{
- ListDispose (devlist);
-
- return 0;
-}
diff --git a/common/lists.c b/common/lists.c
deleted file mode 100644
index 0dc090a..0000000
--- a/common/lists.c
+++ /dev/null
@@ -1,734 +0,0 @@
-#include <common.h>
-#include <malloc.h>
-#include <lists.h>
-
-#define MAX(a,b) (((a)>(b)) ? (a) : (b))
-#define MIN(a,b) (((a)<(b)) ? (a) : (b))
-#define CAT4CHARS(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | d)
-
-/* increase list size by 10% every time it is full */
-#define kDefaultAllocationPercentIncrease 10
-
-/* always increase list size by 4 items when it is full */
-#define kDefaultAllocationminNumItemsIncrease 4
-
-/*
- * how many items to expand the list by when it becomes full
- * = current listSize (in items) + (hiword percent of list size) + loword
- */
-#define NUMITEMSPERALLOC(list) MAX(((*list)->listSize * \
- ((*list)->percentIncrease + 100)) / 100, \
- (*list)->minNumItemsIncrease )
-
-#define ITEMPTR(list,item) &(((char *)&(*list)->itemList)[(*(list))->itemSize * (item)])
-
-#define LIST_SIGNATURE CAT4CHARS('L', 'I', 'S', 'T');
-
-#define calloc(size,num) malloc(size*num)
-
-/********************************************************************/
-
-Handle NewHandle (unsigned int numBytes)
-{
- void *memPtr;
- HandleRecord *hanPtr;
-
- memPtr = calloc (numBytes, 1);
- hanPtr = (HandleRecord *) calloc (sizeof (HandleRecord), 1);
- if (hanPtr && (memPtr || numBytes == 0)) {
- hanPtr->ptr = memPtr;
- hanPtr->size = numBytes;
- return (Handle) hanPtr;
- } else {
- free (memPtr);
- free (hanPtr);
- return NULL;
- }
-}
-/********************************************************************/
-
-void DisposeHandle (Handle handle)
-{
- if (handle) {
- free (*handle);
- free ((void *) handle);
- }
-}
-/********************************************************************/
-
-unsigned int GetHandleSize (Handle handle)
-{
- return ((HandleRecord *) handle)->size;
-}
-/********************************************************************/
-
-int SetHandleSize (Handle handle, unsigned int newSize)
-{
- HandleRecord *hanRecPtr = (HandleRecord *) handle;
- void *newPtr, *oldPtr;
- unsigned int oldSize;
-
-
- oldPtr = hanRecPtr->ptr;
- oldSize = hanRecPtr->size;
-
- if (oldSize == newSize)
- return 1;
-
- if (oldPtr == NULL) {
- newPtr = malloc (newSize);
- } else {
- newPtr = realloc (oldPtr, newSize);
- }
- if (newPtr || (newSize == 0)) {
- hanRecPtr->ptr = newPtr;
- hanRecPtr->size = newSize;
- if (newSize > oldSize)
- memset ((char *) newPtr + oldSize, 0, newSize - oldSize);
- return 1;
- } else
- return 0;
-}
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-/* Used to compare list elements by their raw data contents */
-static int ListMemBlockCmp (void *a, void *b, int size)
-{
- return memcmp (a, b, size);
-}
-
-/***************************************************************************/
-
-/*
- * Binary search numElements of size elementSize in array for a match
- * to the. item. Return the index of the element that matches
- * (0 - numElements - 1). If no match is found return the -i-1 where
- * i is the index (0 - numElements) where the item should be placed.
- * (*theCmp)(a,b) should return <0 if a<b, 0 if a==b, >0 if a>b.
- *
- * This function is like the C-Library function bsearch() except that
- * this function returns the index where the item should be placed if
- * it is not found.
- */
-int BinSearch ( void *array, int numElements, int elementSize,
- void *itemPtr, CompareFunction compareFunction)
-{
- int low, high, mid, cmp;
- void *arrayItemPtr;
-
- for (low = 0, high = numElements - 1, mid = 0, cmp = -1; low <= high;) {
- mid = (low + high) >> 1;
-
- arrayItemPtr = (void *) (((char *) array) + (mid * elementSize));
- cmp = compareFunction
- ? compareFunction (itemPtr, arrayItemPtr)
- : ListMemBlockCmp (itemPtr, arrayItemPtr, elementSize);
- if (cmp == 0) {
- return mid;
- } else if (cmp < 0) {
- high = mid - 1;
- } else {
- low = mid + 1;
- }
- }
- if (cmp > 0)
- mid++;
-
- return -mid - 1;
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
-
-/*******************************************************************************/
-
-/*
- * If numNewItems == 0 then expand the list by the number of items
- * indicated by its allocation policy.
- * If numNewItems > 0 then expand the list by exactly the number of
- * items indicated.
- * If numNewItems < 0 then expand the list by the absolute value of
- * numNewItems plus the number of items indicated by its allocation
- * policy.
- * Returns 1 for success, 0 if out of memory
-*/
-static int ExpandListSpace (list_t list, int numNewItems)
-{
- if (numNewItems == 0) {
- numNewItems = NUMITEMSPERALLOC (list);
- } else if (numNewItems < 0) {
- numNewItems = (-numNewItems) + NUMITEMSPERALLOC (list);
- }
-
- if (SetHandleSize ((Handle) list,
- sizeof (ListStruct) +
- ((*list)->listSize +
- numNewItems) * (*list)->itemSize)) {
- (*list)->listSize += numNewItems;
- return 1;
- } else {
- return 0;
- }
-}
-
-/*******************************/
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-/*
- * This function reallocate the list, minus any currently unused
- * portion of its allotted memory.
- */
-void ListCompact (list_t list)
-{
-
- if (!SetHandleSize ((Handle) list,
- sizeof (ListStruct) +
- (*list)->numItems * (*list)->itemSize)) {
- return;
- }
-
- (*list)->listSize = (*list)->numItems;
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
-
-/*******************************/
-
-list_t ListCreate (int elementSize)
-{
- list_t list;
-
- list = (list_t) (NewHandle (sizeof (ListStruct))); /* create empty list */
- if (list) {
- (*list)->signature = LIST_SIGNATURE;
- (*list)->numItems = 0;
- (*list)->listSize = 0;
- (*list)->itemSize = elementSize;
- (*list)->percentIncrease = kDefaultAllocationPercentIncrease;
- (*list)->minNumItemsIncrease =
- kDefaultAllocationminNumItemsIncrease;
- }
-
- return list;
-}
-
-/*******************************/
-
-void ListSetAllocationPolicy (list_t list, int minItemsPerAlloc,
- int percentIncreasePerAlloc)
-{
- (*list)->percentIncrease = percentIncreasePerAlloc;
- (*list)->minNumItemsIncrease = minItemsPerAlloc;
-}
-
-/*******************************/
-
-void ListDispose (list_t list)
-{
- DisposeHandle ((Handle) list);
-}
-/*******************************/
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-void ListDisposePtrList (list_t list)
-{
- int index;
- int numItems;
-
- if (list) {
- numItems = ListNumItems (list);
-
- for (index = 1; index <= numItems; index++)
- free (*(void **) ListGetPtrToItem (list, index));
-
- ListDispose (list);
- }
-}
-
-/*******************************/
-
-/*
- * keeps memory, resets the number of items to 0
- */
-void ListClear (list_t list)
-{
- if (!list)
- return;
- (*list)->numItems = 0;
-}
-
-/*******************************/
-
-/*
- * copy is only as large as necessary
- */
-list_t ListCopy (list_t originalList)
-{
- list_t tempList = NULL;
- int numItems;
-
- if (!originalList)
- return NULL;
-
- tempList = ListCreate ((*originalList)->itemSize);
- if (tempList) {
- numItems = ListNumItems (originalList);
-
- if (!SetHandleSize ((Handle) tempList,
- sizeof (ListStruct) +
- numItems * (*tempList)->itemSize)) {
- ListDispose (tempList);
- return NULL;
- }
-
- (*tempList)->numItems = (*originalList)->numItems;
- (*tempList)->listSize = (*originalList)->numItems;
- (*tempList)->itemSize = (*originalList)->itemSize;
- (*tempList)->percentIncrease = (*originalList)->percentIncrease;
- (*tempList)->minNumItemsIncrease =
- (*originalList)->minNumItemsIncrease;
-
- memcpy (ITEMPTR (tempList, 0), ITEMPTR (originalList, 0),
- numItems * (*tempList)->itemSize);
- }
-
- return tempList;
-}
-
-/********************************/
-
-/*
- * list1 = list1 + list2
- */
-int ListAppend (list_t list1, list_t list2)
-{
- int numItemsL1, numItemsL2;
-
- if (!list2)
- return 1;
-
- if (!list1)
- return 0;
- if ((*list1)->itemSize != (*list2)->itemSize)
- return 0;
-
- numItemsL1 = ListNumItems (list1);
- numItemsL2 = ListNumItems (list2);
-
- if (numItemsL2 == 0)
- return 1;
-
- if (!SetHandleSize ((Handle) list1,
- sizeof (ListStruct) + (numItemsL1 + numItemsL2) *
- (*list1)->itemSize)) {
- return 0;
- }
-
- (*list1)->numItems = numItemsL1 + numItemsL2;
- (*list1)->listSize = numItemsL1 + numItemsL2;
-
- memmove (ITEMPTR (list1, numItemsL1),
- ITEMPTR (list2, 0),
- numItemsL2 * (*list2)->itemSize);
-
- return 1;
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
-
-/*******************************/
-
-/*
- * returns 1 if the item is inserted, returns 0 if out of memory or
- * bad arguments were passed.
- */
-int ListInsertItem (list_t list, void *ptrToItem, int itemPosition)
-{
- return ListInsertItems (list, ptrToItem, itemPosition, 1);
-}
-
-/*******************************/
-
-int ListInsertItems (list_t list, void *ptrToItems, int firstItemPosition,
- int numItemsToInsert)
-{
- int numItems = (*list)->numItems;
-
- if (firstItemPosition == numItems + 1)
- firstItemPosition = LIST_END;
- else if (firstItemPosition > numItems)
- return 0;
-
- if ((*list)->numItems >= (*list)->listSize) {
- if (!ExpandListSpace (list, -numItemsToInsert))
- return 0;
- }
-
- if (firstItemPosition == LIST_START) {
- if (numItems == 0) {
- /* special case for empty list */
- firstItemPosition = LIST_END;
- } else {
- firstItemPosition = 1;
- }
- }
-
- if (firstItemPosition == LIST_END) { /* add at the end of the list */
- if (ptrToItems)
- memcpy (ITEMPTR (list, numItems), ptrToItems,
- (*list)->itemSize * numItemsToInsert);
- else
- memset (ITEMPTR (list, numItems), 0,
- (*list)->itemSize * numItemsToInsert);
-
- (*list)->numItems += numItemsToInsert;
- } else { /* move part of list up to make room for new item */
- memmove (ITEMPTR (list, firstItemPosition - 1 + numItemsToInsert),
- ITEMPTR (list, firstItemPosition - 1),
- (numItems + 1 - firstItemPosition) * (*list)->itemSize);
-
- if (ptrToItems)
- memmove (ITEMPTR (list, firstItemPosition - 1), ptrToItems,
- (*list)->itemSize * numItemsToInsert);
- else
- memset (ITEMPTR (list, firstItemPosition - 1), 0,
- (*list)->itemSize * numItemsToInsert);
-
- (*list)->numItems += numItemsToInsert;
- }
-
- return 1;
-}
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-/*******************************/
-
-int ListEqual (list_t list1, list_t list2)
-{
- if (list1 == list2)
- return 1;
-
- if (list1 == NULL || list2 == NULL)
- return 0;
-
- if ((*list1)->itemSize == (*list1)->itemSize) {
- if ((*list1)->numItems == (*list2)->numItems) {
- return (memcmp (ITEMPTR (list1, 0), ITEMPTR (list2, 0),
- (*list1)->itemSize * (*list1)->numItems) == 0);
- }
- }
-
- return 0;
-}
-
-/*******************************/
-
-/*
- * The item pointed to by ptrToItem is copied over the current item
- * at itemPosition
- */
-void ListReplaceItem (list_t list, void *ptrToItem, int itemPosition)
-{
- ListReplaceItems (list, ptrToItem, itemPosition, 1);
-}
-
-/*******************************/
-
-/*
- * The item pointed to by ptrToItems is copied over the current item
- * at itemPosition
- */
-void ListReplaceItems ( list_t list, void *ptrToItems,
- int firstItemPosition, int numItemsToReplace)
-{
-
- if (firstItemPosition == LIST_END)
- firstItemPosition = (*list)->numItems;
- else if (firstItemPosition == LIST_START)
- firstItemPosition = 1;
-
- memmove (ITEMPTR (list, firstItemPosition - 1), ptrToItems,
- (*list)->itemSize * numItemsToReplace);
-}
-
-/*******************************/
-
-void ListGetItem (list_t list, void *itemDestination, int itemPosition)
-{
- ListGetItems (list, itemDestination, itemPosition, 1);
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
-
-/*******************************/
-
-#if defined(CFG_ALL_LIST_FUNCTIONS) || defined(CFG_DEVICE_DEREGISTER)
-
-void ListRemoveItem (list_t list, void *itemDestination, int itemPosition)
-{
- ListRemoveItems (list, itemDestination, itemPosition, 1);
-}
-
-/*******************************/
-
-void ListRemoveItems (list_t list, void *itemsDestination,
- int firstItemPosition, int numItemsToRemove)
-{
- int firstItemAfterChunk, numToMove;
-
- if (firstItemPosition == LIST_START)
- firstItemPosition = 1;
- else if (firstItemPosition == LIST_END)
- firstItemPosition = (*list)->numItems;
-
- if (itemsDestination != NULL)
- memcpy (itemsDestination, ITEMPTR (list, firstItemPosition - 1),
- (*list)->itemSize * numItemsToRemove);
-
- firstItemAfterChunk = firstItemPosition + numItemsToRemove;
- numToMove = (*list)->numItems - (firstItemAfterChunk - 1);
-
- if (numToMove > 0) {
- /*
- * move part of list down to cover hole left by removed item
- */
- memmove (ITEMPTR (list, firstItemPosition - 1),
- ITEMPTR (list, firstItemAfterChunk - 1),
- (*list)->itemSize * numToMove);
- }
-
- (*list)->numItems -= numItemsToRemove;
-}
-#endif /* CFG_ALL_LIST_FUNCTIONS || CFG_DEVICE_DEREGISTER */
-
-/*******************************/
-
-void ListGetItems (list_t list, void *itemsDestination,
- int firstItemPosition, int numItemsToGet)
-{
-
- if (firstItemPosition == LIST_START)
- firstItemPosition = 1;
- else if (firstItemPosition == LIST_END)
- firstItemPosition = (*list)->numItems;
-
- memcpy (itemsDestination,
- ITEMPTR (list, firstItemPosition - 1),
- (*list)->itemSize * numItemsToGet);
-}
-
-/*******************************/
-
-/*
- * Returns a pointer to the item at itemPosition. returns null if an
- * errors occurred.
- */
-void *ListGetPtrToItem (list_t list, int itemPosition)
-{
- if (itemPosition == LIST_START)
- itemPosition = 1;
- else if (itemPosition == LIST_END)
- itemPosition = (*list)->numItems;
-
- return ITEMPTR (list, itemPosition - 1);
-}
-
-/*******************************/
-
-/*
- * returns a pointer the lists data (abstraction violation for
- * optimization)
- */
-void *ListGetDataPtr (list_t list)
-{
- return &((*list)->itemList[0]);
-}
-
-/********************************/
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-int ListApplyToEach (list_t list, int ascending,
- ListApplicationFunc funcToApply,
- void *callbackData)
-{
- int result = 0, index;
-
- if (!list || !funcToApply)
- goto Error;
-
- if (ascending) {
- for (index = 1; index <= ListNumItems (list); index++) {
- result = funcToApply (index,
- ListGetPtrToItem (list, index),
- callbackData);
- if (result < 0)
- goto Error;
- }
- } else {
- for (index = ListNumItems (list);
- index > 0 && index <= ListNumItems (list);
- index--) {
- result = funcToApply (index,
- ListGetPtrToItem (list, index),
- callbackData);
- if (result < 0)
- goto Error;
- }
- }
-
-Error:
- return result;
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
-
-/********************************/
-
-int ListGetItemSize (list_t list)
-{
- return (*list)->itemSize;
-}
-
-/********************************/
-
-int ListNumItems (list_t list)
-{
- return (*list)->numItems;
-}
-
-/*******************************/
-
-#ifdef CFG_ALL_LIST_FUNCTIONS
-
-void ListRemoveDuplicates (list_t list, CompareFunction compareFunction)
-{
- int numItems, index, startIndexForFind, duplicatesIndex;
-
- numItems = ListNumItems (list);
-
- for (index = 1; index < numItems; index++) {
- startIndexForFind = index + 1;
- while (startIndexForFind <= numItems) {
- duplicatesIndex =
- ListFindItem (list,
- ListGetPtrToItem (list, index),
- startIndexForFind,
- compareFunction);
- if (duplicatesIndex > 0) {
- ListRemoveItem (list, NULL, duplicatesIndex);
- numItems--;
- startIndexForFind = duplicatesIndex;
- } else {
- break;
- }
- }
- }
-}
-
-/*******************************/
-
-
-/*******************************/
-
-int ListFindItem (list_t list, void *ptrToItem, int startingPosition,
- CompareFunction compareFunction)
-{
- int numItems, size, index, cmp;
- void *listItemPtr;
-
- if ((numItems = (*list)->numItems) == 0)
- return 0;
-
- size = (*list)->itemSize;
-
- if (startingPosition == LIST_START)
- startingPosition = 1;
- else if (startingPosition == LIST_END)
- startingPosition = numItems;
-
- for (index = startingPosition; index <= numItems; index++) {
- listItemPtr = ITEMPTR (list, index - 1);
- cmp = compareFunction
- ? compareFunction (ptrToItem, listItemPtr)
- : ListMemBlockCmp (ptrToItem, listItemPtr, size);
- if (cmp == 0)
- return index;
- }
-
- return 0;
-}
-
-/*******************************/
-
-int ShortCompare (void *a, void *b)
-{
- if (*(short *) a < *(short *) b)
- return -1;
- if (*(short *) a > *(short *) b)
- return 1;
- return 0;
-}
-
-/*******************************/
-
-int IntCompare (void *a, void *b)
-{
- if (*(int *) a < *(int *) b)
- return -1;
- if (*(int *) a > *(int *) b)
- return 1;
- return 0;
-}
-
-/*******************************/
-
-int CStringCompare (void *a, void *b)
-{
- return strcmp (*(char **) a, *(char **) b);
-}
-
-/*******************************/
-
-
-int ListBinSearch (list_t list, void *ptrToItem,
- CompareFunction compareFunction)
-{
- int index;
-
- index = BinSearch (ITEMPTR (list, 0),
- (int) (*list)->numItems,
- (int) (*list)->itemSize, ptrToItem,
- compareFunction);
-
- if (index >= 0)
- index++; /* lists start from 1 */
- else
- index = 0; /* item not found */
-
- return index;
-}
-
-/**************************************************************************/
-
-/*
- * Reserves memory for numItems in the list. If it succeeds then
- * numItems items can be inserted without possibility of an out of
- * memory error (useful to simplify error recovery in complex
- * functions). Returns 1 if success, 0 if out of memory.
- */
-int ListPreAllocate (list_t list, int numItems)
-{
- if ((*list)->listSize - (*list)->numItems < numItems) {
- return ExpandListSpace (list,
- numItems - ((*list)->listSize -
- (*list)->numItems));
- } else {
- return 1; /* enough items are already pre-allocated */
- }
-}
-
-#endif /* CFG_ALL_LIST_FUNCTIONS */
diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index eac8275..5ef4a33 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -29,7 +29,6 @@
#include <common.h>
#include <miiphy.h>
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
#include <asm/types.h>
#include <linux/list.h>
#include <malloc.h>
@@ -487,4 +486,3 @@ int miiphy_link (char *devname, unsigned char addr)
}
}
#endif
-#endif /* CONFIG_MII */
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 04d9730e..108bd60 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -152,7 +152,7 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum);
/* search for keyboard and register it if found */
int drv_usb_kbd_init(void)
{
- int error,i,index;
+ int error,i;
device_t usb_kbd_dev,*old_dev;
struct usb_device *dev;
char *stdinname = getenv ("stdin");
@@ -166,13 +166,11 @@ int drv_usb_kbd_init(void)
if(usb_kbd_probe(dev,0)==1) { /* Ok, we found a keyboard */
/* check, if it is already registered */
USB_KBD_PRINTF("USB KBD found set up device.\n");
- for (index=1; index<=ListNumItems(devlist); index++) {
- old_dev = ListGetPtrToItem(devlist, index);
- if(strcmp(old_dev->name,DEVNAME)==0) {
- /* ok, already registered, just return ok */
- USB_KBD_PRINTF("USB KBD is already registered.\n");
- return 1;
- }
+ old_dev = device_get_by_name(DEVNAME);
+ if(old_dev) {
+ /* ok, already registered, just return ok */
+ USB_KBD_PRINTF("USB KBD is already registered.\n");
+ return 1;
}
/* register the keyboard */
USB_KBD_PRINTF("USB KBD register.\n");
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 1f25afb..6079c05 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
+COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
COBJS := $(COBJS-y)
diff --git a/common/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 23db2ee..23db2ee 100644
--- a/common/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
new file mode 100644
index 0000000..4fe3b05
--- /dev/null
+++ b/drivers/net/phy/Makefile
@@ -0,0 +1,46 @@
+#
+# (C) Copyright 2008
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB := $(obj)libphy.a
+
+COBJS-$(CONFIG_BITBANGMII) += miiphybb.o
+
+COBJS := $(COBJS-y)
+SRCS := $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+
+all: $(LIB)
+
+$(LIB): $(obj).depend $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/common/miiphybb.c b/drivers/net/phy/miiphybb.c
index 6446012..6446012 100644
--- a/common/miiphybb.c
+++ b/drivers/net/phy/miiphybb.c
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 4f7b679..15e0f7a 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk
LIB := $(obj)libspi.a
-COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
+COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
+COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
COBJS := $(COBJS-y)
SRCS := $(COBJS:.o=.c)
diff --git a/common/soft_spi.c b/drivers/spi/soft_spi.c
index 25b589a..25b589a 100644
--- a/common/soft_spi.c
+++ b/drivers/spi/soft_spi.c
diff --git a/fs/Makefile b/fs/Makefile
index 95ac0e9..8bbd563 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -22,7 +22,15 @@
#
#
-SUBDIRS := jffs2 cramfs fdos fat reiserfs ext2 yaffs2
+subdirs-$(CONFIG_CMD_CRAMFS) := cramfs
+subdirs-$(CONFIG_CMD_EXT2) += ext2
+subdirs-$(CONFIG_CMD_FAT) += fat
+subdirs-$(CONFIG_CMD_FDOS) += fdos
+subdirs-$(CONFIG_CMD_JFFS2) += jffs2
+subdirs-$(CONFIG_CMD_REISER) += reiserfs
+subdirs-$(CONFIG_YAFFS2) += yaffs2
+
+SUBDIRS := $(subdirs-y)
$(obj).depend all:
@for dir in $(SUBDIRS) ; do \
diff --git a/fs/cramfs/Makefile b/fs/cramfs/Makefile
index 13c043f..7b6cc0a 100644
--- a/fs/cramfs/Makefile
+++ b/fs/cramfs/Makefile
@@ -26,10 +26,11 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libcramfs.a
AOBJS =
-COBJS = cramfs.o uncompress.o
+COBJS-$(CONFIG_CMD_CRAMFS) := cramfs.o
+COBJS-$(CONFIG_CMD_CRAMFS) += uncompress.o
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
#CPPFLAGS +=
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index e53c783..2956d39 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -26,9 +26,6 @@
#include <common.h>
#include <malloc.h>
-
-#if defined(CONFIG_CMD_CRAMFS)
-
#include <asm/byteorder.h>
#include <linux/stat.h>
#include <jffs2/jffs2.h>
@@ -343,5 +340,3 @@ int cramfs_check (struct part_info *info)
}
return 1;
}
-
-#endif /* CFG_FS_CRAMFS */
diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c
index cf67967..39dd275 100644
--- a/fs/cramfs/uncompress.c
+++ b/fs/cramfs/uncompress.c
@@ -25,8 +25,6 @@
#include <watchdog.h>
#include <zlib.h>
-#if defined(CONFIG_CMD_CRAMFS)
-
static z_stream stream;
void *zalloc(void *, unsigned, unsigned);
@@ -86,5 +84,3 @@ int cramfs_uncompress_exit (void)
inflateEnd (&stream);
return 0;
}
-
-#endif /* CFG_FS_CRAMFS */
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index 8313cdc..712e348 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -30,10 +30,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libext2fs.a
AOBJS =
-COBJS = ext2fs.o dev.o
+COBJS-$(CONFIG_CMD_EXT2) := ext2fs.o dev.o
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
#CPPFLAGS +=
diff --git a/fs/ext2/dev.c b/fs/ext2/dev.c
index 1728b34..3b49650 100644
--- a/fs/ext2/dev.c
+++ b/fs/ext2/dev.c
@@ -25,8 +25,6 @@
#include <common.h>
-#if defined(CONFIG_CMD_EXT2)
-
#include <config.h>
#include <ext2fs.h>
@@ -139,4 +137,3 @@ int ext2fs_devread (int sector, int byte_offset, int byte_len, char *buf) {
}
return (1);
}
-#endif
diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
index 7833551..436f4a4 100644
--- a/fs/ext2/ext2fs.c
+++ b/fs/ext2/ext2fs.c
@@ -24,8 +24,6 @@
*/
#include <common.h>
-
-#if defined(CONFIG_CMD_EXT2)
#include <ext2fs.h>
#include <malloc.h>
#include <asm/byteorder.h>
@@ -874,5 +872,3 @@ fail:
ext2fs_root = NULL;
return (0);
}
-
-#endif
diff --git a/fs/fat/Makefile b/fs/fat/Makefile
index 87af73b..b711460 100644
--- a/fs/fat/Makefile
+++ b/fs/fat/Makefile
@@ -24,10 +24,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libfat.a
AOBJS =
-COBJS = fat.o file.o
+COBJS-$(CONFIG_CMD_FAT) := fat.o file.o
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
all: $(LIB) $(AOBJS)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 49c78ed..2f0bd8c 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -31,8 +31,6 @@
#include <asm/byteorder.h>
#include <part.h>
-#if defined(CONFIG_CMD_FAT)
-
/*
* Convert a string to lowercase.
*/
@@ -1024,5 +1022,3 @@ file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
printf("reading %s\n",filename);
return do_fat_read(filename, buffer, maxsize, LS_NO);
}
-
-#endif
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 514dbae..e870734 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -32,8 +32,6 @@
#include <linux/stat.h>
#include <linux/time.h>
-#if defined(CONFIG_CMD_FAT)
-
/* Supported filesystems */
static const struct filesystem filesystems[] = {
{ file_fat_detectfs, file_fat_ls, file_fat_read, "FAT" },
@@ -204,5 +202,3 @@ file_read(const char *filename, void *buffer, unsigned long maxsize)
return filesystems[current_filesystem].read(arg, buffer, maxsize);
}
-
-#endif
diff --git a/fs/fdos/Makefile b/fs/fdos/Makefile
index 2dba0fb..fce2032 100644
--- a/fs/fdos/Makefile
+++ b/fs/fdos/Makefile
@@ -31,10 +31,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libfdos.a
AOBJS =
-COBJS = fat.o vfat.o dev.o fdos.o fs.o subdir.o
+COBJS-$(CONFIG_CMD_FDOS) := fat.o vfat.o dev.o fdos.o fs.o subdir.o
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
#CPPFLAGS +=
diff --git a/fs/fdos/dev.c b/fs/fdos/dev.c
index 271d0e7..b55b6ed 100644
--- a/fs/fdos/dev.c
+++ b/fs/fdos/dev.c
@@ -28,8 +28,6 @@
#include "dos.h"
#include "fdos.h"
-#if defined(CONFIG_CMD_FDOS)
-
#define NB_HEADS 2
#define NB_TRACKS 80
#define NB_SECTORS 18
@@ -190,6 +188,3 @@ int check_dev (BootSector_t *boot, Fs_t *fs)
return (0);
}
-
-
-#endif
diff --git a/fs/fdos/fat.c b/fs/fdos/fat.c
index 2e2d2b8..5707c19 100644
--- a/fs/fdos/fat.c
+++ b/fs/fdos/fat.c
@@ -26,8 +26,6 @@
#include <config.h>
#include <malloc.h>
-#if defined(CONFIG_CMD_FDOS)
-
#include "dos.h"
#include "fdos.h"
@@ -138,5 +136,3 @@ int read_fat (BootSector_t *boot, Fs_t *fs)
}
return (0);
}
-
-#endif
diff --git a/fs/fdos/fdos.c b/fs/fdos/fdos.c
index 5be6a96..db58562 100644
--- a/fs/fdos/fdos.c
+++ b/fs/fdos/fdos.c
@@ -24,9 +24,8 @@
#include <common.h>
#include <config.h>
-
-#if defined(CONFIG_CMD_FDOS)
#include <malloc.h>
+
#include "dos.h"
#include "fdos.h"
@@ -171,5 +170,3 @@ int dos_dir (void)
free (name);
return (0);
}
-
-#endif
diff --git a/fs/fdos/fs.c b/fs/fdos/fs.c
index aded670..5acf123 100644
--- a/fs/fdos/fs.c
+++ b/fs/fdos/fs.c
@@ -26,8 +26,6 @@
#include <config.h>
#include <malloc.h>
-#if defined(CONFIG_CMD_FDOS)
-
#include "dos.h"
#include "fdos.h"
@@ -114,5 +112,3 @@ int fs_init (Fs_t *fs)
free (boot);
return (0);
}
-
-#endif
diff --git a/fs/fdos/subdir.c b/fs/fdos/subdir.c
index 497f554..5e96b0a 100644
--- a/fs/fdos/subdir.c
+++ b/fs/fdos/subdir.c
@@ -26,8 +26,6 @@
#include <config.h>
#include <malloc.h>
-#if defined(CONFIG_CMD_FDOS)
-
#include "dos.h"
#include "fdos.h"
@@ -345,4 +343,3 @@ int read_file (Fs_t *fs,
}
return (read);
}
-#endif
diff --git a/fs/fdos/vfat.c b/fs/fdos/vfat.c
index 0e7883b..9f357a6 100644
--- a/fs/fdos/vfat.c
+++ b/fs/fdos/vfat.c
@@ -24,8 +24,6 @@
#include <common.h>
#include <config.h>
-
-#if defined(CONFIG_CMD_FDOS)
#include <linux/ctype.h>
#include "dos.h"
@@ -352,6 +350,3 @@ static char *conv_name (char *name, char *ext, char Case, char *ans)
}
return (ans);
}
-
-
-#endif
diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile
index a071af1..fd6a105 100644
--- a/fs/jffs2/Makefile
+++ b/fs/jffs2/Makefile
@@ -26,13 +26,15 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libjffs2.a
AOBJS =
-COBJS-y += jffs2_1pass.o
+ifdef CONFIG_CMD_JFFS2
+COBJS-$(CONFIG_JFFS2_LZO_LZARI) += compr_lzari.o
+COBJS-$(CONFIG_JFFS2_LZO_LZARI) += compr_lzo.o
COBJS-y += compr_rtime.o
COBJS-y += compr_rubin.o
COBJS-y += compr_zlib.o
+COBJS-y += jffs2_1pass.o
COBJS-y += mini_inflate.o
-COBJS-y += compr_lzo.o
-COBJS-y += compr_lzari.o
+endif
COBJS := $(COBJS-y)
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/fs/jffs2/compr_lzari.c b/fs/jffs2/compr_lzari.c
index f64bc74..6a29608 100644
--- a/fs/jffs2/compr_lzari.c
+++ b/fs/jffs2/compr_lzari.c
@@ -50,8 +50,6 @@ All rights reserved. Permission granted for non-commercial use.
#include <config.h>
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_LZO_LZARI)
-
#include <linux/stddef.h>
#include <jffs2/jffs2.h>
@@ -259,4 +257,3 @@ int lzari_decompress(unsigned char *data_in, unsigned char *cpage_out,
{
return Decode(data_in, cpage_out, srclen, destlen);
}
-#endif
diff --git a/fs/jffs2/compr_lzo.c b/fs/jffs2/compr_lzo.c
index a32b993..e648ec4 100644
--- a/fs/jffs2/compr_lzo.c
+++ b/fs/jffs2/compr_lzo.c
@@ -67,8 +67,6 @@
#include <config.h>
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_LZO_LZARI)
-
#include <linux/stddef.h>
#include <jffs2/jffs2.h>
#include <jffs2/compr_rubin.h>
@@ -401,5 +399,3 @@ int lzo_decompress(unsigned char *data_in, unsigned char *cpage_out,
lzo_uint outlen = destlen;
return lzo1x_decompress (data_in, srclen, cpage_out, &outlen, NULL);
}
-
-#endif
diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
index 144263c..89b9f2f 100644
--- a/fs/jffs2/compr_rtime.c
+++ b/fs/jffs2/compr_rtime.c
@@ -46,8 +46,6 @@
*/
#include <config.h>
-#if defined(CONFIG_CMD_JFFS2)
-
#include <jffs2/jffs2.h>
void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
@@ -87,5 +85,3 @@ void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
}
}
}
-
-#endif
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
index f6f3fa1..9ff2217 100644
--- a/fs/jffs2/compr_rubin.c
+++ b/fs/jffs2/compr_rubin.c
@@ -39,8 +39,6 @@
*/
#include <config.h>
-#if defined(CONFIG_CMD_JFFS2)
-
#include <jffs2/jffs2.h>
#include <jffs2/compr_rubin.h>
@@ -122,5 +120,3 @@ void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out,
rubin_do_decompress(bits, data_in+8, cpage_out, dstlen);
}
-
-#endif
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index 29dfe1b..d306b6d 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -37,8 +37,6 @@
#include <common.h>
#include <config.h>
-#if defined(CONFIG_CMD_JFFS2)
-
#include <jffs2/jffs2.h>
#include <jffs2/mini_inflate.h>
@@ -48,5 +46,3 @@ long zlib_decompress(unsigned char *data_in, unsigned char *cpage_out,
return (decompress_block(cpage_out, data_in + 2, (void *) ldr_memcpy));
}
-
-#endif
diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index b5e7ab8..5d22dd7 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -117,9 +117,6 @@
#include <linux/stat.h>
#include <linux/time.h>
#include <watchdog.h>
-
-#if defined(CONFIG_CMD_JFFS2)
-
#include <jffs2/jffs2.h>
#include <jffs2/jffs2_1pass.h>
@@ -1394,5 +1391,3 @@ jffs2_1pass_info(struct part_info * part)
}
return 1;
}
-
-#endif
diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
index 9f6de7d..e288d5a 100644
--- a/fs/jffs2/jffs2_nand_1pass.c
+++ b/fs/jffs2/jffs2_nand_1pass.c
@@ -1,6 +1,6 @@
#include <common.h>
-#if !defined(CONFIG_NAND_LEGACY) && defined(CONFIG_CMD_JFFS2)
+#if !defined(CONFIG_NAND_LEGACY)
#include <malloc.h>
#include <linux/stat.h>
diff --git a/fs/jffs2/mini_inflate.c b/fs/jffs2/mini_inflate.c
index 4c50fc3..bd40a57 100644
--- a/fs/jffs2/mini_inflate.c
+++ b/fs/jffs2/mini_inflate.c
@@ -24,9 +24,6 @@
*/
#include <config.h>
-
-#if defined(CONFIG_CMD_JFFS2)
-
#include <jffs2/mini_inflate.h>
/* The order that the code lengths in section 3.2.7 are in */
@@ -392,5 +389,3 @@ long decompress_block(unsigned char *dest, unsigned char *source,
#endif
return stream.error ? -stream.error : stream.decoded;
}
-
-#endif
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
index e8711a4..9cef8ee 100644
--- a/fs/reiserfs/Makefile
+++ b/fs/reiserfs/Makefile
@@ -30,10 +30,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)libreiserfs.a
AOBJS =
-COBJS = reiserfs.o dev.o mode_string.o
+COBJS-$(CONFIG_CMD_REISER) := reiserfs.o dev.o mode_string.o
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
#CPPFLAGS +=
diff --git a/fs/reiserfs/dev.c b/fs/reiserfs/dev.c
index 46dc414..1facfaf 100644
--- a/fs/reiserfs/dev.c
+++ b/fs/reiserfs/dev.c
@@ -19,8 +19,6 @@
#include <common.h>
-#if defined(CONFIG_CMD_REISER)
-
#include <config.h>
#include <reiserfs.h>
@@ -119,5 +117,3 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
return 1;
}
-
-#endif
diff --git a/fs/reiserfs/mode_string.c b/fs/reiserfs/mode_string.c
index 3e57ee4..801263d 100644
--- a/fs/reiserfs/mode_string.c
+++ b/fs/reiserfs/mode_string.c
@@ -25,7 +25,6 @@
#include <common.h>
-#if defined(CONFIG_CMD_REISER)
#include <linux/stat.h>
#if ( S_ISUID != 04000 ) || ( S_ISGID != 02000 ) || ( S_ISVTX != 01000 ) \
@@ -137,5 +136,3 @@ const char *bb_mode_string(int mode)
}
#endif
-
-#endif
diff --git a/fs/reiserfs/reiserfs.c b/fs/reiserfs/reiserfs.c
index aa96361..d84fb20 100644
--- a/fs/reiserfs/reiserfs.c
+++ b/fs/reiserfs/reiserfs.c
@@ -29,8 +29,6 @@
*/
#include <common.h>
-#if defined(CONFIG_CMD_REISER)
-
#include <malloc.h>
#include <linux/ctype.h>
#include <linux/time.h>
@@ -982,5 +980,3 @@ reiserfs_open (char *filename)
}
return filemax;
}
-
-#endif
diff --git a/include/devices.h b/include/devices.h
index 2d9e282..490016b 100644
--- a/include/devices.h
+++ b/include/devices.h
@@ -21,7 +21,7 @@
* MA 02111-1307 USA
*/
-#include <lists.h>
+#include <linux/list.h>
#ifndef _DEVICES_H_
#define _DEVICES_H_
@@ -59,6 +59,7 @@ typedef struct {
/* Other functions */
void *priv; /* Private extensions */
+ struct list_head list;
} device_t;
/*
@@ -82,7 +83,6 @@ typedef struct {
/*
* VARIABLES
*/
-extern list_t devlist;
extern device_t *stdio_devices[];
extern char *stdio_names[MAX_FILES];
@@ -91,8 +91,10 @@ extern char *stdio_names[MAX_FILES];
*/
int device_register (device_t * dev);
int devices_init (void);
-int devices_done (void);
int device_deregister(char *devname);
+struct list_head* device_get_list(void);
+device_t* device_get_by_name(char* name);
+
#ifdef CONFIG_LCD
int drv_lcd_init (void);
#endif
diff --git a/include/linux/list.h b/include/linux/list.h
index e6492f7..aeeeb21 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -1,6 +1,9 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
+#include <linux/stddef.h>
+#include <linux/poison.h>
+
#ifndef ARCH_HAS_PREFETCH
#define ARCH_HAS_PREFETCH
static inline void prefetch(const void *x) {;}
@@ -25,9 +28,11 @@ struct list_head {
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
-#define INIT_LIST_HEAD(ptr) do { \
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
/*
* Insert a new entry between two known consecutive entries.
@@ -87,13 +92,37 @@ static inline void __list_del(struct list_head *prev, struct list_head *next)
/**
* list_del - deletes entry from list.
* @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
*/
static inline void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
- entry->next = (void *) 0;
- entry->prev = (void *) 0;
+ entry->next = LIST_POISON1;
+ entry->prev = LIST_POISON2;
+}
+
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static inline void list_replace(struct list_head *old,
+ struct list_head *new)
+{
+ new->next = old->next;
+ new->next->prev = new;
+ new->prev = old->prev;
+ new->prev->next = new;
+}
+
+static inline void list_replace_init(struct list_head *old,
+ struct list_head *new)
+{
+ list_replace(old, new);
+ INIT_LIST_HEAD(old);
}
/**
@@ -130,37 +159,129 @@ static inline void list_move_tail(struct list_head *list,
}
/**
+ * list_is_last - tests whether @list is the last entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+ const struct list_head *head)
+{
+ return list->next == head;
+}
+
+/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
-static inline int list_empty(struct list_head *head)
+static inline int list_empty(const struct list_head *head)
{
return head->next == head;
}
-static inline void __list_splice(struct list_head *list,
- struct list_head *head)
+/**
+ * list_empty_careful - tests whether a list is empty and not being modified
+ * @head: the list to test
+ *
+ * Description:
+ * tests whether a list is empty _and_ checks that no other CPU might be
+ * in the process of modifying either member (next or prev)
+ *
+ * NOTE: using list_empty_careful() without synchronization
+ * can only be safe if the only activity that can happen
+ * to the list entry is list_del_init(). Eg. it cannot be used
+ * if another CPU could re-list_add() it.
+ */
+static inline int list_empty_careful(const struct list_head *head)
+{
+ struct list_head *next = head->next;
+ return (next == head) && (next == head->prev);
+}
+
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+ return !list_empty(head) && (head->next == head->prev);
+}
+
+static inline void __list_cut_position(struct list_head *list,
+ struct list_head *head, struct list_head *entry)
+{
+ struct list_head *new_first = entry->next;
+ list->next = head->next;
+ list->next->prev = list;
+ list->prev = entry;
+ entry->next = list;
+ head->next = new_first;
+ new_first->prev = head;
+}
+
+/**
+ * list_cut_position - cut a list into two
+ * @list: a new list to add all removed entries
+ * @head: a list with entries
+ * @entry: an entry within head, could be the head itself
+ * and if so we won't cut the list
+ *
+ * This helper moves the initial part of @head, up to and
+ * including @entry, from @head to @list. You should
+ * pass on @entry an element you know is on @head. @list
+ * should be an empty list or a list you do not care about
+ * losing its data.
+ *
+ */
+static inline void list_cut_position(struct list_head *list,
+ struct list_head *head, struct list_head *entry)
+{
+ if (list_empty(head))
+ return;
+ if (list_is_singular(head) &&
+ (head->next != entry && head != entry))
+ return;
+ if (entry == head)
+ INIT_LIST_HEAD(list);
+ else
+ __list_cut_position(list, head, entry);
+}
+
+static inline void __list_splice(const struct list_head *list,
+ struct list_head *prev,
+ struct list_head *next)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
- struct list_head *at = head->next;
- first->prev = head;
- head->next = first;
+ first->prev = prev;
+ prev->next = first;
- last->next = at;
- at->prev = last;
+ last->next = next;
+ next->prev = last;
}
/**
- * list_splice - join two lists
+ * list_splice - join two lists, this is designed for stacks
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
-static inline void list_splice(struct list_head *list, struct list_head *head)
+static inline void list_splice(const struct list_head *list,
+ struct list_head *head)
{
if (!list_empty(list))
- __list_splice(list, head);
+ __list_splice(list, head, head->next);
+}
+
+/**
+ * list_splice_tail - join two lists, each list being a queue
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice_tail(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head->prev, head);
}
/**
@@ -174,7 +295,24 @@ static inline void list_splice_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
- __list_splice(list, head);
+ __list_splice(list, head, head->next);
+ INIT_LIST_HEAD(list);
+ }
+}
+
+/**
+ * list_splice_tail_init - join two lists and reinitialise the emptied list
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * Each of the lists is a queue.
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_tail_init(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list)) {
+ __list_splice(list, head->prev, head);
INIT_LIST_HEAD(list);
}
}
@@ -186,28 +324,53 @@ static inline void list_splice_init(struct list_head *list,
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+ container_of(ptr, type, member)
+
+/**
+ * list_first_entry - get the first element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+ list_entry((ptr)->next, type, member)
/**
* list_for_each - iterate over a list
- * @pos: the &struct list_head to use as a loop counter.
+ * @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
- for (pos = (head)->next, prefetch(pos->next); pos != (head); \
- pos = pos->next, prefetch(pos->next))
+ for (pos = (head)->next; prefetch(pos->next), pos != (head); \
+ pos = pos->next)
+
+/**
+ * __list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @head: the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
/**
* list_for_each_prev - iterate over a list backwards
- * @pos: the &struct list_head to use as a loop counter.
+ * @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*/
#define list_for_each_prev(pos, head) \
- for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
- pos = pos->prev, prefetch(pos->prev))
+ for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
+ pos = pos->prev)
/**
- * list_for_each_safe - iterate over a list safe against removal of list entry
- * @pos: the &struct list_head to use as a loop counter.
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
* @n: another &struct list_head to use as temporary storage
* @head: the head for your list.
*/
@@ -216,43 +379,296 @@ static inline void list_splice_init(struct list_head *list,
pos = n, n = pos->next)
/**
+ * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop cursor.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_prev_safe(pos, n, head) \
+ for (pos = (head)->prev, n = pos->prev; \
+ prefetch(pos->prev), pos != (head); \
+ pos = n, n = pos->prev)
+
+/**
* list_for_each_entry - iterate over list of given type
- * @pos: the type * to use as a loop counter.
+ * @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member), \
- prefetch(pos->member.next); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member), \
- prefetch(pos->member.next))
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ prefetch(pos->member.next), &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ prefetch(pos->member.prev), &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
+ * @pos: the type * to use as a start point
+ * @head: the head of the list
+ * @member: the name of the list_struct within the struct.
+ *
+ * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
+ */
+#define list_prepare_entry(pos, head, member) \
+ ((pos) ? : list_entry(head, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue - continue iteration over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Continue to iterate over list of given type, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue(pos, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member); \
+ prefetch(pos->member.next), &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue_reverse - iterate backwards from the given point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Start to iterate over list of given type backwards, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_reverse(pos, head, member) \
+ for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
+ prefetch(pos->member.prev), &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from(pos, head, member) \
+ for (; prefetch(pos->member.next), &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
- * @pos: the type * to use as a loop counter.
+ * @pos: the type * to use as a loop cursor.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
- n = list_entry(pos->member.next, typeof(*pos), member); \
- &pos->member != (head); \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
/**
- * list_for_each_entry_continue - iterate over list of given type
- * continuing after existing point
- * @pos: the type * to use as a loop counter.
+ * list_for_each_entry_safe_continue
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing after current point,
+ * safe against removal of list entry.
+ */
+#define list_for_each_entry_safe_continue(pos, n, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_from
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type from current point, safe against
+ * removal of list entry.
+ */
+#define list_for_each_entry_safe_from(pos, n, head, member) \
+ for (n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_reverse
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate backwards over list of given type, safe against removal
+ * of list entry.
+ */
+#define list_for_each_entry_safe_reverse(pos, n, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member), \
+ n = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
+/*
+ * Double linked lists with a single pointer list head.
+ * Mostly useful for hash tables where the two pointer list head is
+ * too wasteful.
+ * You lose the ability to access the tail in O(1).
+ */
+
+struct hlist_head {
+ struct hlist_node *first;
+};
+
+struct hlist_node {
+ struct hlist_node *next, **pprev;
+};
+
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static inline void INIT_HLIST_NODE(struct hlist_node *h)
+{
+ h->next = NULL;
+ h->pprev = NULL;
+}
+
+static inline int hlist_unhashed(const struct hlist_node *h)
+{
+ return !h->pprev;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+ return !h->first;
+}
+
+static inline void __hlist_del(struct hlist_node *n)
+{
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
+ *pprev = next;
+ if (next)
+ next->pprev = pprev;
+}
+
+static inline void hlist_del(struct hlist_node *n)
+{
+ __hlist_del(n);
+ n->next = LIST_POISON1;
+ n->pprev = LIST_POISON2;
+}
+
+static inline void hlist_del_init(struct hlist_node *n)
+{
+ if (!hlist_unhashed(n)) {
+ __hlist_del(n);
+ INIT_HLIST_NODE(n);
+ }
+}
+
+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+ struct hlist_node *first = h->first;
+ n->next = first;
+ if (first)
+ first->pprev = &n->next;
+ h->first = n;
+ n->pprev = &h->first;
+}
+
+/* next must be != NULL */
+static inline void hlist_add_before(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ n->pprev = next->pprev;
+ n->next = next;
+ next->pprev = &n->next;
+ *(n->pprev) = n;
+}
+
+static inline void hlist_add_after(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ next->next = n->next;
+ n->next = next;
+ next->pprev = &n->next;
+
+ if(next->next)
+ next->next->pprev = &next->next;
+}
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each(pos, head) \
+ for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
+ pos = pos->next)
+
+#define hlist_for_each_safe(pos, n, head) \
+ for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
+ pos = n)
+
+/**
+ * hlist_for_each_entry - iterate over list of given type
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ prefetch(pos->next); 1;}) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_continue(tpos, pos, member) \
+ for (pos = (pos)->next; \
+ pos && ({ prefetch(pos->next); 1;}) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_from - iterate over a hlist continuing from current point
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_from(tpos, pos, member) \
+ for (; pos && ({ prefetch(pos->next); 1;}) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @tpos: the type * to use as a loop cursor.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @n: another &struct hlist_node to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
*/
-#define list_for_each_entry_continue(pos, head, member) \
- for (pos = list_entry(pos->member.next, typeof(*pos), member), \
- prefetch(pos->member.next); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member), \
- prefetch(pos->member.next))
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ n = pos->next; 1; }) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = n)
#endif
diff --git a/include/linux/poison.h b/include/linux/poison.h
new file mode 100644
index 0000000..b3d873b
--- /dev/null
+++ b/include/linux/poison.h
@@ -0,0 +1,11 @@
+#ifndef _LINUX_POISON_H
+#define _LINUX_POISON_H
+
+/********** include/linux/list.h **********/
+/*
+ * used to verify that nobody uses non-initialized list entries.
+ */
+#define LIST_POISON1 ((void *) 0x0)
+#define LIST_POISON2 ((void *) 0x0)
+
+#endif
diff --git a/include/lists.h b/include/lists.h
deleted file mode 100644
index 10a2a19..0000000
--- a/include/lists.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef _LISTS_H_
-#define _LISTS_H_
-
-#define LIST_START -1 /* Handy Constants that substitute for item positions */
-#define LIST_END 0 /* END_OF_LIST means one past current length of list when */
- /* inserting. Otherwise it refers the last item in the list. */
-
-typedef struct
- {
- void *ptr;
- unsigned int size;
- } HandleRecord;
-
-typedef void **Handle;
-
-typedef int (*CompareFunction)(void *data1, void *data2) ;
-
-typedef struct ListStructTag
- {
- int signature; /* debugging aid */
- int percentIncrease; /* %of current size to increase by when list is out of space */
- int minNumItemsIncrease; /* fixed number of items to increase by when list is out of space */
- int listSize; /* number of items than can fit in the currently allocated memory */
- int itemSize; /* the size of each item in the list (same for every item) */
- int numItems; /* number of items currently in the list */
- unsigned char itemList[1]; /* resizable array of list elements */
- } ListStruct;
-
-typedef struct ListStructTag **list_t; /* The list abstract data type */
-typedef int ( * ListApplicationFunc)(int index, void *ptrToItem, void *callbackData);
-
-/* Basic List Operations */
-list_t ListCreate(int elementSize);
-int ListNumItems(list_t list);
-int ListInsertItem(list_t list, void *ptrToItem, int itemPosition);
-int ListInsertItems(list_t list, void *ptrToItems, int firstItemPosition, int numItemsToInsert);
-void ListDispose(list_t list);
-void *ListGetPtrToItem(list_t list, int itemPosition);
-void ListRemoveItem(list_t list, void *itemDestination, int itemPosition);
-void ListRemoveItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToRemove);
-
-#if 0 /* rarely ever used; kept here for reference just in case ... */
-void ListDisposePtrList(list_t list);
-void ListGetItem(list_t list, void *itemDestination, int itemPosition);
-void ListReplaceItem(list_t list, void *ptrToItem, int itemPosition);
-void ListRemoveItem(list_t list, void *itemDestination, int itemPosition);
-void ListGetItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToGet);
-void ListReplaceItems(list_t list, void *ptrToItems, int firstItemPosition, int numItemsToReplace);
-void ListRemoveItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToRemove);
-list_t ListCopy(list_t originalList);
-int ListAppend(list_t list1, list_t list2);
-void ListClear(list_t list);
-int ListEqual(list_t list1, list_t list2);
-int ListInsertInOrder(list_t list, void *ptrToItem, CompareFunction compareFunction);
-void *ListGetDataPtr(list_t list);
-int ListApplyToEach(list_t list, int ascending, ListApplicationFunc funcToApply, void *callbackData);
-
-/* List Searching and Sorting */
-int ListFindItem(list_t list, void *ptrToItem, int startingPosition, CompareFunction compareFunction);
-void ListRemoveDuplicates(list_t list, CompareFunction compareFunction);
-int ListBinSearch(list_t list, void *itemPtr, CompareFunction compareFunction);
-void ListQuickSort(list_t list, CompareFunction compareFunction);
-void ListHeapSort(list_t list, CompareFunction compareFunction);
-void ListInsertionSort(list_t list, CompareFunction compareFunction);
-int ListIsSorted(list_t list, CompareFunction compareFunction);
-
-/* Advanced List Functions */
-void ListSetAllocationPolicy(list_t list, int minItemsPerAlloc, int percentIncreasePerAlloc);
-void ListCompact(list_t list);
-int ListPreAllocate(list_t list, int numItems);
-int ListGetItemSize(list_t list);
-int GetIntListFromParmInfo(va_list parmInfo, int numIntegers, list_t *integerList);
-int ListInsertAfterItem(list_t list, void *ptrToItem, void *ptrToItemToInsertAfter, CompareFunction compareFunction);
-int ListInsertBeforeItem(list_t list, void *ptrToItem, void *ptrToItemToInsertBefore, CompareFunction compareFunction);
-#endif /* 0 */
-
-#endif /* _LISTS_H_ */
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index bf0e31d..7df5a2c 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -30,10 +30,12 @@ COBJS-y += bzlib_crctable.o
COBJS-y += bzlib_decompress.o
COBJS-y += bzlib_randtable.o
COBJS-y += bzlib_huffman.o
+COBJS-y += crc16.o
COBJS-y += crc32.o
COBJS-y += ctype.o
COBJS-y += display_options.o
COBJS-y += div64.o
+COBJS-y += gunzip.o
COBJS-y += lmb.o
COBJS-y += ldiv.o
COBJS-$(CONFIG_MD5) += md5.o
diff --git a/common/crc16.c b/lib_generic/crc16.c
index 6904365..6904365 100644
--- a/common/crc16.c
+++ b/lib_generic/crc16.c
diff --git a/common/gunzip.c b/lib_generic/gunzip.c
index 74f0bf9..74f0bf9 100644
--- a/common/gunzip.c
+++ b/lib_generic/gunzip.c