## Automatically generated incremental diff
## From:   linux-2.4.22-bk38
## To:     linux-2.4.22-bk39
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.4.22-bk38/Documentation/Configure.help linux-2.4.22-bk39/Documentation/Configure.help
--- linux-2.4.22-bk38/Documentation/Configure.help	2003-10-23 02:50:31.000000000 -0700
+++ linux-2.4.22-bk39/Documentation/Configure.help	2003-10-23 02:50:40.000000000 -0700
@@ -8395,7 +8395,7 @@
   If you want to compile the driver as a module ( = code which can be
   inserted in and removed from the running kernel whenever you want),
   say M here and read <file:Documentation/modules.txt>.  The module
-  will be called sym53c8xx.o.
+  will be called sym53c8xx_2.o.
 
 PCI DMA addressing mode
 CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE
@@ -19587,30 +19587,8 @@
   The ACPI Sourceforge project may also be of interest:
   <http://sf.net/projects/acpi/>
 
-ACPI Processor Enumeration for HT
-CONFIG_ACPI_HT_ONLY
-  ACPI enumerates both logical (a.k.a. Hyper-Threaded -- HT)
-  and physical processors.  It is designed to obsolete several older
-  specifications, including the MultiProcessor Specification (MPS),
-  which supported only physical processors.
-
-  CONFIG_ACPI_HT_ONLY includes just the minimal ACPI boot-time code
-  necessary to enumerate logical processors and enable HT.
-
-  CONFIG_ACPI includes this code, plus IO APIC enumeration,
-  and the hooks to run the ACPI AML interpreter for run-time events.
-
-  When CONFIG_ACPI is selected, the command-line option "acpi=ht"
-  is available to run just the ACPI boot-time code -- just as if
-  only CONFIG_ACPI_HT_ONLY were selected.
-
   Note that "acpi=off" can be used to disable all ACPI code in the kernel.
 
-Enable ACPI 2.0 with errata 1.3
-CONFIG_ACPI20
-  Enable support for the 2.0 version of the ACPI interpreter.  See the
-  help for ACPI for caveats and discussion.
-
 ACPI kernel configuration manager
 CONFIG_ACPI_KERNEL_CONFIG
   If you say `Y' here, Linux's ACPI support will use the
@@ -19630,23 +19608,6 @@
   particular, many Toshiba laptops require this for correct operation
   of the AC module.
 
-ACPI Bus Manager
-CONFIG_ACPI_BUSMGR
-  The ACPI Bus Manager enumerates devices in the ACPI namespace, and
-  handles PnP messages.  All ACPI devices use its services, so using
-  them requires saying Y here.
-
-ACPI System Driver
-CONFIG_ACPI_SYS
-  This driver will enable your system to shut down using ACPI, and
-  dump your ACPI DSDT table using /proc/acpi/dsdt.
-
-ACPI Processor Driver
-CONFIG_ACPI_CPU
-  This driver installs ACPI as the idle handler for Linux, and uses
-  ACPI C2 and C3 processor states to save power, on systems that
-  support it.
-
 ACPI Button
 CONFIG_ACPI_BUTTON
   This driver registers for events based on buttons, such as the
@@ -19681,11 +19642,6 @@
   the battery and thermal drivers.  If you are compiling for a laptop,
   say Y.
 
-ACPI Control Method Battery
-CONFIG_ACPI_CMBATT
-  This driver adds support for battery information through
-  /proc/acpi/battery. If you have a laptop with a battery, say Y.
-
 ACPI Thermal
 CONFIG_ACPI_THERMAL
   This driver handles overheating conditions on laptops. It is HIGHLY
diff -urN linux-2.4.22-bk38/Makefile linux-2.4.22-bk39/Makefile
--- linux-2.4.22-bk38/Makefile	2003-10-23 02:50:31.000000000 -0700
+++ linux-2.4.22-bk39/Makefile	2003-10-23 02:50:40.000000000 -0700
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 22
-EXTRAVERSION = -bk38
+EXTRAVERSION = -bk39
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
@@ -28,7 +28,7 @@
 AS		= $(CROSS_COMPILE)as
 LD		= $(CROSS_COMPILE)ld
 CC		= $(CROSS_COMPILE)gcc
-CPP		= $(CC) -E
+PP		= $(CC) -E
 AR		= $(CROSS_COMPILE)ar
 NM		= $(CROSS_COMPILE)nm
 STRIP		= $(CROSS_COMPILE)strip
diff -urN linux-2.4.22-bk38/arch/i386/kernel/acpi.c linux-2.4.22-bk39/arch/i386/kernel/acpi.c
--- linux-2.4.22-bk38/arch/i386/kernel/acpi.c	2003-10-23 02:50:31.000000000 -0700
+++ linux-2.4.22-bk39/arch/i386/kernel/acpi.c	2003-10-23 02:50:40.000000000 -0700
@@ -470,6 +470,34 @@
 
 #endif /*CONFIG_ACPI_BOOT*/
 
+#ifdef	CONFIG_ACPI_BUS
+/*
+ * Set specified PIC IRQ to level triggered mode.
+ *
+ * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
+ * for the 8259 PIC.  bit[n] = 1 means irq[n] is Level, otherwise Edge.
+ * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
+ * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
+ *
+ * As the BIOS should have done this for us,
+ * print a warning if the IRQ wasn't already set to level.
+ */
+
+void acpi_pic_set_level_irq(unsigned int irq)
+{
+	unsigned char mask = 1 << (irq & 7);
+	unsigned int port = 0x4d0 + (irq >> 3);
+	unsigned char val = inb(port);
+
+	if (!(val & mask)) {
+		printk(KERN_WARNING PREFIX "IRQ %d was Edge Triggered, "
+			"setting to Level Triggerd\n", irq);
+		outb(val | mask, port);
+	}
+}
+#endif /* CONFIG_ACPI_BUS */
+
+
 
 /* --------------------------------------------------------------------------
                               Low-Level Sleep Support
diff -urN linux-2.4.22-bk38/arch/i386/kernel/dmi_scan.c linux-2.4.22-bk39/arch/i386/kernel/dmi_scan.c
--- linux-2.4.22-bk38/arch/i386/kernel/dmi_scan.c	2003-10-23 02:50:31.000000000 -0700
+++ linux-2.4.22-bk39/arch/i386/kernel/dmi_scan.c	2003-10-23 02:50:40.000000000 -0700
@@ -481,7 +481,7 @@
 
 
 #ifdef	CONFIG_ACPI_BOOT
-extern int acpi_disabled, use_acpi_pci, acpi_force, acpi_ht;
+extern int acpi_disabled, acpi_force, acpi_ht;
 
 static __init __attribute__((unused)) int acpi_disable(struct dmi_blacklist *d) 
 { 
@@ -511,14 +511,18 @@
 	}
 	return 0;
 } 
+#endif	/* CONFIG_ACPI_BOOT */
 
+#ifdef	CONFIG_ACPI_PCI
 static __init int disable_acpi_pci(struct dmi_blacklist *d) 
 { 
-	printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", d->ident); 	
-	use_acpi_pci = 0; 
+	extern __init void pci_disable_acpi(void) ;
+
+	printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n", d->ident);
+	pci_disable_acpi();
 	return 0;
 } 
-#endif
+#endif	/* CONFIG_ACPI_PCI */
 
 /*
  *	Process the DMI blacklists
@@ -920,6 +924,8 @@
 			MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
 			NO_MATCH, NO_MATCH }},
 
+#endif	/* CONFIG_ACPI_BOOT */
+#ifdef	CONFIG_ACPI_PCI
 	/*
 	 *	Boxes that need ACPI PCI IRQ routing disabled
 	 */
@@ -930,7 +936,7 @@
 			/* newer BIOS, Revision 1011, does work */
 			MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"),
 			NO_MATCH }},
-#endif	// CONFIG_ACPI_BOOT
+#endif	/* CONFIG_ACPI_PCI */
 
 	{ NULL, }
 };
diff -urN linux-2.4.22-bk38/arch/i386/kernel/pci-pc.c linux-2.4.22-bk39/arch/i386/kernel/pci-pc.c
--- linux-2.4.22-bk38/arch/i386/kernel/pci-pc.c	2003-10-23 02:50:31.000000000 -0700
+++ linux-2.4.22-bk39/arch/i386/kernel/pci-pc.c	2003-10-23 02:50:40.000000000 -0700
@@ -1415,7 +1415,13 @@
 	return;
 }
 
-int use_acpi_pci __initdata = 1;
+static int use_acpi_pci __initdata = 1;
+
+__init void pci_disable_acpi(void)
+{
+	use_acpi_pci = 0;
+	return;
+}
 
 void __init pcibios_init(void)
 {
@@ -1505,7 +1511,7 @@
 		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
 		return NULL;
 	} else if (!strncmp(str, "noacpi", 6)) {
-		use_acpi_pci = 0;
+		pci_disable_acpi();
 		return NULL;
 	}
 	return str;
diff -urN linux-2.4.22-bk38/drivers/acpi/battery.c linux-2.4.22-bk39/drivers/acpi/battery.c
--- linux-2.4.22-bk38/drivers/acpi/battery.c	2003-08-25 04:44:40.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/battery.c	2003-10-23 02:50:40.000000000 -0700
@@ -348,7 +348,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_info");
 
-	if (!battery)
+	if (!battery || (off != 0))
 		goto end;
 
 	if (battery->flags.present)
@@ -447,7 +447,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_state");
 
-	if (!battery)
+	if (!battery || (off != 0))
 		goto end;
 
 	if (battery->flags.present)
@@ -531,7 +531,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
 
-	if (!battery)
+	if (!battery || (off != 0))
 		goto end;
 
 	if (!battery->flags.present) {
diff -urN linux-2.4.22-bk38/drivers/acpi/bus.c linux-2.4.22-bk39/drivers/acpi/bus.c
--- linux-2.4.22-bk38/drivers/acpi/bus.c	2003-10-23 02:50:32.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/bus.c	2003-10-23 02:50:40.000000000 -0700
@@ -49,7 +49,7 @@
 
 #define	PREFIX			"ACPI: "
 
-extern void eisa_set_level_irq(unsigned int irq);
+extern void acpi_pic_set_level_irq(unsigned int irq);
 
 extern int			acpi_disabled;
 
@@ -1881,7 +1881,7 @@
         if (acpi_ioapic)
          	mp_config_ioapic_for_sci(acpi_fadt.sci_int);
 	else
-                eisa_set_level_irq(acpi_fadt.sci_int);
+		acpi_pic_set_level_irq(acpi_fadt.sci_int);
 #endif
 
 	status = acpi_enable_subsystem(ACPI_FULL_INITIALIZATION);
diff -urN linux-2.4.22-bk38/drivers/acpi/button.c linux-2.4.22-bk39/drivers/acpi/button.c
--- linux-2.4.22-bk38/drivers/acpi/button.c	2003-08-25 04:44:41.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/button.c	2003-10-23 02:50:40.000000000 -0700
@@ -85,7 +85,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_button_read_info");
 
-	if (!button || !button->device)
+	if (!button || !button->device || (off != 0))
 		goto end;
 
 	p += sprintf(p, "type:                    %s\n", 
@@ -119,7 +119,7 @@
 
 	ACPI_FUNCTION_TRACE("acpi_button_lid_read_state");
 
-	if (!button || !button->device)
+	if (!button || !button->device || (off != 0))
 		goto end;
 
 	status=acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
diff -urN linux-2.4.22-bk38/drivers/acpi/ec.c linux-2.4.22-bk39/drivers/acpi/ec.c
--- linux-2.4.22-bk38/drivers/acpi/ec.c	2003-10-23 02:50:32.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/ec.c	2003-10-23 02:50:40.000000000 -0700
@@ -90,6 +90,13 @@
 /* External interfaces use first EC only, so remember */
 static struct acpi_device *first_ec;
 
+/*
+ * We use kernel thread to handle ec's gpe query, so the query may defer.
+ * The query need a context, which can be freed when we replace ec_ecdt
+ * with EC device. So defered query may have a wrong context.
+ * We use an indication to avoid it
+ */
+static int ec_device_init = 0;
 /* --------------------------------------------------------------------------
                              Transaction Management
    -------------------------------------------------------------------------- */
@@ -389,8 +396,11 @@
 
 	acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
 
-	status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
-		acpi_ec_gpe_query, ec);
+	if (!ec_device_init)
+		acpi_ec_gpe_query(ec); /* directly query when device didn't init */
+	else
+		status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
+			acpi_ec_gpe_query, ec);
 }
 
 /* --------------------------------------------------------------------------
@@ -585,6 +595,8 @@
 	   we now have the *real* EC info, so kill the makeshift one.*/
 	acpi_evaluate_integer(ec->handle, "_UID", NULL, &uid);
 	if (ec_ecdt && ec_ecdt->uid == uid) {
+		acpi_disable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR);
+		ec_device_init = 1;
 		acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
 			ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
 	
diff -urN linux-2.4.22-bk38/drivers/acpi/events/evgpe.c linux-2.4.22-bk39/drivers/acpi/events/evgpe.c
--- linux-2.4.22-bk38/drivers/acpi/events/evgpe.c	2003-08-25 04:44:41.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/events/evgpe.c	2003-10-23 02:50:40.000000000 -0700
@@ -218,7 +218,7 @@
 
 					int_status |= acpi_ev_gpe_dispatch (
 							  &gpe_block->event_info[gpe_number],
-							  gpe_number + gpe_block->register_info[gpe_number].base_gpe_number);
+							  j + gpe_register_info->base_gpe_number);
 				}
 			}
 		}
diff -urN linux-2.4.22-bk38/drivers/acpi/power.c linux-2.4.22-bk39/drivers/acpi/power.c
--- linux-2.4.22-bk38/drivers/acpi/power.c	2003-08-25 04:44:41.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/power.c	2003-10-23 02:50:40.000000000 -0700
@@ -323,6 +323,9 @@
 	if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
 		return_VALUE(-EINVAL);
 
+	if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3))
+		return_VALUE(-ENODEV);
+
 	cl = &device->power.states[device->power.state].resources;
 	tl = &device->power.states[state].resources;
 
@@ -345,8 +348,6 @@
 			goto end;
 	}
 
-	device->power.state = state;
-
 	/*
 	 * Then we dereference all power resources used in the current list.
 	 */
@@ -356,6 +357,8 @@
 			goto end;
 	}
 
+	/* We shouldn't change the state till all above operations succeed */
+	device->power.state = state;
 end:
 	if (result)
 		ACPI_DEBUG_PRINT((ACPI_DB_WARN, 
diff -urN linux-2.4.22-bk38/drivers/acpi/utilities/utdelete.c linux-2.4.22-bk39/drivers/acpi/utilities/utdelete.c
--- linux-2.4.22-bk38/drivers/acpi/utilities/utdelete.c	2003-08-25 04:44:41.000000000 -0700
+++ linux-2.4.22-bk39/drivers/acpi/utilities/utdelete.c	2003-10-23 02:50:40.000000000 -0700
@@ -416,7 +416,7 @@
 	u32                             i;
 	union acpi_generic_state         *state_list = NULL;
 	union acpi_generic_state         *state;
-
+	union acpi_operand_object        *tmp;
 
 	ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
 
@@ -448,8 +448,16 @@
 		switch (ACPI_GET_OBJECT_TYPE (object)) {
 		case ACPI_TYPE_DEVICE:
 
-			acpi_ut_update_ref_count (object->device.system_notify, action);
-			acpi_ut_update_ref_count (object->device.device_notify, action);
+			tmp = object->device.system_notify;
+			if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
+				object->device.system_notify = NULL;
+			acpi_ut_update_ref_count (tmp, action);
+
+			tmp = object->device.device_notify;
+			if (tmp && (tmp->common.reference_count <= 1) && action == REF_DECREMENT)
+				object->device.device_notify = NULL;
+			acpi_ut_update_ref_count (tmp, action);
+
 			break;
 
 
@@ -470,6 +478,10 @@
 				if (ACPI_FAILURE (status)) {
 					goto error_exit;
 				}
+
+				tmp = object->package.elements[i];
+				if (tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+					object->package.elements[i] = NULL;
 			}
 			break;
 
@@ -481,6 +493,10 @@
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+
+			tmp = object->buffer_field.buffer_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->buffer_field.buffer_obj = NULL;
 			break;
 
 
@@ -491,6 +507,10 @@
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+
+			tmp = object->field.region_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->field.region_obj = NULL;
 		   break;
 
 
@@ -502,11 +522,19 @@
 				goto error_exit;
 			}
 
+			tmp = object->bank_field.bank_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->bank_field.bank_obj = NULL;
+
 			status = acpi_ut_create_update_state_and_push (
 					 object->bank_field.region_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+
+			tmp = object->bank_field.region_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->bank_field.region_obj = NULL;
 			break;
 
 
@@ -518,11 +546,19 @@
 				goto error_exit;
 			}
 
+			tmp = object->index_field.index_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->index_field.index_obj = NULL;
+
 			status = acpi_ut_create_update_state_and_push (
 					 object->index_field.data_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+
+			tmp = object->index_field.data_obj;
+			if ( tmp && (tmp->common.reference_count <= 1)  && action == REF_DECREMENT)
+				object->index_field.data_obj = NULL;
 			break;
 
 
diff -urN linux-2.4.22-bk38/drivers/char/tty_io.c linux-2.4.22-bk39/drivers/char/tty_io.c
--- linux-2.4.22-bk38/drivers/char/tty_io.c	2003-10-23 02:50:34.000000000 -0700
+++ linux-2.4.22-bk39/drivers/char/tty_io.c	2003-10-23 02:50:41.000000000 -0700
@@ -455,8 +455,6 @@
 		redirect = NULL;
 	}
 	spin_unlock(&redirect_lock);
-	if (f)
-		fput(f);
 	
 	check_tty_count(tty, "do_tty_hangup");
 	file_list_lock();
@@ -543,6 +541,8 @@
 	} else if (tty->driver.hangup)
 		(tty->driver.hangup)(tty);
 	unlock_kernel();
+	if (f)
+		fput(f);
 }
 
 void tty_hangup(struct tty_struct * tty)
diff -urN linux-2.4.22-bk38/drivers/ide/ide-disk.c linux-2.4.22-bk39/drivers/ide/ide-disk.c
--- linux-2.4.22-bk38/drivers/ide/ide-disk.c	2003-06-13 07:51:33.000000000 -0700
+++ linux-2.4.22-bk39/drivers/ide/ide-disk.c	2003-10-23 02:50:41.000000000 -0700
@@ -1196,7 +1196,7 @@
 		drive->bios_cyl		= drive->cyl;
 		drive->capacity48	= capacity_2;
 		drive->capacity		= (unsigned long) capacity_2;
-		return;
+		goto check_capacity48;
 	/* Determine capacity, and use LBA if the drive properly supports it */
 	} else if ((id->capability & 2) && lba_capacity_is_ok(id)) {
 		capacity = id->lba_capacity;
@@ -1228,6 +1228,15 @@
 		drive->sect = 63;
 		drive->cyl = (unsigned long)(drive->capacity48) / (drive->head * drive->sect);
 	}
+
+check_capacity48:
+	/* Limit disk size to 137GB if LBA48 addressing is not supported */
+	if (drive->addressing == 0 && drive->capacity48 > (1ULL)<<28) {
+		printk("%s: cannot use LBA48 - capacity reset "
+			"from %llu to %llu\n",
+			drive->name, drive->capacity48, (1ULL)<<28);
+		drive->capacity48 = (1ULL)<<28;
+	}
 }
 
 static unsigned long idedisk_capacity (ide_drive_t *drive)
diff -urN linux-2.4.22-bk38/drivers/ide/pci/pdc202xx_old.c linux-2.4.22-bk39/drivers/ide/pci/pdc202xx_old.c
--- linux-2.4.22-bk38/drivers/ide/pci/pdc202xx_old.c	2003-08-25 04:44:41.000000000 -0700
+++ linux-2.4.22-bk39/drivers/ide/pci/pdc202xx_old.c	2003-10-23 02:50:41.000000000 -0700
@@ -697,9 +697,6 @@
 	hwif->tuneproc  = &config_chipset_for_pio;
 	hwif->quirkproc = &pdc202xx_quirkproc;
 
-	if (hwif->pci_dev->device == PCI_DEVICE_ID_PROMISE_20265)
-		hwif->addressing = (hwif->channel) ? 0 : 1;
-
 	if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) {
 		hwif->busproc   = &pdc202xx_tristate;
 		hwif->resetproc = &pdc202xx_reset;
diff -urN linux-2.4.22-bk38/drivers/ide/pci/serverworks.c linux-2.4.22-bk39/drivers/ide/pci/serverworks.c
--- linux-2.4.22-bk38/drivers/ide/pci/serverworks.c	2003-06-13 07:51:33.000000000 -0700
+++ linux-2.4.22-bk39/drivers/ide/pci/serverworks.c	2003-10-23 02:50:41.000000000 -0700
@@ -273,7 +273,7 @@
 
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= hwif->pci_dev;
-	u8 speed		= ide_rate_filter(svwks_ratemask(drive), xferspeed);
+	u8 speed;
 	u8 pio			= ide_get_best_pio_mode(drive, 255, 5, NULL);
 	u8 unit			= (drive->select.b.unit & 0x01);
 	u8 csb5			= svwks_csb_check(dev);
@@ -281,6 +281,11 @@
 	u8 dma_timing		= 0, pio_timing = 0;
 	u16 csb5_pio		= 0;
 
+	if (xferspeed == 255)	/* PIO auto-tuning */
+		speed = XFER_PIO_0 + pio;
+	else
+		speed = ide_rate_filter(svwks_ratemask(drive), xferspeed);
+
 	/* If we are about to put a disk into UDMA mode we screwed up.
 	   Our code assumes we never _ever_ do this on an OSB4 */
 	   
diff -urN linux-2.4.22-bk38/drivers/video/aty/atyfb_base.c linux-2.4.22-bk39/drivers/video/aty/atyfb_base.c
--- linux-2.4.22-bk38/drivers/video/aty/atyfb_base.c	2003-10-23 02:50:36.000000000 -0700
+++ linux-2.4.22-bk39/drivers/video/aty/atyfb_base.c	2003-10-23 02:50:44.000000000 -0700
@@ -323,7 +323,8 @@
        It's also often a good idea to contact ATi.
        
        Lastly, third party board vendors might use different memory clocks
-       than ATi. No examples of this have been found yet, but it is possible.
+       than ATi. An example of this is the Apple iBook1 which is handled specially
+       in aty_init.
        
        (Daniel Mantione, 26 June 2003)
      */
@@ -356,7 +357,7 @@
 
     /* Mach64 LT */
     { 0x4c54, 0x4c54, 0x00, 0x00, m64n_lt,      135,  63,  63, M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP },
-    { 0x4c47, 0x4c47, 0x00, 0x00, m64n_ltg,     230,  63,  63, M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_LT_SLEEP | M64F_G3_PB_1024x768 },
+    { 0x4c47, 0x4c47, 0x00, 0x00, m64n_ltg,     230,  63,  63, M64F_GT | M64F_INTEGRATED | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT | M64F_LT_SLEEP | M64F_G3_PB_1024x768 | M64F_FIFO_24 },
 
     /* Mach64 GTC (3D RAGE PRO) */
     { 0x4742, 0x4742, 0x00, 0x00, m64n_gtc_ba,  230, 100, 100, M64F_GT | M64F_INTEGRATED | M64F_RESET_3D | M64F_GTB_DSP | M64F_SDRAM_MAGIC_PLL | M64F_EXTRA_BRIGHT },
@@ -2075,6 +2076,14 @@
         ramname = aty_ct_ram[info->ram_type];
         info->dac_ops = &aty_dac_ct;
         info->pll_ops = &aty_pll_ct;
+#ifdef CONFIG_ALL_PPC
+	/* The Apple iBook1 uses non-standard memory frequencies. We detect it
+	   and set the frequency manually. */
+	if ((type==0x4c4e) && machine_is_compatible("PowerBook2,1")) {
+	    mclk=70;
+	    xclk=53;
+	};
+#endif
 	/*
 	 * I disable the hack below because it is completely unreliable. 
 	 * DRAM at 67 is very well imaginable. If a chip is indeed clocked
