Index: include/fs.h
===================================================================
--- include/fs.h	(revision 45)
+++ include/fs.h	(working copy)
@@ -5,11 +5,18 @@
 
 typedef uint64_t sector_t;
 
-#ifdef IDE_DISK
+#if defined IDE_DISK || defined SATA_DISK
+int ide_read(int drive, sector_t sector, void *buffer, int isIDE);
+#endif
+
+#if defined IDE_DISK
 int ide_probe(int drive);
-int ide_read(int drive, sector_t sector, void *buffer);
 #endif
 
+#if defined SATA_DISK
+int sata_probe(int drive);
+#endif
+
 #ifdef USB_DISK
 int usb_probe(int drive);
 int usb_read(int drive, sector_t sector, void *buffer);
@@ -18,6 +25,7 @@
 #define DISK_IDE 1
 #define DISK_MEM 2
 #define DISK_USB 3
+#define DISK_SATA 4
 
 int devopen(const char *name, int *reopen);
 int devread(unsigned long sector, unsigned long byte_offset,
Index: main/grub/stage2.c
===================================================================
--- main/grub/stage2.c	(revision 45)
+++ main/grub/stage2.c	(working copy)
@@ -1195,7 +1195,7 @@
 	  /* If no acceptable config file, goto command-line, starting
 	     heap from where the config entries would have been stored
 	     if there were any.  */
-	  enter_cmdline (config_entries, 1);
+//	  enter_cmdline (config_entries, 1);
 	}
       else
 	{
Index: main/grub/builtins.c
===================================================================
--- main/grub/builtins.c	(revision 45)
+++ main/grub/builtins.c	(working copy)
@@ -1,3 +1,5 @@
+/* changed by fainshf to add USB (and no partition) support */
+
 #include "lib.h"
 
 #define grub_strcmp strcmp
@@ -474,6 +476,23 @@
 		arg+=7; // FIXME only 9 disks with 9 partitions for booting
 		sprintf(dummy, "hd%c%c:", disk+'a', part+'1');
 	}
+#ifdef USB_DISK
+	else if(arg[0]=='(' && arg[1]=='u' && arg[2]=='d') {
+		disk=arg[3]-'0';
+		part=arg[5]-'0';
+		arg+=7; // FIXME only 9 disks with 9 partitions for booting
+		sprintf(dummy, "ud%c%c:", disk+'a', part+'1');
+	}
+#endif
+#ifdef SATA_DISK
+	else if(arg[0]=='(' && arg[1]=='s' && arg[2]=='d') {
+		disk=arg[3]-'0';
+		part=arg[5]-'0';
+		arg+=7; // FIXME only 9 disks with 9 partitions for booting
+		sprintf(dummy, "sd%c%c:", disk+'a', part+'1');
+	}
+#endif
+
 	strncat(boot_line," initrd=", 1000);
 	if(dummy[0]) strncat(boot_line,dummy, 1000);
 	grub_strncat(boot_line,arg, 1000);
@@ -499,6 +518,9 @@
 kernel_func (char *arg, int flags)
 {
 	int disk,part;
+
+  printf("kernel: %s\n", arg);
+
 	/* Needed to pass grub checks */
 	kernel_type=KERNEL_TYPE_LINUX;
 	if(arg[0]=='(' && arg[1]=='h' && arg[2]=='d') {
@@ -506,7 +528,28 @@
 		part=arg[5]-'0';
 		arg+=7; // FIXME only 9 disks with 9 partitions for booting
 		sprintf(boot_line, "hd%c%c:", disk+'a', part+'1');
-	} else if (root_device[0]=='h' && root_device[1]=='d') {
+#ifdef USB_DISK
+	} else if (arg[0]=='(' && arg[1]=='u' && arg[2]=='d'){
+		disk=arg[3]-'0';
+		part=arg[5]-'0';
+		arg+=7; // FIXME only 9 disks with 9 partitions for booting
+		sprintf(boot_line, "ud%c%c:", disk+'a', part+'1');
+#endif
+#ifdef SATA_DISK
+	} else if (arg[0]=='(' && arg[1]=='s' && arg[2]=='d'){
+		disk=arg[3]-'0';
+		part=arg[5]-'0';
+		arg+=7; // FIXME only 9 disks with 9 partitions for booting
+		sprintf(boot_line, "sd%c%c:", disk+'a', part+'1');
+#endif
+	} else if ((root_device[0]=='h'
+#ifdef USB_DISK
+	|| root_device[0]=='u'
+#endif
+#ifdef SATA_DISK
+	|| root_device[0]=='s'
+#endif
+	) && root_device[1]=='d') {
 		strcpy(boot_line, root_device);
 	}
 	
@@ -711,12 +754,41 @@
 {
   int disk, part;
 
+  printf("root: %s\n", arg);
+
   if(arg[0]!='(') return 1;
-  if(arg[1]!='h') return 1;
+  
+  if(arg[1]!='h' && arg[1]!='u' && arg[1]!='s')
+  {
+      return 1;
+  }
+
   if(arg[2]!='d') return 1;
   disk=arg[3]-'0';
+
+  if(arg[5] == '-')
+  {
+      part = -1; /* no partitions case */
+  }
+  else
+  {
   part=arg[5]-'0';
+  }
+
   sprintf(root_device, "hd%c%c:", disk+'a', part+'1');
+
+#ifdef USB_DISK
+   if(arg[1] == 'u') {
+       root_device[0] = 'u';
+   }
+#endif
+
+#ifdef SATA_DISK
+   if(arg[1] == 's') {
+       root_device[0] = 's';
+   }
+#endif
+
   return 0;
 }
 
Index: main/elfload.c
===================================================================
--- main/elfload.c	(revision 45)
+++ main/elfload.c	(working copy)
@@ -338,6 +338,10 @@
 	    goto out;
     }
 
+#ifdef USB_DISK 
+    hci_stop();
+#endif
+
     boot_notes = build_boot_notes(info, cmdline);
 
     debug("current time: %lu\n", currticks());
Index: main/malloc.c
===================================================================
--- main/malloc.c	(revision 45)
+++ main/malloc.c	(working copy)
@@ -186,21 +186,23 @@
 
 
 // very dumb allot2 implementation to get 
-// usb stack working quickly.
-
+// usb stack working quickly. This should be
+// redone later..
+// 
+// note: this will fail if alignment is smaller than sizeof(unsigned long)
+/* redone by fainshf to fix USB bugs */
 void *allot2(size_t size, unsigned int alignment)
 {
 	void *addr;
 	unsigned long addrval;
+	int           pSize = sizeof(unsigned long);
 
-	if(((alignment + 1) & alignment) != 0) {
-		debug("alignment not power of 2");
+    if(((alignment + 1) & alignment) != 0)
 		return (void *)0;
-	}
 
-	addr=malloc(size + alignment + sizeof(unsigned long));
+	addr=malloc(size + alignment + /*2**/pSize);
 
-	addrval=(unsigned long)addr;
+	addrval=(unsigned long)addr/* + pSize*/;
 	addrval+=alignment+1; //  0x12345600 + 0xff + 1
 	addrval&=~alignment;  //  0x12345700
 	*(unsigned long *)(addrval-sizeof(unsigned long))=addr;
@@ -215,6 +217,8 @@
 	free((void *)addr);
 }
 
+// end of ugly code.
+
 void malloc_diag(void)
 {
     debug("alloc: %lu bytes (%u blocks), free: %lu bytes (%u blocks)\n",
Index: fs/blockdev.c
===================================================================
--- fs/blockdev.c	(revision 45)
+++ fs/blockdev.c	(working copy)
@@ -137,16 +137,25 @@
 	*type = DISK_IDE;
 	name += 2;
 	if (*name < 'a' || *name > 'z') {
-	    printf("Invalid drive\n");
+	    printf("Invalid IDE drive\n");
 	    return 0;
 	}
 	*drive = *name - 'a';
 	name++;
+    } else if (memcmp(name, "sd", 2) == 0) {
+	*type = DISK_SATA;
+	name += 2;
+	if (*name < 'a' || *name > 'z') {
+	    printf("Invalid SATA drive\n");
+	    return 0;
+	}
+	*drive = *name - 'a';
+	name++;
     } else if (memcmp(name, "ud", 2) == 0) {
 	*type = DISK_USB;
 	name += 2;
         if (*name < 'a' || *name > 'z') {
-	    printf("Invalid drive\n");
+	    printf("Invalid USB drive\n");
 	    return 0;
 	}
 	*drive = *name - 'a';
@@ -184,6 +193,7 @@
     uint64_t offset, length;
     uint32_t disk_size = 0;
 
+#if 1
     /* Don't re-open the device that's already open */
     if (strcmp(name, dev_name) == 0) {
 	debug("already open\n");
@@ -191,6 +201,7 @@
 	return 1;
     }
     *reopen = 0;
+#endif
 
     if (!parse_device_name(name, &type, &drive, &part, &offset, &length)) {
 	debug("failed to parse device name: %s\n", name);
@@ -211,12 +222,21 @@
 #ifdef IDE_DISK
     case DISK_IDE:
 	if (ide_probe(drive) != 0) {
-	    debug("failed to open ide\n");
+	    debug("failed to open %s\n", "ide");
 	    return 0;
 	}
 	disk_size = (uint32_t) -1; /* FIXME */
 	break;
 #endif
+#ifdef SATA_DISK
+    case DISK_SATA:
+	if (sata_probe(drive) != 0) {
+	    debug("failed to open %s\n", "SATA");
+	    return 0;
+	}
+	disk_size = (uint32_t) -1; /* FIXME */
+	break;
+#endif
 #ifdef USB_DISK
     case DISK_USB:
         if (usb_probe(drive) != 0) {
@@ -308,11 +328,15 @@
     if (cache_sect[hash] != sector) {
 	cache_sect[hash] = (unsigned long) -1;
 	switch (dev_type) {
-#ifdef IDE_DISK
+#if defined IDE_DISK || defined SATA_DISK
 	case DISK_IDE:
-	    if (ide_read(dev_drive, sector, buf) != 0)
+	    if (ide_read(dev_drive, sector, buf, 1) != 0)
 		goto readerr;
 	    break;
+	case DISK_SATA:
+	    if (ide_read(dev_drive, sector, buf, 0) != 0)
+		goto readerr;
+	    break;
 #endif
 #ifdef USB_DISK
         case DISK_USB:
Index: i386/linux_load.c
===================================================================
--- i386/linux_load.c	(revision 45)
+++ i386/linux_load.c	(working copy)
@@ -655,6 +655,8 @@
 
     hardware_setup();
 
+    hci_stop();
+
     start_linux(kern_addr, params);
     return 0;
 }
Index: i386/segment.c
===================================================================
--- i386/segment.c	(revision 45)
+++ i386/segment.c	(working copy)
@@ -48,7 +48,7 @@
     unsigned long new_offset;
     unsigned d0, d1, d2;
     struct gdtarg gdtarg;
-#define ALIGNMENT 0x1000
+#define ALIGNMENT 0xfff /* changed by fainshf to fit USB regardments */
 
     prog_addr = virt_to_phys(&_start);
     prog_size = virt_to_phys(&_end) - virt_to_phys(&_start);
Index: i386/ldscript
===================================================================
--- i386/ldscript	(revision 45)
+++ i386/ldscript	(working copy)
@@ -8,9 +8,9 @@
  */
 BASE_ADDR = 0x100000;
 
-/* 32KB heap and 16k stack */
+/* 32KB heap and stack */
 HEAP_SIZE = 32768;
-STACK_SIZE = 16384;
+STACK_SIZE = 32768;
 
 SECTIONS
 {
Index: drivers/ide.c
===================================================================
--- drivers/ide.c	(revision 45)
+++ drivers/ide.c	(working copy)
@@ -11,8 +11,10 @@
 #define DEBUG_THIS DEBUG_IDE
 #include <debug.h>
 
-#define IDE_MAX_CONTROLLERS 4
+#define IDE_MAX_CONTROLLERS 2
 #define IDE_MAX_DRIVES (IDE_MAX_CONTROLLERS * 2)
+#define SATA_MAX_CONTROLLERS 2
+#define SATA_MAX_DRIVES (SATA_MAX_CONTROLLERS * 2)
 
 #define BSY_SET_DURING_SPINUP 1
 /*
@@ -222,10 +224,13 @@
 	0
 };
 
-static struct controller controllers[IDE_MAX_CONTROLLERS];
-static struct harddisk_info harddisk_info[IDE_MAX_DRIVES];
+static struct controller ide_controllers[IDE_MAX_CONTROLLERS];
+static struct controller sata_controllers[SATA_MAX_CONTROLLERS];
+static struct harddisk_info idedisk_info[IDE_MAX_DRIVES];
+static struct harddisk_info satadisk_info[SATA_MAX_DRIVES];
 
 static unsigned char ide_buffer[IDE_SECTOR_SIZE];
+static unsigned char sata_buffer[IDE_SECTOR_SIZE];
 
 static int await_ide(int (*done)(struct controller *ctrl), 
 	struct controller *ctrl, unsigned long timeout)
@@ -306,40 +311,39 @@
 	/* Wait a little bit in case this is immediately after
 	 * hardware reset.
 	 */
-	mdelay(2);
+	mdelay(10);
 	/* A software reset should not be delivered while the bsy bit
 	 * is set.  If the bsy bit does not clear in a reasonable
 	 * amount of time give up.
 	 */
 	debug("Waiting for ide%d to become ready for reset... ",
-			ctrl - controllers);
+			ctrl - ide_controllers);
 	if (await_ide(not_bsy, ctrl, currticks() + IDE_TIMEOUT) < 0) {
 		debug("failed\n");
 		return -1;
 	}
 	debug("ok\n");
 
-	debug("Resetting ide%d... ",
-			ctrl - controllers);
+	debug("Assert IDE bus reset... ");
 	/* Disable Interrupts and reset the ide bus */
 	outb(IDE_CTRL_HD15 | IDE_CTRL_SRST | IDE_CTRL_NIEN, 
 		IDE_REG_DEVICE_CONTROL(ctrl));
+	mdelay(50);
 	/* If BSY bit is not asserted within 400ns, no device there */
 	if (await_ide(bsy, ctrl, currticks() + IDE_RESET_PULSE) < 0) {
 		if (slave_exist)
 			printf ("reset failed, but slave maybe exist\n");
-		else {
-			// return -1;
-			printf("reset failed, but we may be on SATA\n");
-		}
+		else
+			return -1;
 	}
 	debug("ok\n");
-
+	debug("Deassert IDE bus reset... ");
 	outb(IDE_CTRL_HD15 | IDE_CTRL_NIEN, IDE_REG_DEVICE_CONTROL(ctrl));
 	mdelay(2);
 	if (await_ide(not_bsy, ctrl, currticks() + IDE_TIMEOUT) < 0) {
 		return -1;
 	}
+	debug("ok\n");
 	return 0;
 }
 
@@ -597,11 +601,17 @@
 	return 0;
 }
 
-int ide_read(int drive, sector_t sector, void *buffer)
+int ide_read(int drive, sector_t sector, void *buffer, int isIDE)
 {
-	struct harddisk_info *info = &harddisk_info[drive];
+	struct harddisk_info *info;
 	int result;
 
+    if(isIDE) {
+		info = &idedisk_info[drive];
+    } else {
+		info = &satadisk_info[drive];
+    }
+
 	//debug("drive=%d, sector=%ld\n",drive,(unsigned long) sector);
 	/* Report the buffer is empty */
 	if (sector > info->sectors) {
@@ -862,7 +872,7 @@
 	return 1;
 }
 
-static int init_controller(struct controller *ctrl, int drive, unsigned char *buffer) 
+static int init_controller(struct controller *ctrl, int drive, unsigned char *buffer, int isIDE) 
 {
 	struct harddisk_info *info;
 
@@ -918,7 +928,11 @@
 
 	/* Now initialize the individual drives */
 	int master_drive = drive & ~1;
-	info = &harddisk_info[master_drive];
+    if(isIDE) {
+		info = &idedisk_info[master_drive];
+    } else {
+		info = &satadisk_info[master_drive];
+    }
 
 	/* master */
 	init_drive(info, ctrl, 0, master_drive, buffer, IDE_CMD_IDENTIFY_DEVICE);
@@ -943,7 +957,11 @@
 
 	/* slave */
 	debug("/*slave */ -- drive is %d\n", drive);
-	info = &harddisk_info[drive];
+    if(isIDE) {
+		info = &idedisk_info[master_drive];
+    } else {
+		info = &satadisk_info[master_drive];
+    }
 	if (!info->drive_exists) {
 		debug("NO MASTER -- check slave!\n");
 		init_drive(info, ctrl, 1, drive, buffer, IDE_CMD_IDENTIFY_DEVICE);
@@ -1093,32 +1111,43 @@
 }
 
 #ifdef SUPPORT_PCI
-static int find_ide_controller(struct controller *ctrl, int ctrl_index)
+static int find_ide_controller(struct controller *ctrl, int ctrl_index, int type)
 {
 	int pci_index;
-	struct pci_dev *dev;
+	struct pci_dev *dev, *dev1;
 	unsigned int mask;
 
 	/* A PCI IDE controller has two channels (pri, sec) */
 	pci_index = ctrl_index >> 1;
 
 	/* Find a IDE storage class device */
-	dev = pci_find_device(-1, -1, 0x0180, -1, pci_index); // S-ATA first.
-	if (!dev) {
-		dev = pci_find_device(-1, -1, 0x0101, -1, pci_index);
+	if (type != 0) {
+		dev = pci_find_device(-1, -1, 0x0101, -1, pci_index); // IDE
 		if (!dev) {
 			debug("PCI IDE #%d not found\n", pci_index);
 			return -1;
 		}
-	}
-
 	debug("found PCI IDE controller %04x:%04x prog_if=%#x\n",
 			dev->vendor, dev->device, dev->prog_if);
+	} else {
+		dev = pci_find_device(-1, -1, 0x0104, -1, pci_index); // S-ATA first.
+		if (!dev) {
+			debug("PCI SATA #%d not found\n", pci_index);
+			return -1;
+		} else {
+			unsigned char	c;
+			c = pci_read8(dev->addr, 0x04);
+			pci_write8(dev->addr, 0x04, 0x07);
+		}
+		debug("found PCI SATA controller %04x:%04x prog_if=%#x\n",
+			dev->vendor, dev->device, dev->prog_if);
+	}
 
 	/* See how this controller is configured */
 	mask = (ctrl_index & 1) ? 4 : 1;
-	debug("%s channel: ", (ctrl_index & 1) ? "secondary" : "primary");
+	debug("%s channel: ", (ctrl_index & 1) ? "secodary" : "primary");
 	if ((dev->prog_if & mask) || (dev->devclass != 0x0101)) {
+//	if (dev->prog_if & mask){
 		debug("native PCI mode\n");
 		if ((ctrl_index & 1) == 0) {
 			/* Primary channel */
@@ -1162,28 +1191,38 @@
 	struct controller *ctrl;
 	int ctrl_index;
 	struct harddisk_info *info;
+    int orig_drive = drive;
 
 	if (drive >= IDE_MAX_DRIVES) {
 		printf("Unsupported drive number\n");
 		return -1;
 	}
 
+   /* fainshf */
+#if 0
+   memset(controllers, 0, sizeof(struct ide_controllers) * IDE_MAX_CONTROLLERS);
+   memset(harddisk_info, 0, sizeof(struct harddisk_info) * IDE_MAX_DRIVES);
+   memset(ide_buffer, 0, sizeof(unsigned char) * IDE_SECTOR_SIZE);
+#endif
+
 	/* A controller has two drives (master, slave) */
 	ctrl_index = drive >> 1;
 
-	ctrl = &controllers[ctrl_index];
+    ctrl = &ide_controllers[ctrl_index];
 	if (ctrl->cmd_base == 0) {
-		if (find_ide_controller(ctrl, ctrl_index) != 0) {
+        if (find_ide_controller(ctrl, ctrl_index, 1) != 0) {
 			printf("IDE channel %d not found\n", ctrl_index);
 			return -1;
 		}
-		if (init_controller(ctrl, drive, ide_buffer) != 0) {
+    
+        if (init_controller(ctrl, drive & ~1, ide_buffer, 1) != 0) {
 			printf("No drive detected on IDE channel %d\n",
 					ctrl_index);
 			return -1;
 		}
 	}
-	info = &harddisk_info[drive];
+
+    info = &idedisk_info[drive];
 	if (!info->drive_exists) {
 		printf("Drive %d does not exist\n", drive);
 		return -1;
@@ -1196,6 +1235,60 @@
 		}
 	}
 
+
+    return 0;
+}
+
+int sata_probe(int drive)
+{
+    struct controller *ctrl;
+    int ctrl_index;
+    struct harddisk_info *info;
+    int orig_drive = drive;
+
+    if (drive >= IDE_MAX_DRIVES) {
+        printf("Unsupported drive number\n");
+        return -1;
+    }
+
+   /* fainshf */
+#if 0
+   memset(controllers, 0, sizeof(struct controller) * IDE_MAX_CONTROLLERS);
+   memset(harddisk_info, 0, sizeof(struct harddisk_info) * IDE_MAX_DRIVES);
+   memset(ide_buffer, 0, sizeof(unsigned char) * IDE_SECTOR_SIZE);
+#endif
+
+    /* A controller has two drives (master, slave) */
+    ctrl_index = drive >> 1;
+
+    ctrl = &sata_controllers[ctrl_index];
+    if (ctrl->cmd_base == 0) {
+        if (find_ide_controller(ctrl, ctrl_index, 0) != 0) {
+             printf("SATA channel %d not found\n", ctrl_index);
+             return -1;
+        }
+    
+        if (init_controller(ctrl, drive & ~1, sata_buffer, 0) != 0) {
+             printf("No drive detected on SATA channel %d\n",
+                        ctrl_index);
+             return -1;
+        }
+    }
+
+    info = &satadisk_info[drive];
+    if (!info->drive_exists) {
+        printf("Drive %d does not exist\n", drive);
+        return -1;
+    }
+
+    if (info->removable) {
+        if (detect_medium(info) != 0) {
+            printf("Media detection failed\n");
+            return -1;
+        }
+    }
+
+
 	return 0;
 }
 
Index: drivers/usb/usb.h
===================================================================
--- drivers/usb/usb.h	(revision 45)
+++ drivers/usb/usb.h	(working copy)
@@ -418,6 +418,7 @@
 
 void init_devices(void);
 void hci_init(void);
+void hci_stop(void);
 int hc_init(struct pci_dev *dev);
 inline int set_address(uchar address);
 inline int clear_stall(uchar device, uchar endpoint);
Index: drivers/usb/debug_x.c
===================================================================
--- drivers/usb/debug_x.c	(revision 45)
+++ drivers/usb/debug_x.c	(working copy)
@@ -35,7 +35,7 @@
 
 void dump_link( link_pointer_t *link, char *prefix)
 {
-	DPRINTF("%saddr: %08x\n", prefix, MEM_ADDR(link->link) );
+	DPRINTF("%saddr: %08x\n", prefix, (unsigned)MEM_ADDR(link->link) );
 	DPRINTF("%s raw addr: %04x\n", prefix, (link->link) <<4 );
 	DPRINTF("%sterminate: %x\n", prefix, link->terminate);
 	DPRINTF("%squeue: %x\n", prefix, link->queue);
@@ -118,7 +118,7 @@
 	newpre[0]='\t';
 	strcpy(newpre+1, prefix);
 
-	DPRINTF("%sTD(%08x):\n", prefix, td);
+	DPRINTF("%sTD(%08x):\n", prefix, (unsigned)td);
 
 	switch(td->packet_type) {
 		case SETUP_TOKEN:
@@ -206,7 +206,7 @@
 	newpre[0] = '\t';
 	strcpy(newpre+1, prefix);
 
-	DPRINTF("%sQUEUE HEAD(%x):\n", prefix, qh);
+	DPRINTF("%sQUEUE HEAD(%x):\n", prefix, (unsigned)qh);
 	DPRINTF("%sdepth:\n", prefix);
 	dump_link( &(qh->depth), newpre);
 
@@ -240,7 +240,7 @@
 	strcpy(newpre+1, prefix);
 
 
-	DPRINTF("%s TRANSACTION(%x):\n", prefix, trans);
+	DPRINTF("%s TRANSACTION(%x):\n", prefix, (unsigned)trans);
 	dump_queue_head( trans->qh, newpre);
 
 	DPRINTF("%s TDs:\n", prefix);
@@ -360,14 +360,14 @@
 
 	DPRINTF("%sbMaxPower: %02x\n", prefix, config->bMaxPower);
 
-	DPRINTF("\n%sInterface(%x):\n", prefix, iface);
+	DPRINTF("\n%sInterface(%x):\n", prefix, (unsigned)iface);
 	dump_interface_descriptor(iface, newpre);
 
 	newpre[1] = '\t';
 	strcpy(newpre+2, prefix);
 
 	for(i=0; i<iface->bNumEndpoints; i++) {
-		DPRINTF("\n%sEndpoint (%x):\n", newpre+1, ep+i);
+		DPRINTF("\n%sEndpoint (%x):\n", newpre+1, (unsigned)(ep+i));
 		dump_endpoint_descriptor( ep+i, newpre);
 	}
 }
Index: drivers/usb/ohci.c
===================================================================
--- drivers/usb/ohci.c	(revision 45)
+++ drivers/usb/ohci.c	(working copy)
@@ -86,7 +86,8 @@
         value &= ~0x40;
         writel(value, port);
 
-        do {
+    do
+    {
                 value = readl(port);
         } while(value & 0x40);
 }       
@@ -97,7 +98,8 @@
 	
 	value = readl(port);
 	
-	if((value & RH_PS_CCS)) {  // if connected
+    if ( (value & RH_PS_CCS) )
+    {  // if connected
 		writel( RH_PS_PES, port);
 		udelay(10);
 		writel( RH_PS_PESC, port); // Clear Change bit
@@ -118,7 +120,8 @@
         uint32_t value;
 
         writel( RH_PS_PRS, port);
-        do {
+    do
+    {
                value = readl( port );
         } while (!(value & RH_PS_PRSC) );
 	writel(RH_PS_PRSC, port);  //Clear Change bit
@@ -130,8 +133,7 @@
 	oport_reset(port);
 }
 
-#if 0
-
+#if 1
 int ohc_stop(uchar dev)
 {
         unsigned short tmp;
@@ -153,39 +155,46 @@
 ohci_td_t *_ohci_td;
 uint8_t	_ohci_td_tag[MAX_OHCI_TD]; //1: used, 0:unused
 
-void init_ohci_td(){
+void init_ohci_td()
+{
 	_ohci_td = allot2(sizeof(ohci_td_t)*MAX_OHCI_TD, 0x1f); // 32 byte aligna
-	if(_ohci_td==0) {
+    if ( _ohci_td==0 )
+    {
 		printf("init_ohci_td: NOMEM\n");
 	}
 	memset(_ohci_td_tag, 0, sizeof(_ohci_td_tag));
 }
 
-ohci_td_t *td_alloc(ohci_t *ohci, int memflag){
+ohci_td_t *td_alloc(ohci_t *ohci, int memflag)
+{
 	int i;
 	ohci_td_t *td;
-	for(i = 0; i< MAX_OHCI_TD; i++ ) {
+    for ( i = 0; i< MAX_OHCI_TD; i++ )
+    {
 		if(_ohci_td_tag[i]==1) continue;
 		td = &_ohci_td[i];
 		memset(td, 0, sizeof(ohci_td_t));
 		td->td_dma = (void *)virt_to_phys(td);
 		_ohci_td_tag[i] = 1;
-		return td;
+        return(td);
 	}
 	printf("td_alloc: no free slot\n");
-	return 0;
+    return(0);
 }
 
-int td_free(ohci_t *ohci, ohci_td_t *td) {
+int td_free(ohci_t *ohci, ohci_td_t *td)
+{
 	int i;
-	for(i = 0; i< MAX_OHCI_TD; i++ ) {
+    for ( i = 0; i< MAX_OHCI_TD; i++ )
+    {
                 if(_ohci_td_tag[i]==0) continue;
-		if(&_ohci_td[i] == td ) {
+        if ( &_ohci_td[i] == td )
+        {
 			_ohci_td_tag[i] = 0;
-			return 1;
+            return(1);
 		}
         }
-        return 0;
+    return(0);
 }
 
 
@@ -194,15 +203,17 @@
 {
         int i;  
         ohci_td_t *td;
-        for(i = 0; i< MAX_OHCI_TD; i++ ) {
+    for ( i = 0; i< MAX_OHCI_TD; i++ )
+    {
                 if(_ohci_td_tag[i]==0) continue;
 		td = &_ohci_td[i];
-                if(td->td_dma == td_dma ) {
-                        return td;
+        if ( td->td_dma == td_dma )
+        {
+            return(td);
                 }
         }
 	printf("dma_to_td: can not find td\n");
-        return 0;
+    return(0);
 
 }
 
@@ -216,34 +227,45 @@
 static int ohci_get_current_frame_number (struct usbdev *usb_dev)
 {
         ohci_t * ohci = &_ohci_x[usb_dev->controller]; 
- 
-        return le16_to_cpu (ohci->hcca->frame_no);
+    debug("ohci->hcca->frame_no: 0x%x\n", ohci->hcca->frame_no);
+    debug("be**ohci->hcca->frame_no: 0x%x\n", be16_to_cpu(ohci->hcca->frame_no));
+    return(le16_to_cpu (ohci->hcca->frame_no));
 }
  
-
-
 static u32 roothub_a (struct ohci *hc)
-        { return readl (&hc->regs->roothub.a); }
+{
+    return(readl (&hc->regs->roothub.a));
+}
 static inline u32 roothub_b (struct ohci *hc)
-        { return readl (&hc->regs->roothub.b); }
+{
+    return(readl (&hc->regs->roothub.b));
+}
 static inline u32 roothub_status (struct ohci *hc)
-        { return readl (&hc->regs->roothub.status); }
+{
+    return(readl (&hc->regs->roothub.status));
+}
 static u32 roothub_portstatus (struct ohci *hc, int i)
-        { return readl (&hc->regs->roothub.portstatus[i]);}
- 
- 
-#if DEBUG_USB==1
+{
+    return(readl (&hc->regs->roothub.portstatus[i]));
+}
 
+#ifdef OHCI_DEBUG_ALL
 #define OHCI_VERBOSE_DEBUG
-
 # define dbg(...) \
     do { printf(__VA_ARGS__); printf("\n"); } while (0)
+#else
+        #define dbg(...)
+#endif
 
+
+    #if DEBUG_USB==1
+
 static void urb_print (struct urb * urb, char * str, int small)
 {
         unsigned int pipe= urb->pipe;
         
-        if (!urb->dev ) { 
+    if ( !urb->dev )
+    {
                 dbg("%s URB: no dev", str);
                 return;
         }
@@ -267,13 +289,15 @@
 //        if (!small) {
                 int i, len;
 
-                if (usb_pipecontrol (pipe)) {
+    if ( usb_pipecontrol (pipe) )
+    {
                         printf ("ohci.c: cmd(8):");
                         for (i = 0; i < 8 ; i++)
                                 printf (" %02x", ((u8 *) urb->setup_packet) [i]);
                         printf ("\n");
                 }
-                if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
+    if ( urb->transfer_buffer_length > 0 && urb->transfer_buffer )
+    {
                          printf("ohci.c: data(%d/%d):",
                                 urb->actual_length,
                                 urb->transfer_buffer_length);
@@ -288,17 +312,20 @@
 }
 
 /* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
-void ep_print_int_eds (ohci_t * ohci, char * str) {
+void ep_print_int_eds (ohci_t * ohci, char * str)
+{
         int i, j;
          u32 * ed_p;
-        for (i= 0; i < 32; i++) {
+    for ( i= 0; i < 32; i++ )
+    {
                 j = 5;
                 ed_p = &(ohci->hcca->int_table [i]);
                 if (*ed_p == 0)
                     continue;
                 printf ("ohci.c: %s branch int %2d(%2x):", str, i, i);
 #if 0
-                while (*ed_p != 0 && j--) {
+        while ( *ed_p != 0 && j-- )
+        {
                         ed_t *ed = dma_to_ed (ohci, le32_to_cpup(ed_p));
                         printk (" ed: %4x;", ed->hwINFO);
                         ed_p = &ed->hwNextED;
@@ -330,13 +357,14 @@
 }
 static char *hcfs2string (int state)
 {
-        switch (state) {
-                case OHCI_USB_RESET:    return "reset";
-                case OHCI_USB_RESUME:   return "resume";
-                case OHCI_USB_OPER:     return "operational";
-                case OHCI_USB_SUSPEND:  return "suspend";
+    switch ( state )
+    {
+    case OHCI_USB_RESET:    return("reset");
+    case OHCI_USB_RESUME:   return("resume");
+    case OHCI_USB_OPER:     return("operational");
+    case OHCI_USB_SUSPEND:  return("suspend");
         }
-        return "?";
+    return("?");
 }
 // dump control and status registers
 static void ohci_dump_status (ohci_t *controller)
@@ -395,7 +423,8 @@
                 return;
         ndp = (temp & RH_A_NDP);
 
-        if (verbose) {
+    if ( verbose )
+    {
                 dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
                         ((temp & RH_A_POTPGT) >> 24) & 0xff,
                         (temp & RH_A_NOCP) ? " NOCP" : "",
@@ -423,7 +452,8 @@
                         );
         }
 
-        for (i = 0; i < ndp; i++) {
+    for ( i = 0; i < ndp; i++ )
+    {
                 temp = roothub_portstatus (controller, i);
                 dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
                         i,
@@ -463,7 +493,7 @@
         ohci = &_ohci_x[controller];
         ohci_dump (ohci, 1);
 }
-#endif
+    #endif /* DEBUG_USB==1 */
 
 /* link an ed into one of the HC chains */
 
@@ -478,18 +508,23 @@
 
         ed->state = ED_OPER;
 	
-        switch (ed->type) {
+    switch ( ed->type )
+    {
         case PIPE_CONTROL:
                 ed->hwNextED = 0;
-                if (ohci->ed_controltail == NULL) {
-//			debug("ep_link control 21 ed->dma = %x\n", (uint32_t)ed->dma);
+        if ( ohci->ed_controltail == NULL )
+        {
+            debug("ep_link control 21 ed->dma = %x\n", (uint32_t)ed->dma);
                         writel ((uint32_t)ed->dma, &ohci->regs->ed_controlhead);
-                } else {
-//			debug("ep_link control 22 ed->dma = %x\n", (uint32_t)ed->dma);
+        }
+        else
+        {
+            debug("ep_link control 22 ed->dma = %x\n", (uint32_t)ed->dma);
                         ohci->ed_controltail->hwNextED = cpu_to_le32 ((uint32_t)ed->dma);
                 }
                 ed->ed_prev = ohci->ed_controltail;
-                if (!ohci->ed_controltail) {
+        if ( !ohci->ed_controltail )
+        {
 			/* enable control ed list */
                         ohci->hc_control |= OHCI_CTRL_CLE;  //5
                         writel (ohci->hc_control, &ohci->regs->control);
@@ -499,15 +534,19 @@
 
         case PIPE_BULK:
                 ed->hwNextED = 0;
-                if (ohci->ed_bulktail == NULL) {
+        if ( ohci->ed_bulktail == NULL )
+        {
 		//	debug("ep_link control 31 ed->dma = %x\n", (uint32_t)ed->dma);
                         writel ((uint32_t)ed->dma, &ohci->regs->ed_bulkhead);
-                } else {
+        }
+        else
+        {
 		//	debug("ep_link control 32 ed->dma = %x\n", (uint32_t)ed->dma);
                         ohci->ed_bulktail->hwNextED = cpu_to_le32 ((uint32_t)ed->dma);
                 }
                 ed->ed_prev = ohci->ed_bulktail;
-                if (!ohci->ed_bulktail) {
+        if ( !ohci->ed_bulktail )
+        {
 			/* enable bulk ed list */
                         ohci->hc_control |= OHCI_CTRL_BLE;  //5
                         writel (ohci->hc_control, &ohci->regs->control);
@@ -515,7 +554,7 @@
                 ohci->ed_bulktail = edi;
                 break;
         }
-        return 0;
+    return(0);
 }
 /* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
  * but the USB stack is a little bit stateless  so we do it at every transaction
@@ -543,9 +582,11 @@
 	i = (usb_pipeendpoint (pipe) << 1) |(usb_pipecontrol (pipe)? 0: usb_pipeout (pipe));
         ed = (ed_t *)&ohci->ed[i];
 
-//	debug("ep_add_ed: usb_dev port=%x, controller = %d ohci=%x ohci->ed=%x ed=%x ed->dma=%x\n", usb_dev->port,usb_dev->controller, ohci, ohci->ed, ed, ed->dma);
+    dbg("ep_add_ed: usb_dev port=%x, controller = %d ohci=%x ohci->ed=%x ed=%x ed->dma=%x\n", 
+       usb_dev->port,usb_dev->controller, (unsigned)ohci, (unsigned)ohci->ed, (unsigned)ed, (unsigned)ed->dma);
 
-        if (ed->state == ED_NEW) {
+    if ( ed->state == ED_NEW )
+    {
                 ed->hwINFO = cpu_to_le32 (OHCI_ED_SKIP); /* skip ed */
                 /* dummy td; end of td list for ed */
                 td = td_alloc (ohci, 0);
@@ -556,7 +597,8 @@
                 ed->type = usb_pipetype (pipe);
                 ohci->ed_cnt++;  // we will be used to calcaulate next pipe
 
-//	        debug("ep_add_ed 1 td=%x dma=%x ed->dma=%x ed->hwHeadP=%x ed->hwTailP=%x\n", td, td->td_dma, ed->dma, ed->hwHeadP, ed->hwTailP); 
+        dbg("ep_add_ed 1 td=%x dma=%x ed->dma=%x ed->hwHeadP=%x ed->hwTailP=%x\n", 
+           (unsigned)td, (unsigned)td->td_dma, (unsigned)ed->dma, ed->hwHeadP, ed->hwTailP); 
 		
         }
 
@@ -569,9 +611,10 @@
                         | usb_pipeslow (pipe) << 13
                         | usb_maxpacket (usb_dev, pipe, usb_pipeout (pipe)) << 16);
 
-//	debug("ep_add_ed:  pipe=%x ed_num=%d ed->dma=%x ed->hwInfo=%x ed->hwHeadP=%x ed->hwTailP=%x\n", pipe, i, ed->dma, ed->hwINFO, ed->hwHeadP, ed->hwTailP);
+    dbg("ep_add_ed:  pipe=%x ed_num=%d ed->dma=%x ed->hwInfo=%x ed->hwHeadP=%x ed->hwTailP=%x\n", 
+        pipe, i, (unsigned)ed->dma, ed->hwINFO, ed->hwHeadP, ed->hwTailP);
 
-        return ed;
+    return(ed);
 }
 
 /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
@@ -584,7 +627,8 @@
         ohci_td_t  * td, * td_pt;
         urb_priv_t * urb_priv = urb->hcpriv;
         
-        if (index >= urb_priv->length) {
+    if ( index >= urb_priv->length )
+    {
                 printf("internal OHCI error: TD index > length");
                 return;
         }       
@@ -597,7 +641,8 @@
         td = urb_priv->td [index] = dma_to_td (ohci,
                         (void *)(le32_to_cpup (&urb_priv->ed->hwTailP) & ~0xf));
 	
-//	debug("td_fill 2 td = %x, dma=%x , ed->hwHeadP=%x, ed->hwTailP=%x \n", td, td->td_dma, urb_priv->ed->hwHeadP, urb_priv->ed->hwTailP ); 
+    dbg("td_fill 2 td = %x, dma=%x , ed->hwHeadP=%x, ed->hwTailP=%x \n", 
+        (unsigned)td, (unsigned)td->td_dma, urb_priv->ed->hwHeadP, urb_priv->ed->hwTailP ); 
 
         td->ed = urb_priv->ed;
         td->next_dl_td = NULL;
@@ -618,8 +663,9 @@
 
         /* append to queue */
         td->ed->hwTailP = td->hwNextTD;
- //	debug("td_fill 4 td->td_dma=%x, td->hwINFO=%x\n", td->td_dma, td->hwINFO );
- //       debug("td_fill 5 ed->dma=%x, ed->hwHeadP=%x, ed->hwTailP=%x \n", urb_priv->ed->dma, urb_priv->ed->hwHeadP, urb_priv->ed->hwTailP );
+    dbg("td_fill 4 td->td_dma=%x, td->hwINFO=%x\n", (unsigned)td->td_dma, td->hwINFO );
+    dbg("td_fill 5 ed->dma=%x, ed->hwHeadP=%x, ed->hwTailP=%x \n", 
+        (unsigned)urb_priv->ed->dma, urb_priv->ed->hwHeadP, urb_priv->ed->hwTailP );
 }
 
 /* prepare all TDs of a transfer */
@@ -636,24 +682,31 @@
 	void *setup_buffer;
 
         /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
-        if(usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe))) {
+    if ( usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe)) )
+    {
                 toggle = TD_T_TOGGLE;
-        } else {
+    }
+    else
+    {
                 toggle = TD_T_DATA0;
                 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 1);
         }
         
         urb_priv->td_cnt = 0;
         
-        if (data_len) {
+    if ( data_len )
+    {
                 data = (void *)virt_to_phys(urb->transfer_buffer);
-        } else  
+    }
+    else
                 data = 0;
-        switch (usb_pipetype (urb->pipe)) {
+    switch ( usb_pipetype (urb->pipe) )
+    {
                 case PIPE_BULK:
                         info = usb_pipeout (urb->pipe)?
                                 TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
-                        while(data_len > 4096) {
+        while ( data_len > 4096 )
+        {
                                 td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, urb, cnt);
                                 data += 4096; data_len -= 4096; cnt++;
                         }
@@ -669,13 +722,14 @@
                         if ((urb->transfer_flags & USB_ZERO_PACKET) &&
                             usb_pipeout (urb->pipe) &&
                             (urb->transfer_buffer_length != 0) &&
-                            ((urb->transfer_buffer_length % maxps) == 0)) {
+             ((urb->transfer_buffer_length % maxps) == 0) )
+        {
                                 td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), 0, 0, urb, cnt);
                                 cnt++;
                         }
 #endif
 
-//			debug("td_submit_urb 2 -- set OHCI_BLF\n");
+        dbg("td_submit_urb 2 -- set OHCI_BLF\n");
                         writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
                         (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
                         break;
@@ -684,9 +738,10 @@
                 case PIPE_CONTROL:
                         info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
 			setup_buffer = (void *)virt_to_phys(urb->setup_packet);	
-//			debug("td_sumbit_urb 11 setup_buffer = %x\n", setup_buffer);
+        dbg("td_sumbit_urb 11 setup_buffer = %x\n", (unsigned)setup_buffer);
         	        td_fill (ohci, info, setup_buffer , 8, urb, cnt++);
-                        if (data_len > 0) {
+        if ( data_len > 0 )
+        {
                                 info = usb_pipeout (urb->pipe)?
                                         TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
                                 /* NOTE:  mishandles transfers >8K, some >4K */
@@ -695,16 +750,17 @@
                         info = usb_pipeout (urb->pipe)?
                                 TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
                         td_fill (ohci, info, data, 0, urb, cnt++);
-//                        debug("td_sumbit_urb 11 data = %x\n", data);
+        dbg("td_sumbit_urb 11 data = %x\n", (unsigned)data);
 
-//			debug("td_submit_urb 2 -- set OHCI_CLF\n");
+        dbg("td_submit_urb 2 -- set OHCI_CLF\n");
                         writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
                         (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
                         break;
 
         }
-        if (urb_priv->length != cnt) {
-                debug("TD LENGTH %d != CNT %d", urb_priv->length, cnt);
+    if ( urb_priv->length != cnt )
+    {
+        dbg("TD LENGTH %d != CNT %d", urb_priv->length, cnt);
 	}
 }
 
@@ -717,8 +773,10 @@
         int             len;
         struct ohci_td       *td;
                         
-        if (last >= 0) {
+    if ( last >= 0 )
+    {
 #if 0
+
                 /* ISOC, BULK, INTR data buffer starts at td 0 
                  * CTRL setup starts at td 0 */
                 td = urb_priv->td [0];
@@ -726,7 +784,8 @@
                 len = td->urb->transfer_buffer_length;
                                 
                 /* unmap CTRL URB setup */
-                if (usb_pipecontrol (td->urb->pipe)) {
+        if ( usb_pipecontrol (td->urb->pipe) )
+        {
 // it should be freed in usb_control_msg_x
 //			forget2((void *)phys_to_virt((uint32_t)td->data_dma));  // 8 bytes
                  
@@ -736,13 +795,15 @@
                 } 
         
                 /* unmap data buffer */
-                if (len && td->data_dma) {
+        if ( len && td->data_dma )
+        {
 // Don't need
 //				forget2((void *)phys_to_virt((uint32_t)td->data_dma)); 
 			}
 #endif
  
-                for (i = 0; i <= last; i++) {
+        for ( i = 0; i <= last; i++ )
+        {
                         td = urb_priv->td [i];
                         if (td)
                                 td_free (hc, td);
@@ -765,41 +826,47 @@
         int mem_flags = 0;
 
         if (!urb->dev)
-                return -ENODEV;
+        return(-ENODEV);
 
         if (urb->hcpriv)                        /* urb already in use */
-                return -EINVAL;
+        return(-EINVAL);
 
 
         ohci = (ohci_t *) &_ohci_x[urb->dev->controller];
-//	printf("ohci_submit_urb: urb->dev port=%x, controller = %d ohci=%x ohci->ed=%x ohci->hcca=%x\n", urb->dev->port,urb->dev->controller, ohci, ohci->ed, ohci->hcca);
+    dbg("ohci_submit_urb: urb->dev port=%x, controller = %d ohci=%x ohci->ed=%x ohci->hcca=%x\n",
+        urb->dev->port,urb->dev->controller, (unsigned)ohci, (unsigned)ohci->ed, (unsigned)ohci->hcca);
 
 #if DEBUG_USB==1
-//        urb_print (urb, "SUB", usb_pipein (pipe));
+
+    urb_print (urb, "SUB", usb_pipein (pipe));
 #endif
 
 
 #if 0
+
         /* handle a request to the virtual root hub */
         if (usb_pipedevice (pipe) == ohci->rh.devnum)
-                return rh_submit_urb (urb);
+        return(rh_submit_urb (urb));
 
         /* when controller's hung, permit only roothub cleanup attempts
          * such as powering down ports */
-        if (ohci->disabled) {
+    if ( ohci->disabled )
+    {
                 usb_dec_dev_use (urb->dev);
-                return -ESHUTDOWN;
+        return(-ESHUTDOWN);
         }
 #endif
 
         /* every endpoint has a ed, locate and fill it */
-        if (!(ed = ep_add_ed (urb->dev, pipe, urb->interval, 1, mem_flags))) {
-                return -ENOMEM;
+    if ( !(ed = ep_add_ed (urb->dev, pipe, urb->interval, 1, mem_flags)) )
+    {
+        return(-ENOMEM);
         }
-//	debug("ohci_submit_usb: ed->dma=%x\n", ed->dma);
+    dbg("ohci_submit_usb: ed->dma=%x\n", (unsigned)ed->dma);
 
                                            /* for the private part of the URB we need the number of TDs (size) */
-        switch (usb_pipetype (pipe)) {
+    switch ( usb_pipetype (pipe) )
+    {
                 case PIPE_BULK: /* one TD for every 4096 Byte */
                         size = (urb->transfer_buffer_length - 1) / 4096 + 1;
 #if 0
@@ -822,9 +889,10 @@
         /* allocate the private part of the URB */
 #if URB_PRE_ALLOCATE!=1
         urb_priv = allot2 (sizeof (urb_priv_t) + size * sizeof (ohci_td_t *), 0xff);
-        if (urb_priv == 0) {
+    if ( urb_priv == 0 )
+    {
 		printf("ohci_submit_usb: urb_priv allocated no mem\n");
-                return -ENOMEM;
+        return(-ENOMEM);
         }
 #else 
 	urb_priv = ohci->urb_priv;
@@ -836,25 +904,29 @@
         urb_priv->ed = ed;
 
         /* allocate the TDs (updating hash chains) */
-        for (i = 0; i < size; i++) {
+    for ( i = 0; i < size; i++ )
+    {
                 urb_priv->td[i] = td_alloc (ohci, 0);
-                if (!urb_priv->td[i]) {
+        if ( !urb_priv->td[i] )
+        {
                         urb_priv->length = i;
                         urb_free_priv (ohci, urb_priv);
-                        return -ENOMEM;
+            return(-ENOMEM);
                 }
         }
 
-        if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
+    if ( ed->state == ED_NEW || (ed->state & ED_DEL) )
+    {
                 urb_free_priv (ohci, urb_priv);
-                return -EINVAL;
+        return(-EINVAL);
         }
 
         urb->actual_length = 0;
         urb->hcpriv = urb_priv;
         urb->status = USB_ST_URB_PENDING;
         /* link the ed into a chain if is not already */
-        if (ed->state != ED_OPER) {
+    if ( ed->state != ED_OPER )
+    {
                 ep_link (ohci, ed);
 	}
 
@@ -867,7 +939,7 @@
         (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
 #endif
 
-        return 0;
+    return(0);
 }
 /* calculate the transfer length and update the urb */
 
@@ -883,8 +955,10 @@
 
 
                 if (!(usb_pipetype (urb->pipe) == PIPE_CONTROL &&
-                                ((td->index == 0) || (td->index == urb_priv->length - 1)))) {
-                        if (tdBE != 0) {
+           ((td->index == 0) || (td->index == urb_priv->length - 1))) )
+    {
+        if ( tdBE != 0 )
+        {
                                 if (td->hwCBP == 0)
                                         urb->actual_length += tdBE - (uint32_t)td->data_dma + 1;
                                 else
@@ -893,7 +967,7 @@
 			
                 }
 
-//	debug("td->td_dma=%x, urb->actual_length=%d\n", td->td_dma, urb->actual_length);	
+    dbg("td->td_dma=%x, urb->actual_length=%d\n", (unsigned)td->td_dma, urb->actual_length);    
 }
 
 /*-------------------------------------------------------------------------*/
@@ -914,12 +988,14 @@
 // Here need to process across the frame tds
         td_list_hc = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
 	td_list_hc2 = readl(&ohci->regs->donehead);
-//	debug("ohci->hcca->done_head = %x ohci->hcca=%x ohci=%x ohci->regs->donehead=%x\n", td_list_hc, ohci->hcca, ohci, td_list_hc2);
+    dbg("ohci->hcca->done_head = %x ohci->hcca=%x ohci=%x ohci->regs->donehead=%x\n", 
+        td_list_hc, (unsigned)ohci->hcca, (unsigned)ohci, td_list_hc2);
 
 	td_list = dma_to_td (ohci, (void *)td_list_hc);
 	urb_priv = (urb_priv_t *) td_list->urb->hcpriv;
 	
-	while(/*(td_list_hc2!=0) || */(td_list->index < urb_priv->length-1) && (timeout>0)) { // wait another update for donehead
+    while ( /*(td_list_hc2!=0) || */(td_list->index < urb_priv->length-1) && (timeout>0) )
+    { // wait another update for donehead
 		// To handle 1. ohci->hcca->donehead !=0 and regs->donehead!=0
 		//	     2. ohci->hcca->donehead !=0 and regs->donehead ==0 but regs-->donehead will be filled 
 	
@@ -929,18 +1005,23 @@
         	value &= readl(&ohci->regs->intrenable);
 
 	//      We need to clear that the bit, otherwise We will not get next return.
-        	if(value & OHCI_INTR_WDH) {
+        if ( value & OHCI_INTR_WDH )
+        {
               		writel(value, &ohci->regs->intrstatus);
 	      		(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
-//		      debug("OHCI_INTR_WDH cleared intrstatus=%x value=%x \n", readl(&ohci->regs->intrstatus), value);
+            debug("OHCI_INTR_WDH cleared intrstatus=%x value=%x \n", readl(&ohci->regs->intrstatus), value);
         	}
-		while(timeout>0) {  // wait for next DONEHEAD_WRITEBACK
+        while ( timeout>0 )
+        {  // wait for next DONEHEAD_WRITEBACK
                 	value = readl(&ohci->regs->intrstatus);
-                	if(!(value & OHCI_INTR_WDH)) {
+            if ( !(value & OHCI_INTR_WDH) )
+            {
                         	udelay(1);
                         	timeout--;
                         	continue;
-                	} else {
+            }
+            else
+            {
                         	break;
                 	}
 		}
@@ -948,9 +1029,11 @@
 		td_list_hc2 = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
 		// merge td_list_hc the tail of td_list_hc2 
 
-		if(td_list_hc2!=0) {
+        if ( td_list_hc2!=0 )
+        {
 
-			while (td_list_hc2) {
+            while ( td_list_hc2 )
+            {
                 		td_list = dma_to_td (ohci, (void *)td_list_hc2);
                 		td_list_hc2 = le32_to_cpup (&td_list->hwNextTD) & 0xfffffff0;
 			}
@@ -960,7 +1043,9 @@
 			td_list_hc = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
 
 			td_list = dma_to_td (ohci, (void *)td_list_hc);
-		} else {
+        }
+        else
+        {
 			printf(".");
 		}
 		
@@ -969,7 +1054,7 @@
 	ohci->hcca->done_head = 0;
 	
 	value = readl(&ohci->regs->intrstatus);
-//        debug("OHCI_INTR_WDH value=%x \n", value);
+    dbg("OHCI_INTR_WDH value=%x \n", value);
         value &= readl(&ohci->regs->intrenable);
         
 //      We need to clear that the bit, otherwise We will not get next return.
@@ -980,7 +1065,8 @@
 //        }	
 
 #if 0	
-        if (value & OHCI_INTR_SO) {
+    if ( value & OHCI_INTR_SO )
+    {
                 debug("USB Schedule overrun");
                 writel (OHCI_INTR_SO, &ohci->regs->intrenable);
                 (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
@@ -988,21 +1074,26 @@
 #endif
            
 
-	while (td_list_hc) {
-//		debug("td_list_hc = %x\n", td_list_hc);
+    while ( td_list_hc )
+    {
+        dbg("td_list_hc = %x\n", td_list_hc);
                 td_list = dma_to_td (ohci, (void *)td_list_hc);
 
-                if (TD_CC_GET (le32_to_cpup (&td_list->hwINFO))) {
+        if ( TD_CC_GET (le32_to_cpup (&td_list->hwINFO)) )
+        {
                         urb_priv = (urb_priv_t *) td_list->urb->hcpriv;
                         debug(" USB-error/status: %x : %x\n",
-                                        TD_CC_GET (le32_to_cpup (&td_list->hwINFO)), td_list);
-                        if (td_list->ed->hwHeadP & cpu_to_le32 (0x1)) {
-                                if (urb_priv && ((td_list->index + 1) < urb_priv->length)) {
+                  TD_CC_GET (le32_to_cpup (&td_list->hwINFO)), (unsigned)td_list);
+            if ( td_list->ed->hwHeadP & cpu_to_le32 (0x1) )
+            {
+                if ( urb_priv && ((td_list->index + 1) < urb_priv->length) )
+                {
                                         td_list->ed->hwHeadP =
                                                 (urb_priv->td[urb_priv->length - 1]->hwNextTD & cpu_to_le32 (0xfffffff0)) |
                                                                         (td_list->ed->hwHeadP & cpu_to_le32 (0x2));
                                         urb_priv->td_cnt += urb_priv->length - td_list->index - 1;
-                                } else
+                }
+                else
                                         td_list->ed->hwHeadP &= cpu_to_le32 (0xfffffff2);
                         }
                 }
@@ -1011,7 +1102,7 @@
                 td_rev = td_list;
                 td_list_hc = le32_to_cpup (&td_list->hwNextTD) & 0xfffffff0;
         }
-        return td_list;
+    return(td_list);
 }
 /*-------------------------------------------------------------------------*/
 /* td done list */
@@ -1027,7 +1118,8 @@
 
 //        unsigned long flags;
 
-        while (td_list) {
+    while ( td_list )
+    {
                 td_list_next = td_list->next_dl_td;
 
                 urb = td_list->urb;
@@ -1049,18 +1141,22 @@
                                 && (cc == TD_DATAUNDERRUN))
                         cc = TD_CC_NOERROR;
 
-                if (++(urb_priv->td_cnt) == urb_priv->length) {
+        if ( ++(urb_priv->td_cnt) == urb_priv->length )
+        {
                         if ((ed->state & (ED_OPER | ED_UNLINK))
-                                        && (urb_priv->state != URB_DEL)) {
+                 && (urb_priv->state != URB_DEL) )
+            {
                                 urb->status = cc_to_error[cc];
                                 ohci_return_urb (ohci, urb);
                         } 
-			else {
+            else
+            {
                                 dl_del_urb (urb);
                         }
                 }
 
-                if (ed->state != ED_NEW) {
+        if ( ed->state != ED_NEW )
+        {
                         edHeadP = le32_to_cpup (&ed->hwHeadP) & 0xfffffff0;
                         edTailP = le32_to_cpup (&ed->hwTailP);
 
@@ -1074,7 +1170,8 @@
         }
 }
 
-void ohci_wait_urb_done(struct urb *urb, int timeout) { // timeout usually ==10000 --> 10milisecond
+void ohci_wait_urb_done(struct urb *urb, int timeout)
+{ // timeout usually ==10000 --> 10milisecond
         //here need to according the urb or ed type judge the BLF and CLF, We may need one time out in it
 	// Or need to check intrstatus and see if the hcca->done_head has been filled.
 	// We need to clear that the bit, otherwise We will get next return.
@@ -1083,24 +1180,32 @@
 	usbdev_t *usb_dev = urb->dev;
 	ohci_t *ohci = &_ohci_x[usb_dev->controller];
 	uint32_t type;
-	while(timeout>0) {
+    while ( timeout>0 )
+    {
 #if 1
 		value = readl(&ohci->regs->intrstatus);
-		if(!(value & OHCI_INTR_WDH)) {
+        if ( !(value & OHCI_INTR_WDH) )
+        {
 			udelay(1);
 			timeout--;
 			continue;
-		} else {
+        }
+        else
+        {
 			break;
 		}
 #endif
 	}
 #if 1
-	while (timeout>0) {
+    while ( timeout>0 )
+    {
                 type = usb_pipetype (pipe);
-                if(type ==PIPE_BULK) {
+        if ( type ==PIPE_BULK )
+        {
                                 if( (readl(&ohci->regs->cmdstatus) & OHCI_BLF) == 0) break;
-                } else if(type == PIPE_CONTROL) {
+        }
+        else if ( type == PIPE_CONTROL )
+        {
                                 if( (readl(&ohci->regs->cmdstatus) & OHCI_CLF) == 0) break;
                 }
                 udelay(1); // 
@@ -1110,8 +1215,10 @@
 
 	
 }
-void ohci_urb_complete(struct urb *urb) {
 
+void ohci_urb_complete(struct urb *urb)
+{
+
         ohci_t *ohci = &_ohci_x[urb->dev->controller];
         // it will clear the done list. and urb's actual_length is updated
         dl_done_list (ohci, dl_reverse_done_list (ohci));
@@ -1126,7 +1233,8 @@
 /*-------------------------------------------------------------------*/
 // it will 1. call usb_bulk_msg_x 
 // 	   2. call dl_list and find the data return
-int ohci_bulk_transfer( uchar devnum, uchar ep, unsigned int data_len, uchar *data) {
+int ohci_bulk_transfer( uchar devnum, uchar ep, unsigned int data_len, uchar *data)
+{
 	int actual_length;
         uint32_t t = devnum;
         uint32_t pipe = ((ep&0x80)? 0x80:0)|(t<<8)|(3<<30);
@@ -1135,7 +1243,7 @@
 	
 	usb_bulk_msg_x(&usb_device[devnum], pipe, data, data_len, &actual_length, 10000, ohci_urb_complete);
 	
-	return actual_length;
+    return(actual_length);
 
 
 }
@@ -1144,11 +1252,12 @@
 //		and assigned that to urb
 
 int ohci_control_msg( uchar devnum, uchar request_type, uchar request, unsigned short wValue, unsigned short wIndex, unsigned short
-wLength, void *data){
+                      wLength, void *data)
+{
 
 	uint32_t t = devnum;
         uint32_t pipe = ((request_type&0x80)? 0x80:0)|(t<<8)|(2<<30);
-	return usb_control_msg_x(&usb_device[devnum], pipe, request, request_type, wValue, wIndex, data, wLength, 10000, ohci_urb_complete);
+    return(usb_control_msg_x(&usb_device[devnum], pipe, request, request_type, wValue, wIndex, data, wLength, 10000, ohci_urb_complete));
 	
 }               
 
@@ -1163,15 +1272,19 @@
         ohci_t *ohci = &_ohci_x[controller];
 
 #ifndef __hppa__
+
         /* PA-RISC doesn't have SMM, but PDC might leave IR set */
-        if (readl (&ohci_regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
+    if ( readl (&ohci_regs->control) & OHCI_CTRL_IR )
+    { /* SMM owns the HC */
                 writel (OHCI_OCR, &ohci_regs->cmdstatus); /* request ownership */
                 debug("USB HC TakeOver from SMM");
-                while (readl (&ohci_regs->control) & OHCI_CTRL_IR) {
+        while ( readl (&ohci_regs->control) & OHCI_CTRL_IR )
+        {
                         mdelay (10);
-                        if (--smm_timeout == 0) {
+            if ( --smm_timeout == 0 )
+            {
                                 printf("USB HC TakeOver failed!");
-                                return -1;
+                return(-1);
                         }
                 }
         }
@@ -1190,18 +1303,20 @@
 
         /* HC Reset requires max 10 ms delay */
         writel (OHCI_HCR,  &ohci_regs->cmdstatus);
-        while ((readl (&ohci_regs->cmdstatus) & OHCI_HCR) != 0) {
-                if (--timeout == 0) {
+    while ( (readl (&ohci_regs->cmdstatus) & OHCI_HCR) != 0 )
+    {
+        if ( --timeout == 0 )
+        {
                         printf("USB HC reset timed out!");
-                        return -1;
+            return(-1);
                 }
                 udelay (1);
         }
-        return 0;
+    return(0);
 }
          
-
-int ohc_start(uchar controller) {
+int ohc_start(uchar controller)
+{
  //       unsigned short tmp;
 	u32 mask;
 	unsigned int fminterval;
@@ -1214,8 +1329,12 @@
         writel (0, &ohci_regs->ed_controlhead);
         writel (0, &ohci_regs->ed_bulkhead);
 
+    debug("ohci_regs->hcca = 0x%x\n", ohci_regs->hcca);
+
         writel ((uint32_t)ohci->hcca_dma, &ohci_regs->hcca); /* a reset clears this */ //3
 
+    debug("ohci_regs->hcca = 0x%x\n", ohci_regs->hcca);
+
         fminterval = 0x2edf;	//6
         writel ((fminterval * 9) / 10, &ohci_regs->periodicstart); // Don't worry, we can disable periodic in contol or let the ED list null
         fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
@@ -1237,14 +1356,14 @@
         writel (RH_HS_LPSC, &ohci->regs->roothub.status);
 
 	(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
-	
+    debug("PCI posting flush: 0x%x\n", ohci->regs->intrdisable);
         // POTPGT delay is bits 24-31, in 2 ms units.
 	delaytime = ((roothub_a (ohci) >> 23) & 0x1fe)*5/2; // for apacer 256 usb 2.0 + NEC 2.0 chip
 //	delaytime = ((roothub_a (ohci) >> 23) & 0x1fe);
 	
         mdelay (delaytime);
 	
-//	printf("delaytime: %d\n", delaytime);
+    debug("delaytime: %d\n", delaytime);
 	
         return(0);
 }
@@ -1260,6 +1379,7 @@
 	int size;
                 
         dword=pci_read32(dev->addr, 0x10);  // it will be 4k range
+    debug("dword: 0x%x\n", dword);
         hc_base[num_controllers] =  (uint32_t)phys_to_virt(dword);
 	ohci = &_ohci_x[num_controllers];
         debug("ohc_init num_controllers=%d ohci=%x\n", num_controllers, (uint32_t)ohci);	
@@ -1268,29 +1388,37 @@
 	ohci_regs  = ohci->regs;
 
         ohci->hcca = allot2(sizeof (struct ohci_hcca), 0xff); //1
-        if (!ohci->hcca) {
+    if ( !ohci->hcca )
+    {
 		printf("ohc_init: hcca allocated no MEM\n");
-                return -ENOMEM;
+        return(-ENOMEM);
         }
         memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
 	ohci->hcca_dma = (void *)virt_to_phys(ohci->hcca);
 
+    debug("ohci->hcca = 0x%x\n", (unsigned)ohci->hcca);
+    debug("ohci->hcca_dma = 0x%x\n", (unsigned)ohci->hcca_dma);
+
 	//init ed;
 	ohci->ed = allot2(sizeof(ed_t)*NUM_EDS,0xf);
-	if(ohci->ed==0) {
+    if ( ohci->ed==0 )
+    {
 		printf("ohci_init: ed allocate no MEM\n");
 	}
-//	debug("ohci->ed = %x\n", ohci->ed);
-	for(i=0; i<NUM_EDS;i++) {
+    debug("ohci->ed = %x\n", (unsigned)ohci->ed);
+    for ( i=0; i<NUM_EDS;i++ )
+    {
 		ed = (ed_t *)&ohci->ed[i];
+        debug("i=%d, ed->dma = %x\n", i, (unsigned)ed);
 		ed->dma = (void *)virt_to_phys(ed);
-//		debug("i=%d, ed dma = %x\n", i, (uint32_t)ed->dma);
+        debug("i=%d, ed dma = %x\n", i, (uint32_t)ed->dma);
 		ed->state = ED_NEW;
 	}
 
 //	init urb and urb_priv
         ohci->urb = (struct urb *)allot2(sizeof(struct urb),0xff);
-        if (!ohci->urb) {
+    if ( !ohci->urb )
+    {
                 printf("ohci_init:  urb allocate failed");
         }
         memset(ohci->urb, 0, sizeof(urb_t));
@@ -1299,13 +1427,15 @@
         /* allocate the private part of the URB */
 	size = 4;
         ohci->urb_priv = allot2 (sizeof (urb_priv_t) + size * sizeof (ohci_td_t *), 0xff);
-        if (ohci->urb_priv == 0) {
+    if ( ohci->urb_priv == 0 )
+    {
                 printf("ohci_init: urb_priv allocated no mem\n");
         }
         memset (ohci->urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (ohci_td_t *));
 
         // set master
         word=pci_read16(dev->addr, 0x04);
+    debug("word: 0x%x\n", word);
         word |= 0x04;
         pci_write16(dev->addr, 0x04, word);
 
@@ -1326,13 +1456,16 @@
 //	writel( 0xffffffff, &ohci_regs->intrdisable);
 
         NDP = readl(&ohci->regs->roothub.a) & 0xff;
-        for(j=0;j<NDP;j++) {
+    debug("NDP: 0x%x\n", NDP);
+    for ( j=0;j<NDP;j++ )
+    {
         	writel(RH_PS_PSS, &ohci->regs->roothub.portstatus[j]);
 	}
 
         /* FIXME this is a second HC reset; why?? */
         writel (ohci->hc_control = OHCI_USB_RESET, &ohci->regs->control);
         (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
+    debug("PCI posting flush: 0x%x\n", ohci->regs->intrdisable);
         mdelay (10);	
 
         ohc_start(num_controllers);
@@ -1340,12 +1473,32 @@
         num_controllers++;
 
 #if  DEBUG_USB==1
-//        ohci_dump (ohci, 1);
+    mdelay(1000);
+    ohci_dump (ohci, 1);
 #endif
 
-//	debug("ohci->ed = %x\n", ohci->ed);
+    debug("ohci->ed = %x\n", (unsigned)ohci->ed);
         return(0);
 }
+
+void ohc_graceful_stop(void)
+{
+    int     i;
+    ohci_t *ohci;
+
+    for(i = 0; i < num_controllers; i++) {
+        ohci = &_ohci_x[num_controllers];
+        ohc_reset(i);
+        ohc_stop(i);
+        /*urb_free_priv(ohci, ohci->urb_priv);*/
+        /* forget2(ohci->urb_priv); */
+        /*forget2(ohci->urb);*/
+        /*forget2(ohci->ed);*/
+        /*forget2(ohci->hcca);*/
+
+    }
+}
+
 int poll_o_root_hub(uint32_t port, uchar controller)
 {
         uint32_t value;
@@ -1359,38 +1512,43 @@
 	
 	debug("poll_o_root_hub1 v=%08x port = %x, controller = %d\n", value, port, controller);
 
-	if(value == 0xffffffff) return addr; // stupid port 
+    if ( value == 0xffffffff ) return(addr); // stupid port 
 
-        if((value & RH_PS_CSC) || do_over == port) {
+    if ( (value & RH_PS_CSC) || do_over == port )
+    {
 		debug("poll_o_root_hub2 v=%08x\t", value);
                 do_over=0;
-                if(value & RH_PS_CCS ) {     // if port connected
+        if ( value & RH_PS_CCS )
+        {     // if port connected
 			debug("poll_o_root_hub21 v=%08x\t", value);
                         DPRINTF("Connection on port %04x\n", port);
 
                         writel(value, port);
-                        for(i=0; i<40; i++) {
+            for ( i=0; i<40; i++ )
+            {
                                 udelay(10000+usec_offset);
                                 value = readl(port);
-                                if(value & RH_PS_CSC) {
+                if ( value & RH_PS_CSC )
+                {
                                         writel(value, port);  //Clear Change bit
                                         i=0;
                                         DPRINTF("BOUNCE!\n");
                                 }
                         }
-//	 	 	debug("poll_o_root_hub211 v=%08x\t", value);
+            debug("poll_o_root_hub211 v=%08x\t", value);
 
                         oport_wakeup(port);
-//                      DPRINTF("Wakup %04x\n", port);
+            DPRINTF("Wakup %04x\n", port);
                 
-//   		 	debug("poll_o_root_hub212 v=%08x\t", readl(port)); 
+            debug("poll_o_root_hub212 v=%08x\t", readl(port)); 
                         oport_reset(port);
-//  		     	debug("poll_o_root_hub213 v=%08x\t", readl(port));
+            debug("poll_o_root_hub213 v=%08x\t", readl(port));
                         mdelay(10);
                         oport_enable(port);
-// 		        debug("poll_o_root_hub214 v=%08x\t", readl(port));
+            debug("poll_o_root_hub214 v=%08x\t", readl(port));
                 
-                        if(!(value & RH_PS_CCS)) {
+            if ( !(value & RH_PS_CCS) )
+            {
                                 DPRINTF("Device went away!\n");
                                 return(-1);
                         }
@@ -1409,9 +1567,10 @@
 			usb_control_msg(addr, 0xa1, 0xfe, 0, 0, 1, &what); // get MAX L // get MAX LUN
 #endif
 
-//			debug("poll_o_root_hub215 v=%08x  addr = %d\n", readl(port), addr);
+            debug("poll_o_root_hub215 v=%08x  addr = %d\n", readl(port), addr);
 
-                        if(addr<0) {
+            if ( addr<0 )
+            {
                                 oport_disable(port);
                                 udelay(20000);
 //                              oport_reset(port);
@@ -1421,8 +1580,10 @@
                                 ohc_clear_stat(controller);
 
                         }
-                } else {
-//			debug("poll_o_root_hub22 v=%08x\t", readl(port));
+        }
+        else
+        {
+            debug("poll_o_root_hub22 v=%08x\t", readl(port));
                         oport_suspend(port);
                         oport_disable(port);
                         DPRINTF("Port %04x disconnected\n", port);
Index: drivers/usb/ohci.h
===================================================================
--- drivers/usb/ohci.h	(revision 45)
+++ drivers/usb/ohci.h	(working copy)
@@ -310,6 +310,7 @@
 
 void ohci_init(void);
 int ohc_init(struct pci_dev *dev);
+void ohc_graceful_stop(void);
 int ohci_submit_urb (struct urb * urb);
 #endif
 
Index: drivers/usb/uhci.c
===================================================================
--- drivers/usb/uhci.c	(revision 45)
+++ drivers/usb/uhci.c	(working copy)
@@ -238,7 +238,7 @@
 	queue_head_t *qh;
 
 	if(!trans) {
-		DPRINTF("new_transaction( td = %x) failed!\n", td);
+		DPRINTF("new_transaction( td = %x) failed!\n", (unsigned)td);
 		return(NULL);
 	}
 
@@ -301,7 +301,7 @@
 	memset(frame_list[dev], 0, 1024 * sizeof(link_pointer_t));
 
 
-	DPRINTF("frame_list is at %x\n", frame_list[dev]);
+	DPRINTF("frame_list is at %x\n", (unsigned)frame_list[dev]);
 
 	for(i=0;i<1024;i++)
 		frame_list[dev][i].terminate=1;
@@ -952,7 +952,8 @@
 #endif
 
 	if(data_len < len) {
-		DPRINTF("bulk_transfer( dev= %d, ep = %d, len = %d, buffer = %x) = %d:short transaction:\n", devnum, ep, len, data, data_len);
+		DPRINTF("bulk_transfer( dev= %d, ep = %d, len = %d, buffer = %x) = %d:short transaction:\n", 
+             devnum, ep, len, (unsigned)data, data_len);
 		dump_td(trans->td_list, "short_transaction:");
 	}
 
Index: drivers/usb/usb.c
===================================================================
--- drivers/usb/usb.c	(revision 45)
+++ drivers/usb/usb.c	(working copy)
@@ -94,6 +94,12 @@
 	ohci_init();
 }
 
+/* fainshf: temporal hack */
+void hci_stop(void)
+{
+    debug("Stopping USB ...\n");
+    ohc_graceful_stop();
+}
 
 int next_usb_dev;
 usbdev_t usb_device[MAX_USB_DEV];
@@ -508,7 +514,7 @@
 		usb_device[addr].protocol = iface->bInterfaceProtocol;
 	}
 
-	printf("%02x:%02x:%02x\n", usb_device[addr].class, usb_device[addr].subclass, usb_device[addr].protocol);
+	debug("class:subclass:protocol=%02x:%02x:%02x\n", usb_device[addr].class, usb_device[addr].subclass, usb_device[addr].protocol);
 #if 0
 	get_string(addr, desc->iManufacturor, sizeof(string), string);
 	printf("Manufacturor: %s\n", string);
