]> err.no Git - linux-2.6/commitdiff
Merge branch 'audit.b39' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 22 Jul 2007 18:18:20 +0000 (11:18 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 22 Jul 2007 18:18:20 +0000 (11:18 -0700)
* 'audit.b39' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current:
  [PATCH] get rid of AVC_PATH postponed treatment
  [PATCH] allow audit filtering on bit & operations
  [PATCH] audit: fix broken class-based syscall audit
  [PATCH] Make IPC mode consistent

120 files changed:
Documentation/feature-removal-schedule.txt
Documentation/thinkpad-acpi.txt
MAINTAINERS
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/alternative.c
arch/i386/kernel/cpu/amd.c
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
arch/i386/kernel/cpu/cyrix.c
arch/i386/kernel/cpu/mcheck/mce.c
arch/i386/kernel/cpu/mtrr/cyrix.c
arch/i386/kernel/cpu/mtrr/state.c
arch/i386/kernel/cpu/perfctr-watchdog.c
arch/i386/kernel/kprobes.c
arch/i386/kernel/nmi.c
arch/i386/kernel/paravirt.c
arch/i386/kernel/signal.c
arch/i386/kernel/smpboot.c
arch/i386/kernel/traps.c
arch/i386/mm/fault.c
arch/i386/mm/init.c
arch/i386/xen/xen-head.S
arch/powerpc/configs/prpmc2800_defconfig
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/smp.c
arch/powerpc/mm/fault.c
arch/powerpc/mm/hash_utils_64.c
arch/powerpc/platforms/Kconfig.cputype
arch/powerpc/platforms/cell/spufs/file.c
arch/powerpc/platforms/embedded6xx/Kconfig
arch/powerpc/platforms/pseries/firmware.c
arch/powerpc/platforms/pseries/pseries.h
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/xmon/nonstdio.c
arch/powerpc/xmon/nonstdio.h
arch/powerpc/xmon/start.c
arch/powerpc/xmon/xmon.c
arch/ppc/syslib/mv64x60.c
arch/x86_64/boot/compressed/Makefile
arch/x86_64/kernel/head.S
arch/x86_64/kernel/hpet.c
arch/x86_64/kernel/kprobes.c
arch/x86_64/kernel/mce.c
arch/x86_64/kernel/nmi.c
arch/x86_64/kernel/process.c
arch/x86_64/kernel/setup.c
arch/x86_64/kernel/signal.c
arch/x86_64/kernel/suspend.c
arch/x86_64/kernel/traps.c
arch/x86_64/kernel/vmlinux.lds.S
arch/x86_64/mm/fault.c
arch/x86_64/mm/init.c
arch/x86_64/mm/pageattr.c
drivers/acpi/Kconfig
drivers/acpi/battery.c
drivers/acpi/bay.c
drivers/acpi/bus.c
drivers/acpi/dock.c
drivers/acpi/ec.c
drivers/acpi/event.c
drivers/acpi/events/evgpeblk.c
drivers/acpi/events/evrgnini.c
drivers/acpi/glue.c
drivers/acpi/osl.c
drivers/acpi/pci_link.c
drivers/acpi/processor_core.c
drivers/acpi/processor_idle.c
drivers/acpi/processor_throttling.c
drivers/acpi/sbs.c
drivers/acpi/sleep/main.c
drivers/acpi/system.c
drivers/acpi/tables/tbfadt.c
drivers/acpi/utilities/uteval.c
drivers/acpi/video.c
drivers/char/hvc_iseries.c
drivers/char/hvc_rtas.c
drivers/char/hvcs.c
drivers/kvm/Kconfig
drivers/macintosh/rack-meter.c
drivers/misc/Kconfig
drivers/misc/sony-laptop.c
drivers/misc/thinkpad_acpi.c
drivers/misc/thinkpad_acpi.h
drivers/pcmcia/m8xx_pcmcia.c
drivers/video/Kconfig
drivers/video/Makefile
fs/nfs/super.c
include/acpi/acmacros.h
include/acpi/acoutput.h
include/acpi/acpi_bus.h
include/acpi/platform/acenv.h
include/acpi/platform/aclinux.h
include/acpi/processor.h
include/asm-i386/alternative.h
include/asm-i386/cmpxchg.h
include/asm-i386/mce.h
include/asm-i386/nmi.h
include/asm-i386/processor-cyrix.h [new file with mode: 0644]
include/asm-i386/processor.h
include/asm-powerpc/mpic.h
include/asm-powerpc/prom.h
include/asm-ppc/system.h
include/asm-x86_64/alternative.h
include/asm-x86_64/cmpxchg.h
include/asm-x86_64/hypertransport.h
include/asm-x86_64/mce.h
include/asm-x86_64/msidef.h
include/asm-x86_64/nmi.h
include/asm-x86_64/pgtable.h
include/asm-x86_64/processor.h
include/asm-x86_64/proto.h
include/asm-x86_64/system.h
include/linux/of_platform.h
include/linux/pci_ids.h
include/linux/signal.h
kernel/signal.c
kernel/sysctl.c
mm/sparse.c

index a5cb7839a679eadc040c71a6db06d33af5083ffc..c175eedadb5fb358f589d93da61720e9453b73ad 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 9e6b94face4bb2a11f0ea743246f0b85adbbd105..6711fbcf408078644bf237b2f46466b69b7040ff 100644 (file)
@@ -1,11 +1,11 @@
                     ThinkPad ACPI Extras Driver
 
-                            Version 0.14
-                          April 21st, 2007
+                            Version 0.15
+                           July 1st, 2007
 
                Borislav Deianov <borislav@users.sf.net>
-            Henrique de Moraes Holschuh <hmh@hmh.eng.br>
-                     http://ibm-acpi.sf.net/
+             Henrique de Moraes Holschuh <hmh@hmh.eng.br>
+                      http://ibm-acpi.sf.net/
 
 
 This is a Linux driver for the IBM and Lenovo ThinkPad laptops. It
@@ -134,54 +134,68 @@ end of this document.  Changes to the sysfs interface done by the kernel
 subsystems are not documented here, nor are they tracked by this
 attribute.
 
+Changes to the thinkpad-acpi sysfs interface are only considered
+non-experimental when they are submitted to Linux mainline, at which
+point the changes in this interface are documented and interface_version
+may be updated.  If you are using any thinkpad-acpi features not yet
+sent to mainline for merging, you do so on your own risk: these features
+may disappear, or be implemented in a different and incompatible way by
+the time they are merged in Linux mainline.
+
+Changes that are backwards-compatible by nature (e.g. the addition of
+attributes that do not change the way the other attributes work) do not
+always warrant an update of interface_version.  Therefore, one must
+expect that an attribute might not be there, and deal with it properly
+(an attribute not being there *is* a valid way to make it clear that a
+feature is not available in sysfs).
+
 Hot keys
 --------
 
 procfs: /proc/acpi/ibm/hotkey
 sysfs device attribute: hotkey_*
 
-Without this driver, only the Fn-F4 key (sleep button) generates an
-ACPI event. With the driver loaded, the hotkey feature enabled and the
-mask set (see below), the various hot keys generate ACPI events in the
+In a ThinkPad, the ACPI HKEY handler is responsible for comunicating
+some important events and also keyboard hot key presses to the operating
+system.  Enabling the hotkey functionality of thinkpad-acpi signals the
+firmware that such a driver is present, and modifies how the ThinkPad
+firmware will behave in many situations.
+
+When the hotkey feature is enabled and the hot key mask is set (see
+below), the various hot keys either generate ACPI events in the
 following format:
 
        ibm/hotkey HKEY 00000080 0000xxxx
 
-The last four digits vary depending on the key combination pressed.
-All labeled Fn-Fx key combinations generate distinct events. In
-addition, the lid microswitch and some docking station buttons may
-also generate such events.
-
-The bit mask allows some control over which hot keys generate ACPI
-events. Not all bits in the mask can be modified. Not all bits that
-can be modified do anything. Not all hot keys can be individually
-controlled by the mask. Most recent ThinkPad models honor the
-following bits (assuming the hot keys feature has been enabled):
-
-       key     bit     behavior when set       behavior when unset
-
-       Fn-F3                   always generates ACPI event
-       Fn-F4                   always generates ACPI event
-       Fn-F5   0010    generate ACPI event     enable/disable Bluetooth
-       Fn-F7   0040    generate ACPI event     switch LCD and external display
-       Fn-F8   0080    generate ACPI event     expand screen or none
-       Fn-F9   0100    generate ACPI event     none
-       Fn-F12                  always generates ACPI event
-
-Some models do not support all of the above. For example, the T30 does
-not support Fn-F5 and Fn-F9. Other models do not support the mask at
-all. On those models, hot keys cannot be controlled individually.
-
-Note that enabling ACPI events for some keys prevents their default
-behavior. For example, if events for Fn-F5 are enabled, that key will
-no longer enable/disable Bluetooth by itself. This can still be done
-from an acpid handler for the ibm/hotkey event.
-
-Note also that not all Fn key combinations are supported through
-ACPI. For example, on the X40, the brightness, volume and "Access IBM"
-buttons do not generate ACPI events even with this driver. They *can*
-be used through the "ThinkPad Buttons" utility, see
-http://www.nongnu.org/tpb/
+or events over the input layer.  The input layer support accepts the
+standard IOCTLs to remap the keycodes assigned to each hotkey.
+
+When the input device is open, the driver will suppress any ACPI hot key
+events that get translated into a meaningful input layer event, in order
+to avoid sending duplicate events to userspace.  Hot keys that are
+mapped to KEY_RESERVED in the keymap are not translated, and will always
+generate an ACPI ibm/hotkey HKEY event, and no input layer events.
+
+The hot key bit mask allows some control over which hot keys generate
+events.  If a key is "masked" (bit set to 0 in the mask), the firmware
+will handle it.  If it is "unmasked", it signals the firmware that
+thinkpad-acpi would prefer to handle it, if the firmware would be so
+kind to allow it (and it often doesn't!).
+
+Not all bits in the mask can be modified.  Not all bits that can be
+modified do anything.  Not all hot keys can be individually controlled
+by the mask.  Some models do not support the mask at all, and in those
+models, hot keys cannot be controlled individually.  The behaviour of
+the mask is, therefore, higly dependent on the ThinkPad model.
+
+Note that unmasking some keys prevents their default behavior.  For
+example, if Fn+F5 is unmasked, that key will no longer enable/disable
+Bluetooth by itself.
+
+Note also that not all Fn key combinations are supported through ACPI.
+For example, on the X40, the brightness, volume and "Access IBM" buttons
+do not generate ACPI events even with this driver.  They *can* be used
+through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/
 
 procfs notes:
 
@@ -189,9 +203,9 @@ The following commands can be written to the /proc/acpi/ibm/hotkey file:
 
        echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
        echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
-       echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys
-       echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
-       ... any other 4-hex-digit mask ...
+       echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
+       echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
+       ... any other 8-hex-digit mask ...
        echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
 
 sysfs notes:
@@ -202,7 +216,7 @@ sysfs notes:
                key feature status will be restored to this value.
 
                0: hot keys were disabled
-               1: hot keys were enabled
+               1: hot keys were enabled (unusual)
 
        hotkey_bios_mask:
                Returns the hot keys mask when thinkpad-acpi was loaded.
@@ -217,9 +231,182 @@ sysfs notes:
                1: enables the hot keys feature / feature enabled
 
        hotkey_mask:
-               bit mask to enable ACPI event generation for each hot
-               key (see above).  Returns the current status of the hot
-               keys mask, and allows one to modify it.
+               bit mask to enable driver-handling and ACPI event
+               generation for each hot key (see above).  Returns the
+               current status of the hot keys mask, and allows one to
+               modify it.
+
+       hotkey_all_mask:
+               bit mask that should enable event reporting for all
+               supported hot keys, when echoed to hotkey_mask above.
+               Unless you know which events need to be handled
+               passively (because the firmware *will* handle them
+               anyway), do *not* use hotkey_all_mask.  Use
+               hotkey_recommended_mask, instead. You have been warned.
+
+       hotkey_recommended_mask:
+               bit mask that should enable event reporting for all
+               supported hot keys, except those which are always
+               handled by the firmware anyway.  Echo it to
+               hotkey_mask above, to use.
+
+       hotkey_radio_sw:
+               if the ThinkPad has a hardware radio switch, this
+               attribute will read 0 if the switch is in the "radios
+               disabled" postition, and 1 if the switch is in the
+               "radios enabled" position.
+
+input layer notes:
+
+A Hot key is mapped to a single input layer EV_KEY event, possibly
+followed by an EV_MSC MSC_SCAN event that shall contain that key's scan
+code.  An EV_SYN event will always be generated to mark the end of the
+event block.
+
+Do not use the EV_MSC MSC_SCAN events to process keys.  They are to be
+used as a helper to remap keys, only.  They are particularly useful when
+remapping KEY_UNKNOWN keys.
+
+The events are available in an input device, with the following id:
+
+       Bus:            BUS_HOST
+       vendor:         0x1014 (PCI_VENDOR_ID_IBM)  or
+                       0x17aa (PCI_VENDOR_ID_LENOVO)
+       product:        0x5054 ("TP")
+       version:        0x4101
+
+The version will have its LSB incremented if the keymap changes in a
+backwards-compatible way.  The MSB shall always be 0x41 for this input
+device.  If the MSB is not 0x41, do not use the device as described in
+this section, as it is either something else (e.g. another input device
+exported by a thinkpad driver, such as HDAPS) or its functionality has
+been changed in a non-backwards compatible way.
+
+Adding other event types for other functionalities shall be considered a
+backwards-compatible change for this input device.
+
+Thinkpad-acpi Hot Key event map (version 0x4101):
+
+ACPI   Scan
+event  code    Key             Notes
+
+0x1001 0x00    FN+F1           -
+0x1002 0x01    FN+F2           IBM: battery (rare)
+                               Lenovo: Screen lock
+
+0x1003 0x02    FN+F3           Many IBM models always report
+                               this hot key, even with hot keys
+                               disabled or with Fn+F3 masked
+                               off
+                               IBM: screen lock
+                               Lenovo: battery
+
+0x1004 0x03    FN+F4           Sleep button (ACPI sleep button
+                               semanthics, i.e. sleep-to-RAM).
+                               It is always generate some kind
+                               of event, either the hot key
+                               event or a ACPI sleep button
+                               event. The firmware may
+                               refuse to generate further FN+F4
+                               key presses until a S3 or S4 ACPI
+                               sleep cycle is performed or some
+                               time passes.
+
+0x1005 0x04    FN+F5           Radio.  Enables/disables
+                               the internal BlueTooth hardware
+                               and W-WAN card if left in control
+                               of the firmware.  Does not affect
+                               the WLAN card.
+                               Should be used to turn on/off all
+                               radios (bluetooth+W-WAN+WLAN),
+                               really.
+
+0x1006 0x05    FN+F6           -
+
+0x1007 0x06    FN+F7           Video output cycle.
+                               Do you feel lucky today?
+
+0x1008 0x07    FN+F8           IBM: toggle screen expand
+                               Lenovo: configure ultranav
+
+0x1009 0x08    FN+F9           -
+       ..      ..              ..
+0x100B 0x0A    FN+F11          -
+
+0x100C 0x0B    FN+F12          Sleep to disk.  You are always
+                               supposed to handle it yourself,
+                               either through the ACPI event,
+                               or through a hotkey event.
+                               The firmware may refuse to
+                               generate further FN+F4 key
+                               press events until a S3 or S4
+                               ACPI sleep cycle is performed,
+                               or some time passes.
+
+0x100D 0x0C    FN+BACKSPACE    -
+0x100E 0x0D    FN+INSERT       -
+0x100F 0x0E    FN+DELETE       -
+
+0x1010 0x0F    FN+HOME         Brightness up.  This key is
+                               always handled by the firmware
+                               in IBM ThinkPads, even when
+                               unmasked.  Just leave it alone.
+                               For Lenovo ThinkPads with a new
+                               BIOS, it has to be handled either
+                               by the ACPI OSI, or by userspace.
+0x1011 0x10    FN+END          Brightness down.  See brightness
+                               up for details.
+
+0x1012 0x11    FN+PGUP         Thinklight toggle.  This key is
+                               always handled by the firmware,
+                               even when unmasked.
+
+0x1013 0x12    FN+PGDOWN       -
+
+0x1014 0x13    FN+SPACE        Zoom key
+
+0x1015 0x14    VOLUME UP       Internal mixer volume up. This
+                               key is always handled by the
+                               firmware, even when unmasked.
+                               NOTE: Lenovo seems to be changing
+                               this.
+0x1016 0x15    VOLUME DOWN     Internal mixer volume up. This
+                               key is always handled by the
+                               firmware, even when unmasked.
+                               NOTE: Lenovo seems to be changing
+                               this.
+0x1017 0x16    MUTE            Mute internal mixer. This
+                               key is always handled by the
+                               firmware, even when unmasked.
+
+0x1018 0x17    THINKPAD        Thinkpad/Access IBM/Lenovo key
+
+0x1019 0x18    unknown
+..     ..      ..
+0x1020 0x1F    unknown
+
+The ThinkPad firmware does not allow one to differentiate when most hot
+keys are pressed or released (either that, or we don't know how to, yet).
+For these keys, the driver generates a set of events for a key press and
+immediately issues the same set of events for a key release.  It is
+unknown by the driver if the ThinkPad firmware triggered these events on
+hot key press or release, but the firmware will do it for either one, not
+both.
+
+If a key is mapped to KEY_RESERVED, it generates no input events at all,
+and it may generate a legacy thinkpad-acpi ACPI hotkey event.
+
+If a key is mapped to KEY_UNKNOWN, it generates an input event that
+includes an scan code, and it may also generate a legacy thinkpad-acpi
+ACPI hotkey event.
+
+If a key is mapped to anything else, it will only generate legacy
+thinkpad-acpi ACPI hotkey events if nobody has opened the input device.
+
+Non hot-key ACPI HKEY event map:
+0x5001         Lid closed
+0x5002         Lid opened
+0x7000         Radio Switch may have changed state
 
 
 Bluetooth
@@ -437,27 +624,34 @@ CMOS control
 procfs: /proc/acpi/ibm/cmos
 sysfs device attribute: cmos_command
 
-This feature is used internally by the ACPI firmware to control the
-ThinkLight on most newer ThinkPad models. It may also control LCD
-brightness, sounds volume and more, but only on some models.
+This feature is mostly used internally by the ACPI firmware to keep the legacy
+CMOS NVRAM bits in sync with the current machine state, and to record this
+state so that the ThinkPad will retain such settings across reboots.
+
+Some of these commands actually perform actions in some ThinkPad models, but
+this is expected to disappear more and more in newer models.  As an example, in
+a T43 and in a X40, commands 12 and 13 still control the ThinkLight state for
+real, but commands 0 to 2 don't control the mixer anymore (they have been
+phased out) and just update the NVRAM.
 
 The range of valid cmos command numbers is 0 to 21, but not all have an
 effect and the behavior varies from model to model.  Here is the behavior
 on the X40 (tpb is the ThinkPad Buttons utility):
 
-       0 - no effect but tpb reports "Volume down"
-       1 - no effect but tpb reports "Volume up"
-       2 - no effect but tpb reports "Mute on"
-       3 - simulate pressing the "Access IBM" button
-       4 - LCD brightness up
-       5 - LCD brightness down
-       11 - toggle screen expansion
-       12 - ThinkLight on
-       13 - ThinkLight off
-       14 - no effect but tpb reports ThinkLight status change
+       0 - Related to "Volume down" key press
+       1 - Related to "Volume up" key press
+       2 - Related to "Mute on" key press
+       3 - Related to "Access IBM" key press
+       4 - Related to "LCD brightness up" key pess
+       5 - Related to "LCD brightness down" key press
+       11 - Related to "toggle screen expansion" key press/function
+       12 - Related to "ThinkLight on"
+       13 - Related to "ThinkLight off"
+       14 - Related to "ThinkLight" key press (toggle thinklight)
 
 The cmos command interface is prone to firmware split-brain problems, as
-in newer ThinkPads it is just a compatibility layer.
+in newer ThinkPads it is just a compatibility layer.  Do not use it, it is
+exported just as a debug tool.
 
 LED control -- /proc/acpi/ibm/led
 ---------------------------------
@@ -516,23 +710,15 @@ Temperature sensors
 procfs: /proc/acpi/ibm/thermal
 sysfs device attributes: (hwmon) temp*_input
 
-Most ThinkPads include six or more separate temperature sensors but
-only expose the CPU temperature through the standard ACPI methods.
-This feature shows readings from up to eight different sensors on older
-ThinkPads, and it has experimental support for up to sixteen different
-sensors on newer ThinkPads.
-
-EXPERIMENTAL: The 16-sensors feature is marked EXPERIMENTAL because the
-implementation directly accesses hardware registers and may not work as
-expected. USE WITH CAUTION! To use this feature, you need to supply the
-experimental=1 parameter when loading the module.  When EXPERIMENTAL
-mode is enabled, reading the first 8 sensors on newer ThinkPads will
-also use an new experimental thermal sensor access mode.
+Most ThinkPads include six or more separate temperature sensors but only
+expose the CPU temperature through the standard ACPI methods.  This
+feature shows readings from up to eight different sensors on older
+ThinkPads, and up to sixteen different sensors on newer ThinkPads.
 
 For example, on the X40, a typical output may be:
 temperatures:   42 42 45 41 36 -128 33 -128
 
-EXPERIMENTAL: On the T43/p, a typical output may be:
+On the T43/p, a typical output may be:
 temperatures:   48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128
 
 The mapping of thermal sensors to physical locations varies depending on
@@ -562,7 +748,8 @@ http://thinkwiki.org/wiki/Thermal_Sensors#ThinkPad_T43.2C_T43p
 2:  System board, left side (near PCMCIA slot), reported as HDAPS temp
 3:  PCMCIA slot
 9:  MCH (northbridge) to DRAM Bus
-10: ICH (southbridge), under Mini-PCI card, under touchpad
+10: Clock-generator, mini-pci card and ICH (southbridge), under Mini-PCI
+    card, under touchpad
 11: Power regulator, underside of system board, below F2 key
 
 The A31 has a very atypical layout for the thermal sensors
@@ -681,6 +868,12 @@ cannot be controlled.
 The backlight control has eight levels, ranging from 0 to 7.  Some of the
 levels may not be distinct.
 
+There are two interfaces to the firmware for brightness control, EC and CMOS.
+To select which one should be used, use the brightness_mode module parameter:
+brightness_mode=1 selects EC mode, brightness_mode=2 selects CMOS mode,
+brightness_mode=3 selects both EC and CMOS.  The driver tries to autodetect
+which interface to use.
+
 Procfs notes:
 
        The available commands are:
@@ -976,3 +1169,9 @@ Sysfs interface changelog:
 
 0x000100:      Initial sysfs support, as a single platform driver and
                device.
+0x000200:      Hot key support for 32 hot keys, and radio slider switch
+               support.
+0x010000:      Hot keys are now handled by default over the input
+               layer, the radio switch generates input event EV_RADIO,
+               and the driver enables hot key handling by default in
+               the firmware.
index 773c732b4177d85830e150fb9d4a52acc32dfd1f..a9b9ef614ae7d602c05bad2b101583fe8e6a019a 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 b87cedeaf59b023ccc95ab74788dcc69a0c66beb..cacdd883bf2b8d545b7045daf79f2ad8325dd69a 100644 (file)
@@ -984,14 +984,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
                     DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
                     },
         },
-       {
-        .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",
index 0695be538de53cb88f56e6d068feabbe733d16ae..c3750c2c41137a694be9570443f59b379cc4cc4d 100644 (file)
@@ -2,8 +2,14 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/list.h>
+#include <linux/kprobes.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
 #include <asm/alternative.h>
 #include <asm/sections.h>
+#include <asm/pgtable.h>
+#include <asm/mce.h>
+#include <asm/nmi.h>
 
 #ifdef CONFIG_HOTPLUG_CPU
 static int smp_alt_once;
@@ -150,7 +156,7 @@ static void nop_out(void *insns, unsigned int len)
                unsigned int noplen = len;
                if (noplen > ASM_NOP_MAX)
                        noplen = ASM_NOP_MAX;
-               memcpy(insns, noptable[noplen], noplen);
+               text_poke(insns, noptable[noplen], noplen);
                insns += noplen;
                len -= noplen;
        }
@@ -202,7 +208,7 @@ static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
                        continue;
                if (*ptr > text_end)
                        continue;
-               **ptr = 0xf0; /* lock prefix */
+               text_poke(*ptr, ((unsigned char []){0xf0}), 1); /* add lock prefix */
        };
 }
 
@@ -360,10 +366,6 @@ void apply_paravirt(struct paravirt_patch_site *start,
                /* Pad the rest with nops */
                nop_out(p->instr + used, p->len - used);
        }
-
-       /* Sync to be conservative, in case we patched following
-        * instructions */
-       sync_core();
 }
 extern struct paravirt_patch_site __start_parainstructions[],
        __stop_parainstructions[];
@@ -373,6 +375,14 @@ void __init alternative_instructions(void)
 {
        unsigned long flags;
 
+       /* The patching is not fully atomic, so try to avoid local interruptions
+          that might execute the to be patched code.
+          Other CPUs are not running. */
+       stop_nmi();
+#ifdef CONFIG_MCE
+       stop_mce();
+#endif
+
        local_irq_save(flags);
        apply_alternatives(__alt_instructions, __alt_instructions_end);
 
@@ -405,4 +415,37 @@ void __init alternative_instructions(void)
 #endif
        apply_paravirt(__parainstructions, __parainstructions_end);
        local_irq_restore(flags);
+
+       restart_nmi();
+#ifdef CONFIG_MCE
+       restart_mce();
+#endif
+}
+
+/*
+ * Warning:
+ * When you use this code to patch more than one byte of an instruction
+ * you need to make sure that other CPUs cannot execute this code in parallel.
+ * Also no thread must be currently preempted in the middle of these instructions.
+ * And on the local CPU you need to be protected again NMI or MCE handlers
+ * seeing an inconsistent instruction while you patch.
+ */
+void __kprobes text_poke(void *oaddr, unsigned char *opcode, int len)
+{
+        u8 *addr = oaddr;
+       if (!pte_write(*lookup_address((unsigned long)addr))) {
+               struct page *p[2] = { virt_to_page(addr), virt_to_page(addr+PAGE_SIZE) };
+               addr = vmap(p, 2, VM_MAP, PAGE_KERNEL);
+               if (!addr)
+                       return;
+               addr += ((unsigned long)oaddr) % PAGE_SIZE;
+       }
+       memcpy(addr, opcode, len);
+       sync_core();
+       /* Not strictly needed, but can speed CPU recovery up. Ignore cross cacheline
+          case. */
+       if (cpu_has_clflush)
+               asm("clflush (%0) " :: "r" (oaddr) : "memory");
+       if (addr != oaddr)
+               vunmap(addr);
 }
index 815a5f0aa47416530cdf61658fbd91458b92f5e4..c7ba455d5ac77d97747f1c13a4f5ac6737bfb48d 100644 (file)
@@ -231,6 +231,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
 
        switch (c->x86) {
        case 15:
+       /* Use K8 tuning for Fam10h and Fam11h */
+       case 0x10:
+       case 0x11:
                set_bit(X86_FEATURE_K8, c->x86_capability);
                break;
        case 6:
index 18c8b67ea3a75ce4b5d740e1eb8a68b3cda46915..6f846bee2103d4b17eec817d4a6e4501b675194c 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 194144539a6f34ccddd67e4e7f3393b68e5fecba..461dabc4e4959d23a7b5411d109b1a239a8c3872 100644 (file)
@@ -79,7 +79,7 @@
 #include <linux/smp.h>
 #include <linux/cpufreq.h>
 #include <linux/pci.h>
-#include <asm/processor.h>
+#include <asm/processor-cyrix.h>
 #include <asm/errno.h>
 
 /* PCI config registers, all at F0 */
index e88d2fba156b89d49ea24b9abba1d3b0cd41e5b4..122d2d75aa9f9bbce77211038240686ebf2dc7e8 100644 (file)
@@ -4,7 +4,7 @@
 #include <linux/pci.h>
 #include <asm/dma.h>
 #include <asm/io.h>
-#include <asm/processor.h>
+#include <asm/processor-cyrix.h>
 #include <asm/timer.h>
 #include <asm/pci-direct.h>
 #include <asm/tsc.h>
index 56cd485b127ce59b2da500e9f176b83bb755b7b7..34c781eddee4cdc6fce3419366b63329965655a5 100644 (file)
@@ -60,6 +60,20 @@ void mcheck_init(struct cpuinfo_x86 *c)
        }
 }
 
+static unsigned long old_cr4 __initdata;
+
+void __init stop_mce(void)
+{
+       old_cr4 = read_cr4();
+       clear_in_cr4(X86_CR4_MCE);
+}
+
+void __init restart_mce(void)
+{
+       if (old_cr4 & X86_CR4_MCE)
+               set_in_cr4(X86_CR4_MCE);
+}
+
 static int __init mcheck_disable(char *str)
 {
        mce_disabled = 1;
index 1001f1e0fe6d7dee0ae39147e054881fe5373736..2287d4863a8a01f7b060c39ffcebfe05dc33a94e 100644 (file)
@@ -3,6 +3,7 @@
 #include <asm/mtrr.h>
 #include <asm/msr.h>
 #include <asm/io.h>
+#include <asm/processor-cyrix.h>
 #include "mtrr.h"
 
 int arr3_protected;
index 7b39a2f954d9026c422862d522b5114ead35c242..c9014ca4a575d3bbd1766bf6a0873bd7e2953e1f 100644 (file)
@@ -3,6 +3,7 @@
 #include <asm/io.h>
 #include <asm/mtrr.h>
 #include <asm/msr.h>
+#include <asm-i386/processor-cyrix.h>
 #include "mtrr.h"
 
 
index 30b5e48aa76b84375fc408ce866305980d2eda22..4be488e73bee11760f9de2b9c8b8acd65e556a38 100644 (file)
@@ -325,7 +325,7 @@ static struct wd_ops k7_wd_ops = {
        .stop = single_msr_stop_watchdog,
        .perfctr = MSR_K7_PERFCTR0,
        .evntsel = MSR_K7_EVNTSEL0,
-       .checkbit = 1ULL<<63,
+       .checkbit = 1ULL<<47,
 };
 
 /* Intel Model 6 (PPro+,P2,P3,P-M,Core1) */
@@ -346,7 +346,9 @@ static int setup_p6_watchdog(unsigned nmi_hz)
        perfctr_msr = MSR_P6_PERFCTR0;
        evntsel_msr = MSR_P6_EVNTSEL0;
 
-       wrmsrl(perfctr_msr, 0UL);
+       /* KVM doesn't implement this MSR */
+       if (wrmsr_safe(perfctr_msr, 0, 0) < 0)
+               return 0;
 
        evntsel = P6_EVNTSEL_INT
                | P6_EVNTSEL_OS
index dde828a333c3e8355e49d0a3ed8d562b3071d4f9..448a50b1324c94636d1a2b71f672f901991eedc6 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/cacheflush.h>
 #include <asm/desc.h>
 #include <asm/uaccess.h>
+#include <asm/alternative.h>
 
 void jprobe_return_end(void);
 
@@ -169,16 +170,12 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)
 {
-       *p->addr = BREAKPOINT_INSTRUCTION;
-       flush_icache_range((unsigned long) p->addr,
-                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
+       text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
 }
 
 void __kprobes arch_disarm_kprobe(struct kprobe *p)
 {
-       *p->addr = p->opcode;
-       flush_icache_range((unsigned long) p->addr,
-                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
+       text_poke(p->addr, &p->opcode, 1);
 }
 
 void __kprobes arch_remove_kprobe(struct kprobe *p)
index 03b7f5584d713b60216c25d5ad73df7dbf363e39..99beac7f96ceb4df737c9c02c304ba9d9999710f 100644 (file)
@@ -353,7 +353,7 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
         * Take the local apic timer and PIT/HPET into account. We don't
         * know which one is active, when we have highres/dyntick on
         */
-       sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_irqs(0);
+       sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_cpu(cpu).irqs[0];
 
        /* if the none of the timers isn't firing, this cpu isn't doing much */
        if (!touched && last_irq_sums[cpu] == sum) {
index 53f07a8275e3a9b39ba4581e8f8a03bb75e336ce..ea962c0667d50edb07df04e43a3ab1884dd7df1d 100644 (file)
@@ -124,20 +124,28 @@ unsigned paravirt_patch_ignore(unsigned len)
        return len;
 }
 
+struct branch {
+       unsigned char opcode;
+       u32 delta;
+} __attribute__((packed));
+
 unsigned paravirt_patch_call(void *target, u16 tgt_clobbers,
                             void *site, u16 site_clobbers,
                             unsigned len)
 {
        unsigned char *call = site;
        unsigned long delta = (unsigned long)target - (unsigned long)(call+5);
+       struct branch b;
 
        if (tgt_clobbers & ~site_clobbers)
                return len;     /* target would clobber too much for this site */
        if (len < 5)
                return len;     /* call too long for patch site */
 
-       *call++ = 0xe8;         /* call */
-       *(unsigned long *)call = delta;
+       b.opcode = 0xe8; /* call */
+       b.delta = delta;
+       BUILD_BUG_ON(sizeof(b) != 5);
+       text_poke(call, (unsigned char *)&b, 5);
 
        return 5;
 }
@@ -146,12 +154,14 @@ unsigned paravirt_patch_jmp(void *target, void *site, unsigned len)
 {
        unsigned char *jmp = site;
        unsigned long delta = (unsigned long)target - (unsigned long)(jmp+5);
+       struct branch b;
 
        if (len < 5)
                return len;     /* call too long for patch site */
 
-       *jmp++ = 0xe9;          /* jmp */
-       *(unsigned long *)jmp = delta;
+       b.opcode = 0xe9;        /* jmp */
+       b.delta = delta;
+       text_poke(jmp, (unsigned char *)&b, 5);
 
        return 5;
 }
index d574e38f0f774e67896ad8cfbd8420faca9f9ec9..f5dd85656c1890eb93f8d25fc68fb2d97132e917 100644 (file)
@@ -199,6 +199,13 @@ asmlinkage int sys_sigreturn(unsigned long __unused)
        return eax;
 
 badframe:
+       if (show_unhandled_signals && printk_ratelimit())
+               printk("%s%s[%d] bad frame in sigreturn frame:%p eip:%lx"
+                      " esp:%lx oeax:%lx\n",
+                   current->pid > 1 ? KERN_INFO : KERN_EMERG,
+                   current->comm, current->pid, frame, regs->eip,
+                   regs->esp, regs->orig_eax);
+
        force_sig(SIGSEGV, current);
        return 0;
 }      
index 5910d3fac561d5f33d26df53f63fad2ac0c8d2fe..e4f61d1c6248d8116810e122651f3fb109b5b78e 100644 (file)
@@ -308,7 +308,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 /* representing cpus for which sibling maps can be computed */
 static cpumask_t cpu_sibling_setup_map;
 
-void set_cpu_sibling_map(int cpu)
+void __cpuinit set_cpu_sibling_map(int cpu)
 {
        int i;
        struct cpuinfo_x86 *c = cpu_data;
index 57772a18c39470061cdfcec35467cacb54948825..cfffe3dd9e838315089c9461a49b0fa2b6aef12b 100644 (file)
@@ -618,6 +618,13 @@ fastcall void __kprobes do_general_protection(struct pt_regs * regs,
 
        current->thread.error_code = error_code;
        current->thread.trap_no = 13;
+       if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
+           printk_ratelimit())
+               printk(KERN_INFO
+                   "%s[%d] general protection eip:%lx esp:%lx error:%lx\n",
+                   current->comm, current->pid,
+                   regs->eip, regs->esp, error_code);
+
        force_sig(SIGSEGV, current);
        return;
 
@@ -768,6 +775,8 @@ static __kprobes void default_do_nmi(struct pt_regs * regs)
        reassert_nmi();
 }
 
+static int ignore_nmis;
+
 fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
 {
        int cpu;
@@ -778,11 +787,24 @@ fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
 
        ++nmi_count(cpu);
 
-       default_do_nmi(regs);
+       if (!ignore_nmis)
+               default_do_nmi(regs);
 
        nmi_exit();
 }
 
+void stop_nmi(void)
+{
+       acpi_nmi_disable();
+       ignore_nmis++;
+}
+
+void restart_nmi(void)
+{
+       ignore_nmis--;
+       acpi_nmi_enable();
+}
+
 #ifdef CONFIG_KPROBES
 fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
index e92a10124935c006a22a55775b0aee755b2b08c3..01ffdd4964f08e9bec86c5ae759da9f5cbe8270a 100644 (file)
@@ -283,6 +283,8 @@ static inline int vmalloc_fault(unsigned long address)
        return 0;
 }
 
+int show_unhandled_signals = 1;
+
 /*
  * This routine handles page faults.  It determines the address,
  * and the problem, and then passes it off to one of the appropriate
@@ -469,6 +471,14 @@ bad_area_nosemaphore:
                if (is_prefetch(regs, address, error_code))
                        return;
 
+               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
+                   printk_ratelimit()) {
+                       printk("%s%s[%d]: segfault at %08lx eip %08lx "
+                           "esp %08lx error %lx\n",
+                           tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
+                           tsk->comm, tsk->pid, address, regs->eip,
+                           regs->esp, error_code);
+               }
                tsk->thread.cr2 = address;
                /* Kernel addresses are always protection faults */
                tsk->thread.error_code = error_code | (address >= TASK_SIZE);
index e1a9a805c445c58573e5e77dd1be682d52d9b5ee..c3b9905af2d5024b71451e796c052a2ad1813718 100644 (file)
@@ -800,17 +800,9 @@ void mark_rodata_ro(void)
        unsigned long start = PFN_ALIGN(_text);
        unsigned long size = PFN_ALIGN(_etext) - start;
 
-#ifndef CONFIG_KPROBES
-#ifdef CONFIG_HOTPLUG_CPU
-       /* It must still be possible to apply SMP alternatives. */
-       if (num_possible_cpus() <= 1)
-#endif
-       {
-               change_page_attr(virt_to_page(start),
-                                size >> PAGE_SHIFT, PAGE_KERNEL_RX);
-               printk("Write protecting the kernel text: %luk\n", size >> 10);
-       }
-#endif
+       change_page_attr(virt_to_page(start),
+                        size >> PAGE_SHIFT, PAGE_KERNEL_RX);
+       printk("Write protecting the kernel text: %luk\n", size >> 10);
        start += size;
        size = (unsigned long)__end_rodata - start;
        change_page_attr(virt_to_page(start),
index 2998d55a001790b96196b04dabd3718067bc9629..bc71f3bc40141019214201586ed292b743f81dc3 100644 (file)
@@ -7,6 +7,7 @@
 #include <asm/boot.h>
 #include <xen/interface/elfnote.h>
 
+       .section .init.text
 ENTRY(startup_xen)
        movl %esi,xen_start_info
        cld
@@ -19,6 +20,7 @@ ENTRY(hypercall_page)
        .skip 0x1000
 .popsection
 
+       .section .text
        ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
        ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
        ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
index fb504a714625faeb08d07d7f308ab651e8e935fc..858f865f2d59da7deb96c53d6cb16483330443e8 100644 (file)
@@ -48,7 +48,7 @@ CONFIG_PPC_STD_MMU_32=y
 # CONFIG_PPC_MM_SLICES is not set
 # CONFIG_SMP is not set
 CONFIG_NOT_COHERENT_CACHE=y
-CONFIG_CONFIG_CHECK_CACHE_COHERENCY=y
+CONFIG_CHECK_CACHE_COHERENCY=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
index 94b4a028232a957b5e65321204de4cdf327f5c18..fe7d1255e11ea903dbd01f41e56c839ccb04f703 100644 (file)
@@ -166,7 +166,7 @@ int pcibios_add_platform_entries(struct pci_dev *pdev)
 
 }
 
-char __init *pcibios_setup(char *str)
+char __devinit *pcibios_setup(char *str)
 {
        return str;
 }
index bdcd23d8d8b99f8648b61a63aa4ece60f66c375a..a38197b12d3e991a22dd06850911cecdd1869cce 100644 (file)
@@ -1218,7 +1218,7 @@ void of_attach_node(struct device_node *np)
  * a reference to the node.  The memory associated with the node
  * is not freed until its refcount goes to zero.
  */
-void of_detach_node(const struct device_node *np)
+void of_detach_node(struct device_node *np)
 {
        struct device_node *parent;
 
index d577b71db37549433ca2f36aa6ad0bcea8cd3a5a..087c92f2a3ebd75bac059df639c9bd1d75d92081 100644 (file)
@@ -284,7 +284,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
                        int wait)
 {
        cpumask_t map = CPU_MASK_NONE;
-       int ret = -EBUSY;
+       int ret = 0;
 
        if (!cpu_online(cpu))
                return -EINVAL;
@@ -292,6 +292,11 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
        cpu_set(cpu, map);
        if (cpu != get_cpu())
                ret = smp_call_function_map(func,info,nonatomic,wait,map);
+       else {
+               local_irq_disable();
+               func(info);
+               local_irq_enable();
+       }
        put_cpu();
        return ret;
 }
index 3767211b3d0f665e0666dcfcea246009c1d159ed..ab3546c5ac3a2a8f4b022ba8150c13a9c7686728 100644 (file)
@@ -283,7 +283,13 @@ good_area:
                /* protection fault */
                if (error_code & DSISR_PROTFAULT)
                        goto bad_area;
-               if (!(vma->vm_flags & VM_EXEC))
+               /*
+                * Allow execution from readable areas if the MMU does not
+                * provide separate controls over reading and executing.
+                */
+               if (!(vma->vm_flags & VM_EXEC) &&
+                   (cpu_has_feature(CPU_FTR_NOEXECUTE) ||
+                    !(vma->vm_flags & (VM_READ | VM_WRITE))))
                        goto bad_area;
 #else
                pte_t *ptep;
index 2ce9491b48d409d4763d4822426415c4f5a8c088..bc7b0cedae5e555ab711d2d5099059070766de17 100644 (file)
@@ -609,7 +609,7 @@ static void demote_segment_4k(struct mm_struct *mm, unsigned long addr)
        mm->context.sllp = SLB_VSID_USER | mmu_psize_defs[MMU_PAGE_4K].sllp;
 #endif /* CONFIG_PPC_MM_SLICES */
 
-#ifdef CONFIG_SPE_BASE
+#ifdef CONFIG_SPU_BASE
        spu_flush_all_slbs(mm);
 #endif
 }
@@ -744,7 +744,7 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
                               "to 4kB pages because of "
                               "non-cacheable mapping\n");
                        psize = mmu_vmalloc_psize = MMU_PAGE_4K;
-#ifdef CONFIG_SPE_BASE
+#ifdef CONFIG_SPU_BASE
                        spu_flush_all_slbs(mm);
 #endif
                }
index b8b5fde9466863cc634b32b5d0430391da0874a9..e4b2aee53a73f2ce9815b5d63e19b318c44de006 100644 (file)
@@ -215,7 +215,7 @@ config NOT_COHERENT_CACHE
        depends on 4xx || 8xx || E200
        default y
 
-config CONFIG_CHECK_CACHE_COHERENCY
+config CHECK_CACHE_COHERENCY
        bool
 
 endmenu
index c2aaec5289dc2ce042333260bd81ff2974d7d75a..4100ddc52f0227fb0fcb300fb50da78bffa9b9d3 100644 (file)
@@ -941,13 +941,6 @@ static const struct file_operations spufs_signal1_nosched_fops = {
        .mmap = spufs_signal1_mmap,
 };
 
-static const struct file_operations spufs_signal1_nosched_fops = {
-       .open = spufs_signal1_open,
-       .release = spufs_signal1_release,
-       .write = spufs_signal1_write,
-       .mmap = spufs_signal1_mmap,
-};
-
 static int spufs_signal2_open(struct inode *inode, struct file *file)
 {
        struct spufs_inode_info *i = SPUFS_I(inode);
@@ -1083,13 +1076,6 @@ static const struct file_operations spufs_signal2_nosched_fops = {
        .mmap = spufs_signal2_mmap,
 };
 
-static const struct file_operations spufs_signal2_nosched_fops = {
-       .open = spufs_signal2_open,
-       .release = spufs_signal2_release,
-       .write = spufs_signal2_write,
-       .mmap = spufs_signal2_mmap,
-};
-
 static void spufs_signal1_type_set(void *data, u64 val)
 {
        struct spu_context *ctx = data;
index bec772674e4066db350f22b77d77bf74c5b32134..2d12f77e46bcbee9987213561cfe7c2c5a022db6 100644 (file)
@@ -59,7 +59,7 @@ config MPC10X_BRIDGE
 config MV64X60
        bool
        select PPC_INDIRECT_PCI
-       select CONFIG_CHECK_CACHE_COHERENCY
+       select CHECK_CACHE_COHERENCY
 
 config MPC10X_OPENPIC
        bool
index 29bf83bfb1f086b98f6657357606229b0332c266..8b18a1c40092c5e7c68402c8ce78a1232a67ef41 100644 (file)
@@ -66,24 +66,13 @@ firmware_features_table[FIRMWARE_MAX_FEATURES] = {
  * device-tree/ibm,hypertas-functions.  Ultimately this functionality may
  * be moved into prom.c prom_init().
  */
-void __init fw_feature_init(void)
+void __init fw_feature_init(const char *hypertas, unsigned long len)
 {
-       struct device_node *dn;
-       const char *hypertas, *s;
-       int len, i;
+       const char *s;
+       int i;
 
        DBG(" -> fw_feature_init()\n");
 
-       dn = of_find_node_by_path("/rtas");
-       if (dn == NULL) {
-               printk(KERN_ERR "WARNING! Cannot find RTAS in device-tree!\n");
-               goto out;
-       }
-
-       hypertas = of_get_property(dn, "ibm,hypertas-functions", &len);
-       if (hypertas == NULL)
-               goto out;
-
        for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
                for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) {
                        /* check value against table of strings */
@@ -98,7 +87,5 @@ void __init fw_feature_init(void)
                }
        }
 
-out:
-       of_node_put(dn);
        DBG(" <- fw_feature_init()\n");
 }
index 61e19f78b923099c3691de50ece491adbf158d31..61136d019554944e1c681da0b191504a6a7b94ca 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef _PSERIES_PSERIES_H
 #define _PSERIES_PSERIES_H
 
-extern void __init fw_feature_init(void);
+extern void __init fw_feature_init(const char *hypertas, unsigned long len);
 
 struct pt_regs;
 
index 59e69f085cb419e2ca037fb1273ccbcf1b8824d9..f0b7146a110f7238abcd39d633db63dd44711481 100644 (file)
@@ -320,8 +320,6 @@ static void __init pSeries_init_early(void)
 {
        DBG(" -> pSeries_init_early()\n");
 
-       fw_feature_init();
-
        if (firmware_has_feature(FW_FEATURE_LPAR))
                find_udbg_vterm();
 
@@ -343,14 +341,21 @@ static int __init pSeries_probe_hypertas(unsigned long node,
                                         const char *uname, int depth,
                                         void *data)
 {
+       const char *hypertas;
+       unsigned long len;
+
        if (depth != 1 ||
            (strcmp(uname, "rtas") != 0 && strcmp(uname, "rtas@0") != 0))
-               return 0;
+               return 0;
+
+       hypertas = of_get_flat_dt_prop(node, "ibm,hypertas-functions", &len);
+       if (!hypertas)
+               return 1;
 
-       if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL) != NULL)
-               powerpc_firmware_features |= FW_FEATURE_LPAR;
+       powerpc_firmware_features |= FW_FEATURE_LPAR;
+       fw_feature_init(hypertas, len);
 
-       return 1;
+       return 1;
 }
 
 static int __init pSeries_probe(void)
index 75aad38179f0131e733690bde4a51461fb67b8d6..74c64c0d3b71d91841703f1c4b069508dca71769 100644 (file)
@@ -877,6 +877,8 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 
        if (hw == mpic->spurious_vec)
                return -EINVAL;
+       if (mpic->protected && test_bit(hw, mpic->protected))
+               return -EINVAL;
 
 #ifdef CONFIG_SMP
        else if (hw >= mpic->ipi_vecs[0]) {
@@ -1034,6 +1036,25 @@ struct mpic * __init mpic_alloc(struct device_node *node,
        if (node && of_get_property(node, "big-endian", NULL) != NULL)
                mpic->flags |= MPIC_BIG_ENDIAN;
 
+       /* Look for protected sources */
+       if (node) {
+               unsigned int psize, bits, mapsize;
+               const u32 *psrc =
+                       of_get_property(node, "protected-sources", &psize);
+               if (psrc) {
+                       psize /= 4;
+                       bits = intvec_top + 1;
+                       mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long);
+                       mpic->protected = alloc_bootmem(mapsize);
+                       BUG_ON(mpic->protected == NULL);
+                       memset(mpic->protected, 0, mapsize);
+                       for (i = 0; i < psize; i++) {
+                               if (psrc[i] > intvec_top)
+                                       continue;
+                               __set_bit(psrc[i], mpic->protected);
+                       }
+               }
+       }
 
 #ifdef CONFIG_MPIC_WEIRD
        mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)];
@@ -1213,6 +1234,9 @@ void __init mpic_init(struct mpic *mpic)
                u32 vecpri = MPIC_VECPRI_MASK | i |
                        (8 << MPIC_VECPRI_PRIORITY_SHIFT);
                
+               /* check if protected */
+               if (mpic->protected && test_bit(i, mpic->protected))
+                       continue;
                /* init hw */
                mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
                mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION),
@@ -1407,6 +1431,14 @@ unsigned int mpic_get_one_irq(struct mpic *mpic)
                        mpic_eoi(mpic);
                return NO_IRQ;
        }
+       if (unlikely(mpic->protected && test_bit(src, mpic->protected))) {
+               if (printk_ratelimit())
+                       printk(KERN_WARNING "%s: Got protected source %d !\n",
+                              mpic->name, (int)src);
+               mpic_eoi(mpic);
+               return NO_IRQ;
+       }
+
        return irq_linear_revmap(mpic->irqhost, src);
 }
 
index 78765833f4c0459fa66022596824b2df951a607d..bfac84fbe7806693797decdd8db0deaea98bf097 100644 (file)
@@ -132,3 +132,8 @@ void xmon_printf(const char *format, ...)
        va_end(args);
        xmon_write(xmon_outbuf, n);
 }
+
+void xmon_puts(const char *str)
+{
+       xmon_write(str, strlen(str));
+}
index 47cebbd2b1b1b06e3d53d99c9dc3a41eb42b6db2..23dd95f4599c3fd049eb17be31990ca6b00d3732 100644 (file)
@@ -5,10 +5,11 @@
 
 extern int xmon_putchar(int c);
 extern int xmon_getchar(void);
+extern void xmon_puts(const char *);
 extern char *xmon_gets(char *, int);
 extern void xmon_printf(const char *, ...);
 extern void xmon_map_scc(void);
 extern int xmon_expect(const char *str, unsigned long timeout);
-extern int xmon_write(void *ptr, int nb);
+extern int xmon_write(const void *ptr, int nb);
 extern int xmon_readchar(void);
 extern int xmon_read_poll(void);
index 712552c4f24215f263d495c75bbbc2cc1cf72481..8864de2af382f767540ad4aeac24a7606750e72e 100644 (file)
@@ -14,7 +14,7 @@ void xmon_map_scc(void)
 {
 }
 
-int xmon_write(void *ptr, int nb)
+int xmon_write(const void *ptr, int nb)
 {
        return udbg_write(ptr, nb);
 }
index 669e6566ad70983fc2fa1d3a246460521d3cf059..121b04d165d1937b2805a5a1dabaaa30c0467f6f 100644 (file)
@@ -833,7 +833,7 @@ cmds(struct pt_regs *excp)
                        mdelay(2000);
                        return cmd;
                case '?':
-                       printf(help_string);
+                       xmon_puts(help_string);
                        break;
                case 'b':
                        bpt_cmds();
index 032f4b7f42257c7566fee56e084bd88ed6f5bc23..d212b1c418a99cef263e33d6125d5b150a33c0fd 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/spinlock.h>
 #include <linux/mv643xx.h>
@@ -2359,7 +2360,7 @@ mv64460_chip_specific_init(struct mv64x60_handle *bh,
 /* Export the hotswap register via sysfs for enum event monitoring */
 #define        VAL_LEN_MAX     11 /* 32-bit hex or dec stringified number + '\n' */
 
-DECLARE_MUTEX(mv64xxx_hs_lock);
+static DEFINE_MUTEX(mv64xxx_hs_lock);
 
 static ssize_t
 mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -2372,14 +2373,14 @@ mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
        if (count < VAL_LEN_MAX)
                return -EINVAL;
 
-       if (down_interruptible(&mv64xxx_hs_lock))
+       if (mutex_lock_interruptible(&mv64xxx_hs_lock))
                return -ERESTARTSYS;
        save_exclude = mv64x60_pci_exclude_bridge;
        mv64x60_pci_exclude_bridge = 0;
        early_read_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
                        MV64360_PCICFG_CPCI_HOTSWAP, &v);
        mv64x60_pci_exclude_bridge = save_exclude;
-       up(&mv64xxx_hs_lock);
+       mutex_unlock(&mv64xxx_hs_lock);
 
        return sprintf(buf, "0x%08x\n", v);
 }
@@ -2396,14 +2397,14 @@ mv64xxx_hs_reg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
                return -EINVAL;
 
        if (sscanf(buf, "%i", &v) == 1) {
-               if (down_interruptible(&mv64xxx_hs_lock))
+               if (mutex_lock_interruptible(&mv64xxx_hs_lock))
                        return -ERESTARTSYS;
                save_exclude = mv64x60_pci_exclude_bridge;
                mv64x60_pci_exclude_bridge = 0;
                early_write_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
                                MV64360_PCICFG_CPCI_HOTSWAP, v);
                mv64x60_pci_exclude_bridge = save_exclude;
-               up(&mv64xxx_hs_lock);
+               mutex_unlock(&mv64xxx_hs_lock);
        }
        else
                count = -EINVAL;
@@ -2433,10 +2434,10 @@ mv64xxx_hs_reg_valid_show(struct device *dev, struct device_attribute *attr,
        pdev = container_of(dev, struct platform_device, dev);
        pdp = (struct mv64xxx_pdata *)pdev->dev.platform_data;
 
-       if (down_interruptible(&mv64xxx_hs_lock))
+       if (mutex_lock_interruptible(&mv64xxx_hs_lock))
                return -ERESTARTSYS;
        v = pdp->hs_reg_valid;
-       up(&mv64xxx_hs_lock);
+       mutex_unlock(&mv64xxx_hs_lock);
 
        return sprintf(buf, "%i\n", v);
 }
index c9f2da7496c14d738b0c8453dd835dd70db9cf96..877c0bdbbc67006473a1ca9754721f186910bf61 100644 (file)
@@ -3,8 +3,6 @@
 #
 # create a compressed vmlinux image from the original vmlinux
 #
-# Note all the files here are compiled/linked as 32bit executables.
-#
 
 targets                := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
 
index 941c84baecc8da3fc4496d912216760a083e034a..e89abcdbdde8172e25d6dff0ddb8323471495c66 100644 (file)
@@ -25,7 +25,7 @@
  */
 
        .text
-       .section .bootstrap.text
+       .section .text.head
        .code64
        .globl startup_64
 startup_64:
@@ -243,10 +243,16 @@ ENTRY(secondary_startup_64)
        lretq
 
        /* SMP bootup changes these two */
+#ifndef CONFIG_HOTPLUG_CPU
+       .pushsection .init.data
+#endif
        .align  8
        .globl  initial_code
 initial_code:
        .quad   x86_64_start_kernel
+#ifndef CONFIG_HOTPLUG_CPU
+       .popsection
+#endif
        .globl init_rsp
 init_rsp:
        .quad  init_thread_union+THREAD_SIZE-8
index 636f4f9fc6bb185b8e77300662e006b7b72a37d3..e2d1b912e15469c1110553fa3ebc27c97fc3af9e 100644 (file)
@@ -133,7 +133,7 @@ struct clocksource clocksource_hpet = {
        .vread          = vread_hpet,
 };
 
-int hpet_arch_init(void)
+int __init hpet_arch_init(void)
 {
        unsigned int id;
        u64 tmp;
index d4a0d0ac99351a8fd1b67ca9f65fa6aa01861b9b..a30e004682e2dc60fe81a7e1caf007fbbcf314a7 100644 (file)
@@ -39,9 +39,9 @@
 #include <linux/module.h>
 #include <linux/kdebug.h>
 
-#include <asm/cacheflush.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
+#include <asm/alternative.h>
 
 void jprobe_return_end(void);
 static void __kprobes arch_copy_kprobe(struct kprobe *p);
@@ -209,16 +209,12 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)
 {
-       *p->addr = BREAKPOINT_INSTRUCTION;
-       flush_icache_range((unsigned long) p->addr,
-                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
+       text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
 }
 
 void __kprobes arch_disarm_kprobe(struct kprobe *p)
 {
-       *p->addr = p->opcode;
-       flush_icache_range((unsigned long) p->addr,
-                          (unsigned long) p->addr + sizeof(kprobe_opcode_t));
+       text_poke(p->addr, &p->opcode, 1);
 }
 
 void __kprobes arch_remove_kprobe(struct kprobe *p)
index 4d8450ee3635e8ee587f5f639f7862b5a5155a74..a66d607f5b924e09d864120d1d656c3e1a1c2da0 100644 (file)
@@ -667,6 +667,20 @@ static struct miscdevice mce_log_device = {
        &mce_chrdev_ops,
 };
 
+static unsigned long old_cr4 __initdata;
+
+void __init stop_mce(void)
+{
+       old_cr4 = read_cr4();
+       clear_in_cr4(X86_CR4_MCE);
+}
+
+void __init restart_mce(void)
+{
+       if (old_cr4 & X86_CR4_MCE)
+               set_in_cr4(X86_CR4_MCE);
+}
+
 /* 
  * Old style boot options parsing. Only for compatibility. 
  */
index edbbc59b752334d570cb939c70ece3f43ca8ae42..cb8ee9d02f8682d4e52374aae1847a4daf03292a 100644 (file)
@@ -384,11 +384,14 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
        return rc;
 }
 
+static unsigned ignore_nmis;
+
 asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
 {
        nmi_enter();
        add_pda(__nmi_count,1);
-       default_do_nmi(regs);
+       if (!ignore_nmis)
+               default_do_nmi(regs);
        nmi_exit();
 }
 
@@ -401,6 +404,18 @@ int do_nmi_callback(struct pt_regs * regs, int cpu)
        return 0;
 }
 
+void stop_nmi(void)
+{
+       acpi_nmi_disable();
+       ignore_nmis++;
+}
+
+void restart_nmi(void)
+{
+       ignore_nmis--;
+       acpi_nmi_enable();
+}
+
 #ifdef CONFIG_SYSCTL
 
 static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
index 92fade4a62cfb8aad73678fe2665830d5b87d280..e7ac629d4c4654ec97ddc387fc5ba71c0892e92a 100644 (file)
@@ -342,10 +342,10 @@ void __show_regs(struct pt_regs * regs)
        rdmsrl(MSR_GS_BASE, gs); 
        rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); 
 
-       asm("movq %%cr0, %0": "=r" (cr0));
-       asm("movq %%cr2, %0": "=r" (cr2));
-       asm("movq %%cr3, %0": "=r" (cr3));
-       asm("movq %%cr4, %0": "=r" (cr4));
+       cr0 = read_cr0();
+       cr2 = read_cr2();
+       cr3 = read_cr3();
+       cr4 = read_cr4();
 
        printk("FS:  %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n", 
               fs,fsindex,gs,gsindex,shadowgs); 
index 6fa0a302e2aa9b121daa487220b27efdbd88f570..af838f6b0b7fc9b7e3ed4de0ab12992e48cf9f18 100644 (file)
@@ -608,6 +608,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
        else
                num_cache_leaves = 3;
 
+       if (c->x86 == 0xf || c->x86 == 0x10 || c->x86 == 0x11)
+               set_bit(X86_FEATURE_K8, &c->x86_capability);
+
        /* RDTSC can be speculated around */
        clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
 
index 4886afcd628746c2f78b0516754de3e47eadad50..739175b01e06ee9553760729c5b8e6dbd6bf89cb 100644 (file)
@@ -487,7 +487,7 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
 { 
        struct task_struct *me = current; 
-       if (exception_trace)
+       if (show_unhandled_signals && printk_ratelimit())
                printk("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n",
               me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax); 
 
index 6a5a98f2a75c5aac97d543f116db736182b6e73c..ea83a9f91965d3217d1f9346fefa45679f69d62a 100644 (file)
@@ -55,11 +55,11 @@ void __save_processor_state(struct saved_context *ctxt)
         * control registers 
         */
        rdmsrl(MSR_EFER, ctxt->efer);
-       asm volatile ("movq %%cr0, %0" : "=r" (ctxt->cr0));
-       asm volatile ("movq %%cr2, %0" : "=r" (ctxt->cr2));
-       asm volatile ("movq %%cr3, %0" : "=r" (ctxt->cr3));
-       asm volatile ("movq %%cr4, %0" : "=r" (ctxt->cr4));
-       asm volatile ("movq %%cr8, %0" : "=r" (ctxt->cr8));
+       ctxt->cr0 = read_cr0();
+       ctxt->cr2 = read_cr2();
+       ctxt->cr3 = read_cr3();
+       ctxt->cr4 = read_cr4();
+       ctxt->cr8 = read_cr8();
 }
 
 void save_processor_state(void)
@@ -81,11 +81,11 @@ void __restore_processor_state(struct saved_context *ctxt)
         * control registers
         */
        wrmsrl(MSR_EFER, ctxt->efer);
-       asm volatile ("movq %0, %%cr8" :: "r" (ctxt->cr8));
-       asm volatile ("movq %0, %%cr4" :: "r" (ctxt->cr4));
-       asm volatile ("movq %0, %%cr3" :: "r" (ctxt->cr3));
-       asm volatile ("movq %0, %%cr2" :: "r" (ctxt->cr2));
-       asm volatile ("movq %0, %%cr0" :: "r" (ctxt->cr0));
+       write_cr8(ctxt->cr8);
+       write_cr4(ctxt->cr4);
+       write_cr3(ctxt->cr3);
+       write_cr2(ctxt->cr2);
+       write_cr0(ctxt->cr0);
 
        /*
         * now restore the descriptor tables to their proper values
index 8713ad4a4db14ca350a00a5eee55a9cc365a7373..03888420775d03320f0cea3c40989e100fea3e7c 100644 (file)
@@ -584,7 +584,8 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
                tsk->thread.error_code = error_code;
                tsk->thread.trap_no = trapnr;
 
-               if (exception_trace && unhandled_signal(tsk, signr))
+               if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
+                   printk_ratelimit())
                        printk(KERN_INFO
                               "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
                               tsk->comm, tsk->pid, str,
@@ -688,7 +689,8 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
                tsk->thread.error_code = error_code;
                tsk->thread.trap_no = 13;
 
-               if (exception_trace && unhandled_signal(tsk, SIGSEGV))
+               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
+                   printk_ratelimit())
                        printk(KERN_INFO
                       "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
                               tsk->comm, tsk->pid,
index e7a5eb6cd785a50e914566291d104ef47146754c..ba8ea97abd219359d6e7c68541e375dbe97f5c7a 100644 (file)
@@ -28,7 +28,7 @@ SECTIONS
   _text = .;                   /* Text and read-only data */
   .text :  AT(ADDR(.text) - LOAD_OFFSET) {
        /* First the code that has to be first for bootstrapping */
-       *(.bootstrap.text)
+       *(.text.head)
        _stext = .;
        /* Then the rest */
        TEXT_TEXT
index 2074bddd4f04eea21a6dd9d6a8b848bf95a22be2..327c9f2fa6269f3020f94f856cd8e0b8b36ab494 100644 (file)
@@ -159,7 +159,7 @@ void dump_pagetable(unsigned long address)
        pmd_t *pmd;
        pte_t *pte;
 
-       asm("movq %%cr3,%0" : "=r" (pgd));
+       pgd = (pgd_t *)read_cr3();
 
        pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 
        pgd += pgd_index(address);
@@ -221,16 +221,6 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
        return 0;
 } 
 
-int unhandled_signal(struct task_struct *tsk, int sig)
-{
-       if (is_init(tsk))
-               return 1;
-       if (tsk->ptrace & PT_PTRACED)
-               return 0;
-       return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
-               (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
-}
-
 static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
                                 unsigned long error_code)
 {
@@ -302,7 +292,7 @@ static int vmalloc_fault(unsigned long address)
 }
 
 static int page_fault_trace;
-int exception_trace = 1;
+int show_unhandled_signals = 1;
 
 /*
  * This routine handles page faults.  It determines the address,
@@ -326,7 +316,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
        prefetchw(&mm->mmap_sem);
 
        /* get the address */
-       __asm__("movq %%cr2,%0":"=r" (address));
+       address = read_cr2();
 
        info.si_code = SEGV_MAPERR;
 
@@ -494,7 +484,8 @@ bad_area_nosemaphore:
                    (address >> 32))
                        return;
 
-               if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
+               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
+                   printk_ratelimit()) {
                        printk(
                       "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
                                        tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
index 381c2ecd407e3b08137b2f1d7cb4ac6afa1d62ce..38f5d63680060769a58b7ac607f9085b6acf19d3 100644 (file)
@@ -383,7 +383,7 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
        } 
 
        if (!after_bootmem)
-               asm volatile("movq %%cr4,%0" : "=r" (mmu_cr4_features));
+               mmu_cr4_features = read_cr4();
        __flush_tlb_all();
 }
 
@@ -600,16 +600,6 @@ void mark_rodata_ro(void)
 {
        unsigned long start = (unsigned long)_stext, end;
 
-#ifdef CONFIG_HOTPLUG_CPU
-       /* It must still be possible to apply SMP alternatives. */
-       if (num_possible_cpus() > 1)
-               start = (unsigned long)_etext;
-#endif
-
-#ifdef CONFIG_KPROBES
-       start = (unsigned long)__start_rodata;
-#endif
-       
        end = (unsigned long)__end_rodata;
        start = (start + PAGE_SIZE - 1) & PAGE_MASK;
        end &= PAGE_MASK;
@@ -697,39 +687,6 @@ int kern_addr_valid(unsigned long addr)
        return pfn_valid(pte_pfn(*pte));
 }
 
-#ifdef CONFIG_SYSCTL
-#include <linux/sysctl.h>
-
-static ctl_table debug_table2[] = {
-       {
-               .ctl_name       = 99,
-               .procname       = "exception-trace",
-               .data           = &exception_trace,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec
-       },
-       {}
-}; 
-
-static ctl_table debug_root_table2[] = { 
-       {
-               .ctl_name = CTL_DEBUG,
-               .procname = "debug",
-               .mode = 0555,
-               .child = debug_table2
-       },
-       {}
-}; 
-
-static __init int x8664_sysctl_init(void)
-{ 
-       register_sysctl_table(debug_root_table2);
-       return 0;
-}
-__initcall(x8664_sysctl_init);
-#endif
-
 /* A pseudo VMA to allow ptrace access for the vsyscall page.  This only
    covers the 64bit vsyscall page now. 32bit has a real VMA now and does
    not need special handling anymore. */
@@ -767,7 +724,7 @@ int in_gate_area_no_task(unsigned long addr)
        return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
 }
 
-void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
+void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
 {
        return __alloc_bootmem_core(pgdat->bdata, size,
                        SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
index 36377b6b8efe9af1039104b753665edf96a80821..7e161c698af47cb98a766c8253c8596cfeeb4b74 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/tlbflush.h>
 #include <asm/io.h>
 
-static inline pte_t *lookup_address(unsigned long address) 
+pte_t *lookup_address(unsigned long address)
 { 
        pgd_t *pgd = pgd_offset_k(address);
        pud_t *pud;
index 139f41f033d8bae09144493eb77c1ac2b09d3d41..408b45168aba324a8e12e26a140dc244011c2837 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.
@@ -124,7 +118,7 @@ config ACPI_BUTTON
 
 config ACPI_VIDEO
        tristate "Video"
-       depends on X86 && BACKLIGHT_CLASS_DEVICE
+       depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL
        help
          This driver implement the ACPI Extensions For Display Adapters
          for integrated graphics devices on motherboard, as specified in
@@ -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 e64c76c8b7268a56562969d48b6c940bbda09bfc..cad932de383d02c3f3426f3784a9ff2190a1e4b2 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 fb3f31b5e69f6587ff4c7cada15b2291c64fad40..56a5b3fffeb364a14e8fe3ff7f5b9a1ff103f51e 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 e5084ececb6ff7f004326a3fcdf24828c45e2f0a..6b2658c9624245c7de284623058b4312bb96ff0e 100644 (file)
@@ -292,6 +292,10 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
        if (!device)
                return -EINVAL;
 
+       if (acpi_bus_generate_genetlink_event(device, type, data))
+               printk(KERN_WARNING PREFIX
+                       "Failed to generate an ACPI event via genetlink!\n");
+
        /* drop event on the floor if no one's listening */
        if (!event_is_open)
                return 0;
index 4546bf873aea273c2a0993fb3fbb465d801543ed..6192c8be66df62587e0ee49e3af2a31b145b38bc 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);
@@ -652,6 +682,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
  */
@@ -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 82f496c07675c66e3cf76020cfbf81fc3dc4139f..10e851021ecabcc01e2c86354401eeda2b3cbd47 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 3b23562e6f92d195ea24dad4b1eb24131b6f519a..dfa5853b17f097555095c9b87668d03a39ba6bd8 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <acpi/acpi_drivers.h>
+#include <net/netlink.h>
+#include <net/genetlink.h>
 
 #define _COMPONENT             ACPI_SYSTEM_COMPONENT
 ACPI_MODULE_NAME("event");
@@ -48,7 +50,6 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
        static int chars_remaining = 0;
        static char *ptr;
 
-
        if (!chars_remaining) {
                memset(&event, 0, sizeof(struct acpi_bus_event));
 
@@ -106,23 +107,161 @@ static const struct file_operations acpi_system_event_ops = {
        .poll = acpi_system_poll_event,
 };
 
+#ifdef CONFIG_NET
+unsigned int acpi_event_seqnum;
+struct acpi_genl_event {
+       acpi_device_class device_class;
+       char bus_id[15];
+       u32 type;
+       u32 data;
+};
+
+/* attributes of acpi_genl_family */
+enum {
+       ACPI_GENL_ATTR_UNSPEC,
+       ACPI_GENL_ATTR_EVENT,   /* ACPI event info needed by user space */
+       __ACPI_GENL_ATTR_MAX,
+};
+#define ACPI_GENL_ATTR_MAX (__ACPI_GENL_ATTR_MAX - 1)
+
+/* commands supported by the acpi_genl_family */
+enum {
+       ACPI_GENL_CMD_UNSPEC,
+       ACPI_GENL_CMD_EVENT,    /* kernel->user notifications for ACPI events */
+       __ACPI_GENL_CMD_MAX,
+};
+#define ACPI_GENL_CMD_MAX (__ACPI_GENL_CMD_MAX - 1)
+
+#define ACPI_GENL_FAMILY_NAME          "acpi_event"
+#define ACPI_GENL_VERSION              0x01
+#define ACPI_GENL_MCAST_GROUP_NAME     "acpi_mc_group"
+
+static struct genl_family acpi_event_genl_family = {
+       .id = GENL_ID_GENERATE,
+       .name = ACPI_GENL_FAMILY_NAME,
+       .version = ACPI_GENL_VERSION,
+       .maxattr = ACPI_GENL_ATTR_MAX,
+};
+
+static struct genl_multicast_group acpi_event_mcgrp = {
+       .name = ACPI_GENL_MCAST_GROUP_NAME,
+};
+
+int acpi_bus_generate_genetlink_event(struct acpi_device *device,
+                                     u8 type, int data)
+{
+       struct sk_buff *skb;
+       struct nlattr *attr;
+       struct acpi_genl_event *event;
+       void *msg_header;
+       int size;
+       int result;
+
+       /* allocate memory */
+       size = nla_total_size(sizeof(struct acpi_genl_event)) +
+           nla_total_size(0);
+
+       skb = genlmsg_new(size, GFP_ATOMIC);
+       if (!skb)
+               return -ENOMEM;
+
+       /* add the genetlink message header */
+       msg_header = genlmsg_put(skb, 0, acpi_event_seqnum++,
+                                &acpi_event_genl_family, 0,
+                                ACPI_GENL_CMD_EVENT);
+       if (!msg_header) {
+               nlmsg_free(skb);
+               return -ENOMEM;
+       }
+
+       /* fill the data */
+       attr =
+           nla_reserve(skb, ACPI_GENL_ATTR_EVENT,
+                       sizeof(struct acpi_genl_event));
+       if (!attr) {
+               nlmsg_free(skb);
+               return -EINVAL;
+       }
+
+       event = nla_data(attr);
+       if (!event) {
+               nlmsg_free(skb);
+               return -EINVAL;
+       }
+
+       memset(event, 0, sizeof(struct acpi_genl_event));
+
+       strcpy(event->device_class, device->pnp.device_class);
+       strcpy(event->bus_id, device->dev.bus_id);
+       event->type = type;
+       event->data = data;
+
+       /* send multicast genetlink message */
+       result = genlmsg_end(skb, msg_header);
+       if (result < 0) {
+               nlmsg_free(skb);
+               return result;
+       }
+
+       result =
+           genlmsg_multicast(skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC);
+       if (result)
+               ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+                                 "Failed to send a Genetlink message!\n"));
+       return 0;
+}
+
+static int acpi_event_genetlink_init(void)
+{
+       int result;
+
+       result = genl_register_family(&acpi_event_genl_family);
+       if (result)
+               return result;
+
+       result = genl_register_mc_group(&acpi_event_genl_family,
+                                       &acpi_event_mcgrp);
+       if (result)
+               genl_unregister_family(&acpi_event_genl_family);
+
+       return result;
+}
+
+#else
+int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type,
+                                     int data)
+{
+       return 0;
+}
+
+static int acpi_event_genetlink_init(void)
+{
+       return -ENODEV;
+}
+#endif
+
 static int __init acpi_event_init(void)
 {
        struct proc_dir_entry *entry;
        int error = 0;
 
-
        if (acpi_disabled)
                return 0;
 
+       /* create genetlink for acpi event */
+       error = acpi_event_genetlink_init();
+       if (error)
+               printk(KERN_WARNING PREFIX
+                      "Failed to create genetlink family for ACPI event\n");
+
        /* 'event' [R] */
        entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
        if (entry)
                entry->proc_fops = &acpi_system_event_ops;
-       else {
-               error = -ENODEV;
-       }
-       return error;
+       else
+               return -ENODEV;
+
+       return 0;
 }
 
-subsys_initcall(acpi_event_init);
+fs_initcall(acpi_event_init);
index 902c287b3a4fd0295f2a9f38418a1ba1228904ab..361ebe6c4a6f0b40cdf9c86acb484eb235862dbd 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 400d90fca966ca9c08aa2c68233d56f47790bc00..23ee7bc4a705459579f5122c31ea368bb43235d8 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 41427a41f6201fbcad4c8b7bcbaaa62228e21ed3..4893e256e399bea43ee35a62a0c0fa16667d3bdf 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 00d53c2fd1e823bbf088863d3ae6577ef1da0606..12c09fafce9a29de915966be172e96a94eef79a1 100644 (file)
@@ -77,13 +77,7 @@ static struct workqueue_struct *kacpi_notify_wq;
 #define        OSI_STRING_LENGTH_MAX 64        /* arbitrary */
 static char osi_additional_string[OSI_STRING_LENGTH_MAX];
 
-#define OSI_LINUX_ENABLED
-#ifdef OSI_LINUX_ENABLED
-int osi_linux = 1;     /* enable _OSI(Linux) by default */
-#else
-int osi_linux;         /* disable _OSI(Linux) by default */
-#endif
-
+static int osi_linux;          /* disable _OSI(Linux) by default */
 
 #ifdef CONFIG_DMI
 static struct __initdata dmi_system_id acpi_osl_dmi_table[];
@@ -1183,17 +1177,10 @@ acpi_os_validate_interface (char *interface)
        if (!strcmp("Linux", interface)) {
                printk(KERN_WARNING PREFIX
                        "System BIOS is requesting _OSI(Linux)\n");
-#ifdef OSI_LINUX_ENABLED
-               printk(KERN_WARNING PREFIX
-                       "Please test with \"acpi_osi=!Linux\"\n"
-                       "Please send dmidecode "
-                       "to linux-acpi@vger.kernel.org\n");
-#else
                printk(KERN_WARNING PREFIX
                        "If \"acpi_osi=Linux\" works better,\n"
                        "Please send dmidecode "
                        "to linux-acpi@vger.kernel.org\n");
-#endif
                if(osi_linux)
                        return AE_OK;
        }
@@ -1227,36 +1214,14 @@ acpi_os_validate_address (
 }
 
 #ifdef CONFIG_DMI
-#ifdef OSI_LINUX_ENABLED
-static int dmi_osi_not_linux(struct dmi_system_id *d)
-{
-       printk(KERN_NOTICE "%s detected: requires not _OSI(Linux)\n", d->ident);
-       enable_osi_linux(0);
-       return 0;
-}
-#else
 static int dmi_osi_linux(struct dmi_system_id *d)
 {
-       printk(KERN_NOTICE "%s detected: requires _OSI(Linux)\n", d->ident);
+       printk(KERN_NOTICE "%s detected: enabling _OSI(Linux)\n", d->ident);
        enable_osi_linux(1);
        return 0;
 }
-#endif
 
 static struct dmi_system_id acpi_osl_dmi_table[] __initdata = {
-#ifdef OSI_LINUX_ENABLED
-       /*
-        * Boxes that need NOT _OSI(Linux)
-        */
-       {
-        .callback = dmi_osi_not_linux,
-        .ident = "Toshiba Satellite P100",
-        .matches = {
-                    DMI_MATCH(DMI_BOARD_VENDOR, "TOSHIBA"),
-                    DMI_MATCH(DMI_BOARD_NAME, "Satellite P100"),
-                    },
-        },
-#else
        /*
         * Boxes that need _OSI(Linux)
         */
@@ -1268,7 +1233,6 @@ static struct dmi_system_id acpi_osl_dmi_table[] __initdata = {
                     DMI_MATCH(DMI_BOARD_NAME, "MPAD-MSAE Customer Reference Boards"),
                     },
         },
-#endif
        {}
 };
 #endif /* CONFIG_DMI */
index acc594771379af521ef06a5f7a549ca781583d8d..3448edd61dc406d977afb3b90ec28b3a5e9dfc17 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 e1ca86dfdd661fa2a53fbf78d3207296795ea165..81aceb5da7c7948f905787fd040c5b9f7f810c1b 100644 (file)
@@ -66,6 +66,7 @@
 #define ACPI_PROCESSOR_FILE_LIMIT      "limit"
 #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
 #define ACPI_PROCESSOR_NOTIFY_POWER    0x81
+#define ACPI_PROCESSOR_NOTIFY_THROTTLING       0x82
 
 #define ACPI_PROCESSOR_LIMIT_USER      0
 #define ACPI_PROCESSOR_LIMIT_THERMAL   1
@@ -84,6 +85,8 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
 static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
+extern int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
+
 
 static struct acpi_driver acpi_processor_driver = {
        .name = "processor",
@@ -696,6 +699,9 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
                acpi_processor_cst_has_changed(pr);
                acpi_bus_generate_event(device, event, 0);
                break;
+       case ACPI_PROCESSOR_NOTIFY_THROTTLING:
+               acpi_processor_tstate_has_changed(pr);
+               acpi_bus_generate_event(device, event, 0);
        default:
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Unsupported event [0x%x]\n", event));
index bb5d23be42607fe4ebb3c91c6dd118287242131b..a898991f77cbcfb18fc41c481afeca1fc63f0697 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 b33486009f41c690f1b6bed87f4818beb17a27d6..3f55d1f90c1170d0e308693076b822c514bd65f9 100644 (file)
 #define _COMPONENT              ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("processor_throttling");
 
+static int acpi_processor_get_throttling(struct acpi_processor *pr);
+int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
+
+static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
+{
+       acpi_status status = 0;
+       unsigned long tpc = 0;
+
+       if (!pr)
+               return -EINVAL;
+       status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
+       if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC"));
+               return -ENODEV;
+       }
+       pr->throttling_platform_limit = (int)tpc;
+       return 0;
+}
+
+int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
+{
+       return acpi_processor_get_platform_limit(pr);
+}
+
+/* --------------------------------------------------------------------------
+                             _PTC, _TSS, _TSD support 
+   -------------------------------------------------------------------------- */
+static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
+{
+       int result = 0;
+       acpi_status status = 0;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *ptc = NULL;
+       union acpi_object obj = { 0 };
+
+       status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
+       if (ACPI_FAILURE(status)) {
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC"));
+               return -ENODEV;
+       }
+
+       ptc = (union acpi_object *)buffer.pointer;
+       if (!ptc || (ptc->type != ACPI_TYPE_PACKAGE)
+           || (ptc->package.count != 2)) {
+               printk(KERN_ERR PREFIX "Invalid _PTC data\n");
+               result = -EFAULT;
+               goto end;
+       }
+
+       /*
+        * control_register
+        */
+
+       obj = ptc->package.elements[0];
+
+       if ((obj.type != ACPI_TYPE_BUFFER)
+           || (obj.buffer.length < sizeof(struct acpi_ptc_register))
+           || (obj.buffer.pointer == NULL)) {
+               printk(KERN_ERR PREFIX
+                      "Invalid _PTC data (control_register)\n");
+               result = -EFAULT;
+               goto end;
+       }
+       memcpy(&pr->throttling.control_register, obj.buffer.pointer,
+              sizeof(struct acpi_ptc_register));
+
+       /*
+        * status_register
+        */
+
+       obj = ptc->package.elements[1];
+
+       if ((obj.type != ACPI_TYPE_BUFFER)
+           || (obj.buffer.length < sizeof(struct acpi_ptc_register))
+           || (obj.buffer.pointer == NULL)) {
+               printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n");
+               result = -EFAULT;
+               goto end;
+       }
+
+       memcpy(&pr->throttling.status_register, obj.buffer.pointer,
+              sizeof(struct acpi_ptc_register));
+
+      end:
+       kfree(buffer.pointer);
+
+       return result;
+}
+static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
+{
+       int result = 0;
+       acpi_status status = AE_OK;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
+       struct acpi_buffer state = { 0, NULL };
+       union acpi_object *tss = NULL;
+       int i;
+
+       status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer);
+       if (ACPI_FAILURE(status)) {
+               ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS"));
+               return -ENODEV;
+       }
+
+       tss = buffer.pointer;
+       if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) {
+               printk(KERN_ERR PREFIX "Invalid _TSS data\n");
+               result = -EFAULT;
+               goto end;
+       }
+
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
+                         tss->package.count));
+
+       pr->throttling.state_count = tss->package.count;
+       pr->throttling.states_tss =
+           kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
+                   GFP_KERNEL);
+       if (!pr->throttling.states_tss) {
+               result = -ENOMEM;
+               goto end;
+       }
+
+       for (i = 0; i < pr->throttling.state_count; i++) {
+
+               struct acpi_processor_tx_tss *tx =
+                   (struct acpi_processor_tx_tss *)&(pr->throttling.
+                                                     states_tss[i]);
+
+               state.length = sizeof(struct acpi_processor_tx_tss);
+               state.pointer = tx;
+
+               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
+
+               status = acpi_extract_package(&(tss->package.elements[i]),
+                                             &format, &state);
+               if (ACPI_FAILURE(status)) {
+                       ACPI_EXCEPTION((AE_INFO, status, "Invalid _TSS data"));
+                       result = -EFAULT;
+                       kfree(pr->throttling.states_tss);
+                       goto end;
+               }
+
+               if (!tx->freqpercentage) {
+                       printk(KERN_ERR PREFIX
+                              "Invalid _TSS data: freq is zero\n");
+                       result = -EFAULT;
+                       kfree(pr->throttling.states_tss);
+                       goto end;
+               }
+       }
+
+      end:
+       kfree(buffer.pointer);
+
+       return result;
+}
+static int acpi_processor_get_tsd(struct acpi_processor *pr)
+{
+       int result = 0;
+       acpi_status status = AE_OK;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
+       struct acpi_buffer state = { 0, NULL };
+       union acpi_object *tsd = NULL;
+       struct acpi_tsd_package *pdomain;
+
+       status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer);
+       if (ACPI_FAILURE(status)) {
+               return -ENODEV;
+       }
+
+       tsd = buffer.pointer;
+       if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
+               result = -EFAULT;
+               goto end;
+       }
+
+       if (tsd->package.count != 1) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
+               result = -EFAULT;
+               goto end;
+       }
+
+       pdomain = &(pr->throttling.domain_info);
+
+       state.length = sizeof(struct acpi_tsd_package);
+       state.pointer = pdomain;
+
+       status = acpi_extract_package(&(tsd->package.elements[0]),
+                                     &format, &state);
+       if (ACPI_FAILURE(status)) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
+               result = -EFAULT;
+               goto end;
+       }
+
+       if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n"));
+               result = -EFAULT;
+               goto end;
+       }
+
+       if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n"));
+               result = -EFAULT;
+               goto end;
+       }
+
+      end:
+       kfree(buffer.pointer);
+       return result;
+}
+
 /* --------------------------------------------------------------------------
                               Throttling Control
    -------------------------------------------------------------------------- */
-static int acpi_processor_get_throttling(struct acpi_processor *pr)
+static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
 {
        int state = 0;
        u32 value = 0;
        u32 duty_mask = 0;
        u32 duty_value = 0;
 
-
        if (!pr)
                return -EINVAL;
 
@@ -94,13 +308,115 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
        return 0;
 }
 
-int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
+static int acpi_read_throttling_status(struct acpi_processor_throttling
+                                      *throttling)
+{
+       int value = -1;
+       switch (throttling->status_register.space_id) {
+       case ACPI_ADR_SPACE_SYSTEM_IO:
+               acpi_os_read_port((acpi_io_address) throttling->status_register.
+                                 address, &value,
+                                 (u32) throttling->status_register.bit_width *
+                                 8);
+               break;
+       case ACPI_ADR_SPACE_FIXED_HARDWARE:
+               printk(KERN_ERR PREFIX
+                      "HARDWARE addr space,NOT supported yet\n");
+               break;
+       default:
+               printk(KERN_ERR PREFIX "Unknown addr space %d\n",
+                      (u32) (throttling->status_register.space_id));
+       }
+       return value;
+}
+
+static int acpi_write_throttling_state(struct acpi_processor_throttling
+                                      *throttling, int value)
+{
+       int ret = -1;
+
+       switch (throttling->control_register.space_id) {
+       case ACPI_ADR_SPACE_SYSTEM_IO:
+               acpi_os_write_port((acpi_io_address) throttling->
+                                  control_register.address, value,
+                                  (u32) throttling->control_register.
+                                  bit_width * 8);
+               ret = 0;
+               break;
+       case ACPI_ADR_SPACE_FIXED_HARDWARE:
+               printk(KERN_ERR PREFIX
+                      "HARDWARE addr space,NOT supported yet\n");
+               break;
+       default:
+               printk(KERN_ERR PREFIX "Unknown addr space %d\n",
+                      (u32) (throttling->control_register.space_id));
+       }
+       return ret;
+}
+
+static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
+{
+       int i;
+
+       for (i = 0; i < pr->throttling.state_count; i++) {
+               struct acpi_processor_tx_tss *tx =
+                   (struct acpi_processor_tx_tss *)&(pr->throttling.
+                                                     states_tss[i]);
+               if (tx->control == value)
+                       break;
+       }
+       if (i > pr->throttling.state_count)
+               i = -1;
+       return i;
+}
+
+static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
+{
+       int value = -1;
+       if (state >= 0 && state <= pr->throttling.state_count) {
+               struct acpi_processor_tx_tss *tx =
+                   (struct acpi_processor_tx_tss *)&(pr->throttling.
+                                                     states_tss[state]);
+               value = tx->control;
+       }
+       return value;
+}
+
+static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
+{
+       int state = 0;
+       u32 value = 0;
+
+       if (!pr)
+               return -EINVAL;
+
+       if (!pr->flags.throttling)
+               return -ENODEV;
+
+       pr->throttling.state = 0;
+       local_irq_disable();
+       value = acpi_read_throttling_status(&pr->throttling);
+       if (value >= 0) {
+               state = acpi_get_throttling_state(pr, value);
+               pr->throttling.state = state;
+       }
+       local_irq_enable();
+
+       return 0;
+}
+
+static int acpi_processor_get_throttling(struct acpi_processor *pr)
+{
+       return pr->throttling.acpi_processor_get_throttling(pr);
+}
+
+static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
+                                             int state)
 {
        u32 value = 0;
        u32 duty_mask = 0;
        u32 duty_value = 0;
 
-
        if (!pr)
                return -EINVAL;
 
@@ -113,6 +429,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
        if (state == pr->throttling.state)
                return 0;
 
+       if (state < pr->throttling_platform_limit)
+               return -EPERM;
        /*
         * Calculate the duty_value and duty_mask.
         */
@@ -165,12 +483,51 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
        return 0;
 }
 
+static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
+                                            int state)
+{
+       u32 value = 0;
+
+       if (!pr)
+               return -EINVAL;
+
+       if ((state < 0) || (state > (pr->throttling.state_count - 1)))
+               return -EINVAL;
+
+       if (!pr->flags.throttling)
+               return -ENODEV;
+
+       if (state == pr->throttling.state)
+               return 0;
+
+       if (state < pr->throttling_platform_limit)
+               return -EPERM;
+
+       local_irq_disable();
+
+       value = acpi_get_throttling_value(pr, state);
+       if (value >= 0) {
+               acpi_write_throttling_state(&pr->throttling, value);
+               pr->throttling.state = state;
+       }
+       local_irq_enable();
+
+       return 0;
+}
+
+int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
+{
+       return pr->throttling.acpi_processor_set_throttling(pr, state);
+}
+
 int acpi_processor_get_throttling_info(struct acpi_processor *pr)
 {
        int result = 0;
        int step = 0;
        int i = 0;
-
+       int no_ptc = 0;
+       int no_tss = 0;
+       int no_tsd = 0;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -182,6 +539,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
                return -EINVAL;
 
        /* TBD: Support ACPI 2.0 objects */
+       no_ptc = acpi_processor_get_throttling_control(pr);
+       no_tss = acpi_processor_get_throttling_states(pr);
+       no_tsd = acpi_processor_get_tsd(pr);
+
+       if (no_ptc || no_tss) {
+               pr->throttling.acpi_processor_get_throttling =
+                   &acpi_processor_get_throttling_fadt;
+               pr->throttling.acpi_processor_set_throttling =
+                   &acpi_processor_set_throttling_fadt;
+       } else {
+               pr->throttling.acpi_processor_get_throttling =
+                   &acpi_processor_get_throttling_ptc;
+               pr->throttling.acpi_processor_set_throttling =
+                   &acpi_processor_set_throttling_ptc;
+       }
 
        if (!pr->throttling.address) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
@@ -262,7 +634,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
        int i = 0;
        int result = 0;
 
-
        if (!pr)
                goto end;
 
@@ -280,15 +651,25 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
        }
 
        seq_printf(seq, "state count:             %d\n"
-                  "active state:            T%d\n",
-                  pr->throttling.state_count, pr->throttling.state);
+                  "active state:            T%d\n"
+                  "state available: T%d to T%d\n",
+                  pr->throttling.state_count, pr->throttling.state,
+                  pr->throttling_platform_limit,
+                  pr->throttling.state_count - 1);
 
        seq_puts(seq, "states:\n");
-       for (i = 0; i < pr->throttling.state_count; i++)
-               seq_printf(seq, "   %cT%d:                  %02d%%\n",
-                          (i == pr->throttling.state ? '*' : ' '), i,
-                          (pr->throttling.states[i].performance ? pr->
-                           throttling.states[i].performance / 10 : 0));
+       if (acpi_processor_get_throttling == acpi_processor_get_throttling_fadt)
+               for (i = 0; i < pr->throttling.state_count; i++)
+                       seq_printf(seq, "   %cT%d:                  %02d%%\n",
+                                  (i == pr->throttling.state ? '*' : ' '), i,
+                                  (pr->throttling.states[i].performance ? pr->
+                                   throttling.states[i].performance / 10 : 0));
+       else
+               for (i = 0; i < pr->throttling.state_count; i++)
+                       seq_printf(seq, "   %cT%d:                  %02d%%\n",
+                                  (i == pr->throttling.state ? '*' : ' '), i,
+                                  (int)pr->throttling.states_tss[i].
+                                  freqpercentage);
 
       end:
        return 0;
@@ -301,7 +682,7 @@ static int acpi_processor_throttling_open_fs(struct inode *inode,
                           PDE(inode)->data);
 }
 
-static ssize_t acpi_processor_write_throttling(struct file * file,
+static ssize_t acpi_processor_write_throttling(struct file *file,
                                               const char __user * buffer,
                                               size_t count, loff_t * data)
 {
@@ -310,7 +691,6 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
        struct acpi_processor *pr = m->private;
        char state_string[12] = { '\0' };
 
-
        if (!pr || (count > sizeof(state_string) - 1))
                return -EINVAL;
 
index c1bae106833cef03d6f7faee83e5d42c9fda36a9..974d00ccfe845209c6ced6ec09278f5dbe8b49bf 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 42127c0d612c8940d1060c67a5e8b5893567ef88..3279e72a94f81c0c532f72a9bd0284861a1ba345 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 83a8d3097904e99dbb825736ee84294bd4739de5..edee2806e37bcec904e6640a90fb2423b981260c 100644 (file)
@@ -39,15 +39,12 @@ ACPI_MODULE_NAME("system");
 
 #define ACPI_SYSTEM_CLASS              "system"
 #define ACPI_SYSTEM_DEVICE_NAME                "System"
-#define ACPI_SYSTEM_FILE_INFO          "info"
-#define ACPI_SYSTEM_FILE_EVENT         "event"
-#define ACPI_SYSTEM_FILE_DSDT          "dsdt"
-#define ACPI_SYSTEM_FILE_FADT          "fadt"
 
 /*
  * Make ACPICA version work as module param
  */
-static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
+static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
+{
        int result;
 
        result = sprintf(buffer, "%x", ACPI_CA_VERSION);
@@ -57,10 +54,127 @@ static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
 
 module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
 
+/* --------------------------------------------------------------------------
+                              FS Interface (/sys)
+   -------------------------------------------------------------------------- */
+static LIST_HEAD(acpi_table_attr_list);
+static struct kobject tables_kobj;
+
+struct acpi_table_attr {
+       struct bin_attribute attr;
+       char name[8];
+       int instance;
+       struct list_head node;
+};
+
+static ssize_t acpi_table_show(struct kobject *kobj,
+                              struct bin_attribute *bin_attr, char *buf,
+                              loff_t offset, size_t count)
+{
+       struct acpi_table_attr *table_attr =
+           container_of(bin_attr, struct acpi_table_attr, attr);
+       struct acpi_table_header *table_header = NULL;
+       acpi_status status;
+       ssize_t ret_count = count;
+
+       status =
+           acpi_get_table(table_attr->name, table_attr->instance,
+                          &table_header);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+
+       if (offset >= table_header->length) {
+               ret_count = 0;
+               goto end;
+       }
+
+       if (offset + ret_count > table_header->length)
+               ret_count = table_header->length - offset;
+
+       memcpy(buf, ((char *)table_header) + offset, ret_count);
+
+      end:
+       return ret_count;
+}
+
+static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
+                                struct acpi_table_header *table_header)
+{
+       struct acpi_table_header *header = NULL;
+       struct acpi_table_attr *attr = NULL;
+
+       memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE);
+
+       list_for_each_entry(attr, &acpi_table_attr_list, node) {
+               if (!memcmp(table_header->signature, attr->name,
+                           ACPI_NAME_SIZE))
+                       if (table_attr->instance < attr->instance)
+                               table_attr->instance = attr->instance;
+       }
+       table_attr->instance++;
+
+       if (table_attr->instance > 1 || (table_attr->instance == 1 &&
+                                        !acpi_get_table(table_header->
+                                                        signature, 2,
+                                                        &header)))
+               sprintf(table_attr->name + 4, "%d", table_attr->instance);
+
+       table_attr->attr.size = 0;
+       table_attr->attr.read = acpi_table_show;
+       table_attr->attr.attr.name = table_attr->name;
+       table_attr->attr.attr.mode = 0444;
+       table_attr->attr.attr.owner = THIS_MODULE;
+
+       return;
+}
+
+static int acpi_system_sysfs_init(void)
+{
+       struct acpi_table_attr *table_attr;
+       struct acpi_table_header *table_header = NULL;
+       int table_index = 0;
+       int result;
+
+       tables_kobj.parent = &acpi_subsys.kobj;
+       kobject_set_name(&tables_kobj, "tables");
+       result = kobject_register(&tables_kobj);
+       if (result)
+               return result;
+
+       do {
+               result = acpi_get_table_by_index(table_index, &table_header);
+               if (!result) {
+                       table_index++;
+                       table_attr = NULL;
+                       table_attr =
+                           kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
+                       if (!table_attr)
+                               return -ENOMEM;
+
+                       acpi_table_attr_init(table_attr, table_header);
+                       result =
+                           sysfs_create_bin_file(&tables_kobj,
+                                                 &table_attr->attr);
+                       if (result) {
+                               kfree(table_attr);
+                               return result;
+                       } else
+                               list_add_tail(&table_attr->node,
+                                             &acpi_table_attr_list);
+               }
+       } while (!result);
+
+       return 0;
+}
+
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)
    -------------------------------------------------------------------------- */
 #ifdef CONFIG_ACPI_PROCFS
+#define ACPI_SYSTEM_FILE_INFO          "info"
+#define ACPI_SYSTEM_FILE_EVENT         "event"
+#define ACPI_SYSTEM_FILE_DSDT          "dsdt"
+#define ACPI_SYSTEM_FILE_FADT          "fadt"
 
 static int acpi_system_read_info(struct seq_file *seq, void *offset)
 {
@@ -80,7 +194,6 @@ static const struct file_operations acpi_system_info_ops = {
        .llseek = seq_lseek,
        .release = single_release,
 };
-#endif
 
 static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
                                     loff_t *);
@@ -97,13 +210,11 @@ acpi_system_read_dsdt(struct file *file,
        struct acpi_table_header *dsdt = NULL;
        ssize_t res;
 
-
        status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       res = simple_read_from_buffer(buffer, count, ppos,
-                                     dsdt, dsdt->length);
+       res = simple_read_from_buffer(buffer, count, ppos, dsdt, dsdt->length);
 
        return res;
 }
@@ -123,28 +234,21 @@ acpi_system_read_fadt(struct file *file,
        struct acpi_table_header *fadt = NULL;
        ssize_t res;
 
-
        status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       res = simple_read_from_buffer(buffer, count, ppos,
-                                     fadt, fadt->length);
+       res = simple_read_from_buffer(buffer, count, ppos, fadt, fadt->length);
 
        return res;
 }
 
-static int __init acpi_system_init(void)
+static int acpi_system_procfs_init(void)
 {
        struct proc_dir_entry *entry;
        int error = 0;
        char *name;
 
-
-       if (acpi_disabled)
-               return 0;
-
-#ifdef CONFIG_ACPI_PROCFS
        /* 'info' [R] */
        name = ACPI_SYSTEM_FILE_INFO;
        entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
@@ -153,7 +257,6 @@ static int __init acpi_system_init(void)
        else {
                entry->proc_fops = &acpi_system_info_ops;
        }
-#endif
 
        /* 'dsdt' [R] */
        name = ACPI_SYSTEM_FILE_DSDT;
@@ -177,12 +280,32 @@ static int __init acpi_system_init(void)
       Error:
        remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
        remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
-#ifdef CONFIG_ACPI_PROCFS
        remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
-#endif
 
        error = -EFAULT;
        goto Done;
 }
+#else
+static int acpi_system_procfs_init(void)
+{
+       return 0;
+}
+#endif
+
+static int __init acpi_system_init(void)
+{
+       int result = 0;
+
+       if (acpi_disabled)
+               return 0;
+
+       result = acpi_system_procfs_init();
+       if (result)
+               return result;
+
+       result = acpi_system_sysfs_init();
+
+       return result;
+}
 
 subsys_initcall(acpi_system_init);
index 1285e91474fbff4c504d82e75ebe9b63c608eb24..002bb33003af8c8c30c1b48bfb0607c397d974cf 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 8ec6f8e481385d2908f286249903d44db35cf184..f112af433e36eb01afdfce5cfdcaeacf74dde19d 100644 (file)
@@ -62,16 +62,13 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
 static char *acpi_interfaces_supported[] = {
        /* Operating System Vendor Strings */
 
-       "Windows 2000",
-       "Windows 2001",
-       "Windows 2001 SP0",
-       "Windows 2001 SP1",
-       "Windows 2001 SP2",
-       "Windows 2001 SP3",
-       "Windows 2001 SP4",
-       "Windows 2001.1",
-       "Windows 2001.1 SP1",   /* Added 03/2006 */
-       "Windows 2006",         /* Added 03/2006 */
+       "Windows 2000",         /* Windows 2000 */
+       "Windows 2001",         /* Windows XP */
+       "Windows 2001 SP1",     /* Windows XP SP1 */
+       "Windows 2001 SP2",     /* Windows XP SP2 */
+       "Windows 2001.1",       /* Windows Server 2003 */
+       "Windows 2001.1 SP1",   /* Windows Server 2003 SP1 - Added 03/2006 */
+       "Windows 2006",         /* Windows Vista - Added 03/2006 */
 
        /* Feature Group Strings */
 
index 00d25b34725549e86b739354cf5f972e6a10831f..5f014d3764c85b51b3ac3552f0722732254987fe 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/seq_file.h>
 
 #include <linux/backlight.h>
+#include <linux/video_output.h>
 #include <asm/uaccess.h>
 
 #include <acpi/acpi_bus.h>
@@ -169,6 +170,7 @@ struct acpi_video_device {
        struct acpi_device *dev;
        struct acpi_video_device_brightness *brightness;
        struct backlight_device *backlight;
+       struct output_device *output_dev;
 };
 
 /* bus */
@@ -272,6 +274,10 @@ static int acpi_video_get_next_level(struct acpi_video_device *device,
                                     u32 level_current, u32 event);
 static void acpi_video_switch_brightness(struct acpi_video_device *device,
                                         int event);
+static int acpi_video_device_get_state(struct acpi_video_device *device,
+                           unsigned long *state);
+static int acpi_video_output_get(struct output_device *od);
+static int acpi_video_device_set_state(struct acpi_video_device *device, int state);
 
 /*backlight device sysfs support*/
 static int acpi_video_get_brightness(struct backlight_device *bd)
@@ -297,6 +303,28 @@ static struct backlight_ops acpi_backlight_ops = {
        .update_status  = acpi_video_set_brightness,
 };
 
+/*video output device sysfs support*/
+static int acpi_video_output_get(struct output_device *od)
+{
+       unsigned long state;
+       struct acpi_video_device *vd =
+               (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+       acpi_video_device_get_state(vd, &state);
+       return (int)state;
+}
+
+static int acpi_video_output_set(struct output_device *od)
+{
+       unsigned long state = od->request_state;
+       struct acpi_video_device *vd=
+               (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+       return acpi_video_device_set_state(vd, state);
+}
+
+static struct output_properties acpi_output_properties = {
+       .set_state = acpi_video_output_set,
+       .get_status = acpi_video_output_get,
+};
 /* --------------------------------------------------------------------------
                                Video Management
    -------------------------------------------------------------------------- */
@@ -531,7 +559,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
 
 static void acpi_video_device_find_cap(struct acpi_video_device *device)
 {
-       acpi_integer status;
        acpi_handle h_dummy1;
        int i;
        u32 max_level = 0;
@@ -565,50 +592,55 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                device->cap._DSS = 1;
        }
 
-       status = acpi_video_device_lcd_query_levels(device, &obj);
-
-       if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
-               int count = 0;
-               union acpi_object *o;
-
-               br = kzalloc(sizeof(*br), GFP_KERNEL);
-               if (!br) {
-                       printk(KERN_ERR "can't allocate memory\n");
-               } else {
-                       br->levels = kmalloc(obj->package.count *
-                                            sizeof *(br->levels), GFP_KERNEL);
-                       if (!br->levels)
-                               goto out;
-
-                       for (i = 0; i < obj->package.count; i++) {
-                               o = (union acpi_object *)&obj->package.
-                                   elements[i];
-                               if (o->type != ACPI_TYPE_INTEGER) {
-                                       printk(KERN_ERR PREFIX "Invalid data\n");
-                                       continue;
-                               }
-                               br->levels[count] = (u32) o->integer.value;
-                               if (br->levels[count] > max_level)
-                                       max_level = br->levels[count];
-                               count++;
-                       }
-                     out:
-                       if (count < 2) {
-                               kfree(br->levels);
-                               kfree(br);
+       if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
+
+               if (obj->package.count >= 2) {
+                       int count = 0;
+                       union acpi_object *o;
+
+                       br = kzalloc(sizeof(*br), GFP_KERNEL);
+                       if (!br) {
+                               printk(KERN_ERR "can't allocate memory\n");
                        } else {
-                               br->count = count;
-                               device->brightness = br;
-                               ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                                                 "found %d brightness levels\n",
-                                                 count));
+                               br->levels = kmalloc(obj->package.count *
+                                                    sizeof *(br->levels), GFP_KERNEL);
+                               if (!br->levels)
+                                       goto out;
+
+                               for (i = 0; i < obj->package.count; i++) {
+                                       o = (union acpi_object *)&obj->package.
+                                           elements[i];
+                                       if (o->type != ACPI_TYPE_INTEGER) {
+                                               printk(KERN_ERR PREFIX "Invalid data\n");
+                                               continue;
+                                       }
+                                       br->levels[count] = (u32) o->integer.value;
+
+                                       if (br->levels[count] > max_level)
+                                               max_level = br->levels[count];
+                                       count++;
+                               }
+                             out:
+                               if (count < 2) {
+                                       kfree(br->levels);
+                                       kfree(br);
+                               } else {
+                                       br->count = count;
+                                       device->brightness = br;
+                                       ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+                                                         "found %d brightness levels\n",
+                                                         count));
+                               }
                        }
                }
+
+       } else {
+               ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
        }
 
        kfree(obj);
 
-       if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
+       if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
                unsigned long tmp;
                static int count = 0;
                char *name;
@@ -626,6 +658,17 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 
                kfree(name);
        }
+       if (device->cap._DCS && device->cap._DSS){
+               static int count = 0;
+               char *name;
+               name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
+               if (!name)
+                       return;
+               sprintf(name, "acpi_video%d", count++);
+               device->output_dev = video_output_register(name,
+                               NULL, device, &acpi_output_properties);
+               kfree(name);
+       }
        return;
 }
 
@@ -1669,6 +1712,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_device_notify);
        backlight_device_unregister(device->backlight);
+       video_output_unregister(device->output_dev);
        return 0;
 }
 
index b37f1d5a5be6e19e9604e80b36988573f500d58f..a08f8f981c11c8446176e8e588c0d917562dfcfb 100644 (file)
@@ -472,7 +472,7 @@ static void hvc_handle_event(struct HvLpEvent *event)
        }
 }
 
-static int send_open(HvLpIndex remoteLp, void *sem)
+static int __init send_open(HvLpIndex remoteLp, void *sem)
 {
        return HvCallEvent_signalLpEventFast(remoteLp,
                        HvLpEvent_Type_VirtualIo,
@@ -484,7 +484,7 @@ static int send_open(HvLpIndex remoteLp, void *sem)
                        0, 0, 0, 0);
 }
 
-static int hvc_vio_init(void)
+static int __init hvc_vio_init(void)
 {
        atomic_t wait_flag;
        int rc;
@@ -552,14 +552,14 @@ static int hvc_vio_init(void)
 }
 module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
 
-static void hvc_vio_exit(void)
+static void __exit hvc_vio_exit(void)
 {
        vio_unregister_driver(&hvc_vio_driver);
 }
 module_exit(hvc_vio_exit);
 
 /* the device tree order defines our numbering */
-static int hvc_find_vtys(void)
+static int __init hvc_find_vtys(void)
 {
        struct device_node *vty;
        int num_found = 0;
index 4b97eaf18602cbb4f139d5691c24e5a4aa5b1d71..bb09413d5a21ed5d09db2b1185c50141553ab0da 100644 (file)
@@ -115,7 +115,7 @@ static void __exit hvc_rtas_exit(void)
 module_exit(hvc_rtas_exit);
 
 /* This will happen prior to module init.  There is no tty at this time? */
-static int hvc_rtas_console_init(void)
+static int __init hvc_rtas_console_init(void)
 {
        rtascons_put_char_token = rtas_token("put-term-char");
        if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
index 17f96e04266fbbb5192c64ea717d50dedd8efcc1..69d8866de783f36a70ff38d63d4b47d9f0688385 100644 (file)
@@ -210,9 +210,9 @@ static struct ktermios hvcs_tty_termios = {
 static int hvcs_parm_num_devs = -1;
 module_param(hvcs_parm_num_devs, int, 0);
 
-char hvcs_driver_name[] = "hvcs";
-char hvcs_device_node[] = "hvcs";
-char hvcs_driver_string[]
+static const char hvcs_driver_name[] = "hvcs";
+static const char hvcs_device_node[] = "hvcs";
+static const char hvcs_driver_string[]
        = "IBM hvcs (Hypervisor Virtual Console Server) Driver";
 
 /* Status of partner info rescan triggered via sysfs. */
@@ -1092,7 +1092,7 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
  * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
  * calling this function or you will get deadlock.
  */
-struct hvcs_struct *hvcs_get_by_index(int index)
+static struct hvcs_struct *hvcs_get_by_index(int index)
 {
        struct hvcs_struct *hvcsd = NULL;
        unsigned long flags;
index 2f661e5f0dae67f37209879e34bbf50546d4486b..6cecc396e04064e6ca8f91ca766e02ea8842783e 100644 (file)
@@ -11,6 +11,7 @@ if VIRTUALIZATION
 config KVM
        tristate "Kernel-based Virtual Machine (KVM) support"
        depends on X86 && EXPERIMENTAL
+       select ANON_INODES
        ---help---
          Support hosting fully virtualized guest machines using hardware
          virtualization extensions.  You will need a fairly recent
index 4177ff004753299152a4d79471b784184eb7efdb..2c21d4f25cc82e85ab138aca5e4490f4166865f3 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/machdep.h>
 #include <asm/pmac_feature.h>
 #include <asm/dbdma.h>
-#include <asm/dbdma.h>
 #include <asm/macio.h>
 #include <asm/keylargo.h>
 
index 1d516f24ba53696336b483ab0bd859be836cbb37..aaaa61ea4217a5013da3933b768da1e99d261ed3 100644 (file)
@@ -150,6 +150,7 @@ config THINKPAD_ACPI
        depends on X86 && ACPI
        select BACKLIGHT_CLASS_DEVICE
        select HWMON
+       select NVRAM
        ---help---
          This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
          support for Fn-Fx key combinations, Bluetooth control, video
@@ -196,4 +197,17 @@ config THINKPAD_ACPI_BAY
 
          If you are not sure, say Y here.
 
+config THINKPAD_ACPI_INPUT_ENABLED
+       bool "Enable input layer support by default"
+       depends on THINKPAD_ACPI
+       default y
+       ---help---
+         Enables hot key handling over the input layer by default.  If unset,
+         the driver does not enable any hot key handling by default, and also
+         starts up with a mostly empty keymap.
+
+         If you are not sure, say Y here.  Say N to retain the deprecated
+         behavior of ibm-acpi, and thinkpad-acpi for kernels up to 2.6.21.
+
+
 endif # MISC_DEVICES
index 9623eaf4f89fdf7cb479cb0ad0bc06bec915e206..303e48ca0e8ae77459bb72dcf9c66d096b344636 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),
@@ -688,14 +794,117 @@ static struct backlight_ops sony_backlight_ops = {
        .get_brightness = sony_backlight_get_brightness,
 };
 
+/*
+ * 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 95c0b96e83f2110b751d775c2a53e66d718c6564..f15a58f7403fd4b231ddd267ebb02f098d22957b 100644 (file)
@@ -21,8 +21,8 @@
  *  02110-1301, USA.
  */
 
-#define IBM_VERSION "0.14"
-#define TPACPI_SYSFS_VERSION 0x000100
+#define IBM_VERSION "0.15"
+#define TPACPI_SYSFS_VERSION 0x010000
 
 /*
  *  Changelog:
@@ -92,6 +92,29 @@ MODULE_LICENSE("GPL");
 /* Please remove this in year 2009 */
 MODULE_ALIAS("ibm_acpi");
 
+/*
+ * DMI matching for module autoloading
+ *
+ * See http://thinkwiki.org/wiki/List_of_DMI_IDs
+ * See http://thinkwiki.org/wiki/BIOS_Upgrade_Downloads
+ *
+ * Only models listed in thinkwiki will be supported, so add yours
+ * if it is not there yet.
+ */
+#define IBM_BIOS_MODULE_ALIAS(__type) \
+       MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW")
+
+/* Non-ancient thinkpads */
+MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
+MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");
+
+/* Ancient thinkpad BIOSes have to be identified by
+ * BIOS type or model number, and there are far less
+ * BIOS types than model numbers... */
+IBM_BIOS_MODULE_ALIAS("I[B,D,H,I,M,N,O,T,W,V,Y,Z]");
+IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]");
+IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
+
 #define __unused __attribute__ ((unused))
 
 /****************************************************************************
@@ -106,7 +129,7 @@ MODULE_ALIAS("ibm_acpi");
  * ACPI basic handles
  */
 
-static acpi_handle root_handle = NULL;
+static acpi_handle root_handle;
 
 #define IBM_HANDLE(object, parent, paths...)                   \
        static acpi_handle  object##_handle;                    \
@@ -487,19 +510,36 @@ static char *next_cmd(char **cmds)
 /****************************************************************************
  ****************************************************************************
  *
- * Device model: hwmon and platform
+ * Device model: input, hwmon and platform
  *
  ****************************************************************************
  ****************************************************************************/
 
-static struct platform_device *tpacpi_pdev = NULL;
-static struct class_device *tpacpi_hwmon = NULL;
+static struct platform_device *tpacpi_pdev;
+static struct class_device *tpacpi_hwmon;
+static struct input_dev *tpacpi_inputdev;
+
+
+static int tpacpi_resume_handler(struct platform_device *pdev)
+{
+       struct ibm_struct *ibm, *itmp;
+
+       list_for_each_entry_safe(ibm, itmp,
+                                &tpacpi_all_drivers,
+                                all_drivers) {
+               if (ibm->resume)
+                       (ibm->resume)();
+       }
+
+       return 0;
+}
 
 static struct platform_driver tpacpi_pdriver = {
        .driver = {
                .name = IBM_DRVR_NAME,
                .owner = THIS_MODULE,
        },
+       .resume = tpacpi_resume_handler,
 };
 
 
@@ -677,9 +717,19 @@ static int __init thinkpad_acpi_driver_init(struct ibm_init_struct *iibm)
        printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
        printk(IBM_INFO "%s\n", IBM_URL);
 
-       if (ibm_thinkpad_ec_found)
-               printk(IBM_INFO "ThinkPad EC firmware %s\n",
-                      ibm_thinkpad_ec_found);
+       printk(IBM_INFO "ThinkPad BIOS %s, EC %s\n",
+               (thinkpad_id.bios_version_str) ?
+                       thinkpad_id.bios_version_str : "unknown",
+               (thinkpad_id.ec_version_str) ?
+                       thinkpad_id.ec_version_str : "unknown");
+
+       if (thinkpad_id.vendor && thinkpad_id.model_str)
+               printk(IBM_INFO "%s %s\n",
+                       (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) ?
+                               "IBM" : ((thinkpad_id.vendor ==
+                                               PCI_VENDOR_ID_LENOVO) ?
+                                       "Lenovo" : "Unknown vendor"),
+                       thinkpad_id.model_str);
 
        return 0;
 }
@@ -704,16 +754,28 @@ static struct ibm_struct thinkpad_acpi_driver_data = {
  */
 
 static int hotkey_orig_status;
-static int hotkey_orig_mask;
+static u32 hotkey_orig_mask;
+static u32 hotkey_all_mask;
+static u32 hotkey_reserved_mask;
+
+static u16 *hotkey_keycode_map;
 
-static struct attribute_set *hotkey_dev_attributes = NULL;
+static struct attribute_set *hotkey_dev_attributes;
+
+static int hotkey_get_wlsw(int *status)
+{
+       if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
+               return -EIO;
+       return 0;
+}
 
 /* sysfs hotkey enable ------------------------------------------------- */
 static ssize_t hotkey_enable_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        res = hotkey_get(&status, &mask);
        if (res)
@@ -727,7 +789,8 @@ static ssize_t hotkey_enable_store(struct device *dev,
                            const char *buf, size_t count)
 {
        unsigned long t;
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        if (parse_strtoul(buf, 1, &t))
                return -EINVAL;
@@ -748,13 +811,14 @@ static ssize_t hotkey_mask_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
        res = hotkey_get(&status, &mask);
        if (res)
                return res;
 
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n", mask);
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", mask);
 }
 
 static ssize_t hotkey_mask_store(struct device *dev,
@@ -762,9 +826,10 @@ static ssize_t hotkey_mask_store(struct device *dev,
                            const char *buf, size_t count)
 {
        unsigned long t;
-       int res, status, mask;
+       int res, status;
+       u32 mask;
 
-       if (parse_strtoul(buf, 0xffff, &t))
+       if (parse_strtoul(buf, 0xffffffffUL, &t))
                return -EINVAL;
 
        res = hotkey_get(&status, &mask);
@@ -794,26 +859,123 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
                           struct device_attribute *attr,
                           char *buf)
 {
-       return snprintf(buf, PAGE_SIZE, "0x%04x\n", hotkey_orig_mask);
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
 }
 
 static struct device_attribute dev_attr_hotkey_bios_mask =
        __ATTR(hotkey_bios_mask, S_IRUGO, hotkey_bios_mask_show, NULL);
 
+/* sysfs hotkey all_mask ----------------------------------------------- */
+static ssize_t hotkey_all_mask_show(struct device *dev,
+                          struct device_attribute *attr,
+                          char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_all_mask);
+}
+
+static struct device_attribute dev_attr_hotkey_all_mask =
+       __ATTR(hotkey_all_mask, S_IRUGO, hotkey_all_mask_show, NULL);
+
+/* sysfs hotkey recommended_mask --------------------------------------- */
+static ssize_t hotkey_recommended_mask_show(struct device *dev,
+                                           struct device_attribute *attr,
+                                           char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+                       hotkey_all_mask & ~hotkey_reserved_mask);
+}
+
+static struct device_attribute dev_attr_hotkey_recommended_mask =
+       __ATTR(hotkey_recommended_mask, S_IRUGO,
+               hotkey_recommended_mask_show, NULL);
+
+/* sysfs hotkey radio_sw ----------------------------------------------- */
+static ssize_t hotkey_radio_sw_show(struct device *dev,
+                          struct device_attribute *attr,
+                          char *buf)
+{
+       int res, s;
+       res = hotkey_get_wlsw(&s);
+       if (res < 0)
+               return res;
+
+       return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
+}
+
+static struct device_attribute dev_attr_hotkey_radio_sw =
+       __ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL);
+
 /* --------------------------------------------------------------------- */
 
 static struct attribute *hotkey_mask_attributes[] = {
        &dev_attr_hotkey_mask.attr,
        &dev_attr_hotkey_bios_enabled.attr,
        &dev_attr_hotkey_bios_mask.attr,
+       &dev_attr_hotkey_all_mask.attr,
+       &dev_attr_hotkey_recommended_mask.attr,
 };
 
 static int __init hotkey_init(struct ibm_init_struct *iibm)
 {
-       int res;
+
+       static u16 ibm_keycode_map[] __initdata = {
+               /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
+               KEY_FN_F1,      KEY_FN_F2,      KEY_COFFEE,     KEY_SLEEP,
+               KEY_WLAN,       KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
+               KEY_FN_F9,      KEY_FN_F10,     KEY_FN_F11,     KEY_SUSPEND,
+               /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */
+               KEY_UNKNOWN,    /* 0x0C: FN+BACKSPACE */
+               KEY_UNKNOWN,    /* 0x0D: FN+INSERT */
+               KEY_UNKNOWN,    /* 0x0E: FN+DELETE */
+               KEY_RESERVED,   /* 0x0F: FN+HOME (brightness up) */
+               /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
+               KEY_RESERVED,   /* 0x10: FN+END (brightness down) */
+               KEY_RESERVED,   /* 0x11: FN+PGUP (thinklight toggle) */
+               KEY_UNKNOWN,    /* 0x12: FN+PGDOWN */
+               KEY_ZOOM,       /* 0x13: FN+SPACE (zoom) */
+               KEY_RESERVED,   /* 0x14: VOLUME UP */
+               KEY_RESERVED,   /* 0x15: VOLUME DOWN */
+               KEY_RESERVED,   /* 0x16: MUTE */
+               KEY_VENDOR,     /* 0x17: Thinkpad/AccessIBM/Lenovo */
+               /* (assignments unknown, please report if found) */
+               KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+               KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+       };
+       static u16 lenovo_keycode_map[] __initdata = {
+               /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
+               KEY_FN_F1,      KEY_COFFEE,     KEY_BATTERY,    KEY_SLEEP,
+               KEY_WLAN,       KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
+               KEY_FN_F9,      KEY_FN_F10,     KEY_FN_F11,     KEY_SUSPEND,
+               /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */
+               KEY_UNKNOWN,    /* 0x0C: FN+BACKSPACE */
+               KEY_UNKNOWN,    /* 0x0D: FN+INSERT */
+               KEY_UNKNOWN,    /* 0x0E: FN+DELETE */
+               KEY_BRIGHTNESSUP,       /* 0x0F: FN+HOME (brightness up) */
+               /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
+               KEY_BRIGHTNESSDOWN,     /* 0x10: FN+END (brightness down) */
+               KEY_RESERVED,   /* 0x11: FN+PGUP (thinklight toggle) */
+               KEY_UNKNOWN,    /* 0x12: FN+PGDOWN */
+               KEY_ZOOM,       /* 0x13: FN+SPACE (zoom) */
+               KEY_RESERVED,   /* 0x14: VOLUME UP */
+               KEY_RESERVED,   /* 0x15: VOLUME DOWN */
+               KEY_RESERVED,   /* 0x16: MUTE */
+               KEY_VENDOR,     /* 0x17: Thinkpad/AccessIBM/Lenovo */
+               /* (assignments unknown, please report if found) */
+               KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+               KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
+       };
+
+#define TPACPI_HOTKEY_MAP_LEN          ARRAY_SIZE(ibm_keycode_map)
+#define TPACPI_HOTKEY_MAP_SIZE         sizeof(ibm_keycode_map)
+#define TPACPI_HOTKEY_MAP_TYPESIZE     sizeof(ibm_keycode_map[0])
+
+       int res, i;
+       int status;
 
        vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
 
+       BUG_ON(!tpacpi_inputdev);
+
        IBM_ACPIHANDLE_INIT(hkey);
        mutex_init(&hotkey_mutex);
 
@@ -824,7 +986,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
                str_supported(tp_features.hotkey));
 
        if (tp_features.hotkey) {
-               hotkey_dev_attributes = create_attr_set(4, NULL);
+               hotkey_dev_attributes = create_attr_set(7, NULL);
                if (!hotkey_dev_attributes)
                        return -ENOMEM;
                res = add_to_attr_set(hotkey_dev_attributes,
@@ -840,19 +1002,92 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
                vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
                        str_supported(tp_features.hotkey_mask));
 
+               if (tp_features.hotkey_mask) {
+                       /* MHKA available in A31, R40, R40e, T4x, X31, and later */
+                       if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
+                                       "MHKA", "qd"))
+                               hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */
+               }
+
                res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask);
                if (!res && tp_features.hotkey_mask) {
                        res = add_many_to_attr_set(hotkey_dev_attributes,
                                hotkey_mask_attributes,
                                ARRAY_SIZE(hotkey_mask_attributes));
                }
+
+               /* Not all thinkpads have a hardware radio switch */
+               if (!res && acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
+                       tp_features.hotkey_wlsw = 1;
+                       printk(IBM_INFO
+                               "radio switch found; radios are %s\n",
+                               enabled(status, 0));
+                       res = add_to_attr_set(hotkey_dev_attributes,
+                                       &dev_attr_hotkey_radio_sw.attr);
+               }
+
                if (!res)
                        res = register_attr_set_with_sysfs(
                                        hotkey_dev_attributes,
                                        &tpacpi_pdev->dev.kobj);
+               if (res)
+                       return res;
+
+               /* Set up key map */
+
+               hotkey_keycode_map = kmalloc(TPACPI_HOTKEY_MAP_SIZE,
+                                               GFP_KERNEL);
+               if (!hotkey_keycode_map) {
+                       printk(IBM_ERR "failed to allocate memory for key map\n");
+                       return -ENOMEM;
+               }
+
+               if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) {
+                       dbg_printk(TPACPI_DBG_INIT,
+                                  "using Lenovo default hot key map\n");
+                       memcpy(hotkey_keycode_map, &lenovo_keycode_map,
+                               TPACPI_HOTKEY_MAP_SIZE);
+               } else {
+                       dbg_printk(TPACPI_DBG_INIT,
+                                  "using IBM default hot key map\n");
+                       memcpy(hotkey_keycode_map, &ibm_keycode_map,
+                               TPACPI_HOTKEY_MAP_SIZE);
+               }
 
+#ifndef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
+               for (i = 0; i < 12; i++)
+                       hotkey_keycode_map[i] = KEY_UNKNOWN;
+#endif /* ! CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
+
+               set_bit(EV_KEY, tpacpi_inputdev->evbit);
+               set_bit(EV_MSC, tpacpi_inputdev->evbit);
+               set_bit(MSC_SCAN, tpacpi_inputdev->mscbit);
+               tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE;
+               tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN;
+               tpacpi_inputdev->keycode = hotkey_keycode_map;
+               for (i = 0; i < TPACPI_HOTKEY_MAP_LEN; i++) {
+                       if (hotkey_keycode_map[i] != KEY_RESERVED) {
+                               set_bit(hotkey_keycode_map[i],
+                                       tpacpi_inputdev->keybit);
+                       } else {
+                               if (i < sizeof(hotkey_reserved_mask)*8)
+                                       hotkey_reserved_mask |= 1 << i;
+                       }
+               }
+
+               if (tp_features.hotkey_wlsw) {
+                       set_bit(EV_SW, tpacpi_inputdev->evbit);
+                       set_bit(SW_RADIO, tpacpi_inputdev->swbit);
+               }
+
+#ifdef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
+               dbg_printk(TPACPI_DBG_INIT,
+                               "enabling hot key handling\n");
+               res = hotkey_set(1, (hotkey_all_mask & ~hotkey_reserved_mask)
+                                       | hotkey_orig_mask);
                if (res)
                        return res;
+#endif /* CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
        }
 
        return (tp_features.hotkey)? 0 : 1;
@@ -875,22 +1110,101 @@ static void hotkey_exit(void)
        }
 }
 
+static void tpacpi_input_send_key(unsigned int scancode,
+                                 unsigned int keycode)
+{
+       if (keycode != KEY_RESERVED) {
+               input_report_key(tpacpi_inputdev, keycode, 1);
+               if (keycode == KEY_UNKNOWN)
+                       input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
+                                   scancode);
+               input_sync(tpacpi_inputdev);
+
+               input_report_key(tpacpi_inputdev, keycode, 0);
+               if (keycode == KEY_UNKNOWN)
+                       input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
+                                   scancode);
+               input_sync(tpacpi_inputdev);
+       }
+}
+
+static void tpacpi_input_send_radiosw(void)
+{
+       int wlsw;
+
+       if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw))
+               input_report_switch(tpacpi_inputdev,
+                                   SW_RADIO, !!wlsw);
+}
+
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 {
-       int hkey;
+       u32 hkey;
+       unsigned int keycode, scancode;
+       int sendacpi = 1;
+
+       if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
+               if (tpacpi_inputdev->users > 0) {
+                       switch (hkey >> 12) {
+                       case 1:
+                               /* 0x1000-0x1FFF: key presses */
+                               scancode = hkey & 0xfff;
+                               if (scancode > 0 && scancode < 0x21) {
+                                       scancode--;
+                                       keycode = hotkey_keycode_map[scancode];
+                                       tpacpi_input_send_key(scancode, keycode);
+                                       sendacpi = (keycode == KEY_RESERVED
+                                               || keycode == KEY_UNKNOWN);
+                               } else {
+                                       printk(IBM_ERR
+                                              "hotkey 0x%04x out of range for keyboard map\n",
+                                              hkey);
+                               }
+                               break;
+                       case 5:
+                               /* 0x5000-0x5FFF: LID */
+                               /* we don't handle it through this path, just
+                                * eat up known LID events */
+                               if (hkey != 0x5001 && hkey != 0x5002) {
+                                       printk(IBM_ERR
+                                               "unknown LID-related hotkey event: 0x%04x\n",
+                                               hkey);
+                               }
+                               break;
+                       case 7:
+                               /* 0x7000-0x7FFF: misc */
+                               if (tp_features.hotkey_wlsw && hkey == 0x7000) {
+                                               tpacpi_input_send_radiosw();
+                                               sendacpi = 0;
+                                       break;
+                               }
+                               /* fallthrough to default */
+                       default:
+                               /* case 2: dock-related */
+                               /*      0x2305 - T43 waking up due to bay lever eject while aslept */
+                               /* case 3: ultra-bay related. maybe bay in dock? */
+                               /*      0x3003 - T43 after wake up by bay lever eject (0x2305) */
+                               printk(IBM_NOTICE "unhandled hotkey event 0x%04x\n", hkey);
+                       }
+               }
 
-       if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d"))
-               acpi_bus_generate_event(ibm->acpi->device, event, hkey);
-       else {
-               printk(IBM_ERR "unknown hotkey event %d\n", event);
+               if (sendacpi)
+                       acpi_bus_generate_event(ibm->acpi->device, event, hkey);
+       else {
+               printk(IBM_ERR "unknown hotkey notification event %d\n", event);
                acpi_bus_generate_event(ibm->acpi->device, event, 0);
        }
 }
 
+static void hotkey_resume(void)
+{
+       tpacpi_input_send_radiosw();
+}
+
 /*
  * Call with hotkey_mutex held
  */
-static int hotkey_get(int *status, int *mask)
+static int hotkey_get(int *status, u32 *mask)
 {
        if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
                return -EIO;
@@ -905,7 +1219,7 @@ static int hotkey_get(int *status, int *mask)
 /*
  * Call with hotkey_mutex held
  */
-static int hotkey_set(int status, int mask)
+static int hotkey_set(int status, u32 mask)
 {
        int i;
 
@@ -926,7 +1240,8 @@ static int hotkey_set(int status, int mask)
 /* procfs -------------------------------------------------------------- */
 static int hotkey_read(char *p)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
        int len = 0;
 
        if (!tp_features.hotkey) {
@@ -944,7 +1259,7 @@ static int hotkey_read(char *p)
 
        len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
        if (tp_features.hotkey_mask) {
-               len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
+               len += sprintf(p + len, "mask:\t\t0x%08x\n", mask);
                len += sprintf(p + len,
                               "commands:\tenable, disable, reset, <mask>\n");
        } else {
@@ -957,7 +1272,8 @@ static int hotkey_read(char *p)
 
 static int hotkey_write(char *buf)
 {
-       int res, status, mask;
+       int res, status;
+       u32 mask;
        char *cmd;
        int do_cmd = 0;
 
@@ -1012,6 +1328,7 @@ static struct ibm_struct hotkey_driver_data = {
        .read = hotkey_read,
        .write = hotkey_write,
        .exit = hotkey_exit,
+       .resume = hotkey_resume,
        .acpi = &ibm_hotkey_acpidriver,
 };
 
@@ -1770,7 +2087,10 @@ static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
         .type = ACPI_SYSTEM_NOTIFY,
        },
        {
-        .hid = IBM_PCI_HID,
+       /* THIS ONE MUST NEVER BE USED FOR DRIVER AUTOLOADING.
+        * We just use it to get notifications of dock hotplug
+        * in very old thinkpads */
+        .hid = PCI_ROOT_HID_STRING,
         .notify = dock_notify,
         .handle = &pci_handle,
         .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +2149,7 @@ static int __init dock_init2(struct ibm_init_struct *iibm)
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
        int docked = dock_docked();
-       int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
+       int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, PCI_ROOT_HID_STRING);
 
        if (event == 1 && !pci) /* 570 */
                acpi_bus_generate_event(ibm->acpi->device, event, 1);   /* button */
@@ -2389,7 +2709,7 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
 
        acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
 
-       if (ibm_thinkpad_ec_found && experimental) {
+       if (thinkpad_id.ec_model) {
                /*
                 * Direct EC access mode: sensors at registers
                 * 0x78-0x7F, 0xC0-0xC7.  Registers return 0x00 for
@@ -2533,6 +2853,8 @@ static int thermal_get_sensor(int idx, s32 *value)
                        snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx);
                        if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
                                return -EIO;
+                       if (t > 127 || t < -127)
+                               t = TP_EC_THERMAL_TMP_NA;
                        *value = t * 1000;
                        return 0;
                }
@@ -2671,22 +2993,39 @@ static struct ibm_struct ecdump_driver_data = {
  * Backlight/brightness subdriver
  */
 
-static struct backlight_device *ibm_backlight_device = NULL;
+static struct backlight_device *ibm_backlight_device;
 
 static struct backlight_ops ibm_backlight_data = {
         .get_brightness = brightness_get,
         .update_status  = brightness_update_status,
 };
 
+static struct mutex brightness_mutex;
+
 static int __init brightness_init(struct ibm_init_struct *iibm)
 {
        int b;
 
        vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
 
+       mutex_init(&brightness_mutex);
+
+       if (!brightness_mode) {
+               if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
+                       brightness_mode = 2;
+               else
+                       brightness_mode = 3;
+
+               dbg_printk(TPACPI_DBG_INIT, "selected brightness_mode=%d\n",
+                       brightness_mode);
+       }
+
+       if (brightness_mode > 3)
+               return -EINVAL;
+
        b = brightness_get(NULL);
        if (b < 0)
-               return b;
+               return 1;
 
        ibm_backlight_device = backlight_device_register(
                                        TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
@@ -2722,34 +3061,79 @@ static int brightness_update_status(struct backlight_device *bd)
                                bd->props.brightness : 0);
 }
 
+/*
+ * ThinkPads can read brightness from two places: EC 0x31, or
+ * CMOS NVRAM byte 0x5E, bits 0-3.
+ */
 static int brightness_get(struct backlight_device *bd)
 {
-       u8 level;
-       if (!acpi_ec_read(brightness_offset, &level))
-               return -EIO;
+       u8 lec = 0, lcmos = 0, level = 0;
 
-       level &= 0x7;
+       if (brightness_mode & 1) {
+               if (!acpi_ec_read(brightness_offset, &lec))
+                       return -EIO;
+               lec &= 7;
+               level = lec;
+       };
+       if (brightness_mode & 2) {
+               lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
+                        & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
+                       >> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
+               level = lcmos;
+       }
+
+       if (brightness_mode == 3 && lec != lcmos) {
+               printk(IBM_ERR
+                       "CMOS NVRAM (%u) and EC (%u) do not agree "
+                       "on display brightness level\n",
+                       (unsigned int) lcmos,
+                       (unsigned int) lec);
+               return -EIO;
+       }
 
        return level;
 }
 
 static int brightness_set(int value)
 {
-       int cmos_cmd, inc, i;
-       int current_value = brightness_get(NULL);
+       int cmos_cmd, inc, i, res;
+       int current_value;
+
+       if (value > 7)
+               return -EINVAL;
 
-       value &= 7;
+       res = mutex_lock_interruptible(&brightness_mutex);
+       if (res < 0)
+               return res;
+
+       current_value = brightness_get(NULL);
+       if (current_value < 0) {
+               res = current_value;
+               goto errout;
+       }
 
-       cmos_cmd = value > current_value ? TP_CMOS_BRIGHTNESS_UP : TP_CMOS_BRIGHTNESS_DOWN;
+       cmos_cmd = value > current_value ?
+                       TP_CMOS_BRIGHTNESS_UP :
+                       TP_CMOS_BRIGHTNESS_DOWN;
        inc = value > current_value ? 1 : -1;
+
+       res = 0;
        for (i = current_value; i != value; i += inc) {
-               if (issue_thinkpad_cmos_command(cmos_cmd))
-                       return -EIO;
-               if (!acpi_ec_write(brightness_offset, i + inc))
-                       return -EIO;
+               if ((brightness_mode & 2) &&
+                   issue_thinkpad_cmos_command(cmos_cmd)) {
+                       res = -EIO;
+                       goto errout;
+               }
+               if ((brightness_mode & 1) &&
+                   !acpi_ec_write(brightness_offset, i + inc)) {
+                       res = -EIO;
+                       goto errout;;
+               }
        }
 
-       return 0;
+errout:
+       mutex_unlock(&brightness_mutex);
+       return res;
 }
 
 static int brightness_read(char *p)
@@ -3273,20 +3657,19 @@ static int __init fan_init(struct ibm_init_struct *iibm)
                         * Enable for TP-1Y (T43), TP-78 (R51e),
                         * TP-76 (R52), TP-70 (T43, R52), which are known
                         * to be buggy. */
-                       if (fan_control_initial_status == 0x07 &&
-                           ibm_thinkpad_ec_found &&
-                           ((ibm_thinkpad_ec_found[0] == '1' &&
-                             ibm_thinkpad_ec_found[1] == 'Y') ||
-                            (ibm_thinkpad_ec_found[0] == '7' &&
-                             (ibm_thinkpad_ec_found[1] == '6' ||
-                              ibm_thinkpad_ec_found[1] == '8' ||
-                              ibm_thinkpad_ec_found[1] == '0'))
-                           )) {
-                               printk(IBM_NOTICE
-                                      "fan_init: initial fan status is "
-                                      "unknown, assuming it is in auto "
-                                      "mode\n");
-                               tp_features.fan_ctrl_status_undef = 1;
+                       if (fan_control_initial_status == 0x07) {
+                               switch (thinkpad_id.ec_model) {
+                               case 0x5931: /* TP-1Y */
+                               case 0x3837: /* TP-78 */
+                               case 0x3637: /* TP-76 */
+                               case 0x3037: /* TP-70 */
+                                       printk(IBM_NOTICE
+                                              "fan_init: initial fan status is "
+                                              "unknown, assuming it is in auto "
+                                              "mode\n");
+                                       tp_features.fan_ctrl_status_undef = 1;
+                                       ;;
+                               }
                        }
                } else {
                        printk(IBM_ERR
@@ -3474,7 +3857,7 @@ static void fan_watchdog_fire(struct work_struct *ignored)
 
 static void fan_watchdog_reset(void)
 {
-       static int fan_watchdog_active = 0;
+       static int fan_watchdog_active;
 
        if (fan_control_access_mode == TPACPI_FAN_WR_NONE)
                return;
@@ -3877,7 +4260,7 @@ static struct ibm_struct fan_driver_data = {
  ****************************************************************************/
 
 /* /proc support */
-static struct proc_dir_entry *proc_dir = NULL;
+static struct proc_dir_entry *proc_dir;
 
 /* Subdriver registry */
 static LIST_HEAD(tpacpi_all_drivers);
@@ -4020,13 +4403,30 @@ static void ibm_exit(struct ibm_struct *ibm)
 
 /* Probing */
 
-static char *ibm_thinkpad_ec_found = NULL;
-
-static char* __init check_dmi_for_ec(void)
+static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp)
 {
        struct dmi_device *dev = NULL;
        char ec_fw_string[18];
 
+       if (!tp)
+               return;
+
+       memset(tp, 0, sizeof(*tp));
+
+       if (dmi_name_in_vendors("IBM"))
+               tp->vendor = PCI_VENDOR_ID_IBM;
+       else if (dmi_name_in_vendors("LENOVO"))
+               tp->vendor = PCI_VENDOR_ID_LENOVO;
+       else
+               return;
+
+       tp->bios_version_str = kstrdup(dmi_get_system_info(DMI_BIOS_VERSION),
+                                       GFP_KERNEL);
+       if (!tp->bios_version_str)
+               return;
+       tp->bios_model = tp->bios_version_str[0]
+                        | (tp->bios_version_str[1] << 8);
+
        /*
         * ThinkPad T23 or newer, A31 or newer, R50e or newer,
         * X32 or newer, all Z series;  Some models must have an
@@ -4040,10 +4440,20 @@ static char* __init check_dmi_for_ec(void)
                           ec_fw_string) == 1) {
                        ec_fw_string[sizeof(ec_fw_string) - 1] = 0;
                        ec_fw_string[strcspn(ec_fw_string, " ]")] = 0;
-                       return kstrdup(ec_fw_string, GFP_KERNEL);
+
+                       tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL);
+                       tp->ec_model = ec_fw_string[0]
+                                       | (ec_fw_string[1] << 8);
+                       break;
                }
        }
-       return NULL;
+
+       tp->model_str = kstrdup(dmi_get_system_info(DMI_PRODUCT_VERSION),
+                                       GFP_KERNEL);
+       if (strnicmp(tp->model_str, "ThinkPad", 8) != 0) {
+               kfree(tp->model_str);
+               tp->model_str = NULL;
+       }
 }
 
 static int __init probe_for_thinkpad(void)
@@ -4057,7 +4467,7 @@ static int __init probe_for_thinkpad(void)
         * Non-ancient models have better DMI tagging, but very old models
         * don't.
         */
-       is_thinkpad = dmi_name_in_vendors("ThinkPad");
+       is_thinkpad = (thinkpad_id.model_str != NULL);
 
        /* ec is required because many other handles are relative to it */
        IBM_ACPIHANDLE_INIT(ec);
@@ -4073,7 +4483,7 @@ static int __init probe_for_thinkpad(void)
         * false positives a damn great deal
         */
        if (!is_thinkpad)
-               is_thinkpad = dmi_name_in_vendors("IBM");
+               is_thinkpad = (thinkpad_id.vendor == PCI_VENDOR_ID_IBM);
 
        if (!is_thinkpad && !force_load)
                return -ENODEV;
@@ -4185,10 +4595,13 @@ static u32 dbg_level;
 module_param_named(debug, dbg_level, uint, 0);
 
 static int force_load;
-module_param(force_load, int, 0);
+module_param(force_load, bool, 0);
 
 static int fan_control_allowed;
-module_param_named(fan_control, fan_control_allowed, int, 0);
+module_param_named(fan_control, fan_control_allowed, bool, 0);
+
+static int brightness_mode;
+module_param_named(brightness_mode, brightness_mode, int, 0);
 
 #define IBM_PARAM(feature) \
        module_param_call(feature, set_ibm_param, NULL, NULL, 0)
@@ -4216,12 +4629,16 @@ static int __init thinkpad_acpi_module_init(void)
        int ret, i;
 
        /* Driver-level probe */
+
+       get_thinkpad_model_data(&thinkpad_id);
        ret = probe_for_thinkpad();
-       if (ret)
+       if (ret) {
+               thinkpad_acpi_module_exit();
                return ret;
+       }
 
        /* Driver initialization */
-       ibm_thinkpad_ec_found = check_dmi_for_ec();
+
        IBM_ACPIHANDLE_INIT(ecrd);
        IBM_ACPIHANDLE_INIT(ecwr);
 
@@ -4265,6 +4682,22 @@ static int __init thinkpad_acpi_module_init(void)
                thinkpad_acpi_module_exit();
                return ret;
        }
+       tpacpi_inputdev = input_allocate_device();
+       if (!tpacpi_inputdev) {
+               printk(IBM_ERR "unable to allocate input device\n");
+               thinkpad_acpi_module_exit();
+               return -ENOMEM;
+       } else {
+               /* Prepare input device, but don't register */
+               tpacpi_inputdev->name = "ThinkPad Extra Buttons";
+               tpacpi_inputdev->phys = IBM_DRVR_NAME "/input0";
+               tpacpi_inputdev->id.bustype = BUS_HOST;
+               tpacpi_inputdev->id.vendor = (thinkpad_id.vendor) ?
+                                               thinkpad_id.vendor :
+                                               PCI_VENDOR_ID_IBM;
+               tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
+               tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
+       }
        for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
                ret = ibm_init(&ibms_init[i]);
                if (ret >= 0 && *ibms_init[i].param)
@@ -4274,6 +4707,14 @@ static int __init thinkpad_acpi_module_init(void)
                        return ret;
                }
        }
+       ret = input_register_device(tpacpi_inputdev);
+       if (ret < 0) {
+               printk(IBM_ERR "unable to register input device\n");
+               thinkpad_acpi_module_exit();
+               return ret;
+       } else {
+               tp_features.input_device_registered = 1;
+       }
 
        return 0;
 }
@@ -4290,6 +4731,13 @@ static void thinkpad_acpi_module_exit(void)
 
        dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
 
+       if (tpacpi_inputdev) {
+               if (tp_features.input_device_registered)
+                       input_unregister_device(tpacpi_inputdev);
+               else
+                       input_free_device(tpacpi_inputdev);
+       }
+
        if (tpacpi_hwmon)
                hwmon_device_unregister(tpacpi_hwmon);
 
@@ -4302,7 +4750,9 @@ static void thinkpad_acpi_module_exit(void)
        if (proc_dir)
                remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
 
-       kfree(ibm_thinkpad_ec_found);
+       kfree(thinkpad_id.bios_version_str);
+       kfree(thinkpad_id.ec_version_str);
+       kfree(thinkpad_id.model_str);
 }
 
 module_init(thinkpad_acpi_module_init);
index 72d62f2dabb976069ef26dabb4be6abad030be57..b7a4a888cc8b5d209e7a562f633001f37c8119ff 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/list.h>
 #include <linux/mutex.h>
 
+#include <linux/nvram.h>
 #include <linux/proc_fs.h>
 #include <linux/sysfs.h>
 #include <linux/backlight.h>
@@ -39,6 +40,7 @@
 #include <linux/platform_device.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/input.h>
 #include <asm/uaccess.h>
 
 #include <linux/dmi.h>
@@ -48,6 +50,7 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/acnamesp.h>
 
+#include <linux/pci_ids.h>
 
 /****************************************************************************
  * Main driver
 #define TP_CMOS_BRIGHTNESS_UP  4
 #define TP_CMOS_BRIGHTNESS_DOWN        5
 
+/* ThinkPad CMOS NVRAM constants */
+#define TP_NVRAM_ADDR_BRIGHTNESS       0x5e
+#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07
+#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0
+
 #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
 #define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
 #define strlencmp(a,b) (strncmp((a), (b), strlen(b)))
@@ -98,9 +106,13 @@ static const char *str_supported(int is_supported);
 #define vdbg_printk(a_dbg_level, format, arg...)
 #endif
 
+/* Input IDs */
+#define TPACPI_HKEY_INPUT_VENDOR       PCI_VENDOR_ID_IBM
+#define TPACPI_HKEY_INPUT_PRODUCT      0x5054 /* "TP" */
+#define TPACPI_HKEY_INPUT_VERSION      0x4101
+
 /* ACPI HIDs */
 #define IBM_HKEY_HID    "IBM0068"
-#define IBM_PCI_HID     "PNP0A03"
 
 /* ACPI helpers */
 static int __must_check acpi_evalf(acpi_handle handle,
@@ -161,6 +173,7 @@ static int parse_strtoul(const char *buf, unsigned long max,
 static struct platform_device *tpacpi_pdev;
 static struct class_device *tpacpi_hwmon;
 static struct platform_driver tpacpi_pdriver;
+static struct input_dev *tpacpi_inputdev;
 static int tpacpi_create_driver_attributes(struct device_driver *drv);
 static void tpacpi_remove_driver_attributes(struct device_driver *drv);
 
@@ -168,9 +181,7 @@ static void tpacpi_remove_driver_attributes(struct device_driver *drv);
 static int experimental;
 static u32 dbg_level;
 static int force_load;
-static char *ibm_thinkpad_ec_found;
 
-static char* check_dmi_for_ec(void);
 static int thinkpad_acpi_module_init(void);
 static void thinkpad_acpi_module_exit(void);
 
@@ -197,6 +208,7 @@ struct ibm_struct {
        int (*read) (char *);
        int (*write) (char *);
        void (*exit) (void);
+       void (*resume) (void);
 
        struct list_head all_drivers;
 
@@ -228,12 +240,29 @@ static struct {
        u16 bluetooth:1;
        u16 hotkey:1;
        u16 hotkey_mask:1;
+       u16 hotkey_wlsw:1;
        u16 light:1;
        u16 light_status:1;
        u16 wan:1;
        u16 fan_ctrl_status_undef:1;
+       u16 input_device_registered:1;
 } tp_features;
 
+struct thinkpad_id_data {
+       unsigned int vendor;    /* ThinkPad vendor:
+                                * PCI_VENDOR_ID_IBM/PCI_VENDOR_ID_LENOVO */
+
+       char *bios_version_str; /* Something like 1ZET51WW (1.03z) */
+       char *ec_version_str;   /* Something like 1ZHT51WW-1.04a */
+
+       u16 bios_model;         /* Big Endian, TP-1Y = 0x5931, 0 = unknown */
+       u16 ec_model;
+
+       char *model_str;
+};
+
+static struct thinkpad_id_data thinkpad_id;
+
 static struct list_head tpacpi_all_drivers;
 
 static struct ibm_init_struct ibms_init[];
@@ -300,6 +329,7 @@ static int bluetooth_write(char *buf);
 
 static struct backlight_device *ibm_backlight_device;
 static int brightness_offset = 0x31;
+static int brightness_mode;
 
 static int brightness_init(struct ibm_init_struct *iibm);
 static void brightness_exit(void);
@@ -415,14 +445,14 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc);
  */
 
 static int hotkey_orig_status;
-static int hotkey_orig_mask;
+static u32 hotkey_orig_mask;
 
 static struct mutex hotkey_mutex;
 
 static int hotkey_init(struct ibm_init_struct *iibm);
 static void hotkey_exit(void);
-static int hotkey_get(int *status, int *mask);
-static int hotkey_set(int status, int mask);
+static int hotkey_get(int *status, u32 *mask);
+static int hotkey_set(int status, u32 mask);
 static void hotkey_notify(struct ibm_struct *ibm, u32 event);
 static int hotkey_read(char *p);
 static int hotkey_write(char *buf);
index 3c45142c40b2f0f8421cf488440ada36dd3b67f2..b01985498460f926d0f6e920d900b10fb1b59cb8 100644 (file)
@@ -1316,7 +1316,7 @@ static struct of_device_id m8xx_pcmcia_match[] = {
 MODULE_DEVICE_TABLE(of, m8xx_pcmcia_match);
 
 static struct of_platform_driver m8xx_pcmcia_driver = {
-       .name = (char *)driver_name,
+       .name = driver_name,
        .match_table = m8xx_pcmcia_match,
        .probe = m8xx_probe,
        .remove = m8xx_remove,
index 2a237f09ee5d444ebc28d8ef5ff33be5b3905ce3..564cc9b5182243ddf4f24c3ddb131231ff913ed1 100644 (file)
@@ -12,6 +12,13 @@ config VGASTATE
        tristate
        default n
 
+config VIDEO_OUTPUT_CONTROL
+       tristate "Lowlevel video output switch controls"
+       default m
+       help
+         This framework adds support for low-level control of the video 
+         output switch.
+
 config FB
        tristate "Support for frame buffer devices"
        ---help---
index a562f9d69d2c2285bc7e633e59ec6c5ec4d884d9..518933d4905f4f97098dac3608d13ccb81503ec4 100644 (file)
@@ -123,3 +123,6 @@ obj-$(CONFIG_FB_OF)               += offb.o
 
 # the test framebuffer is last
 obj-$(CONFIG_FB_VIRTUAL)          += vfb.o
+
+#video output switch sysfs driver
+obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o
index b34b7a711d5b6e3e7f8280b71ee26940523f0eaf..b2a851c1b8cb0230a59a2dfef0a2dd77f9c9593d 100644 (file)
@@ -732,7 +732,7 @@ static int nfs_parse_mount_options(char *raw,
                                return 0;
                        if (option < 0 || option > 65535)
                                return 0;
-                       mnt->nfs_server.address.sin_port = htonl(option);
+                       mnt->nfs_server.address.sin_port = htons(option);
                        break;
                case Opt_rsize:
                        if (match_int(args, &mnt->rsize))
index 8948a6461834d1d8fa2eb5cd3a3239d48a8a4483..45662f6dbdb66b34b8966670187ffd6655737aa6 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 7812267b577f2d857827ed501faf66894829afcf..c090a8b0bc99d68e486ab0170bef9a75dc87aeb6 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 c6fa5e023bc78289b92cb4d5b5da5d94f3df0266..5e3dcf3299bf90c68ae537de9c07d9fbbb9d69f6 100644 (file)
@@ -321,7 +321,8 @@ struct acpi_bus_event {
 };
 
 extern struct kset acpi_subsys;
-
+extern int acpi_bus_generate_genetlink_event(struct acpi_device *device,
+                                               u8 type, int data);
 /*
  * External Functions
  */
index dab2ec59a3b0b7a822d49c99cdec3f98b9834214..c785485e62a6cd55d476da76092deca582b761df 100644 (file)
 
 /*! [Begin] no source code translation */
 
-#if defined(__linux__)
+#if defined(_LINUX) || defined(__linux__)
 #include "aclinux.h"
 
 #elif defined(_AED_EFI)
index a568717f98c6dcbbeb1808fc329b167caafacf7b..6ed15a0978ebb7b9fd0b308699b37eef280e124b 100644 (file)
 #define ACPI_USE_NATIVE_DIVIDE
 #endif
 
+#ifndef __cdecl
 #define __cdecl
+#endif
+
 #define ACPI_FLUSH_CPU_CACHE()
 #endif                         /* __KERNEL__ */
 
index b4b0ffdab098f50c5e1bb44f12400150e8ff923c..f9f987f8e661b9afef361919314363500c05b183 100644 (file)
@@ -21,6 +21,8 @@
 #define ACPI_PSD_REV0_REVISION         0       /* Support for _PSD as in ACPI 3.0 */
 #define ACPI_PSD_REV0_ENTRIES          5
 
+#define ACPI_TSD_REV0_REVISION         0       /* Support for _PSD as in ACPI 3.0 */
+#define ACPI_TSD_REV0_ENTRIES          5
 /*
  * Types of coordination defined in ACPI 3.0. Same macros can be used across
  * P, C and T states
@@ -125,17 +127,53 @@ struct acpi_processor_performance {
 
 /* Throttling Control */
 
+struct acpi_tsd_package {
+       acpi_integer num_entries;
+       acpi_integer revision;
+       acpi_integer domain;
+       acpi_integer coord_type;
+       acpi_integer num_processors;
+} __attribute__ ((packed));
+
+struct acpi_ptc_register {
+       u8 descriptor;
+       u16 length;
+       u8 space_id;
+       u8 bit_width;
+       u8 bit_offset;
+       u8 reserved;
+       u64 address;
+} __attribute__ ((packed));
+
+struct acpi_processor_tx_tss {
+       acpi_integer freqpercentage;    /* */
+       acpi_integer power;     /* milliWatts */
+       acpi_integer transition_latency;        /* microseconds */
+       acpi_integer control;   /* control value */
+       acpi_integer status;    /* success indicator */
+};
 struct acpi_processor_tx {
        u16 power;
        u16 performance;
 };
 
+struct acpi_processor;
 struct acpi_processor_throttling {
-       int state;
+       unsigned int state;
+       unsigned int platform_limit;
+       struct acpi_pct_register control_register;
+       struct acpi_pct_register status_register;
+       unsigned int state_count;
+       struct acpi_processor_tx_tss *states_tss;
+       struct acpi_tsd_package domain_info;
+       cpumask_t shared_cpu_map;
+       int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
+       int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
+                                             int state);
+
        u32 address;
        u8 duty_offset;
        u8 duty_width;
-       int state_count;
        struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
 };
 
@@ -169,6 +207,9 @@ struct acpi_processor {
        u32 id;
        u32 pblk;
        int performance_platform_limit;
+       int throttling_platform_limit;
+       /* 0 - states 0..n-th state available */
+
        struct acpi_processor_flags flags;
        struct acpi_processor_power power;
        struct acpi_processor_performance *performance;
@@ -270,7 +311,7 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
 
 /* in processor_throttling.c */
 int acpi_processor_get_throttling_info(struct acpi_processor *pr);
-int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
+extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
 extern struct file_operations acpi_processor_throttling_fops;
 
 /* in processor_idle.c */
index eb7da5402bfaa17623bb523bed36c171adc0c776..bda6c810c0f4e3ac48973f3af52fdd478862f05b 100644 (file)
@@ -149,4 +149,6 @@ apply_paravirt(struct paravirt_patch_site *start,
 #define __parainstructions_end NULL
 #endif
 
+extern void text_poke(void *addr, unsigned char *opcode, int len);
+
 #endif /* _I386_ALTERNATIVE_H */
index 64dcdf46117bf2c1dbaeba8e88fa36912fab67c2..f86ede28f6dc84750ab60250cc7d122534d9c74a 100644 (file)
@@ -34,7 +34,7 @@ static inline void __set_64bit (unsigned long long * ptr,
                "\n1:\t"
                "movl (%0), %%eax\n\t"
                "movl 4(%0), %%edx\n\t"
-               "lock cmpxchg8b (%0)\n\t"
+               LOCK_PREFIX "cmpxchg8b (%0)\n\t"
                "jnz 1b"
                : /* no outputs */
                :       "D"(ptr),
index b0a02ee34ffd74720747c295077720e86604933c..d56d89742e8fdcd0bfd96ccd1ff83292eea0bc99 100644 (file)
@@ -5,3 +5,7 @@ extern void mcheck_init(struct cpuinfo_x86 *c);
 #endif
 
 extern int mce_disabled;
+
+extern void stop_mce(void);
+extern void restart_mce(void);
+
index fb1e133efd9fecdc182d827ddd8c75841b8c6660..ff30c98f87b023290c8d1355f3873540e7d6c2ae 100644 (file)
@@ -57,5 +57,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz);
 int lapic_watchdog_ok(void);
 void disable_lapic_nmi_watchdog(void);
 void enable_lapic_nmi_watchdog(void);
+void stop_nmi(void);
+void restart_nmi(void);
 
 #endif /* ASM_NMI_H */
diff --git a/include/asm-i386/processor-cyrix.h b/include/asm-i386/processor-cyrix.h
new file mode 100644 (file)
index 0000000..97568ad
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * NSC/Cyrix CPU indexed register access. Must be inlined instead of
+ * macros to ensure correct access ordering
+ * Access order is always 0x22 (=offset), 0x23 (=value)
+ *
+ * When using the old macros a line like
+ *   setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
+ * gets expanded to:
+ *  do {
+ *    outb((CX86_CCR2), 0x22);
+ *    outb((({
+ *        outb((CX86_CCR2), 0x22);
+ *        inb(0x23);
+ *    }) | 0x88), 0x23);
+ *  } while (0);
+ *
+ * which in fact violates the access order (= 0x22, 0x22, 0x23, 0x23).
+ */
+
+static inline u8 getCx86(u8 reg)
+{
+       outb(reg, 0x22);
+       return inb(0x23);
+}
+
+static inline void setCx86(u8 reg, u8 data)
+{
+       outb(reg, 0x22);
+       outb(data, 0x23);
+}
index 48a7f69bb767a650c72000f9bad8b25ea7612dfb..3845fe72383e518d89075695c2eec4dd0a9f277c 100644 (file)
@@ -168,17 +168,6 @@ static inline void clear_in_cr4 (unsigned long mask)
        write_cr4(cr4);
 }
 
-/*
- *      NSC/Cyrix CPU indexed register access macros
- */
-
-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
-
-#define setCx86(reg, data) do { \
-       outb((reg), 0x22); \
-       outb((data), 0x23); \
-} while (0)
-
 /* Stop speculative execution */
 static inline void sync_core(void)
 {
index 2ffb06abe881c703d98347ee3bf9c0f0528a35c2..262db6b8da7349c073f0eaf126f4e245133e4c6a 100644 (file)
@@ -296,6 +296,9 @@ struct mpic
        unsigned int            dcr_base;
 #endif
 
+       /* Protected sources */
+       unsigned long           *protected;
+
 #ifdef CONFIG_MPIC_WEIRD
        /* Pointer to HW info array */
        u32                     *hw_set;
index 6e391c9894ce7e513f7e75e1a62c263d5f7a6eb1..672083787a1d8eb1664ba77c5509cf58e708cd96 100644 (file)
@@ -139,7 +139,7 @@ extern unsigned long __init of_get_flat_dt_root(void);
 
 /* For updating the device tree at runtime */
 extern void of_attach_node(struct device_node *);
-extern void of_detach_node(const struct device_node *);
+extern void of_detach_node(struct device_node *);
 
 /* Other Prototypes */
 extern void finish_device_tree(void);
index f1311a8f310fe9e3c75c28a1d47644c2f1db3465..cc45780421cac15412e44ef5fc62a425aa089fe8 100644 (file)
@@ -54,6 +54,7 @@ extern void show_regs(struct pt_regs * regs);
 extern void flush_instruction_cache(void);
 extern void hard_reset_now(void);
 extern void poweroff_now(void);
+extern int set_dabr(unsigned long dabr);
 #ifdef CONFIG_6xx
 extern long _get_L2CR(void);
 extern long _get_L3CR(void);
index eea7aecfac787cef93d9ae09b66745cb313dda06..ab161e810151aa2fbe9bed5f08fef5194b0f28c2 100644 (file)
@@ -154,4 +154,6 @@ apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
 #define __parainstructions_end NULL
 #endif
 
+extern void text_poke(void *addr, unsigned char *opcode, int len);
+
 #endif /* _X86_64_ALTERNATIVE_H */
index 09a6b6b6b74dac10a753cf605acd87949d8c3eb9..5e182062e6ec98ca49e75729cb93a29e3c1622b4 100644 (file)
@@ -128,7 +128,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
        ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
                                        (unsigned long)(n),sizeof(*(ptr))))
 #define cmpxchg_local(ptr,o,n)\
-       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
+       ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\
                                        (unsigned long)(n),sizeof(*(ptr))))
 
 #endif
index c16c6ff4bdd739f79a96d4c1e1ee46fcc7441509..5cbf9fa5e0b5e26c675f5bce99003dc470f1a704 100644 (file)
@@ -1,42 +1 @@
-#ifndef ASM_HYPERTRANSPORT_H
-#define ASM_HYPERTRANSPORT_H
-
-/*
- * Constants for x86 Hypertransport Interrupts.
- */
-
-#define HT_IRQ_LOW_BASE                        0xf8000000
-
-#define HT_IRQ_LOW_VECTOR_SHIFT                16
-#define  HT_IRQ_LOW_VECTOR_MASK                0x00ff0000
-#define  HT_IRQ_LOW_VECTOR(v)          (((v) << HT_IRQ_LOW_VECTOR_SHIFT) & HT_IRQ_LOW_VECTOR_MASK)
-
-#define HT_IRQ_LOW_DEST_ID_SHIFT       8
-#define  HT_IRQ_LOW_DEST_ID_MASK       0x0000ff00
-#define  HT_IRQ_LOW_DEST_ID(v)         (((v) << HT_IRQ_LOW_DEST_ID_SHIFT) & HT_IRQ_LOW_DEST_ID_MASK)
-
-#define HT_IRQ_LOW_DM_PHYSICAL         0x0000000
-#define HT_IRQ_LOW_DM_LOGICAL          0x0000040
-
-#define HT_IRQ_LOW_RQEOI_EDGE          0x0000000
-#define HT_IRQ_LOW_RQEOI_LEVEL         0x0000020
-
-
-#define HT_IRQ_LOW_MT_FIXED            0x0000000
-#define HT_IRQ_LOW_MT_ARBITRATED       0x0000004
-#define HT_IRQ_LOW_MT_SMI              0x0000008
-#define HT_IRQ_LOW_MT_NMI              0x000000c
-#define HT_IRQ_LOW_MT_INIT             0x0000010
-#define HT_IRQ_LOW_MT_STARTUP          0x0000014
-#define HT_IRQ_LOW_MT_EXTINT           0x0000018
-#define HT_IRQ_LOW_MT_LINT1            0x000008c
-#define HT_IRQ_LOW_MT_LINT0            0x0000098
-
-#define HT_IRQ_LOW_IRQ_MASKED          0x0000001
-
-
-#define HT_IRQ_HIGH_DEST_ID_SHIFT      0
-#define  HT_IRQ_HIGH_DEST_ID_MASK      0x00ffffff
-#define  HT_IRQ_HIGH_DEST_ID(v)                ((((v) >> 8) << HT_IRQ_HIGH_DEST_ID_SHIFT) & HT_IRQ_HIGH_DEST_ID_MASK)
-
-#endif /* ASM_HYPERTRANSPORT_H */
+#include <asm-i386/hypertransport.h>
index 556be5563e308f2d80e7e67f65b4ab19b67b3b49..7bc030a1996de9c2ad53763eac202643e459a54b 100644 (file)
@@ -107,6 +107,9 @@ extern void do_machine_check(struct pt_regs *, long);
 
 extern int mce_notify_user(void);
 
+extern void stop_mce(void);
+extern void restart_mce(void);
+
 #endif
 
 #endif
index 5b8acddb70fba262cac24bd6d27c88c9c8266717..083ad5827e482f170480f6821b2090eaba117289 100644 (file)
@@ -1,47 +1 @@
-#ifndef ASM_MSIDEF_H
-#define ASM_MSIDEF_H
-
-/*
- * Constants for Intel APIC based MSI messages.
- */
-
-/*
- * Shifts for MSI data
- */
-
-#define MSI_DATA_VECTOR_SHIFT          0
-#define  MSI_DATA_VECTOR_MASK          0x000000ff
-#define         MSI_DATA_VECTOR(v)             (((v) << MSI_DATA_VECTOR_SHIFT) & MSI_DATA_VECTOR_MASK)
-
-#define MSI_DATA_DELIVERY_MODE_SHIFT   8
-#define  MSI_DATA_DELIVERY_FIXED       (0 << MSI_DATA_DELIVERY_MODE_SHIFT)
-#define  MSI_DATA_DELIVERY_LOWPRI      (1 << MSI_DATA_DELIVERY_MODE_SHIFT)
-
-#define MSI_DATA_LEVEL_SHIFT           14
-#define         MSI_DATA_LEVEL_DEASSERT        (0 << MSI_DATA_LEVEL_SHIFT)
-#define         MSI_DATA_LEVEL_ASSERT          (1 << MSI_DATA_LEVEL_SHIFT)
-
-#define MSI_DATA_TRIGGER_SHIFT         15
-#define  MSI_DATA_TRIGGER_EDGE         (0 << MSI_DATA_TRIGGER_SHIFT)
-#define  MSI_DATA_TRIGGER_LEVEL                (1 << MSI_DATA_TRIGGER_SHIFT)
-
-/*
- * Shift/mask fields for msi address
- */
-
-#define MSI_ADDR_BASE_HI               0
-#define MSI_ADDR_BASE_LO               0xfee00000
-
-#define MSI_ADDR_DEST_MODE_SHIFT       2
-#define  MSI_ADDR_DEST_MODE_PHYSICAL   (0 << MSI_ADDR_DEST_MODE_SHIFT)
-#define         MSI_ADDR_DEST_MODE_LOGICAL     (1 << MSI_ADDR_DEST_MODE_SHIFT)
-
-#define MSI_ADDR_REDIRECTION_SHIFT     3
-#define  MSI_ADDR_REDIRECTION_CPU      (0 << MSI_ADDR_REDIRECTION_SHIFT) /* dedicated cpu */
-#define  MSI_ADDR_REDIRECTION_LOWPRI   (1 << MSI_ADDR_REDIRECTION_SHIFT) /* lowest priority */
-
-#define MSI_ADDR_DEST_ID_SHIFT         12
-#define         MSI_ADDR_DEST_ID_MASK          0x00ffff0
-#define  MSI_ADDR_DEST_ID(dest)                (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK)
-
-#endif /* ASM_MSIDEF_H */
+#include <asm-i386/msidef.h>
index d0a7f53b1497cf65442c2162716608378589c467..5fb3c0de5cccba5a421a3820bb551619d489fad9 100644 (file)
@@ -88,5 +88,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz);
 int lapic_watchdog_ok(void);
 void disable_lapic_nmi_watchdog(void);
 void enable_lapic_nmi_watchdog(void);
+void stop_nmi(void);
+void restart_nmi(void);
 
 #endif /* ASM_NMI_H */
index 60cff1e4f7a34b9797dcb8eb4b6e39e6ff839867..c9d8764c89d182920dc1b50b4938f63521292c70 100644 (file)
@@ -403,6 +403,8 @@ extern struct list_head pgd_list;
 
 extern int kern_addr_valid(unsigned long addr); 
 
+pte_t *lookup_address(unsigned long addr);
+
 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)                \
                remap_pfn_range(vma, vaddr, pfn, size, prot)
 
index a1645bbc03bd20cb066908073cd3d7954f8eb930..19525175b91c2a7793bf463c4e78eba925030d3c 100644 (file)
@@ -389,17 +389,6 @@ static inline void prefetchw(void *x)
 
 #define cpu_relax()   rep_nop()
 
-/*
- *      NSC/Cyrix CPU indexed register access macros
- */
-
-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
-
-#define setCx86(reg, data) do { \
-       outb((reg), 0x22); \
-       outb((data), 0x23); \
-} while (0)
-
 static inline void serialize_cpu(void)
 {
        __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
index d6e3225549c0a820bcefa529e4b39739644fbfb9..31f20ad65876b25f588e6c2e7e693fff23eb19b0 100644 (file)
@@ -75,8 +75,6 @@ extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
 extern void early_quirks(void);
 extern void check_efer(void);
 
-extern int unhandled_signal(struct task_struct *tsk, int sig);
-
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
 
 extern unsigned long table_start, table_end;
index 6313d33a06869f8e564feec78d86357f669302cd..02175aa1d16a8aea903a51e6b5e1c71fda57d075 100644 (file)
@@ -75,19 +75,31 @@ static inline unsigned long read_cr0(void)
        unsigned long cr0;
        asm volatile("movq %%cr0,%0" : "=r" (cr0));
        return cr0;
-} 
+}
 
 static inline void write_cr0(unsigned long val) 
 { 
        asm volatile("movq %0,%%cr0" :: "r" (val));
-} 
+}
+
+static inline unsigned long read_cr2(void)
+{
+       unsigned long cr2;
+       asm("movq %%cr2,%0" : "=r" (cr2));
+       return cr2;
+}
+
+static inline void write_cr2(unsigned long val)
+{
+       asm volatile("movq %0,%%cr2" :: "r" (val));
+}
 
 static inline unsigned long read_cr3(void)
 { 
        unsigned long cr3;
        asm("movq %%cr3,%0" : "=r" (cr3));
        return cr3;
-} 
+}
 
 static inline void write_cr3(unsigned long val)
 {
@@ -99,12 +111,24 @@ static inline unsigned long read_cr4(void)
        unsigned long cr4;
        asm("movq %%cr4,%0" : "=r" (cr4));
        return cr4;
-} 
+}
 
 static inline void write_cr4(unsigned long val)
 { 
        asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
-} 
+}
+
+static inline unsigned long read_cr8(void)
+{
+       unsigned long cr8;
+       asm("movq %%cr8,%0" : "=r" (cr8));
+       return cr8;
+}
+
+static inline void write_cr8(unsigned long val)
+{
+       asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
+}
 
 #define stts() write_cr0(8 | read_cr0())
 
index 5fd44e63fb2671d34df4f9e889569d8b1dde0ff5..448f70b30a0c81fd2148b0b04bbe150bec69e60c 100644 (file)
@@ -31,8 +31,8 @@ extern struct bus_type of_platform_bus_type;
  */
 struct of_platform_driver
 {
-       char                    *name;
-       struct of_device_id     *match_table;
+       const char              *name;
+       const struct of_device_id       *match_table;
        struct module           *owner;
 
        int     (*probe)(struct of_device* dev,
index b15c6498fe67b0ecf8e650724237444242acff93..ced4d3f761046cb2c2a1ae80e03162be14a2c7d5 100644 (file)
 #define PCI_DEVICE_ID_ALTIMA_AC9100    0x03ea
 #define PCI_DEVICE_ID_ALTIMA_AC1003    0x03eb
 
+#define PCI_VENDOR_ID_LENOVO           0x17aa
+
 #define PCI_VENDOR_ID_ARECA            0x17d3
 #define PCI_DEVICE_ID_ARECA_1110       0x1110
 #define PCI_DEVICE_ID_ARECA_1120       0x1120
index ea91abe740da0b76810b19a522b9d814f0e8aa6e..0ae338866240dee807f7f35a5f8280ebe1aa15b2 100644 (file)
@@ -237,12 +237,15 @@ extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct
 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
 extern long do_sigpending(void __user *, unsigned long);
 extern int sigprocmask(int, sigset_t *, sigset_t *);
+extern int show_unhandled_signals;
 
 struct pt_regs;
 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
 
 extern struct kmem_cache *sighand_cachep;
 
+int unhandled_signal(struct task_struct *tsk, int sig);
+
 /*
  * In POSIX a signal is sent either to a specific thread (Linux task)
  * or to the process as a whole (Linux thread group).  How the signal
index 39d122753bac93eb7cfa62d0f2e2e451a4908dd5..ef8156a6aad519014c030f62e856302dacf045e7 100644 (file)
@@ -255,6 +255,16 @@ flush_signal_handlers(struct task_struct *t, int force_default)
        }
 }
 
+int unhandled_signal(struct task_struct *tsk, int sig)
+{
+       if (is_init(tsk))
+               return 1;
+       if (tsk->ptrace & PT_PTRACED)
+               return 0;
+       return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
+               (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
+}
+
 
 /* Notify the system that a driver wants to block all signals for this
  * process, and wants to be notified if any signals at all were to be
index 222299844ad1b5a495b5796f1898f95174157632..ddebf3f2affe937d8a9ccb694de85dc9d567f1fb 100644 (file)
@@ -1203,6 +1203,16 @@ static ctl_table fs_table[] = {
 };
 
 static ctl_table debug_table[] = {
+#ifdef CONFIG_X86
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "exception-trace",
+               .data           = &show_unhandled_signals,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec
+       },
+#endif
        { .ctl_name = 0 }
 };
 
index e03b39f3540f79adf384c476f185e7a9da91e4ac..3047bf06c1f3256bd59965fc064a32b439135369 100644 (file)
@@ -209,7 +209,7 @@ static int __meminit sparse_init_one_section(struct mem_section *ms,
        return 1;
 }
 
-__attribute__((weak))
+__attribute__((weak)) __init
 void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
 {
        return NULL;