[ltp] patch for thinkpad-modules under 2.6.9-rc2
Theodore Ts'o
linux-thinkpad@linux-thinkpad.org
Thu, 16 Sep 2004 08:26:41 -0400
--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Sep 15, 2004 at 05:24:55PM -0400, Ari Pollak wrote:
> the format of referencing cpu_gdt_table changed in 2.6.9, so the
> attached patch fixes compiling thinkpad-modules under it.
Here's the patch I hacked up, which has backwards compatibility with
older kernels, plus another one to avoid a gcc warning.
- Ted
--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="2.6-portability"
Index: thinkpad/2.6/drivers/thinkpadpm.c
===================================================================
--- thinkpad.orig/2.6/drivers/thinkpadpm.c 2004-01-20 02:24:43.000000000 -0500
+++ thinkpad/2.6/drivers/thinkpadpm.c 2004-09-12 16:33:06.083722231 -0400
@@ -175,6 +175,14 @@
# define APM_DO_RESTORE_SEGS
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#define get_gdt_table() (cpu_gdt_table[get_cpu()])
+#define put_gdt_table() put_cpu()
+#else
+#define get_gdt_table() (get_cpu_ptr(cpu_gdt_table))
+#define put_gdt_table() put_cpu_ptr(cpu_gdt_table)
+#endif
+
/**
* apm_bios_call - Make an APM BIOS 32bit call
* @func: APM function to execute
@@ -201,14 +209,13 @@
APM_DECL_SEGS
unsigned long flags;
unsigned long cpus;
- int cpu;
- struct desc_struct save_desc_40;
+ struct desc_struct save_desc_40, *desc40_ptr;
cpus = apm_save_cpus();
- cpu = get_cpu();
- save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
- cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
+ desc40_ptr = get_gdt_table() + (0x40/8);
+ save_desc_40 = *desc40_ptr;
+ *desc40_ptr = bad_bios_desc;
local_save_flags(flags);
APM_DO_CLI;
@@ -231,8 +238,8 @@
: "memory", "cc");
APM_DO_RESTORE_SEGS;
local_irq_restore(flags);
- cpu_gdt_table[cpu][0x40 / 8] = save_desc_40;
- put_cpu();
+ *desc40_ptr = save_desc_40;
+ put_gdt_table();
apm_restore_cpus(cpus);
return *eax & 0xff;
@@ -258,15 +265,13 @@
APM_DECL_SEGS
unsigned long flags;
unsigned long cpus;
- int cpu;
- struct desc_struct save_desc_40;
-
+ struct desc_struct save_desc_40, *desc40_ptr;
cpus = apm_save_cpus();
- cpu = get_cpu();
- save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
- cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
+ desc40_ptr = get_gdt_table() + (0x40/8);
+ save_desc_40 = *desc40_ptr;
+ *desc40_ptr = bad_bios_desc;
local_save_flags(flags);
APM_DO_CLI;
@@ -293,8 +298,8 @@
}
APM_DO_RESTORE_SEGS;
local_irq_restore(flags);
- cpu_gdt_table[smp_processor_id()][0x40 / 8] = save_desc_40;
- put_cpu();
+ *desc40_ptr = save_desc_40;
+ put_gdt_table();
apm_restore_cpus(cpus);
return error;
}
--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="2.6-indirect"
Index: thinkpad/2.6/drivers/smapi_call.s
===================================================================
--- thinkpad.orig/2.6/drivers/smapi_call.s 2001-01-08 16:41:53.000000000 -0500
+++ thinkpad/2.6/drivers/smapi_call.s 2004-09-12 16:45:52.288097932 -0400
@@ -47,7 +47,7 @@
movl $0,%eax
movw %cs,wSegSmapiBios
- lcall farpxSmapiBios
+ lcall *farpxSmapiBios
add $0x10,%esp
popl %ebp
--/04w6evG8XlLl3ft--