Pull thinkpad into release branch
authorLen Brown <len.brown@intel.com>
Sun, 22 Jul 2007 06:28:06 +0000 (02:28 -0400)
committerLen Brown <len.brown@intel.com>
Sun, 22 Jul 2007 06:28:06 +0000 (02:28 -0400)
52 files changed:
Documentation/feature-removal-schedule.txt
MAINTAINERS
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
arch/sparc/kernel/entry.S
arch/sparc/kernel/irq.c
arch/sparc/kernel/irq.h [new file with mode: 0644]
arch/sparc/kernel/pcic.c
arch/sparc/kernel/smp.c
arch/sparc/kernel/sparc_ksyms.c
arch/sparc/kernel/sun4c_irq.c
arch/sparc/kernel/sun4d_irq.c
arch/sparc/kernel/sun4d_smp.c
arch/sparc/kernel/sun4m_irq.c
arch/sparc/kernel/sun4m_smp.c
arch/sparc/kernel/tick14.c
arch/sparc/kernel/time.c
arch/sparc/mm/init.c
arch/sparc/mm/srmmu.c
arch/sparc/mm/sun4c.c
arch/sparc64/kernel/sparc64_ksyms.c
drivers/acpi/Kconfig
drivers/acpi/battery.c
drivers/acpi/bay.c
drivers/acpi/dock.c
drivers/acpi/ec.c
drivers/acpi/events/evgpeblk.c
drivers/acpi/events/evrgnini.c
drivers/acpi/glue.c
drivers/acpi/pci_link.c
drivers/acpi/processor_idle.c
drivers/acpi/sbs.c
drivers/acpi/sleep/main.c
drivers/acpi/tables/tbfadt.c
drivers/misc/sony-laptop.c
drivers/net/Kconfig
drivers/net/irda/Kconfig
drivers/net/irda/Makefile
drivers/net/irda/ep7211-sir.c [new file with mode: 0644]
include/acpi/acmacros.h
include/acpi/acoutput.h
include/acpi/platform/acenv.h
include/acpi/platform/aclinux.h
include/asm-sparc/irq.h
include/asm-sparc/pgtable.h
include/linux/irda.h
include/linux/netdevice.h
net/core/dev.c
net/core/sock.c
net/ipv4/inetpeer.c
net/ipv6/ip6_tunnel.c
net/irda/irnetlink.c

index a5cb783..c175eed 100644 (file)
@@ -180,24 +180,11 @@ Who:   Adrian Bunk <bunk@stusta.de>
 
 ---------------------------
 
-What:  /sys/firmware/acpi/namespace
-When:  2.6.21
-Why:   The ACPI namespace is effectively the symbol list for
-       the BIOS.  The device names are completely arbitrary
-       and have no place being exposed to user-space.
-
-       For those interested in the BIOS ACPI namespace,
-       the BIOS can be extracted and disassembled with acpidump
-       and iasl as documented in the pmtools package here:
-       http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils
-Who:   Len Brown <len.brown@intel.com>
-
----------------------------
-
 What:  ACPI procfs interface
-When:  July 2007
-Why:   After ACPI sysfs conversion, ACPI attributes will be duplicated
-       in sysfs and the ACPI procfs interface should be removed.
+When:  July 2008
+Why:   ACPI sysfs conversion should be finished by January 2008.
+       ACPI procfs interface will be removed in July 2008 so that
+       there is enough time for the user space to catch up.
 Who:   Zhang Rui <rui.zhang@intel.com>
 
 ---------------------------
index 773c732..a9b9ef6 100644 (file)
@@ -225,15 +225,15 @@ T:        git kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
 S:     Supported
 
 ACPI BATTERY DRIVERS
-P:     Vladimir P. Lebedev
-M:     vladimir.p.lebedev@intel.com
+P:     Alexey Starikovskiy
+M:     astarikovskiy@suse.de
 L:     linux-acpi@vger.kernel.org
 W:     http://acpi.sourceforge.net/
 S:     Supported
 
 ACPI EC DRIVER
 P:     Alexey Starikovskiy
-M:     alexey.y.starikovskiy@linux.intel.com
+M:     astarikovskiy@suse.de
 L:     linux-acpi@vger.kernel.org
 W:     http://acpi.sourceforge.net/
 S:     Supported
index b87cede..cacdd88 100644 (file)
@@ -986,14 +986,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
         },
        {
         .callback = force_acpi_ht,
-        .ident = "DELL GX240",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
-                    DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
-                    },
-        },
-       {
-        .callback = force_acpi_ht,
         .ident = "HP VISUALIZE NT Workstation",
         .matches = {
                     DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
index 18c8b67..6f846be 100644 (file)
@@ -665,8 +665,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
        data->max_freq = perf->states[0].core_frequency * 1000;
        /* table init */
        for (i=0; i<perf->state_count; i++) {
-               if (i>0 && perf->states[i].core_frequency ==
-                   perf->states[i-1].core_frequency)
+               if (i>0 && perf->states[i].core_frequency >=
+                   data->freq_table[valid_states-1].frequency / 1000)
                        continue;
 
                data->freq_table[valid_states].index = i;
index 831f540..eac3838 100644 (file)
@@ -1749,8 +1749,8 @@ fpload:
 __ndelay:
        save    %sp, -STACKFRAME_SZ, %sp
        mov     %i0, %o0
-       call    .umul
-        mov    0x1ad, %o1              ! 2**32 / (1 000 000 000 / HZ)
+       call    .umul                   ! round multiplier up so large ns ok
+        mov    0x1ae, %o1              ! 2**32 / (1 000 000 000 / HZ)
        call    .umul
         mov    %i1, %o1                ! udelay_val
        ba      delay_continue
@@ -1760,11 +1760,17 @@ __ndelay:
 __udelay:
        save    %sp, -STACKFRAME_SZ, %sp
        mov     %i0, %o0
-       sethi   %hi(0x10c6), %o1
+       sethi   %hi(0x10c7), %o1        ! round multiplier up so large us ok
        call    .umul
-        or     %o1, %lo(0x10c6), %o1   ! 2**32 / 1 000 000
+        or     %o1, %lo(0x10c7), %o1   ! 2**32 / 1 000 000
        call    .umul
         mov    %i1, %o1                ! udelay_val
+       sethi   %hi(0x028f4b62), %l0    ! Add in rounding constant * 2**32,
+       or      %g0, %lo(0x028f4b62), %l0
+       addcc   %o0, %l0, %o0           ! 2**32 * 0.009 999
+       bcs,a   3f
+        add    %o1, 0x01, %o1
+3:
        call    .umul
         mov    HZ, %o0                 ! >>32 earlier for wider range
 
index f257a67..75b2240 100644 (file)
@@ -47,6 +47,8 @@
 #include <asm/cacheflush.h>
 #include <asm/irq_regs.h>
 
+#include "irq.h"
+
 #ifdef CONFIG_SMP
 #define SMP_NOP2 "nop; nop;\n\t"
 #define SMP_NOP3 "nop; nop; nop;\n\t"
@@ -268,7 +270,7 @@ void free_irq(unsigned int irq, void *dev_id)
        kfree(action);
 
        if (!sparc_irq[cpu_irq].action)
-               disable_irq(irq);
+               __disable_irq(irq);
 
 out_unlock:
        spin_unlock_irqrestore(&irq_action_lock, flags);
@@ -464,7 +466,7 @@ int request_fast_irq(unsigned int irq,
 
        sparc_irq[cpu_irq].action = action;
 
-       enable_irq(irq);
+       __enable_irq(irq);
 
        ret = 0;
 out_unlock:
@@ -544,7 +546,7 @@ int request_irq(unsigned int irq,
 
        *actionp = action;
 
-       enable_irq(irq);
+       __enable_irq(irq);
 
        ret = 0;
 out_unlock:
@@ -555,6 +557,25 @@ out:
 
 EXPORT_SYMBOL(request_irq);
 
+void disable_irq_nosync(unsigned int irq)
+{
+       return __disable_irq(irq);
+}
+EXPORT_SYMBOL(disable_irq_nosync);
+
+void disable_irq(unsigned int irq)
+{
+       return __disable_irq(irq);
+}
+EXPORT_SYMBOL(disable_irq);
+
+void enable_irq(unsigned int irq)
+{
+       return __enable_irq(irq);
+}
+
+EXPORT_SYMBOL(enable_irq);
+
 /* We really don't need these at all on the Sparc.  We only have
  * stubs here because they are exported to modules.
  */
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
new file mode 100644 (file)
index 0000000..32ef3eb
--- /dev/null
@@ -0,0 +1,68 @@
+#include <asm/btfixup.h>
+
+/* Dave Redman (djhr@tadpole.co.uk)
+ * changed these to function pointers.. it saves cycles and will allow
+ * the irq dependencies to be split into different files at a later date
+ * sun4c_irq.c, sun4m_irq.c etc so we could reduce the kernel size.
+ * Jakub Jelinek (jj@sunsite.mff.cuni.cz)
+ * Changed these to btfixup entities... It saves cycles :)
+ */
+
+BTFIXUPDEF_CALL(void, disable_irq, unsigned int)
+BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
+BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
+BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
+BTFIXUPDEF_CALL(void, clear_clock_irq, void)
+BTFIXUPDEF_CALL(void, clear_profile_irq, int)
+BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
+
+static inline void __disable_irq(unsigned int irq)
+{
+       BTFIXUP_CALL(disable_irq)(irq);
+}
+
+static inline void __enable_irq(unsigned int irq)
+{
+       BTFIXUP_CALL(enable_irq)(irq);
+}
+
+static inline void disable_pil_irq(unsigned int irq)
+{
+       BTFIXUP_CALL(disable_pil_irq)(irq);
+}
+
+static inline void enable_pil_irq(unsigned int irq)
+{
+       BTFIXUP_CALL(enable_pil_irq)(irq);
+}
+
+static inline void clear_clock_irq(void)
+{
+       BTFIXUP_CALL(clear_clock_irq)();
+}
+
+static inline void clear_profile_irq(int irq)
+{
+       BTFIXUP_CALL(clear_profile_irq)(irq);
+}
+
+static inline void load_profile_irq(int cpu, int limit)
+{
+       BTFIXUP_CALL(load_profile_irq)(cpu, limit);
+}
+
+extern void (*sparc_init_timers)(irq_handler_t lvl10_irq);
+
+extern void claim_ticker14(irq_handler_t irq_handler,
+                          int irq,
+                          unsigned int timeout);
+
+#ifdef CONFIG_SMP
+BTFIXUPDEF_CALL(void, set_cpu_int, int, int)
+BTFIXUPDEF_CALL(void, clear_cpu_int, int, int)
+BTFIXUPDEF_CALL(void, set_irq_udt, int)
+
+#define set_cpu_int(cpu,level) BTFIXUP_CALL(set_cpu_int)(cpu,level)
+#define clear_cpu_int(cpu,level) BTFIXUP_CALL(clear_cpu_int)(cpu,level)
+#define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
+#endif
index 7917711..f2eae45 100644 (file)
@@ -36,6 +36,7 @@
 #include <asm/uaccess.h>
 #include <asm/irq_regs.h>
 
+#include "irq.h"
 
 /*
  * I studied different documents and many live PROMs both from 2.30
index 4fea3ac..6724ab9 100644 (file)
@@ -33,6 +33,8 @@
 #include <asm/tlbflush.h>
 #include <asm/cpudata.h>
 
+#include "irq.h"
+
 int smp_num_cpus = 1;
 volatile unsigned long cpu_callin_map[NR_CPUS] __initdata = {0,};
 unsigned char boot_cpu_id = 0;
index d8e008a..55bac51 100644 (file)
@@ -154,8 +154,6 @@ EXPORT_SYMBOL(BTFIXUP_CALL(___xchg32));
 #else
 EXPORT_SYMBOL(BTFIXUP_CALL(__hard_smp_processor_id));
 #endif
-EXPORT_SYMBOL(BTFIXUP_CALL(enable_irq));
-EXPORT_SYMBOL(BTFIXUP_CALL(disable_irq));
 EXPORT_SYMBOL(BTFIXUP_CALL(mmu_unlockarea));
 EXPORT_SYMBOL(BTFIXUP_CALL(mmu_lockarea));
 EXPORT_SYMBOL(BTFIXUP_CALL(mmu_get_scsi_sgl));
index 009e891..c6ac9fc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include "irq.h"
 
 #include <asm/ptrace.h>
 #include <asm/processor.h>
@@ -40,6 +41,20 @@ static struct resource sun4c_timer_eb = { "sun4c_timer" };
 static struct resource sun4c_intr_eb = { "sun4c_intr" };
 #endif
 
+/*
+ * Bit field defines for the interrupt registers on various
+ * Sparc machines.
+ */
+
+/* The sun4c interrupt register. */
+#define SUN4C_INT_ENABLE  0x01     /* Allow interrupts. */
+#define SUN4C_INT_E14     0x80     /* Enable level 14 IRQ. */
+#define SUN4C_INT_E10     0x20     /* Enable level 10 IRQ. */
+#define SUN4C_INT_E8      0x10     /* Enable level 8 IRQ. */
+#define SUN4C_INT_E6      0x08     /* Enable level 6 IRQ. */
+#define SUN4C_INT_E4      0x04     /* Enable level 4 IRQ. */
+#define SUN4C_INT_E1      0x02     /* Enable level 1 IRQ. */
+
 /* Pointer to the interrupt enable byte
  *
  * Dave Redman (djhr@tadpole.co.uk)
index 396797e..e0efab2 100644 (file)
@@ -39,6 +39,8 @@
 #include <asm/cacheflush.h>
 #include <asm/irq_regs.h>
 
+#include "irq.h"
+
 /* If you trust current SCSI layer to handle different SCSI IRQs, enable this. I don't trust it... -jj */
 /* #define DISTRIBUTE_IRQS */
 
@@ -188,7 +190,7 @@ void sun4d_free_irq(unsigned int irq, void *dev_id)
        kfree(action);
 
        if (!(*actionp))
-               disable_irq(irq);
+               __disable_irq(irq);
 
 out_unlock:
        spin_unlock_irqrestore(&irq_action_lock, flags);
@@ -346,7 +348,7 @@ int sun4d_request_irq(unsigned int irq,
        else
                *actionp = action;
                
-       enable_irq(irq);
+       __enable_irq(irq);
 
        ret = 0;
 out_unlock:
index 098c94f..89a6de9 100644 (file)
@@ -36,6 +36,7 @@
 #include <asm/cacheflush.h>
 #include <asm/cpudata.h>
 
+#include "irq.h"
 #define IRQ_CROSS_CALL         15
 
 extern ctxd_t *srmmu_ctx_table_phys;
index 91a803e..b92d6d2 100644 (file)
 #include <asm/sbus.h>
 #include <asm/cacheflush.h>
 
+#include "irq.h"
+
+/* On the sun4m, just like the timers, we have both per-cpu and master
+ * interrupt registers.
+ */
+
+/* These registers are used for sending/receiving irqs from/to
+ * different cpu's.
+ */
+struct sun4m_intreg_percpu {
+       unsigned int tbt;        /* Interrupts still pending for this cpu. */
+
+       /* These next two registers are WRITE-ONLY and are only
+        * "on bit" sensitive, "off bits" written have NO affect.
+        */
+       unsigned int clear;  /* Clear this cpus irqs here. */
+       unsigned int set;    /* Set this cpus irqs here. */
+       unsigned char space[PAGE_SIZE - 12];
+};
+
+/*
+ * djhr
+ * Actually the clear and set fields in this struct are misleading..
+ * according to the SLAVIO manual (and the same applies for the SEC)
+ * the clear field clears bits in the mask which will ENABLE that IRQ
+ * the set field sets bits in the mask to DISABLE the IRQ.
+ *
+ * Also the undirected_xx address in the SLAVIO is defined as
+ * RESERVED and write only..
+ *
+ * DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
+ *             sun4m machines, for MP the layout makes more sense.
+ */
+struct sun4m_intregs {
+       struct sun4m_intreg_percpu cpu_intregs[SUN4M_NCPUS];
+       unsigned int tbt;                /* IRQ's that are still pending. */
+       unsigned int irqs;               /* Master IRQ bits. */
+
+       /* Again, like the above, two these registers are WRITE-ONLY. */
+       unsigned int clear;              /* Clear master IRQ's by setting bits here. */
+       unsigned int set;                /* Set master IRQ's by setting bits here. */
+
+       /* This register is both READ and WRITE. */
+       unsigned int undirected_target;  /* Which cpu gets undirected irqs. */
+};
+
 static unsigned long dummy;
 
 struct sun4m_intregs *sun4m_interrupts;
 unsigned long *irq_rcvreg = &dummy;
 
+/* Dave Redman (djhr@tadpole.co.uk)
+ * The sun4m interrupt registers.
+ */
+#define SUN4M_INT_ENABLE       0x80000000
+#define SUN4M_INT_E14          0x00000080
+#define SUN4M_INT_E10          0x00080000
+
+#define SUN4M_HARD_INT(x)      (0x000000001 << (x))
+#define SUN4M_SOFT_INT(x)      (0x000010000 << (x))
+
+#define        SUN4M_INT_MASKALL       0x80000000        /* mask all interrupts */
+#define        SUN4M_INT_MODULE_ERR    0x40000000        /* module error */
+#define        SUN4M_INT_M2S_WRITE     0x20000000        /* write buffer error */
+#define        SUN4M_INT_ECC           0x10000000        /* ecc memory error */
+#define        SUN4M_INT_FLOPPY        0x00400000        /* floppy disk */
+#define        SUN4M_INT_MODULE        0x00200000        /* module interrupt */
+#define        SUN4M_INT_VIDEO         0x00100000        /* onboard video */
+#define        SUN4M_INT_REALTIME      0x00080000        /* system timer */
+#define        SUN4M_INT_SCSI          0x00040000        /* onboard scsi */
+#define        SUN4M_INT_AUDIO         0x00020000        /* audio/isdn */
+#define        SUN4M_INT_ETHERNET      0x00010000        /* onboard ethernet */
+#define        SUN4M_INT_SERIAL        0x00008000        /* serial ports */
+#define        SUN4M_INT_KBDMS         0x00004000        /* keyboard/mouse */
+#define        SUN4M_INT_SBUSBITS      0x00003F80        /* sbus int bits */
+
+#define SUN4M_INT_SBUS(x)      (1 << (x+7))
+#define SUN4M_INT_VME(x)       (1 << (x))
+
 /* These tables only apply for interrupts greater than 15..
  * 
  * any intr value below 0x10 is considered to be a soft-int
index 63ed19b..730eb57 100644 (file)
@@ -31,6 +31,8 @@
 #include <asm/oplib.h>
 #include <asm/cpudata.h>
 
+#include "irq.h"
+
 #define IRQ_RESCHEDULE         13
 #define IRQ_STOP_CPU           14
 #define IRQ_CROSS_CALL         15
index f1a7bd1..707bfda 100644 (file)
@@ -25,6 +25,8 @@
 #include <asm/irq.h>
 #include <asm/io.h>
 
+#include "irq.h"
+
 extern unsigned long lvl14_save[5];
 static unsigned long *linux_lvl14 = NULL;
 static unsigned long obp_lvl14[4];
@@ -62,7 +64,7 @@ void claim_ticker14(irq_handler_t handler,
 
        /* first we copy the obp handler instructions
         */
-       disable_irq(irq_nr);
+       __disable_irq(irq_nr);
        if (!handler)
                return;
     
@@ -79,6 +81,6 @@ void claim_ticker14(irq_handler_t handler,
                         NULL)) {
                install_linux_ticker();
                load_profile_irq(cpu, timeout);
-               enable_irq(irq_nr);
+               __enable_irq(irq_nr);
        }
 }
index f2fdbb3..6a25133 100644 (file)
@@ -44,6 +44,8 @@
 #include <asm/of_device.h>
 #include <asm/irq_regs.h>
 
+#include "irq.h"
+
 DEFINE_SPINLOCK(rtc_lock);
 enum sparc_clock_type sp_clock_typ;
 DEFINE_SPINLOCK(mostek_lock);
index a532922..a1bef07 100644 (file)
@@ -308,6 +308,9 @@ extern void sun4c_paging_init(void);
 extern void srmmu_paging_init(void);
 extern void device_scan(void);
 
+pgprot_t PAGE_SHARED __read_mostly;
+EXPORT_SYMBOL(PAGE_SHARED);
+
 void __init paging_init(void)
 {
        switch(sparc_cpu_model) {
index ca26232..17b485f 100644 (file)
@@ -2154,7 +2154,7 @@ void __init ld_mmu_srmmu(void)
        BTFIXUPSET_SIMM13(ptrs_per_pgd, SRMMU_PTRS_PER_PGD);
 
        BTFIXUPSET_INT(page_none, pgprot_val(SRMMU_PAGE_NONE));
-       BTFIXUPSET_INT(page_shared, pgprot_val(SRMMU_PAGE_SHARED));
+       PAGE_SHARED = pgprot_val(SRMMU_PAGE_SHARED);
        BTFIXUPSET_INT(page_copy, pgprot_val(SRMMU_PAGE_COPY));
        BTFIXUPSET_INT(page_readonly, pgprot_val(SRMMU_PAGE_RDONLY));
        BTFIXUPSET_INT(page_kernel, pgprot_val(SRMMU_PAGE_KERNEL));
index bdd835f..a57a366 100644 (file)
@@ -2155,7 +2155,7 @@ void __init ld_mmu_sun4c(void)
        BTFIXUPSET_SIMM13(user_ptrs_per_pgd, KERNBASE / SUN4C_PGDIR_SIZE);
 
        BTFIXUPSET_INT(page_none, pgprot_val(SUN4C_PAGE_NONE));
-       BTFIXUPSET_INT(page_shared, pgprot_val(SUN4C_PAGE_SHARED));
+       PAGE_SHARED = pgprot_val(SUN4C_PAGE_SHARED);
        BTFIXUPSET_INT(page_copy, pgprot_val(SUN4C_PAGE_COPY));
        BTFIXUPSET_INT(page_readonly, pgprot_val(SUN4C_PAGE_READONLY));
        BTFIXUPSET_INT(page_kernel, pgprot_val(SUN4C_PAGE_KERNEL));
index 7d36531..d270c2f 100644 (file)
@@ -280,6 +280,7 @@ EXPORT_SYMBOL(sys_getgid);
 EXPORT_SYMBOL(svr4_getcontext);
 EXPORT_SYMBOL(svr4_setcontext);
 EXPORT_SYMBOL(compat_sys_ioctl);
+EXPORT_SYMBOL(sys_ioctl);
 EXPORT_SYMBOL(sparc32_open);
 #endif
 
index 139f41f..501ed6f 100644 (file)
@@ -2,16 +2,12 @@
 # ACPI Configuration
 #
 
-menu "ACPI (Advanced Configuration and Power Interface) Support"
+menuconfig ACPI
+       bool "ACPI Support (Advanced Configuration and Power Interface) Support"
        depends on !X86_NUMAQ
        depends on !X86_VISWS
        depends on !IA64_HP_SIM
        depends on IA64 || X86
-       depends on PM
-
-config ACPI
-       bool "ACPI Support"
-       depends on IA64 || X86
        depends on PCI
        depends on PM
        select PNP
@@ -49,7 +45,6 @@ if ACPI
 config ACPI_SLEEP
        bool "Sleep States"
        depends on X86 && (!SMP || SUSPEND_SMP)
-       depends on PM
        default y
        ---help---
          This option adds support for ACPI suspend states. 
@@ -82,7 +77,6 @@ config ACPI_SLEEP_PROC_SLEEP
 
 config ACPI_PROCFS
        bool "Procfs interface (deprecated)"
-       depends on ACPI
        default y
        ---help---
          The Procfs interface for ACPI is made optional for backward compatibility.
@@ -280,6 +274,14 @@ config ACPI_DEBUG
          of verbosity. Saying Y enables these statements. This will increase
          your kernel size by around 50K.
 
+config ACPI_DEBUG_FUNC_TRACE
+       bool "Additionally enable ACPI function tracing"
+       default n
+       depends on ACPI_DEBUG
+       help
+         ACPI Debug Statements slow down ACPI processing. Function trace
+         is about half of the penalty and is rarely useful.
+
 config ACPI_EC
        bool
        default y
@@ -330,7 +332,6 @@ config ACPI_CONTAINER
 
 config ACPI_HOTPLUG_MEMORY
        tristate "Memory Hotplug"
-       depends on ACPI
        depends on MEMORY_HOTPLUG
        default n
        help
@@ -359,5 +360,3 @@ config ACPI_SBS
          to today's ACPI "Control Method" battery.
 
 endif  # ACPI
-
-endmenu
index e64c76c..cad932d 100644 (file)
 #define ACPI_BATTERY_CLASS             "battery"
 #define ACPI_BATTERY_HID               "PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME       "Battery"
-#define ACPI_BATTERY_FILE_INFO         "info"
-#define ACPI_BATTERY_FILE_STATUS       "state"
-#define ACPI_BATTERY_FILE_ALARM                "alarm"
 #define ACPI_BATTERY_NOTIFY_STATUS     0x80
 #define ACPI_BATTERY_NOTIFY_INFO       0x81
 #define ACPI_BATTERY_UNITS_WATTS       "mW"
 #define ACPI_BATTERY_UNITS_AMPS                "mA"
 
 #define _COMPONENT             ACPI_BATTERY_COMPONENT
+
+#define ACPI_BATTERY_UPDATE_TIME       0
+
+#define ACPI_BATTERY_NONE_UPDATE       0
+#define ACPI_BATTERY_EASY_UPDATE       1
+#define ACPI_BATTERY_INIT_UPDATE       2
+
 ACPI_MODULE_NAME("battery");
 
 MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI Battery Driver");
 MODULE_LICENSE("GPL");
 
+static unsigned int update_time = ACPI_BATTERY_UPDATE_TIME;
+
+/* 0 - every time, > 0 - by update_time */
+module_param(update_time, uint, 0644);
+
 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
 extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
 
@@ -76,7 +85,7 @@ static struct acpi_driver acpi_battery_driver = {
                },
 };
 
-struct acpi_battery_status {
+struct acpi_battery_state {
        acpi_integer state;
        acpi_integer present_rate;
        acpi_integer remaining_capacity;
@@ -99,33 +108,111 @@ struct acpi_battery_info {
        acpi_string oem_info;
 };
 
-struct acpi_battery_flags {
-       u8 present:1;           /* Bay occupied? */
-       u8 power_unit:1;        /* 0=watts, 1=apms */
-       u8 alarm:1;             /* _BTP present? */
-       u8 reserved:5;
+enum acpi_battery_files{
+       ACPI_BATTERY_INFO = 0,
+       ACPI_BATTERY_STATE,
+       ACPI_BATTERY_ALARM,
+       ACPI_BATTERY_NUMFILES,
 };
 
-struct acpi_battery_trips {
-       unsigned long warning;
-       unsigned long low;
+struct acpi_battery_flags {
+       u8 battery_present_prev;
+       u8 alarm_present;
+       u8 init_update;
+       u8 update[ACPI_BATTERY_NUMFILES];
+       u8 power_unit;
 };
 
 struct acpi_battery {
-       struct acpi_device * device;
+       struct mutex mutex;
+       struct acpi_device *device;
        struct acpi_battery_flags flags;
-       struct acpi_battery_trips trips;
+       struct acpi_buffer bif_data;
+       struct acpi_buffer bst_data;
        unsigned long alarm;
-       struct acpi_battery_info *info;
+       unsigned long update_time[ACPI_BATTERY_NUMFILES];
 };
 
+inline int acpi_battery_present(struct acpi_battery *battery)
+{
+       return battery->device->status.battery_present;
+}
+inline char *acpi_battery_power_units(struct acpi_battery *battery)
+{
+       if (battery->flags.power_unit)
+               return ACPI_BATTERY_UNITS_AMPS;
+       else
+               return ACPI_BATTERY_UNITS_WATTS;
+}
+
+inline acpi_handle acpi_battery_handle(struct acpi_battery *battery)
+{
+       return battery->device->handle;
+}
+
 /* --------------------------------------------------------------------------
                                Battery Management
    -------------------------------------------------------------------------- */
 
-static int
-acpi_battery_get_info(struct acpi_battery *battery,
-                     struct acpi_battery_info **bif)
+static void acpi_battery_check_result(struct acpi_battery *battery, int result)
+{
+       if (!battery)
+               return;
+
+       if (result) {
+               battery->flags.init_update = 1;
+       }
+}
+
+static int acpi_battery_extract_package(struct acpi_battery *battery,
+                                       union acpi_object *package,
+                                       struct acpi_buffer *format,
+                                       struct acpi_buffer *data,
+                                       char *package_name)
+{
+       acpi_status status = AE_OK;
+       struct acpi_buffer data_null = { 0, NULL };
+
+       status = acpi_extract_package(package, format, &data_null);
+       if (status != AE_BUFFER_OVERFLOW) {
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting size %s",
+                               package_name));
+               return -ENODEV;
+       }
+
+       if (data_null.length != data->length) {
+               kfree(data->pointer);
+               data->pointer = kzalloc(data_null.length, GFP_KERNEL);
+               if (!data->pointer) {
+                       ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()"));
+                       return -ENOMEM;
+               }
+               data->length = data_null.length;
+       }
+
+       status = acpi_extract_package(package, format, data);
+       if (ACPI_FAILURE(status)) {
+               ACPI_EXCEPTION((AE_INFO, status, "Extracting %s",
+                               package_name));
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int acpi_battery_get_status(struct acpi_battery *battery)
+{
+       int result = 0;
+
+       result = acpi_bus_get_status(battery->device);
+       if (result) {
+               ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
+               return -ENODEV;
+       }
+       return result;
+}
+
+static int acpi_battery_get_info(struct acpi_battery *battery)
 {
        int result = 0;
        acpi_status status = 0;
@@ -133,16 +220,20 @@ acpi_battery_get_info(struct acpi_battery *battery,
        struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
                ACPI_BATTERY_FORMAT_BIF
        };
-       struct acpi_buffer data = { 0, NULL };
        union acpi_object *package = NULL;
+       struct acpi_buffer *data = NULL;
+       struct acpi_battery_info *bif = NULL;
 
+       battery->update_time[ACPI_BATTERY_INFO] = get_seconds();
 
-       if (!battery || !bif)
-               return -EINVAL;
+       if (!acpi_battery_present(battery))
+               return 0;
 
-       /* Evalute _BIF */
+       /* Evaluate _BIF */
 
-       status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer);
+       status =
+           acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
+                                &buffer);
        if (ACPI_FAILURE(status)) {
                ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
                return -ENODEV;
@@ -150,41 +241,29 @@ acpi_battery_get_info(struct acpi_battery *battery,
 
        package = buffer.pointer;
 
-       /* Extract Package Data */
-
-       status = acpi_extract_package(package, &format, &data);
-       if (status != AE_BUFFER_OVERFLOW) {
-               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
-               result = -ENODEV;
-               goto end;
-       }
+       data = &battery->bif_data;
 
-       data.pointer = kzalloc(data.length, GFP_KERNEL);
-       if (!data.pointer) {
-               result = -ENOMEM;
-               goto end;
-       }
+       /* Extract Package Data */
 
-       status = acpi_extract_package(package, &format, &data);
-       if (ACPI_FAILURE(status)) {
-               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
-               kfree(data.pointer);
-               result = -ENODEV;
+       result =
+           acpi_battery_extract_package(battery, package, &format, data,
+                                        "_BIF");
+       if (result)
                goto end;
-       }
 
       end:
+
        kfree(buffer.pointer);
 
-       if (!result)
-               (*bif) = data.pointer;
+       if (!result) {
+               bif = data->pointer;
+               battery->flags.power_unit = bif->power_unit;
+       }
 
        return result;
 }
 
-static int
-acpi_battery_get_status(struct acpi_battery *battery,
-                       struct acpi_battery_status **bst)
+static int acpi_battery_get_state(struct acpi_battery *battery)
 {
        int result = 0;
        acpi_status status = 0;
@@ -192,16 +271,19 @@ acpi_battery_get_status(struct acpi_battery *battery,
        struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
                ACPI_BATTERY_FORMAT_BST
        };
-       struct acpi_buffer data = { 0, NULL };
        union acpi_object *package = NULL;
+       struct acpi_buffer *data = NULL;
 
+       battery->update_time[ACPI_BATTERY_STATE] = get_seconds();
 
-       if (!battery || !bst)
-               return -EINVAL;
+       if (!acpi_battery_present(battery))
+               return 0;
 
-       /* Evalute _BST */
+       /* Evaluate _BST */
 
-       status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer);
+       status =
+           acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
+                                &buffer);
        if (ACPI_FAILURE(status)) {
                ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
                return -ENODEV;
@@ -209,55 +291,49 @@ acpi_battery_get_status(struct acpi_battery *battery,
 
        package = buffer.pointer;
 
-       /* Extract Package Data */
-
-       status = acpi_extract_package(package, &format, &data);
-       if (status != AE_BUFFER_OVERFLOW) {
-               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
-               result = -ENODEV;
-               goto end;
-       }
+       data = &battery->bst_data;
 
-       data.pointer = kzalloc(data.length, GFP_KERNEL);
-       if (!data.pointer) {
-               result = -ENOMEM;
-               goto end;
-       }
+       /* Extract Package Data */
 
-       status = acpi_extract_package(package, &format, &data);
-       if (ACPI_FAILURE(status)) {
-               ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
-               kfree(data.pointer);
-               result = -ENODEV;
+       result =
+           acpi_battery_extract_package(battery, package, &format, data,
+                                        "_BST");
+       if (result)
                goto end;
-       }
 
       end:
        kfree(buffer.pointer);
 
-       if (!result)
-               (*bst) = data.pointer;
-
        return result;
 }
 
-static int
-acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
+static int acpi_battery_get_alarm(struct acpi_battery *battery)
+{
+       battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
+
+       return 0;
+}
+
+static int acpi_battery_set_alarm(struct acpi_battery *battery,
+                                 unsigned long alarm)
 {
        acpi_status status = 0;
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list arg_list = { 1, &arg0 };
 
+       battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
 
-       if (!battery)
-               return -EINVAL;
+       if (!acpi_battery_present(battery))
+               return -ENODEV;
 
-       if (!battery->flags.alarm)
+       if (!battery->flags.alarm_present)
                return -ENODEV;
 
        arg0.integer.value = alarm;
 
-       status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL);
+       status =
+           acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
+                                &arg_list, NULL);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
@@ -268,65 +344,114 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
        return 0;
 }
 
-static int acpi_battery_check(struct acpi_battery *battery)
+static int acpi_battery_init_alarm(struct acpi_battery *battery)
 {
        int result = 0;
        acpi_status status = AE_OK;
        acpi_handle handle = NULL;
-       struct acpi_device *device = NULL;
-       struct acpi_battery_info *bif = NULL;
+       struct acpi_battery_info *bif = battery->bif_data.pointer;
+       unsigned long alarm = battery->alarm;
 
+       /* See if alarms are supported, and if so, set default */
 
-       if (!battery)
-               return -EINVAL;
-
-       device = battery->device;
+       status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle);
+       if (ACPI_SUCCESS(status)) {
+               battery->flags.alarm_present = 1;
+               if (!alarm && bif) {
+                       alarm = bif->design_capacity_warning;
+               }
+               result = acpi_battery_set_alarm(battery, alarm);
+               if (result)
+                       goto end;
+       } else {
+               battery->flags.alarm_present = 0;
+       }
 
-       result = acpi_bus_get_status(device);
-       if (result)
-               return result;
+      end:
 
-       /* Insertion? */
+       return result;
+}
 
-       if (!battery->flags.present && device->status.battery_present) {
+static int acpi_battery_init_update(struct acpi_battery *battery)
+{
+       int result = 0;
 
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery inserted\n"));
+       result = acpi_battery_get_status(battery);
+       if (result)
+               return result;
 
-               /* Evalute _BIF to get certain static information */
+       battery->flags.battery_present_prev = acpi_battery_present(battery);
 
-               result = acpi_battery_get_info(battery, &bif);
+       if (acpi_battery_present(battery)) {
+               result = acpi_battery_get_info(battery);
+               if (result)
+                       return result;
+               result = acpi_battery_get_state(battery);
                if (result)
                        return result;
 
-               battery->flags.power_unit = bif->power_unit;
-               battery->trips.warning = bif->design_capacity_warning;
-               battery->trips.low = bif->design_capacity_low;
-               kfree(bif);
+               acpi_battery_init_alarm(battery);
+       }
+
+       return result;
+}
 
-               /* See if alarms are supported, and if so, set default */
+static int acpi_battery_update(struct acpi_battery *battery,
+                              int update, int *update_result_ptr)
+{
+       int result = 0;
+       int update_result = ACPI_BATTERY_NONE_UPDATE;
+
+       if (!acpi_battery_present(battery)) {
+               update = 1;
+       }
 
-               status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
-               if (ACPI_SUCCESS(status)) {
-                       battery->flags.alarm = 1;
-                       acpi_battery_set_alarm(battery, battery->trips.warning);
+       if (battery->flags.init_update) {
+               result = acpi_battery_init_update(battery);
+               if (result)
+                       goto end;
+               update_result = ACPI_BATTERY_INIT_UPDATE;
+       } else if (update) {
+               result = acpi_battery_get_status(battery);
+               if (result)
+                       goto end;
+               if ((!battery->flags.battery_present_prev & acpi_battery_present(battery))
+                   || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) {
+                       result = acpi_battery_init_update(battery);
+                       if (result)
+                               goto end;
+                       update_result = ACPI_BATTERY_INIT_UPDATE;
+               } else {
+                       update_result = ACPI_BATTERY_EASY_UPDATE;
                }
        }
 
-       /* Removal? */
+      end:
 
-       else if (battery->flags.present && !device->status.battery_present) {
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery removed\n"));
-       }
+       battery->flags.init_update = (result != 0);
 
-       battery->flags.present = device->status.battery_present;
+       *update_result_ptr = update_result;
 
        return result;
 }
 
-static void acpi_battery_check_present(struct acpi_battery *battery)
+static void acpi_battery_notify_update(struct acpi_battery *battery)
 {
-       if (!battery->flags.present) {
-               acpi_battery_check(battery);
+       acpi_battery_get_status(battery);
+
+       if (battery->flags.init_update) {
+               return;
+       }
+
+       if ((!battery->flags.battery_present_prev &
+            acpi_battery_present(battery)) ||
+           (battery->flags.battery_present_prev &
+            !acpi_battery_present(battery))) {
+               battery->flags.init_update = 1;
+       } else {
+               battery->flags.update[ACPI_BATTERY_INFO] = 1;
+               battery->flags.update[ACPI_BATTERY_STATE] = 1;
+               battery->flags.update[ACPI_BATTERY_ALARM] = 1;
        }
 }
 
@@ -335,37 +460,33 @@ static void acpi_battery_check_present(struct acpi_battery *battery)
    -------------------------------------------------------------------------- */
 
 static struct proc_dir_entry *acpi_battery_dir;
-static int acpi_battery_read_info(struct seq_file *seq, void *offset)
+
+static int acpi_battery_print_info(struct seq_file *seq, int result)
 {
-       int result = 0;
        struct acpi_battery *battery = seq->private;
        struct acpi_battery_info *bif = NULL;
        char *units = "?";
 
-
-       if (!battery)
+       if (result)
                goto end;
 
-       acpi_battery_check_present(battery);
-
-       if (battery->flags.present)
+       if (acpi_battery_present(battery))
                seq_printf(seq, "present:                 yes\n");
        else {
                seq_printf(seq, "present:                 no\n");
                goto end;
        }
 
-       /* Battery Info (_BIF) */
-
-       result = acpi_battery_get_info(battery, &bif);
-       if (result || !bif) {
-               seq_printf(seq, "ERROR: Unable to read battery information\n");
+       bif = battery->bif_data.pointer;
+       if (!bif) {
+               ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BIF buffer is NULL"));
+               result = -ENODEV;
                goto end;
        }
 
-       units =
-           bif->
-           power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
+       /* Battery Units */
+
+       units = acpi_battery_power_units(battery);
 
        if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
                seq_printf(seq, "design capacity:         unknown\n");
@@ -396,7 +517,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
        else
                seq_printf(seq, "design voltage:          %d mV\n",
                           (u32) bif->design_voltage);
-
        seq_printf(seq, "design capacity warning: %d %sh\n",
                   (u32) bif->design_capacity_warning, units);
        seq_printf(seq, "design capacity low:     %d %sh\n",
@@ -411,50 +531,40 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
        seq_printf(seq, "OEM info:                %s\n", bif->oem_info);
 
       end:
-       kfree(bif);
 
-       return 0;
-}
+       if (result)
+               seq_printf(seq, "ERROR: Unable to read battery info\n");
 
-static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
-{
-       return single_open(file, acpi_battery_read_info, PDE(inode)->data);
+       return result;
 }
 
-static int acpi_battery_read_state(struct seq_file *seq, void *offset)
+static int acpi_battery_print_state(struct seq_file *seq, int result)
 {
-       int result = 0;
        struct acpi_battery *battery = seq->private;
-       struct acpi_battery_status *bst = NULL;
+       struct acpi_battery_state *bst = NULL;
        char *units = "?";
 
-
-       if (!battery)
+       if (result)
                goto end;
 
-       acpi_battery_check_present(battery);
-
-       if (battery->flags.present)
+       if (acpi_battery_present(battery))
                seq_printf(seq, "present:                 yes\n");
        else {
                seq_printf(seq, "present:                 no\n");
                goto end;
        }
 
-       /* Battery Units */
-
-       units =
-           battery->flags.
-           power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
-
-       /* Battery Status (_BST) */
-
-       result = acpi_battery_get_status(battery, &bst);
-       if (result || !bst) {
-               seq_printf(seq, "ERROR: Unable to read battery status\n");
+       bst = battery->bst_data.pointer;
+       if (!bst) {
+               ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BST buffer is NULL"));
+               result = -ENODEV;
                goto end;
        }
 
+       /* Battery Units */
+
+       units = acpi_battery_power_units(battery);
+
        if (!(bst->state & 0x04))
                seq_printf(seq, "capacity state:          ok\n");
        else
@@ -490,48 +600,43 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
                           (u32) bst->present_voltage);
 
       end:
-       kfree(bst);
 
-       return 0;
-}
+       if (result) {
+               seq_printf(seq, "ERROR: Unable to read battery state\n");
+       }
 
-static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
-{
-       return single_open(file, acpi_battery_read_state, PDE(inode)->data);
+       return result;
 }
 
-static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
+static int acpi_battery_print_alarm(struct seq_file *seq, int result)
 {
        struct acpi_battery *battery = seq->private;
        char *units = "?";
 
-
-       if (!battery)
+       if (result)
                goto end;
 
-       acpi_battery_check_present(battery);
-
-       if (!battery->flags.present) {
+       if (!acpi_battery_present(battery)) {
                seq_printf(seq, "present:                 no\n");
                goto end;
        }
 
        /* Battery Units */
 
-       units =
-           battery->flags.
-           power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
-
-       /* Battery Alarm */
+       units = acpi_battery_power_units(battery);
 
        seq_printf(seq, "alarm:                   ");
        if (!battery->alarm)
                seq_printf(seq, "unsupported\n");
        else
-               seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
+               seq_printf(seq, "%lu %sh\n", battery->alarm, units);
 
       end:
-       return 0;
+
+       if (result)
+               seq_printf(seq, "ERROR: Unable to read battery alarm\n");
+
+       return result;
 }
 
 static ssize_t
@@ -543,27 +648,113 @@ acpi_battery_write_alarm(struct file *file,
        char alarm_string[12] = { '\0' };
        struct seq_file *m = file->private_data;
        struct acpi_battery *battery = m->private;
-
+       int update_result = ACPI_BATTERY_NONE_UPDATE;
 
        if (!battery || (count > sizeof(alarm_string) - 1))
                return -EINVAL;
 
-       acpi_battery_check_present(battery);
+       mutex_lock(&battery->mutex);
 
-       if (!battery->flags.present)
-               return -ENODEV;
+       result = acpi_battery_update(battery, 1, &update_result);
+       if (result) {
+               result = -ENODEV;
+               goto end;
+       }
+
+       if (!acpi_battery_present(battery)) {
+               result = -ENODEV;
+               goto end;
+       }
 
-       if (copy_from_user(alarm_string, buffer, count))
-               return -EFAULT;
+       if (copy_from_user(alarm_string, buffer, count)) {
+               result = -EFAULT;
+               goto end;
+       }
 
        alarm_string[count] = '\0';
 
        result = acpi_battery_set_alarm(battery,
                                        simple_strtoul(alarm_string, NULL, 0));
        if (result)
-               return result;
+               goto end;
+
+      end:
 
-       return count;
+       acpi_battery_check_result(battery, result);
+
+       if (!result)
+               result = count;
+
+       mutex_unlock(&battery->mutex);
+
+       return result;
+}
+
+typedef int(*print_func)(struct seq_file *seq, int result);
+typedef int(*get_func)(struct acpi_battery *battery);
+
+static struct acpi_read_mux {
+       print_func print;
+       get_func get;
+} acpi_read_funcs[ACPI_BATTERY_NUMFILES] = {
+       {.get = acpi_battery_get_info, .print = acpi_battery_print_info},
+       {.get = acpi_battery_get_state, .print = acpi_battery_print_state},
+       {.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm},
+};
+
+static int acpi_battery_read(int fid, struct seq_file *seq)
+{
+       struct acpi_battery *battery = seq->private;
+       int result = 0;
+       int update_result = ACPI_BATTERY_NONE_UPDATE;
+       int update = 0;
+
+       mutex_lock(&battery->mutex);
+
+       update = (get_seconds() - battery->update_time[fid] >= update_time);
+       update = (update | battery->flags.update[fid]);
+
+       result = acpi_battery_update(battery, update, &update_result);
+       if (result)
+               goto end;
+
+       if (update_result == ACPI_BATTERY_EASY_UPDATE) {
+               result = acpi_read_funcs[fid].get(battery);
+               if (result)
+                       goto end;
+       }
+
+      end:
+       result = acpi_read_funcs[fid].print(seq, result);
+       acpi_battery_check_result(battery, result);
+       battery->flags.update[fid] = result;
+       mutex_unlock(&battery->mutex);
+       return result;
+}
+
+static int acpi_battery_read_info(struct seq_file *seq, void *offset)
+{
+       return acpi_battery_read(ACPI_BATTERY_INFO, seq);
+}
+
+static int acpi_battery_read_state(struct seq_file *seq, void *offset)
+{
+       return acpi_battery_read(ACPI_BATTERY_STATE, seq);
+}
+
+static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
+{
+       return acpi_battery_read(ACPI_BATTERY_ALARM, seq);
+}
+
+static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
+{
+       return single_open(file, acpi_battery_read_info, PDE(inode)->data);
+}
+
+static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
+{
+       return single_open(file, acpi_battery_read_state, PDE(inode)->data);
 }
 
 static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
@@ -571,35 +762,51 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
        return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
 }
 
-static const struct file_operations acpi_battery_info_ops = {
+static struct battery_file {
+       struct file_operations ops;
+       mode_t mode;
+       char *name;
+} acpi_battery_file[] = {
+       {
+       .name = "info",
+       .mode = S_IRUGO,
+       .ops = {
        .open = acpi_battery_info_open_fs,
        .read = seq_read,
        .llseek = seq_lseek,
        .release = single_release,
        .owner = THIS_MODULE,
-};
-
-static const struct file_operations acpi_battery_state_ops = {
+       },
+       },
+       {
+       .name = "state",
+       .mode = S_IRUGO,
+       .ops = {
        .open = acpi_battery_state_open_fs,
        .read = seq_read,
        .llseek = seq_lseek,
        .release = single_release,
        .owner = THIS_MODULE,
-};
-
-static const struct file_operations acpi_battery_alarm_ops = {
+       },
+       },
+       {
+       .name = "alarm",
+       .mode = S_IFREG | S_IRUGO | S_IWUSR,
+       .ops = {
        .open = acpi_battery_alarm_open_fs,
        .read = seq_read,
        .write = acpi_battery_write_alarm,
        .llseek = seq_lseek,
        .release = single_release,
        .owner = THIS_MODULE,
+       },
+       },
 };
 
 static int acpi_battery_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
-
+       int i;
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@ -609,38 +816,16 @@ static int acpi_battery_add_fs(struct acpi_device *device)
                acpi_device_dir(device)->owner = THIS_MODULE;
        }
 
-       /* 'info' [R] */
-       entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
-                                 S_IRUGO, acpi_device_dir(device));
-       if (!entry)
-               return -ENODEV;
-       else {
-               entry->proc_fops = &acpi_battery_info_ops;
-               entry->data = acpi_driver_data(device);
-               entry->owner = THIS_MODULE;
-       }
-
-       /* 'status' [R] */
-       entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
-                                 S_IRUGO, acpi_device_dir(device));
-       if (!entry)
-               return -ENODEV;
-       else {
-               entry->proc_fops = &acpi_battery_state_ops;
-               entry->data = acpi_driver_data(device);
-               entry->owner = THIS_MODULE;
-       }
-
-       /* 'alarm' [R/W] */
-       entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
-                                 S_IFREG | S_IRUGO | S_IWUSR,
-                                 acpi_device_dir(device));
-       if (!entry)
-               return -ENODEV;
-       else {
-               entry->proc_fops = &acpi_battery_alarm_ops;
-               entry->data = acpi_driver_data(device);
-               entry->owner = THIS_MODULE;
+       for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
+               entry = create_proc_entry(acpi_battery_file[i].name,
+                                 acpi_battery_file[i].mode, acpi_device_dir(device));
+               if (!entry)
+                       return -ENODEV;
+               else {
+                       entry->proc_fops = &acpi_battery_file[i].ops;
+                       entry->data = acpi_driver_data(device);
+                       entry->owner = THIS_MODULE;
+               }
        }
 
        return 0;
@@ -648,15 +833,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
 
 static int acpi_battery_remove_fs(struct acpi_device *device)
 {
-
+       int i;
        if (acpi_device_dir(device)) {
-               remove_proc_entry(ACPI_BATTERY_FILE_ALARM,
+               for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
+                       remove_proc_entry(acpi_battery_file[i].name,
                                  acpi_device_dir(device));
-               remove_proc_entry(ACPI_BATTERY_FILE_STATUS,
-                                 acpi_device_dir(device));
-               remove_proc_entry(ACPI_BATTERY_FILE_INFO,
-                                 acpi_device_dir(device));
-
+               }
                remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
                acpi_device_dir(device) = NULL;
        }
@@ -673,7 +855,6 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
        struct acpi_battery *battery = data;
        struct acpi_device *device = NULL;
 
-
        if (!battery)
                return;
 
@@ -684,8 +865,10 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
        case ACPI_BATTERY_NOTIFY_INFO:
        case ACPI_NOTIFY_BUS_CHECK:
        case ACPI_NOTIFY_DEVICE_CHECK:
-               acpi_battery_check(battery);
-               acpi_bus_generate_event(device, event, battery->flags.present);
+               device = battery->device;
+               acpi_battery_notify_update(battery);
+               acpi_bus_generate_event(device, event,
+                                       acpi_battery_present(battery));
                break;
        default:
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -702,7 +885,6 @@ static int acpi_battery_add(struct acpi_device *device)
        acpi_status status = 0;
        struct acpi_battery *battery = NULL;
 
-
        if (!device)
                return -EINVAL;
 
@@ -710,15 +892,21 @@ static int acpi_battery_add(struct acpi_device *device)
        if (!battery)
                return -ENOMEM;
 
+       mutex_init(&battery->mutex);
+
+       mutex_lock(&battery->mutex);
+
        battery->device = device;
        strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
        acpi_driver_data(device) = battery;
 
-       result = acpi_battery_check(battery);
+       result = acpi_battery_get_status(battery);
        if (result)
                goto end;
 
+       battery->flags.init_update = 1;
+
        result = acpi_battery_add_fs(device);
        if (result)
                goto end;
@@ -727,6 +915,7 @@ static int acpi_battery_add(struct acpi_device *device)
                                             ACPI_ALL_NOTIFY,
                                             acpi_battery_notify, battery);
        if (ACPI_FAILURE(status)) {
+               ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
                result = -ENODEV;
                goto end;
        }
@@ -736,11 +925,14 @@ static int acpi_battery_add(struct acpi_device *device)
               device->status.battery_present ? "present" : "absent");
 
       end:
+
        if (result) {
                acpi_battery_remove_fs(device);
                kfree(battery);
        }
 
+       mutex_unlock(&battery->mutex);
+
        return result;
 }
 
@@ -749,18 +941,27 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
        acpi_status status = 0;
        struct acpi_battery *battery = NULL;
 
-
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
 
        battery = acpi_driver_data(device);
 
+       mutex_lock(&battery->mutex);
+
        status = acpi_remove_notify_handler(device->handle,
                                            ACPI_ALL_NOTIFY,
                                            acpi_battery_notify);
 
        acpi_battery_remove_fs(device);
 
+       kfree(battery->bif_data.pointer);
+
+       kfree(battery->bst_data.pointer);
+
+       mutex_unlock(&battery->mutex);
+
+       mutex_destroy(&battery->mutex);
+
        kfree(battery);
 
        return 0;
@@ -775,7 +976,10 @@ static int acpi_battery_resume(struct acpi_device *device)
                return -EINVAL;
 
        battery = device->driver_data;
-       return acpi_battery_check(battery);
+
+       battery->flags.init_update = 1;
+
+       return 0;
 }
 
 static int __init acpi_battery_init(void)
@@ -800,7 +1004,6 @@ static int __init acpi_battery_init(void)
 
 static void __exit acpi_battery_exit(void)
 {
-
        acpi_bus_unregister_driver(&acpi_battery_driver);
 
        acpi_unlock_battery_dir(acpi_battery_dir);
index fb3f31b..56a5b3f 100644 (file)
@@ -288,6 +288,11 @@ static int bay_add(acpi_handle handle, int id)
        new_bay->pdev = pdev;
        platform_set_drvdata(pdev, new_bay);
 
+       /*
+        * we want the bay driver to be able to send uevents
+        */
+       pdev->dev.uevent_suppress = 0;
+
        if (acpi_bay_add_fs(new_bay)) {
                platform_device_unregister(new_bay->pdev);
                goto bay_add_err;
@@ -328,18 +333,12 @@ static void bay_notify(acpi_handle handle, u32 event, void *data)
 {
        struct bay *bay_dev = (struct bay *)data;
        struct device *dev = &bay_dev->pdev->dev;
+       char event_string[12];
+       char *envp[] = { event_string, NULL };
 
        bay_dprintk(handle, "Bay event");
-
-       switch(event) {
-       case ACPI_NOTIFY_BUS_CHECK:
-       case ACPI_NOTIFY_DEVICE_CHECK:
-       case ACPI_NOTIFY_EJECT_REQUEST:
-               kobject_uevent(&dev->kobj, KOBJ_CHANGE);
-               break;
-       default:
-               printk(KERN_ERR PREFIX "Bay: unknown event %d\n", event);
-       }
+       sprintf(event_string, "BAY_EVENT=%d\n", event);
+       kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
 }
 
 static acpi_status
index 4546bf8..6192c8b 100644 (file)
@@ -40,8 +40,15 @@ MODULE_AUTHOR("Kristen Carlson Accardi");
 MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
 MODULE_LICENSE("GPL");
 
+static int immediate_undock = 1;
+module_param(immediate_undock, bool, 0644);
+MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
+       "undock immediately when the undock button is pressed, 0 will cause"
+       " the driver to wait for userspace to write the undock sysfs file "
+       " before undocking");
+
 static struct atomic_notifier_head dock_notifier_list;
-static struct platform_device dock_device;
+static struct platform_device *dock_device;
 static char dock_device_name[] = "dock";
 
 struct dock_station {
@@ -63,6 +70,7 @@ struct dock_dependent_device {
 };
 
 #define DOCK_DOCKING   0x00000001
+#define DOCK_UNDOCKING  0x00000002
 #define DOCK_EVENT     3
 #define UNDOCK_EVENT   2
 
@@ -327,12 +335,20 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
 
 static void dock_event(struct dock_station *ds, u32 event, int num)
 {
-       struct device *dev = &dock_device.dev;
+       struct device *dev = &dock_device->dev;
+       char event_string[7];
+       char *envp[] = { event_string, NULL };
+
+       if (num == UNDOCK_EVENT)
+               sprintf(event_string, "UNDOCK");
+       else
+               sprintf(event_string, "DOCK");
+
        /*
         * Indicate that the status of the dock station has
         * changed.
         */
-       kobject_uevent(&dev->kobj, KOBJ_CHANGE);
+       kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
 }
 
 /**
@@ -380,12 +396,11 @@ static void handle_dock(struct dock_station *ds, int dock)
        union acpi_object arg;
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-       union acpi_object *obj;
 
        acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer);
-       obj = name_buffer.pointer;
 
-       printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking");
+       printk(KERN_INFO PREFIX "%s - %s\n",
+               (char *)name_buffer.pointer, dock ? "docking" : "undocking");
 
        /* _DCK method has one argument */
        arg_list.count = 1;
@@ -394,7 +409,8 @@ static void handle_dock(struct dock_station *ds, int dock)
        arg.integer.value = dock;
        status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
        if (ACPI_FAILURE(status))
-               pr_debug("%s: failed to execute _DCK\n", obj->string.pointer);
+               printk(KERN_ERR PREFIX "%s - failed to execute _DCK\n",
+                        (char *)name_buffer.pointer);
        kfree(buffer.pointer);
        kfree(name_buffer.pointer);
 }
@@ -420,6 +436,16 @@ static inline void complete_dock(struct dock_station *ds)
        ds->last_dock_time = jiffies;
 }
 
+static inline void begin_undock(struct dock_station *ds)
+{
+       ds->flags |= DOCK_UNDOCKING;
+}
+
+static inline void complete_undock(struct dock_station *ds)
+{
+       ds->flags &= ~(DOCK_UNDOCKING);
+}
+
 /**
  * dock_in_progress - see if we are in the middle of handling a dock event
  * @ds: the dock station
@@ -550,7 +576,7 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
                printk(KERN_ERR PREFIX "Unable to undock!\n");
                return -EBUSY;
        }
-
+       complete_undock(ds);
        return 0;
 }
 
@@ -594,7 +620,11 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
         * to the driver who wish to hotplug.
          */
        case ACPI_NOTIFY_EJECT_REQUEST:
-               handle_eject_request(ds, event);
+               begin_undock(ds);
+               if (immediate_undock)
+                       handle_eject_request(ds, event);
+               else
+                       dock_event(ds, event, UNDOCK_EVENT);
                break;
        default:
                printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
@@ -653,6 +683,17 @@ static ssize_t show_docked(struct device *dev,
 DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
 
 /*
+ * show_flags - read method for flags file in sysfs
+ */
+static ssize_t show_flags(struct device *dev,
+                         struct device_attribute *attr, char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
+
+}
+DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
+
+/*
  * write_undock - write method for "undock" file in sysfs
  */
 static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
@@ -675,16 +716,15 @@ static ssize_t show_dock_uid(struct device *dev,
                             struct device_attribute *attr, char *buf)
 {
        unsigned long lbuf;
-       acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", NULL, &lbuf);
-       if(ACPI_FAILURE(status)) {
+       acpi_status status = acpi_evaluate_integer(dock_station->handle,
+                                       "_UID", NULL, &lbuf);
+       if (ACPI_FAILURE(status))
            return 0;
-       }
+
        return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf);
 }
 DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
 
-
-
 /**
  * dock_add - add a new dock station
  * @handle: the dock station handle
@@ -711,33 +751,53 @@ static int dock_add(acpi_handle handle)
        ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
 
        /* initialize platform device stuff */
-       dock_device.name = dock_device_name;
-       ret = platform_device_register(&dock_device);
+       dock_device =
+               platform_device_register_simple(dock_device_name, 0, NULL, 0);
+       if (IS_ERR(dock_device)) {
+               kfree(dock_station);
+               dock_station = NULL;
+               return PTR_ERR(dock_device);
+       }
+
+       /* we want the dock device to send uevents */
+       dock_device->dev.uevent_suppress = 0;
+
+       ret = device_create_file(&dock_device->dev, &dev_attr_docked);
        if (ret) {
-               printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret);
+               printk("Error %d adding sysfs file\n", ret);
+               platform_device_unregister(dock_device);
                kfree(dock_station);
+               dock_station = NULL;
                return ret;
        }
-       ret = device_create_file(&dock_device.dev, &dev_attr_docked);
+       ret = device_create_file(&dock_device->dev, &dev_attr_undock);
        if (ret) {
                printk("Error %d adding sysfs file\n", ret);
-               platform_device_unregister(&dock_device);
+               device_remove_file(&dock_device->dev, &dev_attr_docked);
+               platform_device_unregister(dock_device);
                kfree(dock_station);
+               dock_station = NULL;
                return ret;
        }
-       ret = device_create_file(&dock_device.dev, &dev_attr_undock);
+       ret = device_create_file(&dock_device->dev, &dev_attr_uid);
        if (ret) {
                printk("Error %d adding sysfs file\n", ret);
-               device_remove_file(&dock_device.dev, &dev_attr_docked);
-               platform_device_unregister(&dock_device);
+               device_remove_file(&dock_device->dev, &dev_attr_docked);
+               device_remove_file(&dock_device->dev, &dev_attr_undock);
+               platform_device_unregister(dock_device);
                kfree(dock_station);
+               dock_station = NULL;
                return ret;
        }
-       ret = device_create_file(&dock_device.dev, &dev_attr_uid);
+       ret = device_create_file(&dock_device->dev, &dev_attr_flags);
        if (ret) {
                printk("Error %d adding sysfs file\n", ret);
-               platform_device_unregister(&dock_device);
+               device_remove_file(&dock_device->dev, &dev_attr_docked);
+               device_remove_file(&dock_device->dev, &dev_attr_undock);
+               device_remove_file(&dock_device->dev, &dev_attr_uid);
+               platform_device_unregister(dock_device);
                kfree(dock_station);
+               dock_station = NULL;
                return ret;
        }
 
@@ -750,6 +810,7 @@ static int dock_add(acpi_handle handle)
        dd = alloc_dock_dependent_device(handle);
        if (!dd) {
                kfree(dock_station);
+               dock_station = NULL;
                ret = -ENOMEM;
                goto dock_add_err_unregister;
        }
@@ -773,10 +834,13 @@ static int dock_add(acpi_handle handle)
 dock_add_err:
        kfree(dd);
 dock_add_err_unregister:
-       device_remove_file(&dock_device.dev, &dev_attr_docked);
-       device_remove_file(&dock_device.dev, &dev_attr_undock);
-       platform_device_unregister(&dock_device);
+       device_remove_file(&dock_device->dev, &dev_attr_docked);
+       device_remove_file(&dock_device->dev, &dev_attr_undock);
+       device_remove_file(&dock_device->dev, &dev_attr_uid);
+       device_remove_file(&dock_device->dev, &dev_attr_flags);
+       platform_device_unregister(dock_device);
        kfree(dock_station);
+       dock_station = NULL;
        return ret;
 }
 
@@ -804,12 +868,15 @@ static int dock_remove(void)
                printk(KERN_ERR "Error removing notify handler\n");
 
        /* cleanup sysfs */
-       device_remove_file(&dock_device.dev, &dev_attr_docked);
-       device_remove_file(&dock_device.dev, &dev_attr_undock);
-       platform_device_unregister(&dock_device);
+       device_remove_file(&dock_device->dev, &dev_attr_docked);
+       device_remove_file(&dock_device->dev, &dev_attr_undock);
+       device_remove_file(&dock_device->dev, &dev_attr_uid);
+       device_remove_file(&dock_device->dev, &dev_attr_flags);
+       platform_device_unregister(dock_device);
 
        /* free dock station memory */
        kfree(dock_station);
+       dock_station = NULL;
        return 0;
 }
 
index 82f496c..10e8510 100644 (file)
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
+#include <linux/list.h>
 #include <asm/io.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/actypes.h>
 
-#define _COMPONENT             ACPI_EC_COMPONENT
-ACPI_MODULE_NAME("ec");
-#define ACPI_EC_COMPONENT              0x00100000
 #define ACPI_EC_CLASS                  "embedded_controller"
 #define ACPI_EC_HID                    "PNP0C09"
 #define ACPI_EC_DEVICE_NAME            "Embedded Controller"
 #define ACPI_EC_FILE_INFO              "info"
+
 #undef PREFIX
 #define PREFIX                         "ACPI: EC: "
+
 /* EC status register */
 #define ACPI_EC_FLAG_OBF       0x01    /* Output buffer full */
 #define ACPI_EC_FLAG_IBF       0x02    /* Input buffer full */
 #define ACPI_EC_FLAG_BURST     0x10    /* burst mode */
 #define ACPI_EC_FLAG_SCI       0x20    /* EC-SCI occurred */
+
 /* EC commands */
 enum ec_command {
        ACPI_EC_COMMAND_READ = 0x80,
@@ -61,6 +62,7 @@ enum ec_command {
        ACPI_EC_BURST_DISABLE = 0x83,
        ACPI_EC_COMMAND_QUERY = 0x84,
 };
+
 /* EC events */
 enum ec_event {
        ACPI_EC_EVENT_OBF_1 = 1,        /* Output buffer full */
@@ -94,6 +96,16 @@ static struct acpi_driver acpi_ec_driver = {
 
 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
 /* External interfaces use first EC only, so remember */
+typedef int (*acpi_ec_query_func) (void *data);
+
+struct acpi_ec_query_handler {
+       struct list_head node;
+       acpi_ec_query_func func;
+       acpi_handle handle;
+       void *data;
+       u8 query_bit;
+};
+
 static struct acpi_ec {
        acpi_handle handle;
        unsigned long gpe;
@@ -104,6 +116,7 @@ static struct acpi_ec {
        atomic_t query_pending;
        atomic_t event_count;
        wait_queue_head_t wait;
+       struct list_head list;
 } *boot_ec, *first_ec;
 
 /* --------------------------------------------------------------------------
@@ -245,7 +258,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
 
        status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0);
        if (status) {
-               printk(KERN_DEBUG PREFIX
+               printk(KERN_ERR PREFIX
                       "input buffer is not empty, aborting transaction\n");
                goto end;
        }
@@ -394,21 +407,67 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
 /* --------------------------------------------------------------------------
                                 Event Management
    -------------------------------------------------------------------------- */
+int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
+                             acpi_handle handle, acpi_ec_query_func func,
+                             void *data)
+{
+       struct acpi_ec_query_handler *handler =
+           kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
+       if (!handler)
+               return -ENOMEM;
+
+       handler->query_bit = query_bit;
+       handler->handle = handle;
+       handler->func = func;
+       handler->data = data;
+       mutex_lock(&ec->lock);
+       list_add_tail(&handler->node, &ec->list);
+       mutex_unlock(&ec->lock);
+       return 0;
+}
+
+EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
+
+void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
+{
+       struct acpi_ec_query_handler *handler;
+       mutex_lock(&ec->lock);
+       list_for_each_entry(handler, &ec->list, node) {
+               if (query_bit == handler->query_bit) {
+                       list_del(&handler->node);
+                       kfree(handler);
+                       break;
+               }
+       }
+       mutex_unlock(&ec->lock);
+}
+
+EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
 
 static void acpi_ec_gpe_query(void *ec_cxt)
 {
        struct acpi_ec *ec = ec_cxt;
        u8 value = 0;
-       char object_name[8];
+       struct acpi_ec_query_handler *handler, copy;
 
        if (!ec || acpi_ec_query(ec, &value))
                return;
-
-       snprintf(object_name, 8, "_Q%2.2X", value);
-
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
-
-       acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
+       mutex_lock(&ec->lock);
+       list_for_each_entry(handler, &ec->list, node) {
+               if (value == handler->query_bit) {
+                       /* have custom handler for this bit */
+                       memcpy(&copy, handler, sizeof(copy));
+                       mutex_unlock(&ec->lock);
+                       if (copy.func) {
+                               copy.func(copy.data);
+                       } else if (copy.handle) {
+                               acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
+                       }
+                       return;
+               }
+       }
+       mutex_unlock(&ec->lock);
+       printk(KERN_ERR PREFIX "Handler for query 0x%x is not found!\n", value);
 }
 
 static u32 acpi_ec_gpe_handler(void *data)
@@ -427,8 +486,7 @@ static u32 acpi_ec_gpe_handler(void *data)
        if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
                atomic_set(&ec->query_pending, 1);
                status =
-                   acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
-                                   ec);
+                   acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
        }
 
        return status == AE_OK ?
@@ -454,57 +512,35 @@ acpi_ec_space_setup(acpi_handle region_handle,
 }
 
 static acpi_status
-acpi_ec_space_handler(u32 function,
-                     acpi_physical_address address,
-                     u32 bit_width,
-                     acpi_integer * value,
+acpi_ec_space_handler(u32 function, acpi_physical_address address,
+                     u32 bits, acpi_integer *value,
                      void *handler_context, void *region_context)
 {
-       int result = 0;
        struct acpi_ec *ec = handler_context;
-       u64 temp = *value;
-       acpi_integer f_v = 0;
-       int i = 0;
+       int result = 0, i = 0;
+       u8 temp = 0;
 
        if ((address > 0xFF) || !value || !handler_context)
                return AE_BAD_PARAMETER;
 
-       if (bit_width != 8 && acpi_strict) {
+       if (function != ACPI_READ && function != ACPI_WRITE)
                return AE_BAD_PARAMETER;
-       }
-
-      next_byte:
-       switch (function) {
-       case ACPI_READ:
-               temp = 0;
-               result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
-               break;
-       case ACPI_WRITE:
-               result = acpi_ec_write(ec, (u8) address, (u8) temp);
-               break;
-       default:
-               result = -EINVAL;
-               goto out;
-               break;
-       }
 
-       bit_width -= 8;
-       if (bit_width) {
-               if (function == ACPI_READ)
-                       f_v |= temp << 8 * i;
-               if (function == ACPI_WRITE)
-                       temp >>= 8;
-               i++;
-               address++;
-               goto next_byte;
-       }
+       if (bits != 8 && acpi_strict)
+               return AE_BAD_PARAMETER;
 
-       if (function == ACPI_READ) {
-               f_v |= temp << 8 * i;
-               *value = f_v;
+       while (bits - i > 0) {
+               if (function == ACPI_READ) {
+                       result = acpi_ec_read(ec, address, &temp);
+                       (*value) |= ((acpi_integer)temp) << i;
+               } else {
+                       temp = 0xff & ((*value) >> i);
+                       result = acpi_ec_write(ec, address, temp);
+               }
+               i += 8;
+               ++address;
        }
 
-      out:
        switch (result) {
        case -EINVAL:
                return AE_BAD_PARAMETER;
@@ -597,9 +633,6 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
 static acpi_status
 ec_parse_io_ports(struct acpi_resource *resource, void *context);
 
-static acpi_status
-ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval);
-
 static struct acpi_ec *make_acpi_ec(void)
 {
        struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
@@ -610,13 +643,52 @@ static struct acpi_ec *make_acpi_ec(void)
        atomic_set(&ec->event_count, 1);
        mutex_init(&ec->lock);
        init_waitqueue_head(&ec->wait);
+       INIT_LIST_HEAD(&ec->list);
 
        return ec;
 }
 
+static acpi_status
+acpi_ec_register_query_methods(acpi_handle handle, u32 level,
+                              void *context, void **return_value)
+{
+       struct acpi_namespace_node *node = handle;
+       struct acpi_ec *ec = context;
+       int value = 0;
+       if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
+               acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
+       }
+       return AE_OK;
+}
+
+static int ec_parse_device(struct acpi_ec *ec, acpi_handle handle)
+{
+       if (ACPI_FAILURE(acpi_walk_resources(handle, METHOD_NAME__CRS,
+                                    ec_parse_io_ports, ec)))
+               return -EINVAL;
+
+       /* Get GPE bit assignment (EC events). */
+       /* TODO: Add support for _GPE returning a package */
+       if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe)))
+               return -EINVAL;
+
+       /* Use the global lock for all EC transactions? */
+       acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
+
+       /* Find and register all query methods */
+       acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
+                           acpi_ec_register_query_methods, ec, NULL);
+
+       ec->handle = handle;
+
+       printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx",
+                         ec->gpe, ec->command_addr, ec->data_addr);
+
+       return 0;
+}
+
 static int acpi_ec_add(struct acpi_device *device)
 {
-       acpi_status status = AE_OK;
        struct acpi_ec *ec = NULL;
 
        if (!device)
@@ -629,8 +701,7 @@ static int acpi_ec_add(struct acpi_device *device)
        if (!ec)
                return -ENOMEM;
 
-       status = ec_parse_device(device->handle, 0, ec, NULL);
-       if (status != AE_CTRL_TERMINATE) {
+       if (ec_parse_device(ec, device->handle)) {
                kfree(ec);
                return -EINVAL;
        }
@@ -641,6 +712,8 @@ static int acpi_ec_add(struct acpi_device *device)
                        /* We might have incorrect info for GL at boot time */
                        mutex_lock(&boot_ec->lock);
                        boot_ec->global_lock = ec->global_lock;
+                       /* Copy handlers from new ec into boot ec */
+                       list_splice(&ec->list, &boot_ec->list);
                        mutex_unlock(&boot_ec->lock);
                        kfree(ec);
                        ec = boot_ec;
@@ -651,22 +724,24 @@ static int acpi_ec_add(struct acpi_device *device)
        acpi_driver_data(device) = ec;
 
        acpi_ec_add_fs(device);
-
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
-                         acpi_device_name(device), acpi_device_bid(device),
-                         (u32) ec->gpe));
-
        return 0;
 }
 
 static int acpi_ec_remove(struct acpi_device *device, int type)
 {
        struct acpi_ec *ec;
+       struct acpi_ec_query_handler *handler;
 
        if (!device)
                return -EINVAL;
 
        ec = acpi_driver_data(device);
+       mutex_lock(&ec->lock);
+       list_for_each_entry(handler, &ec->list, node) {
+               list_del(&handler->node);
+               kfree(handler);
+       }
+       mutex_unlock(&ec->lock);
        acpi_ec_remove_fs(device);
        acpi_driver_data(device) = NULL;
        if (ec == first_ec)
@@ -722,15 +797,13 @@ static int ec_install_handlers(struct acpi_ec *ec)
                return -ENODEV;
        }
 
-       /* EC is fully operational, allow queries */
-       atomic_set(&ec->query_pending, 0);
-
        return 0;
 }
 
 static int acpi_ec_start(struct acpi_device *device)
 {
        struct acpi_ec *ec;
+       int ret = 0;
 
        if (!device)
                return -EINVAL;
@@ -740,14 +813,14 @@ static int acpi_ec_start(struct acpi_device *device)
        if (!ec)
                return -EINVAL;
 
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
-                         ec->gpe, ec->command_addr, ec->data_addr));
-
        /* Boot EC is already working */
-       if (ec == boot_ec)
-               return 0;
+       if (ec != boot_ec)
+               ret = ec_install_handlers(ec);
+
+       /* EC is fully operational, allow queries */
+       atomic_set(&ec->query_pending, 0);
 
-       return ec_install_handlers(ec);
+       return ret;
 }
 
 static int acpi_ec_stop(struct acpi_device *device, int type)
@@ -779,34 +852,6 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
        return 0;
 }
 
-static acpi_status
-ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
-{
-       acpi_status status;
-
-       struct acpi_ec *ec = context;
-       status = acpi_walk_resources(handle, METHOD_NAME__CRS,
-                                    ec_parse_io_ports, ec);
-       if (ACPI_FAILURE(status))
-               return status;
-
-       /* Get GPE bit assignment (EC events). */
-       /* TODO: Add support for _GPE returning a package */
-       status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
-       if (ACPI_FAILURE(status))
-               return status;
-
-       /* Use the global lock for all EC transactions? */
-       acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
-
-       ec->handle = handle;
-
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
-                         ec->gpe, ec->command_addr, ec->data_addr));
-
-       return AE_CTRL_TERMINATE;
-}
-
 int __init acpi_ec_ecdt_probe(void)
 {
        int ret;
@@ -825,7 +870,7 @@ int __init acpi_ec_ecdt_probe(void)
        if (ACPI_FAILURE(status))
                goto error;
 
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
+       printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n");
 
        boot_ec->command_addr = ecdt_ptr->control.address;
        boot_ec->data_addr = ecdt_ptr->data.address;
index 902c287..361ebe6 100644 (file)
@@ -586,6 +586,10 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
        flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
        if (gpe_xrupt->previous) {
                gpe_xrupt->previous->next = gpe_xrupt->next;
+       } else {
+               /* No previous, update list head */
+
+               acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next;
        }
 
        if (gpe_xrupt->next) {
index 400d90f..23ee7bc 100644 (file)
@@ -284,6 +284,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
        }
 
        if (!pci_device_node) {
+               ACPI_FREE(pci_id);
                return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
        }
 
index 41427a4..4893e25 100644 (file)
@@ -16,7 +16,7 @@
 #if ACPI_GLUE_DEBUG
 #define DBG(x...) printk(PREFIX x)
 #else
-#define DBG(x...)
+#define DBG(x...) do { } while(0)
 #endif
 static LIST_HEAD(bus_type_list);
 static DECLARE_RWSEM(bus_type_sem);
index acc5947..3448edd 100644 (file)
@@ -733,7 +733,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
        /* query and set link->irq.active */
        acpi_pci_link_get_current(link);
 
-       printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
+       printk(KERN_INFO PREFIX "%s [%s] (IRQs", acpi_device_name(device),
               acpi_device_bid(device));
        for (i = 0; i < link->irq.possible_count; i++) {
                if (link->irq.active == link->irq.possible[i]) {
index bb5d23b..a898991 100644 (file)
@@ -490,7 +490,17 @@ static void acpi_processor_idle(void)
 
        case ACPI_STATE_C3:
 
-               if (pr->flags.bm_check) {
+               /*
+                * disable bus master
+                * bm_check implies we need ARB_DIS
+                * !bm_check implies we need cache flush
+                * bm_control implies whether we can do ARB_DIS
+                *
+                * That leaves a case where bm_check is set and bm_control is
+                * not set. In that case we cannot do much, we enter C3
+                * without doing anything.
+                */
+               if (pr->flags.bm_check && pr->flags.bm_control) {
                        if (atomic_inc_return(&c3_cpu_count) ==
                            num_online_cpus()) {
                                /*
@@ -499,7 +509,7 @@ static void acpi_processor_idle(void)
                                 */
                                acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
                        }
-               } else {
+               } else if (!pr->flags.bm_check) {
                        /* SMP with no shared cache... Invalidate cache  */
                        ACPI_FLUSH_CPU_CACHE();
                }
@@ -511,7 +521,7 @@ static void acpi_processor_idle(void)
                acpi_cstate_enter(cx);
                /* Get end time (ticks) */
                t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
-               if (pr->flags.bm_check) {
+               if (pr->flags.bm_check && pr->flags.bm_control) {
                        /* Enable bus master arbitration */
                        atomic_dec(&c3_cpu_count);
                        acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
@@ -961,9 +971,9 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
        if (pr->flags.bm_check) {
                /* bus mastering control is necessary */
                if (!pr->flags.bm_control) {
+                       /* In this case we enter C3 without bus mastering */
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                                         "C3 support requires bus mastering control\n"));
-                       return;
+                               "C3 support without bus mastering control\n"));
                }
        } else {
                /*
index c1bae10..974d00c 100644 (file)
@@ -127,7 +127,7 @@ static int acpi_sbs_resume(struct acpi_device *device);
 static struct acpi_driver acpi_sbs_driver = {
        .name = "sbs",
        .class = ACPI_SBS_CLASS,
-       .ids = ACPI_SBS_HID,
+       .ids = "ACPI0001,ACPI0005",
        .ops = {
                .add = acpi_sbs_add,
                .remove = acpi_sbs_remove,
@@ -176,10 +176,8 @@ struct acpi_battery {
 };
 
 struct acpi_sbs {
-       acpi_handle handle;
        int base;
        struct acpi_device *device;
-       struct acpi_ec_smbus *smbus;
        struct mutex mutex;
        int sbsm_present;
        int sbsm_batteries_supported;
@@ -511,7 +509,7 @@ static int acpi_sbsm_get_info(struct acpi_sbs *sbs)
                                "acpi_sbs_read_word() failed"));
                goto end;
        }
-
+       sbs->sbsm_present = 1;
        sbs->sbsm_batteries_supported = battery_system_info & 0x000f;
 
       end:
@@ -1630,13 +1628,12 @@ static int acpi_sbs_add(struct acpi_device *device)
 {
        struct acpi_sbs *sbs = NULL;
        int result = 0, remove_result = 0;
-       unsigned long sbs_obj;
        int id;
        acpi_status status = AE_OK;
        unsigned long val;
 
        status =
-           acpi_evaluate_integer(device->parent->handle, "_EC", NULL, &val);
+           acpi_evaluate_integer(device->handle, "_EC", NULL, &val);
        if (ACPI_FAILURE(status)) {
                ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Error obtaining _EC"));
                return -EIO;
@@ -1653,7 +1650,7 @@ static int acpi_sbs_add(struct acpi_device *device)
 
        sbs_mutex_lock(sbs);
 
-       sbs->base = (val & 0xff00ull) >> 8;
+       sbs->base = 0xff & (val >> 8);
        sbs->device = device;
 
        strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
@@ -1665,24 +1662,10 @@ static int acpi_sbs_add(struct acpi_device *device)
                ACPI_EXCEPTION((AE_INFO, AE_ERROR, "acpi_ac_add() failed"));
                goto end;
        }
-       status = acpi_evaluate_integer(device->handle, "_SBS", NULL, &sbs_obj);
-       if (status) {
-               ACPI_EXCEPTION((AE_INFO, status,
-                               "acpi_evaluate_integer() failed"));
-               result = -EIO;
-               goto end;
-       }
-       if (sbs_obj > 0) {
-               result = acpi_sbsm_get_info(sbs);
-               if (result) {
-                       ACPI_EXCEPTION((AE_INFO, AE_ERROR,
-                                       "acpi_sbsm_get_info() failed"));
-                       goto end;
-               }
-               sbs->sbsm_present = 1;
-       }
 
-       if (sbs->sbsm_present == 0) {
+       acpi_sbsm_get_info(sbs);
+
+       if (!sbs->sbsm_present) {
                result = acpi_battery_add(sbs, 0);
                if (result) {
                        ACPI_EXCEPTION((AE_INFO, AE_ERROR,
@@ -1702,8 +1685,6 @@ static int acpi_sbs_add(struct acpi_device *device)
                }
        }
 
-       sbs->handle = device->handle;
-
        init_timer(&sbs->update_timer);
        result = acpi_check_update_proc(sbs);
        if (result)
index 42127c0..3279e72 100644 (file)
@@ -210,11 +210,6 @@ static void acpi_hibernation_finish(void)
 
        /* reset firmware waking vector */
        acpi_set_firmware_waking_vector((acpi_physical_address) 0);
-
-       if (init_8259A_after_S1) {
-               printk("Broken toshiba laptop -> kicking interrupts\n");
-               init_8259A(0);
-       }
 }
 
 static int acpi_hibernation_pre_restore(void)
index 1285e91..002bb33 100644 (file)
@@ -211,14 +211,17 @@ void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags)
  * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
  *              Performs validation on some important FADT fields.
  *
+ * NOTE:        We create a local copy of the FADT regardless of the version.
+ *
  ******************************************************************************/
 
 void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
 {
 
        /*
-        * Check if the FADT is larger than what we know about (ACPI 2.0 version).
-        * Truncate the table, but make some noise.
+        * Check if the FADT is larger than the largest table that we expect
+        * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
+        * a warning.
         */
        if (length > sizeof(struct acpi_table_fadt)) {
                ACPI_WARNING((AE_INFO,
@@ -227,10 +230,12 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
                              sizeof(struct acpi_table_fadt)));
        }
 
-       /* Copy the entire FADT locally. Zero first for tb_convert_fadt */
+       /* Clear the entire local FADT */
 
        ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt));
 
+       /* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */
+
        ACPI_MEMCPY(&acpi_gbl_FADT, table,
                    ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
 
@@ -251,7 +256,7 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
  * RETURN:      None
  *
  * DESCRIPTION: Converts all versions of the FADT to a common internal format.
- *              -> Expand all 32-bit addresses to 64-bit.
+ *              Expand all 32-bit addresses to 64-bit.
  *
  * NOTE:        acpi_gbl_FADT must be of size (struct acpi_table_fadt),
  *              and must contain a copy of the actual FADT.
@@ -292,8 +297,23 @@ static void acpi_tb_convert_fadt(void)
        }
 
        /*
-        * Expand the 32-bit V1.0 addresses to the 64-bit "X" generic address
-        * structures as necessary.
+        * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
+        * should be zero are indeed zero. This will workaround BIOSs that
+        * inadvertently place values in these fields.
+        *
+        * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
+        * offset 45, 55, 95, and the word located at offset 109, 110.
+        */
+       if (acpi_gbl_FADT.header.revision < 3) {
+               acpi_gbl_FADT.preferred_profile = 0;
+               acpi_gbl_FADT.pstate_control = 0;
+               acpi_gbl_FADT.cst_control = 0;
+               acpi_gbl_FADT.boot_flags = 0;
+       }
+
+       /*
+        * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X"
+        * generic address structures as necessary.
         */
        for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
                target =
@@ -349,18 +369,6 @@ static void acpi_tb_convert_fadt(void)
                    acpi_gbl_FADT.xpm1a_event_block.space_id;
 
        }
-
-       /*
-        * For ACPI 1.0 FADTs, ensure that reserved fields (which should be zero)
-        * are indeed zero. This will workaround BIOSs that inadvertently placed
-        * values in these fields.
-        */
-       if (acpi_gbl_FADT.header.revision < 3) {
-               acpi_gbl_FADT.preferred_profile = 0;
-               acpi_gbl_FADT.pstate_control = 0;
-               acpi_gbl_FADT.cst_control = 0;
-               acpi_gbl_FADT.boot_flags = 0;
-       }
 }
 
 /******************************************************************************
index 9623eaf..303e48c 100644 (file)
@@ -142,43 +142,124 @@ struct sony_laptop_keypress {
        int key;
 };
 
-/* Correspondance table between sonypi events and input layer events */
-static struct {
-       int sonypiev;
-       int inputev;
-} sony_laptop_inputkeys[] = {
-       { SONYPI_EVENT_CAPTURE_PRESSED,         KEY_CAMERA },
-       { SONYPI_EVENT_FNKEY_ONLY,              KEY_FN },
-       { SONYPI_EVENT_FNKEY_ESC,               KEY_FN_ESC },
-       { SONYPI_EVENT_FNKEY_F1,                KEY_FN_F1 },
-       { SONYPI_EVENT_FNKEY_F2,                KEY_FN_F2 },
-       { SONYPI_EVENT_FNKEY_F3,                KEY_FN_F3 },
-       { SONYPI_EVENT_FNKEY_F4,                KEY_FN_F4 },
-       { SONYPI_EVENT_FNKEY_F5,                KEY_FN_F5 },
-       { SONYPI_EVENT_FNKEY_F6,                KEY_FN_F6 },
-       { SONYPI_EVENT_FNKEY_F7,                KEY_FN_F7 },
-       { SONYPI_EVENT_FNKEY_F8,                KEY_FN_F8 },
-       { SONYPI_EVENT_FNKEY_F9,                KEY_FN_F9 },
-       { SONYPI_EVENT_FNKEY_F10,               KEY_FN_F10 },
-       { SONYPI_EVENT_FNKEY_F11,               KEY_FN_F11 },
-       { SONYPI_EVENT_FNKEY_F12,               KEY_FN_F12 },
-       { SONYPI_EVENT_FNKEY_1,                 KEY_FN_1 },
-       { SONYPI_EVENT_FNKEY_2,                 KEY_FN_2 },
-       { SONYPI_EVENT_FNKEY_D,                 KEY_FN_D },
-       { SONYPI_EVENT_FNKEY_E,                 KEY_FN_E },
-       { SONYPI_EVENT_FNKEY_F,                 KEY_FN_F },
-       { SONYPI_EVENT_FNKEY_S,                 KEY_FN_S },
-       { SONYPI_EVENT_FNKEY_B,                 KEY_FN_B },
-       { SONYPI_EVENT_BLUETOOTH_PRESSED,       KEY_BLUE },
-       { SONYPI_EVENT_BLUETOOTH_ON,            KEY_BLUE },
-       { SONYPI_EVENT_PKEY_P1,                 KEY_PROG1 },
-       { SONYPI_EVENT_PKEY_P2,                 KEY_PROG2 },
-       { SONYPI_EVENT_PKEY_P3,                 KEY_PROG3 },
-       { SONYPI_EVENT_BACK_PRESSED,            KEY_BACK },
-       { SONYPI_EVENT_HELP_PRESSED,            KEY_HELP },
-       { SONYPI_EVENT_ZOOM_PRESSED,            KEY_ZOOM },
-       { SONYPI_EVENT_THUMBPHRASE_PRESSED,     BTN_THUMB },
-       { 0, 0 },
+/* Correspondance table between sonypi events
+ * and input layer indexes in the keymap
+ */
+static int sony_laptop_input_index[] = {
+       -1,     /* no event */
+       -1,     /* SONYPI_EVENT_JOGDIAL_DOWN */
+       -1,     /* SONYPI_EVENT_JOGDIAL_UP */
+       -1,     /* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */
+       -1,     /* SONYPI_EVENT_JOGDIAL_UP_PRESSED */
+       -1,     /* SONYPI_EVENT_JOGDIAL_PRESSED */
+       -1,     /* SONYPI_EVENT_JOGDIAL_RELEASED */
+        0,     /* SONYPI_EVENT_CAPTURE_PRESSED */
+        1,     /* SONYPI_EVENT_CAPTURE_RELEASED */
+        2,     /* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
+        3,     /* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
+        4,     /* SONYPI_EVENT_FNKEY_ESC */
+        5,     /* SONYPI_EVENT_FNKEY_F1 */
+        6,     /* SONYPI_EVENT_FNKEY_F2 */
+        7,     /* SONYPI_EVENT_FNKEY_F3 */
+        8,     /* SONYPI_EVENT_FNKEY_F4 */
+        9,     /* SONYPI_EVENT_FNKEY_F5 */
+       10,     /* SONYPI_EVENT_FNKEY_F6 */
+       11,     /* SONYPI_EVENT_FNKEY_F7 */
+       12,     /* SONYPI_EVENT_FNKEY_F8 */
+       13,     /* SONYPI_EVENT_FNKEY_F9 */
+       14,     /* SONYPI_EVENT_FNKEY_F10 */
+       15,     /* SONYPI_EVENT_FNKEY_F11 */
+       16,     /* SONYPI_EVENT_FNKEY_F12 */
+       17,     /* SONYPI_EVENT_FNKEY_1 */
+       18,     /* SONYPI_EVENT_FNKEY_2 */
+       19,     /* SONYPI_EVENT_FNKEY_D */
+       20,     /* SONYPI_EVENT_FNKEY_E */
+       21,     /* SONYPI_EVENT_FNKEY_F */
+       22,     /* SONYPI_EVENT_FNKEY_S */
+       23,     /* SONYPI_EVENT_FNKEY_B */
+       24,     /* SONYPI_EVENT_BLUETOOTH_PRESSED */
+       25,     /* SONYPI_EVENT_PKEY_P1 */
+       26,     /* SONYPI_EVENT_PKEY_P2 */
+       27,     /* SONYPI_EVENT_PKEY_P3 */
+       28,     /* SONYPI_EVENT_BACK_PRESSED */
+       -1,     /* SONYPI_EVENT_LID_CLOSED */
+       -1,     /* SONYPI_EVENT_LID_OPENED */
+       29,     /* SONYPI_EVENT_BLUETOOTH_ON */
+       30,     /* SONYPI_EVENT_BLUETOOTH_OFF */
+       31,     /* SONYPI_EVENT_HELP_PRESSED */
+       32,     /* SONYPI_EVENT_FNKEY_ONLY */
+       33,     /* SONYPI_EVENT_JOGDIAL_FAST_DOWN */
+       34,     /* SONYPI_EVENT_JOGDIAL_FAST_UP */
+       35,     /* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
+       36,     /* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
+       37,     /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
+       38,     /* SONYPI_EVENT_JOGDIAL_VFAST_UP */
+       39,     /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
+       40,     /* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
+       41,     /* SONYPI_EVENT_ZOOM_PRESSED */
+       42,     /* SONYPI_EVENT_THUMBPHRASE_PRESSED */
+       43,     /* SONYPI_EVENT_MEYE_FACE */
+       44,     /* SONYPI_EVENT_MEYE_OPPOSITE */
+       45,     /* SONYPI_EVENT_MEMORYSTICK_INSERT */
+       46,     /* SONYPI_EVENT_MEMORYSTICK_EJECT */
+       -1,     /* SONYPI_EVENT_ANYBUTTON_RELEASED */
+       -1,     /* SONYPI_EVENT_BATTERY_INSERT */
+       -1,     /* SONYPI_EVENT_BATTERY_REMOVE */
+       -1,     /* SONYPI_EVENT_FNKEY_RELEASED */
+       47,     /* SONYPI_EVENT_WIRELESS_ON */
+       48,     /* SONYPI_EVENT_WIRELESS_OFF */
+};
+
+static int sony_laptop_input_keycode_map[] = {
+       KEY_CAMERA,     /*  0 SONYPI_EVENT_CAPTURE_PRESSED */
+       KEY_RESERVED,   /*  1 SONYPI_EVENT_CAPTURE_RELEASED */
+       KEY_RESERVED,   /*  2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
+       KEY_RESERVED,   /*  3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
+       KEY_FN_ESC,     /*  4 SONYPI_EVENT_FNKEY_ESC */
+       KEY_FN_F1,      /*  5 SONYPI_EVENT_FNKEY_F1 */
+       KEY_FN_F2,      /*  6 SONYPI_EVENT_FNKEY_F2 */
+       KEY_FN_F3,      /*  7 SONYPI_EVENT_FNKEY_F3 */
+       KEY_FN_F4,      /*  8 SONYPI_EVENT_FNKEY_F4 */
+       KEY_FN_F5,      /*  9 SONYPI_EVENT_FNKEY_F5 */
+       KEY_FN_F6,      /* 10 SONYPI_EVENT_FNKEY_F6 */
+       KEY_FN_F7,      /* 11 SONYPI_EVENT_FNKEY_F7 */
+       KEY_FN_F8,      /* 12 SONYPI_EVENT_FNKEY_F8 */
+       KEY_FN_F9,      /* 13 SONYPI_EVENT_FNKEY_F9 */
+       KEY_FN_F10,     /* 14 SONYPI_EVENT_FNKEY_F10 */
+       KEY_FN_F11,     /* 15 SONYPI_EVENT_FNKEY_F11 */
+       KEY_FN_F12,     /* 16 SONYPI_EVENT_FNKEY_F12 */
+       KEY_FN_F1,      /* 17 SONYPI_EVENT_FNKEY_1 */
+       KEY_FN_F2,      /* 18 SONYPI_EVENT_FNKEY_2 */
+       KEY_FN_D,       /* 19 SONYPI_EVENT_FNKEY_D */
+       KEY_FN_E,       /* 20 SONYPI_EVENT_FNKEY_E */
+       KEY_FN_F,       /* 21 SONYPI_EVENT_FNKEY_F */
+       KEY_FN_S,       /* 22 SONYPI_EVENT_FNKEY_S */
+       KEY_FN_B,       /* 23 SONYPI_EVENT_FNKEY_B */
+       KEY_BLUETOOTH,  /* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */
+       KEY_PROG1,      /* 25 SONYPI_EVENT_PKEY_P1 */
+       KEY_PROG2,      /* 26 SONYPI_EVENT_PKEY_P2 */
+       KEY_PROG3,      /* 27 SONYPI_EVENT_PKEY_P3 */
+       KEY_BACK,       /* 28 SONYPI_EVENT_BACK_PRESSED */
+       KEY_BLUETOOTH,  /* 29 SONYPI_EVENT_BLUETOOTH_ON */
+       KEY_BLUETOOTH,  /* 30 SONYPI_EVENT_BLUETOOTH_OFF */
+       KEY_HELP,       /* 31 SONYPI_EVENT_HELP_PRESSED */
+       KEY_FN,         /* 32 SONYPI_EVENT_FNKEY_ONLY */
+       KEY_RESERVED,   /* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */
+       KEY_RESERVED,   /* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */
+       KEY_RESERVED,   /* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
+       KEY_RESERVED,   /* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
+       KEY_RESERVED,   /* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
+       KEY_RESERVED,   /* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */
+       KEY_RESERVED,   /* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
+       KEY_RESERVED,   /* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
+       KEY_ZOOM,       /* 41 SONYPI_EVENT_ZOOM_PRESSED */
+       BTN_THUMB,      /* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */
+       KEY_RESERVED,   /* 43 SONYPI_EVENT_MEYE_FACE */
+       KEY_RESERVED,   /* 44 SONYPI_EVENT_MEYE_OPPOSITE */
+       KEY_RESERVED,   /* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */
+       KEY_RESERVED,   /* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */
+       KEY_WLAN,       /* 47 SONYPI_EVENT_WIRELESS_ON */
+       KEY_WLAN,       /* 48 SONYPI_EVENT_WIRELESS_OFF */
 };
 
 /* release buttons after a short delay if pressed */
@@ -202,7 +283,6 @@ static void sony_laptop_report_input_event(u8 event)
        struct input_dev *jog_dev = sony_laptop_input.jog_dev;
        struct input_dev *key_dev = sony_laptop_input.key_dev;
        struct sony_laptop_keypress kp = { NULL };
-       int i;
 
        if (event == SONYPI_EVENT_FNKEY_RELEASED) {
                /* Nothing, not all VAIOs generate this event */
@@ -231,17 +311,22 @@ static void sony_laptop_report_input_event(u8 event)
                break;
 
        default:
-               for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
-                       if (event == sony_laptop_inputkeys[i].sonypiev) {
+               if (event > ARRAY_SIZE (sony_laptop_input_keycode_map)) {
+                       dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
+                       break;
+               }
+               if (sony_laptop_input_index[event] != -1) {
+                       kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
+                       if (kp.key != KEY_UNKNOWN)
                                kp.dev = key_dev;
-                               kp.key = sony_laptop_inputkeys[i].inputev;
-                               break;
-                       }
+               }
                break;
        }
 
        if (kp.dev) {
                input_report_key(kp.dev, kp.key, 1);
+               /* we emit the scancode so we can always remap the key */
+               input_event(kp.dev, EV_MSC, MSC_SCAN, event);
                input_sync(kp.dev);
                kfifo_put(sony_laptop_input.fifo,
                          (unsigned char *)&kp, sizeof(kp));
@@ -296,11 +381,18 @@ static int sony_laptop_setup_input(void)
        key_dev->id.vendor = PCI_VENDOR_ID_SONY;
 
        /* Initialize the Input Drivers: special keys */
-       key_dev->evbit[0] = BIT(EV_KEY);
-       for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
-               if (sony_laptop_inputkeys[i].inputev)
-                       set_bit(sony_laptop_inputkeys[i].inputev,
-                                       key_dev->keybit);
+       set_bit(EV_KEY, key_dev->evbit);
+       set_bit(EV_MSC, key_dev->evbit);
+       set_bit(MSC_SCAN, key_dev->mscbit);
+       key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]);
+       key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map);
+       key_dev->keycode = &sony_laptop_input_keycode_map;
+       for (i = 0; i < ARRAY_SIZE(sony_laptop_input_keycode_map); i++) {
+               if (sony_laptop_input_keycode_map[i] != KEY_RESERVED) {
+                       set_bit(sony_laptop_input_keycode_map[i],
+                               key_dev->keybit);
+               }
+       }
 
        error = input_register_device(key_dev);
        if (error)
@@ -487,6 +579,14 @@ SNC_HANDLE_NAMES(audiopower_set, "AZPW");
 SNC_HANDLE_NAMES(lanpower_get, "GLNP");
 SNC_HANDLE_NAMES(lanpower_set, "LNPW");
 
+SNC_HANDLE_NAMES(lidstate_get, "GLID");
+
+SNC_HANDLE_NAMES(indicatorlamp_get, "GILS");
+SNC_HANDLE_NAMES(indicatorlamp_set, "SILS");
+
+SNC_HANDLE_NAMES(gainbass_get, "GMGB");
+SNC_HANDLE_NAMES(gainbass_set, "CMGB");
+
 SNC_HANDLE_NAMES(PID_get, "GPID");
 
 SNC_HANDLE_NAMES(CTR_get, "GCTR");
@@ -507,6 +607,12 @@ static struct sony_nc_value sony_nc_values[] = {
                        boolean_validate, 0),
        SNC_HANDLE(lanpower, snc_lanpower_get, snc_lanpower_set,
                        boolean_validate, 1),
+       SNC_HANDLE(lidstate, snc_lidstate_get, NULL,
+                       boolean_validate, 0),
+       SNC_HANDLE(indicatorlamp, snc_indicatorlamp_get, snc_indicatorlamp_set,
+                       boolean_validate, 0),
+       SNC_HANDLE(gainbass, snc_gainbass_get, snc_gainbass_set,
+                       boolean_validate, 0),
        /* unknown methods */
        SNC_HANDLE(PID, snc_PID_get, NULL, NULL, 1),
        SNC_HANDLE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1),
@@ -689,13 +795,116 @@ static struct backlight_ops sony_backlight_ops = {
 };
 
 /*
+ * New SNC-only Vaios event mapping to driver known keys
+ */
+struct sony_nc_event {
+       u8      data;
+       u8      event;
+};
+
+static struct sony_nc_event *sony_nc_events;
+
+/* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence
+ * for Fn keys
+ */
+static int sony_nc_C_enable(struct dmi_system_id *id)
+{
+       int result = 0;
+
+       printk(KERN_NOTICE DRV_PFX "detected %s\n", id->ident);
+
+       sony_nc_events = id->driver_data;
+
+       if (acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0x4, &result) < 0
+                       || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x2, &result) < 0
+                       || acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0x10, &result) < 0
+                       || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x0, &result) < 0
+                       || acpi_callsetfunc(sony_nc_acpi_handle, "SN03", 0x2, &result) < 0
+                       || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x101, &result) < 0) {
+               printk(KERN_WARNING DRV_PFX "failed to initialize SNC, some "
+                               "functionalities may be missing\n");
+               return 1;
+       }
+       return 0;
+}
+
+static struct sony_nc_event sony_C_events[] = {
+       { 0x81, SONYPI_EVENT_FNKEY_F1 },
+       { 0x01, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0x85, SONYPI_EVENT_FNKEY_F5 },
+       { 0x05, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0x86, SONYPI_EVENT_FNKEY_F6 },
+       { 0x06, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0x87, SONYPI_EVENT_FNKEY_F7 },
+       { 0x07, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0x8A, SONYPI_EVENT_FNKEY_F10 },
+       { 0x0A, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0x8C, SONYPI_EVENT_FNKEY_F12 },
+       { 0x0C, SONYPI_EVENT_FNKEY_RELEASED },
+       { 0, 0 },
+};
+
+/* SNC-only model map */
+struct dmi_system_id sony_nc_ids[] = {
+               {
+                       .ident = "Sony Vaio FE Series",
+                       .callback = sony_nc_C_enable,
+                       .driver_data = sony_C_events,
+                       .matches = {
+                               DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+                               DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FE"),
+                       },
+               },
+               {
+                       .ident = "Sony Vaio C Series",
+                       .callback = sony_nc_C_enable,
+                       .driver_data = sony_C_events,
+                       .matches = {
+                               DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+                               DMI_MATCH(DMI_PRODUCT_NAME, "VGN-C"),
+                       },
+               },
+               { }
+};
+
+/*
  * ACPI callbacks
  */
 static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-       dprintk("sony_acpi_notify, event: %d\n", event);
-       sony_laptop_report_input_event(event);
-       acpi_bus_generate_event(sony_nc_acpi_device, 1, event);
+       struct sony_nc_event *evmap;
+       u32 ev = event;
+       int result;
+
+       if (ev == 0x92) {
+               /* read the key pressed from EC.GECR
+                * A call to SN07 with 0x0202 will do it as well respecting
+                * the current protocol on different OSes
+                *
+                * Note: the path for GECR may be
+                *   \_SB.PCI0.LPCB.EC (C, FE, AR, N and friends)
+                *   \_SB.PCI0.PIB.EC0 (VGN-FR notifications are sent directly, no GECR)
+                *
+                * TODO: we may want to do the same for the older GHKE -need
+                *       dmi list- so this snippet may become one more callback.
+                */
+               if (acpi_callsetfunc(handle, "SN07", 0x0202, &result) < 0)
+                       dprintk("sony_acpi_notify, unable to decode event 0x%.2x\n", ev);
+               else
+                       ev = result & 0xFF;
+       }
+
+       if (sony_nc_events)
+               for (evmap = sony_nc_events; evmap->event; evmap++) {
+                       if (evmap->data == ev) {
+                               ev = evmap->event;
+                               break;
+                       }
+               }
+
+       dprintk("sony_acpi_notify, event: 0x%.2x\n", ev);
+       sony_laptop_report_input_event(ev);
+       acpi_bus_generate_event(sony_nc_acpi_device, 1, ev);
 }
 
 static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -732,6 +941,10 @@ static int sony_nc_resume(struct acpi_device *device)
                        break;
                }
        }
+
+       /* re-initialize models with specific requirements */
+       dmi_check_system(sony_nc_ids);
+
        return 0;
 }
 
@@ -750,6 +963,15 @@ static int sony_nc_add(struct acpi_device *device)
 
        sony_nc_acpi_handle = device->handle;
 
+       /* read device status */
+       result = acpi_bus_get_status(device);
+       /* bail IFF the above call was successful and the device is not present */
+       if (!result && !device->status.present) {
+               dprintk("Device not present\n");
+               result = -ENODEV;
+               goto outwalk;
+       }
+
        if (debug) {
                status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_nc_acpi_handle,
                                             1, sony_walk_callback, NULL, NULL);
@@ -760,6 +982,15 @@ static int sony_nc_add(struct acpi_device *device)
                }
        }
 
+       /* try to _INI the device if such method exists (ACPI spec 3.0-6.5.1
+        * should be respected as we already checked for the device presence above */
+       if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, METHOD_NAME__INI, &handle))) {
+               dprintk("Invoking _INI\n");
+               if (ACPI_FAILURE(acpi_evaluate_object(sony_nc_acpi_handle, METHOD_NAME__INI,
+                                               NULL, NULL)))
+                       dprintk("_INI Method failed\n");
+       }
+
        /* setup input devices and helper fifo */
        result = sony_laptop_setup_input();
        if (result) {
@@ -772,7 +1003,7 @@ static int sony_nc_add(struct acpi_device *device)
                                             ACPI_DEVICE_NOTIFY,
                                             sony_acpi_notify, NULL);
        if (ACPI_FAILURE(status)) {
-               printk(KERN_WARNING DRV_PFX "unable to install notify handler\n");
+               printk(KERN_WARNING DRV_PFX "unable to install notify handler (%u)\n", status);
                result = -ENODEV;
                goto outinput;
        }
@@ -795,6 +1026,9 @@ static int sony_nc_add(struct acpi_device *device)
 
        }
 
+       /* initialize models with specific requirements */
+       dmi_check_system(sony_nc_ids);
+
        result = sony_pf_add();
        if (result)
                goto outbacklight;
@@ -908,7 +1142,9 @@ static struct acpi_driver sony_nc_driver = {
 #define SONYPI_DEVICE_TYPE2    0x00000002
 #define SONYPI_DEVICE_TYPE3    0x00000004
 
-#define SONY_PIC_EV_MASK       0xff
+#define SONYPI_TYPE1_OFFSET    0x04
+#define SONYPI_TYPE2_OFFSET    0x12
+#define SONYPI_TYPE3_OFFSET    0x12
 
 struct sony_pic_ioport {
        struct acpi_resource_io io;
@@ -922,6 +1158,7 @@ struct sony_pic_irq {
 
 struct sony_pic_dev {
        int                     model;
+       u16                     evport_offset;
        u8                      camera_power;
        u8                      bluetooth_power;
        u8                      wwan_power;
@@ -1999,20 +2236,17 @@ end:
 static irqreturn_t sony_pic_irq(int irq, void *dev_id)
 {
        int i, j;
-       u32 port_val = 0;
        u8 ev = 0;
        u8 data_mask = 0;
        u8 device_event = 0;
 
        struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id;
 
-       acpi_os_read_port(dev->cur_ioport->io.minimum, &port_val,
-                       dev->cur_ioport->io.address_length);
-       ev = port_val & SONY_PIC_EV_MASK;
-       data_mask = 0xff & (port_val >> (dev->cur_ioport->io.address_length - 8));
+       ev = inb_p(dev->cur_ioport->io.minimum);
+       data_mask = inb_p(dev->cur_ioport->io.minimum + dev->evport_offset);
 
-       dprintk("event (0x%.8x [%.2x] [%.2x]) at port 0x%.4x\n",
-                       port_val, ev, data_mask, dev->cur_ioport->io.minimum);
+       dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
+                       ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset);
 
        if (ev == 0x00 || ev == 0xff)
                return IRQ_HANDLED;
@@ -2103,6 +2337,20 @@ static int sony_pic_add(struct acpi_device *device)
        spic_dev.model = sony_pic_detect_device_type();
        mutex_init(&spic_dev.lock);
 
+       /* model specific characteristics */
+       switch(spic_dev.model) {
+               case SONYPI_DEVICE_TYPE1:
+                       spic_dev.evport_offset = SONYPI_TYPE1_OFFSET;
+                       break;
+               case SONYPI_DEVICE_TYPE3:
+                       spic_dev.evport_offset = SONYPI_TYPE3_OFFSET;
+                       break;
+               case SONYPI_DEVICE_TYPE2:
+               default:
+                       spic_dev.evport_offset = SONYPI_TYPE2_OFFSET;
+                       break;
+       }
+
        /* read _PRS resources */
        result = sony_pic_possible_resources(device);
        if (result) {
index 3073f67..f8a602c 100644 (file)
@@ -5,6 +5,7 @@
 
 menuconfig NETDEVICES
        default y if UML
+       depends on NET
        bool "Network device support"
        ---help---
          You can say N here if you don't intend to connect your Linux box to
index 829da9a..2098d0a 100644 (file)
@@ -155,6 +155,15 @@ config KINGSUN_DONGLE
          To compile it as a module, choose M here: the module will be called
          kingsun-sir.
 
+config EP7211_DONGLE
+       tristate "EP7211 I/R support"
+       depends on IRTTY_SIR && ARCH_EP7211 && IRDA && EXPERIMENTAL
+       help
+         Say Y here if you want to build support for the Cirrus logic
+         EP7211 chipset's infrared module.
+
+
+
 comment "Old SIR device drivers"
 
 config IRPORT_SIR
@@ -355,7 +364,7 @@ config WINBOND_FIR
 
 config TOSHIBA_FIR
        tristate "Toshiba Type-O IR Port"
-       depends on IRDA && PCI && !64BIT
+       depends on IRDA && PCI && !64BIT && VIRT_TO_BUS
        help
          Say Y here if you want to build support for the Toshiba Type-O IR
          and Donau oboe chipsets. These chipsets are used by the Toshiba
index 233a2f9..2808ef5 100644 (file)
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE)  += mcp2120-sir.o
 obj-$(CONFIG_ACT200L_DONGLE)   += act200l-sir.o
 obj-$(CONFIG_MA600_DONGLE)     += ma600-sir.o
 obj-$(CONFIG_TOIM3232_DONGLE)  += toim3232-sir.o
+obj-$(CONFIG_EP7211_DONGLE)    += ep7211-sir.o
 obj-$(CONFIG_KINGSUN_DONGLE)   += kingsun-sir.o
 
 # The SIR helper module
diff --git a/drivers/net/irda/ep7211-sir.c b/drivers/net/irda/ep7211-sir.c
new file mode 100644 (file)
index 0000000..8315724
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * IR port driver for the Cirrus Logic EP7211 processor.
+ *
+ * Copyright 2001, Blue Mug Inc.  All rights reserved.
+ * Copyright 2007, Samuel Ortiz <samuel@sortiz.org>
+ */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/tty.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+
+#include <net/irda/irda.h>
+#include <net/irda/irda_device.h>
+
+#include <asm/io.h>
+#include <asm/hardware.h>
+
+#include "sir-dev.h"
+
+#define MIN_DELAY 25      /* 15 us, but wait a little more to be sure */
+#define MAX_DELAY 10000   /* 1 ms */
+
+static int ep7211_open(struct sir_dev *dev);
+static int ep7211_close(struct sir_dev *dev);
+static int ep7211_change_speed(struct sir_dev *dev, unsigned speed);
+static int ep7211_reset(struct sir_dev *dev);
+
+static struct dongle_driver ep7211 = {
+       .owner          = THIS_MODULE,
+       .driver_name    = "EP7211 IR driver",
+       .type           = IRDA_EP7211_DONGLE,
+       .open           = ep7211_open,
+       .close          = ep7211_close,
+       .reset          = ep7211_reset,
+       .set_speed      = ep7211_change_speed,
+};
+
+static int __init ep7211_sir_init(void)
+{
+       return irda_register_dongle(&ep7211);
+}
+
+static void __exit ep7211_sir_cleanup(void)
+{
+       irda_unregister_dongle(&ep7211);
+}
+
+static int ep7211_open(struct sir_dev *dev)
+{
+       unsigned int syscon;
+
+       /* Turn on the SIR encoder. */
+       syscon = clps_readl(SYSCON1);
+       syscon |= SYSCON1_SIREN;
+       clps_writel(syscon, SYSCON1);
+
+       return 0;
+}
+
+static int ep7211_close(struct sir_dev *dev)
+{
+       unsigned int syscon;
+
+       /* Turn off the SIR encoder. */
+       syscon = clps_readl(SYSCON1);
+       syscon &= ~SYSCON1_SIREN;
+       clps_writel(syscon, SYSCON1);
+
+       return 0;
+}
+
+static int ep7211_change_speed(struct sir_dev *dev, unsigned speed)
+{
+       return 0;
+}
+
+static int ep7211_reset(struct sir_dev *dev)
+{
+       return 0;
+}
+
+MODULE_AUTHOR("Samuel Ortiz <samuel@sortiz.org>");
+MODULE_DESCRIPTION("EP7211 IR dongle driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("irda-dongle-13"); /* IRDA_EP7211_DONGLE */
+
+module_init(ep7211_sir_init);
+module_exit(ep7211_sir_cleanup);
index 8948a64..45662f6 100644 (file)
 #define ACPI_FUNCTION_NAME(name)
 #endif
 
+#ifdef DEBUG_FUNC_TRACE
+
 #define ACPI_FUNCTION_TRACE(a)          ACPI_FUNCTION_NAME(a) \
                          acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
 #define ACPI_FUNCTION_TRACE_PTR(a,b)    ACPI_FUNCTION_NAME(a) \
 
 #endif                         /* ACPI_SIMPLE_RETURN_MACROS */
 
+#else /* !DEBUG_FUNC_TRACE */
+
+#define ACPI_FUNCTION_TRACE(a)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)
+#define ACPI_FUNCTION_EXIT
+#define ACPI_FUNCTION_STATUS_EXIT(s)
+#define ACPI_FUNCTION_VALUE_EXIT(s)
+#define ACPI_FUNCTION_TRACE(a)
+#define ACPI_FUNCTION_ENTRY()
+
+#define return_VOID                     return
+#define return_ACPI_STATUS(s)           return(s)
+#define return_VALUE(s)                 return(s)
+#define return_UINT8(s)                 return(s)
+#define return_UINT32(s)                return(s)
+#define return_PTR(s)                   return(s)
+
+#endif /* DEBUG_FUNC_TRACE */
+
 /* Conditional execution */
 
 #define ACPI_DEBUG_EXEC(a)              a
 #define ACPI_DEBUG_EXEC(a)
 #define ACPI_NORMAL_EXEC(a)             a;
 
-#define ACPI_DEBUG_DEFINE(a)
-#define ACPI_DEBUG_ONLY_MEMBERS(a)
-#define ACPI_FUNCTION_NAME(a)
-#define ACPI_FUNCTION_TRACE(a)
-#define ACPI_FUNCTION_TRACE_PTR(a,b)
-#define ACPI_FUNCTION_TRACE_U32(a,b)
-#define ACPI_FUNCTION_TRACE_STR(a,b)
-#define ACPI_FUNCTION_EXIT
-#define ACPI_FUNCTION_STATUS_EXIT(s)
-#define ACPI_FUNCTION_VALUE_EXIT(s)
-#define ACPI_FUNCTION_ENTRY()
-#define ACPI_DUMP_STACK_ENTRY(a)
-#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
-#define ACPI_DUMP_ENTRY(a,b)
-#define ACPI_DUMP_TABLES(a,b)
-#define ACPI_DUMP_PATHNAME(a,b,c,d)
-#define ACPI_DUMP_RESOURCE_LIST(a)
-#define ACPI_DUMP_BUFFER(a,b)
-#define ACPI_DEBUG_PRINT(pl)
-#define ACPI_DEBUG_PRINT_RAW(pl)
+#define ACPI_DEBUG_DEFINE(a)           do { } while(0)
+#define ACPI_DEBUG_ONLY_MEMBERS(a)     do { } while(0)
+#define ACPI_FUNCTION_NAME(a)          do { } while(0)
+#define ACPI_FUNCTION_TRACE(a)         do { } while(0)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)   do { } while(0)
+#define ACPI_FUNCTION_TRACE_U32(a,b)   do { } while(0)
+#define ACPI_FUNCTION_TRACE_STR(a,b)   do { } while(0)
+#define ACPI_FUNCTION_EXIT             do { } while(0)
+#define ACPI_FUNCTION_STATUS_EXIT(s)   do { } while(0)
+#define ACPI_FUNCTION_VALUE_EXIT(s)    do { } while(0)
+#define ACPI_FUNCTION_ENTRY()          do { } while(0)
+#define ACPI_DUMP_STACK_ENTRY(a)       do { } while(0)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e)  do { } while(0)
+#define ACPI_DUMP_ENTRY(a,b)           do { } while(0)
+#define ACPI_DUMP_TABLES(a,b)          do { } while(0)
+#define ACPI_DUMP_PATHNAME(a,b,c,d)    do { } while(0)
+#define ACPI_DUMP_RESOURCE_LIST(a)     do { } while(0)
+#define ACPI_DUMP_BUFFER(a,b)          do { } while(0)
+#define ACPI_DEBUG_PRINT(pl)           do { } while(0)
+#define ACPI_DEBUG_PRINT_RAW(pl)       do { } while(0)
 
 #define return_VOID                     return
 #define return_ACPI_STATUS(s)           return(s)
index 7812267..c090a8b 100644 (file)
 
 /* Defaults for debug_level, debug and normal */
 
-#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
-#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR)
+#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR)
 #define ACPI_DEBUG_ALL              (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
 
 #endif                         /* __ACOUTPUT_H__ */
index dab2ec5..c785485 100644 (file)
 
 /*! [Begin] no source code translation */
 
-#if defined(__linux__)
+#if defined(_LINUX) || defined(__linux__)
 #include "aclinux.h"
 
 #elif defined(_AED_EFI)
index a568717..6ed15a0 100644 (file)
 #define ACPI_USE_NATIVE_DIVIDE
 #endif
 
+#ifndef __cdecl
 #define __cdecl
+#endif
+
 #define ACPI_FLUSH_CPU_CACHE()
 #endif                         /* __KERNEL__ */
 
index ff520ea..afb88a5 100644 (file)
 #ifndef _SPARC_IRQ_H
 #define _SPARC_IRQ_H
 
-#include <linux/linkage.h>
-#include <linux/threads.h>     /* For NR_CPUS */
 #include <linux/interrupt.h>
 
-#include <asm/system.h>     /* For SUN4M_NCPUS */
-#include <asm/btfixup.h>
-
-#define __irq_ino(irq) irq
-#define __irq_pil(irq) irq
-
 #define NR_IRQS    16
 
 #define irq_canonicalize(irq)  (irq)
 
-/* Dave Redman (djhr@tadpole.co.uk)
- * changed these to function pointers.. it saves cycles and will allow
- * the irq dependencies to be split into different files at a later date
- * sun4c_irq.c, sun4m_irq.c etc so we could reduce the kernel size.
- * Jakub Jelinek (jj@sunsite.mff.cuni.cz)
- * Changed these to btfixup entities... It saves cycles :)
- */
-BTFIXUPDEF_CALL(void, disable_irq, unsigned int)
-BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
-BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
-BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
-BTFIXUPDEF_CALL(void, clear_clock_irq, void)
-BTFIXUPDEF_CALL(void, clear_profile_irq, int)
-BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
-
-static inline void disable_irq_nosync(unsigned int irq)
-{
-       BTFIXUP_CALL(disable_irq)(irq);
-}
-
-static inline void disable_irq(unsigned int irq)
-{
-       BTFIXUP_CALL(disable_irq)(irq);
-}
-
-static inline void enable_irq(unsigned int irq)
-{
-       BTFIXUP_CALL(enable_irq)(irq);
-}
-
-static inline void disable_pil_irq(unsigned int irq)
-{
-       BTFIXUP_CALL(disable_pil_irq)(irq);
-}
-
-static inline void enable_pil_irq(unsigned int irq)
-{
-       BTFIXUP_CALL(enable_pil_irq)(irq);
-}
-
-static inline void clear_clock_irq(void)
-{
-       BTFIXUP_CALL(clear_clock_irq)();
-}
-
-static inline void clear_profile_irq(int irq)
-{
-       BTFIXUP_CALL(clear_profile_irq)(irq);
-}
-
-static inline void load_profile_irq(int cpu, int limit)
-{
-       BTFIXUP_CALL(load_profile_irq)(cpu, limit);
-}
-
-extern void (*sparc_init_timers)(irq_handler_t lvl10_irq);
-extern void claim_ticker14(irq_handler_t irq_handler,
-                          int irq,
-                          unsigned int timeout);
-
-#ifdef CONFIG_SMP
-BTFIXUPDEF_CALL(void, set_cpu_int, int, int)
-BTFIXUPDEF_CALL(void, clear_cpu_int, int, int)
-BTFIXUPDEF_CALL(void, set_irq_udt, int)
-
-#define set_cpu_int(cpu,level) BTFIXUP_CALL(set_cpu_int)(cpu,level)
-#define clear_cpu_int(cpu,level) BTFIXUP_CALL(clear_cpu_int)(cpu,level)
-#define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
-#endif
+extern void disable_irq_nosync(unsigned int irq);
+extern void disable_irq(unsigned int irq);
+extern void enable_irq(unsigned int irq);
 
 extern int request_fast_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, __const__ char *devname);
 
-/* On the sun4m, just like the timers, we have both per-cpu and master
- * interrupt registers.
- */
-
-/* These registers are used for sending/receiving irqs from/to
- * different cpu's.
- */
-struct sun4m_intreg_percpu {
-       unsigned int tbt;        /* Interrupts still pending for this cpu. */
-
-       /* These next two registers are WRITE-ONLY and are only
-        * "on bit" sensitive, "off bits" written have NO affect.
-        */
-       unsigned int clear;  /* Clear this cpus irqs here. */
-       unsigned int set;    /* Set this cpus irqs here. */
-       unsigned char space[PAGE_SIZE - 12];
-};
-
-/*
- * djhr
- * Actually the clear and set fields in this struct are misleading..
- * according to the SLAVIO manual (and the same applies for the SEC)
- * the clear field clears bits in the mask which will ENABLE that IRQ
- * the set field sets bits in the mask to DISABLE the IRQ.
- *
- * Also the undirected_xx address in the SLAVIO is defined as
- * RESERVED and write only..
- *
- * DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
- *             sun4m machines, for MP the layout makes more sense.
- */
-struct sun4m_intregs {
-       struct sun4m_intreg_percpu cpu_intregs[SUN4M_NCPUS];
-       unsigned int tbt;                /* IRQ's that are still pending. */
-       unsigned int irqs;               /* Master IRQ bits. */
-
-       /* Again, like the above, two these registers are WRITE-ONLY. */
-       unsigned int clear;              /* Clear master IRQ's by setting bits here. */
-       unsigned int set;                /* Set master IRQ's by setting bits here. */
-
-       /* This register is both READ and WRITE. */
-       unsigned int undirected_target;  /* Which cpu gets undirected irqs. */
-};
-
-extern struct sun4m_intregs *sun4m_interrupts;
-
-/* 
- * Bit field defines for the interrupt registers on various
- * Sparc machines.
- */
-
-/* The sun4c interrupt register. */
-#define SUN4C_INT_ENABLE  0x01     /* Allow interrupts. */
-#define SUN4C_INT_E14     0x80     /* Enable level 14 IRQ. */
-#define SUN4C_INT_E10     0x20     /* Enable level 10 IRQ. */
-#define SUN4C_INT_E8      0x10     /* Enable level 8 IRQ. */
-#define SUN4C_INT_E6      0x08     /* Enable level 6 IRQ. */
-#define SUN4C_INT_E4      0x04     /* Enable level 4 IRQ. */
-#define SUN4C_INT_E1      0x02     /* Enable level 1 IRQ. */
-
-/* Dave Redman (djhr@tadpole.co.uk)
- * The sun4m interrupt registers.
- */
-#define SUN4M_INT_ENABLE       0x80000000
-#define SUN4M_INT_E14          0x00000080
-#define SUN4M_INT_E10          0x00080000
-
-#define SUN4M_HARD_INT(x)      (0x000000001 << (x))
-#define SUN4M_SOFT_INT(x)      (0x000010000 << (x))
-
-#define        SUN4M_INT_MASKALL       0x80000000        /* mask all interrupts */
-#define        SUN4M_INT_MODULE_ERR    0x40000000        /* module error */
-#define        SUN4M_INT_M2S_WRITE     0x20000000        /* write buffer error */
-#define        SUN4M_INT_ECC           0x10000000        /* ecc memory error */
-#define        SUN4M_INT_FLOPPY        0x00400000        /* floppy disk */
-#define        SUN4M_INT_MODULE        0x00200000        /* module interrupt */
-#define        SUN4M_INT_VIDEO         0x00100000        /* onboard video */
-#define        SUN4M_INT_REALTIME      0x00080000        /* system timer */
-#define        SUN4M_INT_SCSI          0x00040000        /* onboard scsi */
-#define        SUN4M_INT_AUDIO         0x00020000        /* audio/isdn */
-#define        SUN4M_INT_ETHERNET      0x00010000        /* onboard ethernet */
-#define        SUN4M_INT_SERIAL        0x00008000        /* serial ports */
-#define        SUN4M_INT_KBDMS         0x00004000        /* keyboard/mouse */
-#define        SUN4M_INT_SBUSBITS      0x00003F80        /* sbus int bits */
-
-#define SUN4M_INT_SBUS(x)      (1 << (x+7))
-#define SUN4M_INT_VME(x)       (1 << (x))
-
 #endif
index a55f4c3..2cc235b 100644 (file)
@@ -46,7 +46,6 @@ BTFIXUPDEF_SIMM13(user_ptrs_per_pgd)
 #define pgd_ERROR(e)   __builtin_trap()
 
 BTFIXUPDEF_INT(page_none)
-BTFIXUPDEF_INT(page_shared)
 BTFIXUPDEF_INT(page_copy)
 BTFIXUPDEF_INT(page_readonly)
 BTFIXUPDEF_INT(page_kernel)
@@ -66,7 +65,7 @@ BTFIXUPDEF_INT(page_kernel)
 #define PTE_SIZE               (PTRS_PER_PTE*4)
 
 #define PAGE_NONE      __pgprot(BTFIXUP_INT(page_none))
-#define PAGE_SHARED    __pgprot(BTFIXUP_INT(page_shared))
+extern pgprot_t PAGE_SHARED;
 #define PAGE_COPY      __pgprot(BTFIXUP_INT(page_copy))
 #define PAGE_READONLY  __pgprot(BTFIXUP_INT(page_readonly))
 
index 8e37357..28f88ec 100644 (file)
@@ -77,6 +77,7 @@ typedef enum {
        IRDA_ACT200L_DONGLE      = 10,
        IRDA_MA600_DONGLE        = 11,
        IRDA_TOIM3232_DONGLE     = 12,
+       IRDA_EP7211_DONGLE       = 13,
 } IRDA_DONGLE;
 
 /* Protocol types to be used for SOCK_DGRAM */
index 9820ca1..4a616d7 100644 (file)
@@ -575,7 +575,7 @@ struct net_device
 
        /* The TX queue control structures */
        unsigned int                    egress_subqueue_count;
-       struct net_device_subqueue      egress_subqueue[0];
+       struct net_device_subqueue      egress_subqueue[1];
 };
 #define to_net_dev(d) container_of(d, struct net_device, dev)
 
index 38212c3..ee40355 100644 (file)
@@ -3624,7 +3624,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
        /* ensure 32-byte alignment of both the device and private area */
        alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST +
-                    (sizeof(struct net_device_subqueue) * queue_count)) &
+                    (sizeof(struct net_device_subqueue) * (queue_count - 1))) &
                     ~NETDEV_ALIGN_CONST;
        alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
 
@@ -3642,7 +3642,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
                dev->priv = ((char *)dev +
                             ((sizeof(struct net_device) +
                               (sizeof(struct net_device_subqueue) *
-                               queue_count) + NETDEV_ALIGN_CONST)
+                               (queue_count - 1)) + NETDEV_ALIGN_CONST)
                              & ~NETDEV_ALIGN_CONST));
        }
 
index bd209c4..cfed7d4 100644 (file)
@@ -182,7 +182,8 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = {
   "clock-21"       , "clock-AF_SNA"      , "clock-AF_IRDA"     ,
   "clock-AF_PPPOX" , "clock-AF_WANPIPE"  , "clock-AF_LLC"      ,
   "clock-27"       , "clock-28"          , "clock-29"          ,
-  "clock-AF_TIPC"  , "clock-AF_BLUETOOTH", "clock-AF_MAX"
+  "clock-AF_TIPC"  , "clock-AF_BLUETOOTH", "clock-AF_IUCV"     ,
+  "clock-AF_RXRPC" , "clock-AF_MAX"
 };
 #endif
 
index 6cbce96..771031d 100644 (file)
@@ -158,7 +158,7 @@ static void unlink_from_unused(struct inet_peer *p)
 #define lookup(_daddr,_stack)                                  \
 ({                                                             \
        struct inet_peer *u, **v;                               \
-       if (_stack) {                                           \
+       if (_stack != NULL) {                                   \
                stackptr = _stack;                              \
                *stackptr++ = &peer_root;                       \
        }                                                       \
@@ -169,7 +169,7 @@ static void unlink_from_unused(struct inet_peer *p)
                        v = &u->avl_left;                       \
                else                                            \
                        v = &u->avl_right;                      \
-               if (_stack)                                     \
+               if (_stack != NULL)                             \
                        *stackptr++ = v;                        \
                u = *v;                                         \
        }                                                       \
index 281aee4..df30976 100644 (file)
@@ -962,8 +962,8 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
        dsfield = ipv4_get_dsfield(iph);
 
        if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
-               fl.fl6_flowlabel |= ntohl(((__u32)iph->tos << IPV6_TCLASS_SHIFT)
-                                         & IPV6_TCLASS_MASK);
+               fl.fl6_flowlabel |= htonl((__u32)iph->tos << IPV6_TCLASS_SHIFT)
+                                         & IPV6_TCLASS_MASK;
 
        err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu);
        if (err != 0) {
index db71658..694ea4d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IrDA netlink layer, for stack configuration.
  *
- * Copyright (c) 2007 Samuel Ortiz <samuel@sortiz>
+ * Copyright (c) 2007 Samuel Ortiz <samuel@sortiz.org>
  *
  * Partly based on the 802.11 nelink implementation
  * (see net/wireless/nl80211.c) which is: