1
0
Fork 0
Commit Graph

273 Commits (4797de450cd2bd439b7c576002d7f4f5fab237e6)

Author SHA1 Message Date
Henrique de Moraes Holschuh d1e14dca6a thinkpad-acpi: add support for model-specific keymaps
Use the quirks engine to select model-specific keymaps, which makes
it much easier to extend should we need it.

Keycodes are based on the tables at
http://www.thinkwiki.org/wiki/Default_meanings_of_special_keys.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-16 11:54:55 -04:00
Henrique de Moraes Holschuh 34a656d22f thinkpad-acpi: lock down size of hotkey keymap
Use a safer coding style for the hotkey keymap.  This does not fix any
problems, as the current code is correct.  But it might help avoid
mistakes in the future.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-16 11:54:52 -04:00
Henrique de Moraes Holschuh 217f09631a thinkpad-acpi: untangle ACPI/vendor backlight selection
acpi_video_backlight_support() already tells us if ACPI is handling
backlight control through the generic ACPI handle.  It is better to just
trust it.

While at it, adjust down a printk priority, and test earlier for
brightness_enable=0.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-16 11:54:50 -04:00
Henrique de Moraes Holschuh 122f26726b thinkpad-acpi: find ACPI video device by synthetic HID
The Linux ACPI core locates the ACPI video devices for us and marks them
with ACPI_VIDEO_HID.  Use that information to locate the video device
instead of a half-baked hunt for _BCL.

This uncouples the detection of the number of backlight brightness
levels on ThinkPads from the ACPI paths in vid_handle.

With this change, the driver should be able to always detect whether the
ThinkPad uses a 8-level or 16-level brightness scale even on newer
models for which the vid_handle paths have not been updated yet.

It will skip deactivated devices in the ACPI device tree, which is a
change in behaviour.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-16 11:54:47 -04:00
Thomas Renninger a420e46412 X86 platform drivers: Remove EC dump from thinkpad_acpi
There is a general interface for that now (provided by
other patches in this patch series):
/sys/kernel/debug/ec/*/io

Signed-off-by: Thomas Renninger <trenn@suse.de>

CC: Alexey Starikovskiy <astarikovskiy@suse.de>
CC: Len Brown <lenb@kernel.org>
CC: linux-kernel@vger.kernel.org
CC: linux-acpi@vger.kernel.org
CC: platform-driver-x86@vger.kernel.org
CC: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
CC: ibm-acpi-devel@lists.sourceforge.net
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-03 09:49:06 -04:00
Henrique de Moraes Holschuh 7d9745cf23 thinkpad-acpi: document backlight level writeback at driver init
Document this, it is no fun to try to second guess why this sort of
stuff is in place years after it was added...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:57 -03:00
Henrique de Moraes Holschuh ef07a5abad thinkpad-acpi: clean up ACPI handles handling
1. Remove <handle>_path, as its only user was already removed in
   a previous commit

2. Move all handle initialization, as well as <handle>_parent and
   <handle>_paths to __init.* sections.  This reduces the driver's
   runtime footprint nicely.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:54 -03:00
Henrique de Moraes Holschuh 2cbb5c8f55 thinkpad-acpi: don't depend on led_path for led firmware type (v2)
Don't depend on the contents of led_path to know which LED interface
the firmware wants.

This removes the only user of *_path for the thinkpad-acpi ACPI
handlers, which will simplify future code.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:50 -03:00
Henrique de Moraes Holschuh 72f1992121 thinkpad-acpi: explain errors from acpi_install_notify_handler
Log more human-friendly errors instead of numeric values when
setup_acpi_notify() fails to install a notification handler.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:48 -03:00
Henrique de Moraes Holschuh 263f4a30e4 thinkpad-acpi: acpi_evalf fixes
Use acpi_format_exception() in acpi_evalf() instead of logging numeric
errors.

Also, when ACPICA returns an error, we should not be touching the return
object, as it is invalid.  In debug mode, acpi_evalf() callers would
printk the returned crap (but fortunately, not use it).

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:45 -03:00
Henrique de Moraes Holschuh 437e470c4c thinkpad-acpi: detect EC node using its HID (v2)
Use the EC HID (PNP0C09) to locate its main node, instead of a static
list.

Suggested-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Matthew Garrett <mjg@redhat.com>
2010-05-16 19:45:43 -03:00
Henrique de Moraes Holschuh 38e11cdec9 thinkpad-acpi: disclose usertask for ALSA callbacks
Disclose the user task doing ALSA access when requested by
the debug bitmask.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:40 -03:00
Henrique de Moraes Holschuh 2899902281 thinkpad-acpi: fix brightness hotkey poll handling
Handle multiple brightness hotkey presses between two polling cycles.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:36 -03:00
Henrique de Moraes Holschuh 77775838bb thinkpad-acpi: let other subdrivers know backlight level range
Extract the backlight level range size detection from the brightness
subdriver, and allow the other subdrivers access to that information.

This also allows us to relocate some code to a more convenient place.
The moved code was largerly unmodified, except for the return type of
tpacpi_check_std_acpi_brightness_support(), which now is correctly
marked as returning "unsigned int", and and two cosmetic fixes to make
checkpatch.pl happy.

Fixes for the NVRAM polling mode for the brightness hotkeys will need
this.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:33 -03:00
Henrique de Moraes Holschuh 7a43f78898 thinkpad-acpi: move greeting messages out of the first subdriver (v2)
Move the driver initial greetings out of the first subdriver, as we do a
lot of other initialization before that point, and the initial greetings
should go as soon as the driver decides that it should load.

These greetings are not cosmetic, they make my life easier when users
report bugs.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:31 -03:00
Henrique de Moraes Holschuh 5d756db99a thinkpad-acpi: fix volume/mute hotkey poll handling
The hotkey polling code is supposed to generate hotkey messages as
close to the way the IBM event-based volume hotkey firmware does as
possible, i.e:

* Pressing MUTE issues a mute hotkey event, even if already mute;

* Pressing Volume up/down issues a volume up/down hotkey event,
  even if already at maximum or minumum volume;

* The act of unmuting issues a volume up/down event, depending on
  which hotkey was used to unmute.

Fix the code to do just that (mute handling was incorrect), and handle
multiple hotkey presses between two polling cycles.

The new code uses the volume_toggle bit in NVRAM only to detect
repeated presses of the mute key and multiple presses of the volume
keys trying to go past the end of the volume scale.  This will work
around a bug in recent Lenovo firmware (e.g. T400), which causes the
firmware to not update the volume_toggle bit in certain situations.

Reported-by: Yang Zhe <yangzhe1990@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:28 -03:00
Henrique de Moraes Holschuh a318930d06 thinkpad-acpi: X100e quick fixes
The X100e needs some quick fixes to work semi-right with this driver.
There are much better ways to do this, but we can start with a quick
update and do it properly later.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:26 -03:00
Henrique de Moraes Holschuh e28393c0c4 thinkpad-acpi: constrain IBM-era support to IBM boxes
Lenovo is playing around with its ACPI BIOS, and will end up reusing
method names.  Their memory is not nearly as long as thinkpad-acpi's...

Secure most of the old IBM codepaths against running in a non-IBM box.
This would happen on the Lenovo X100e in video_init(), for example.  We
would misdetect it as an ancient model 570 firmware.

Also, refuse to load the driver if we cannot identify the vendor.  No
ACPI ThinkPad in existence lacks this information, AFAIK.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
2010-05-16 19:45:23 -03:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Matthew Garrett a19a6ee6ca backlight: Allow properties to be passed at registration
Values such as max_brightness should be set before backlights are
registered, but the current API doesn't allow that. Add a parameter to
backlight_device_register and update drivers to ensure that they
set this correctly.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-16 19:47:54 +00:00
Jiri Kosina 318ae2edc3 Merge branch 'for-next' into for-linus
Conflicts:
	Documentation/filesystems/proc.txt
	arch/arm/mach-u300/include/mach/debug-macro.S
	drivers/net/qlge/qlge_ethtool.c
	drivers/net/qlge/qlge_main.c
	drivers/net/typhoon.c
2010-03-08 16:55:37 +01:00
Henrique de Moraes Holschuh 88cc83772a thinkpad-acpi: fix ALSA callback return status
Clemens Ladisch reports that thinkpad-acpi improperly implements the
ALSA API, and always returns 0 for success for the "put" callbacks
while the API requires it to return "1" when the control value has
been changed in the hardware/firmware.

Rework the volume subdriver to be able to properly implement the ALSA
API.  Based on a patch by Clemens Ladisch <clemens@ladisch.de>.

This fix is also needed on 2.6.33.

Reported-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-27 18:45:29 -03:00
Henrique de Moraes Holschuh b525c06cdb thinkpad-acpi: lock down video output state access
Given the right combination of ThinkPad and X.org, just reading the
video output control state is enough to hard-crash X.org.

Until the day I somehow find out a model or BIOS cut date to not
provide this feature to ThinkPads that can do video switching through
X RandR, change permissions so that only processes with CAP_SYS_ADMIN
can access any sort of video output control state.

This bug could be considered a local DoS I suppose, as it allows any
non-privledged local user to cause some versions of X.org to
hard-crash some ThinkPads.

Reported-by: Jidanni <jidanni@jidanni.org>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-25 22:22:22 -03:00
Henrique de Moraes Holschuh 08fedfc903 thinkpad-acpi: fix bluetooth/wwan resume
Studying the DSDTs of various thinkpads, it looks like bit 3 of the
argument to SBDC and SWAN is not "set radio to last state on resume".
Rather, it seems to be "if this bit is set, enable radio on resume,
otherwise disable it on resume".

So, the proper way to prepare the radios for S3 suspend is: disable
radio and clear bit 3 on the SBDC/SWAN call to to resume with radio
disabled, and enable radio and set bit 3 on the SBDC/SWAN call to
resume with the radio enabled.

Also, for persistent devices, the rfkill core does not restore state,
so we really need to get the firmware to do the right thing.

We don't sync the radio state on suspend, instead we trust the BIOS to
not do anything weird if we never touched the radio state since boot.
Time will tell if that's a wise way of doing things...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-25 22:22:07 -03:00
Henrique de Moraes Holschuh 7f0cf712a7 thinkpad-acpi: make driver events work in NVRAM poll mode
Thadeu Lima de Souza Cascardo reports this:

Brightness notification does not work until the user writes to
hotkey_mask attribute.  That's because the polling thread will only run
if hotkey_user_mask is set and someone is reading the input device or
if hotkey_driver_mask is set.  In this second case, this condition is
not tested after the mask is changed, because the brightness and
volume drivers are started after the hotkey drivers.

Fix tpacpi_hotkey_driver_mask_set() to call hotkey_poll_setup(), so
that the poller kthread will be started when needed.

Reported-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: stable@kernel.org
2010-02-25 21:37:23 -03:00
Henrique de Moraes Holschuh b589ea4c44 thinkpad-acpi: fix poll thread auto-start
The driver was not starting the NVRAM polling thread if the input
device was bound immediately after registration.

This fixes:
http://bugzilla.kernel.org/show_bug.cgi?id=15118

Reported-by: Florian Zumbiehl <florz@florz.de>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-25 21:34:23 -03:00
Henrique de Moraes Holschuh 7d1894d8d1 thinkpad-acpi: R52 brightness_mode has been confirmed
We can stop pestering users for confirmation of the brightness_mode
default for firmware TP-76.

While at it, add a few missing comments in that quirk table.

Reported-by: Whoopie <whoopie79@gmx.net>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-25 21:33:54 -03:00
Henrique de Moraes Holschuh bf8b29c8f7 thinkpad-acpi: document HKEY event 3006
Event 0x3006 is used to help power management of the ODD in the
UltraBay.  The EC generates this event when the ODD eject button is
pressed (even if the bay is powered down).

Normally, Linux doesn't need this as we keep the SATA link powered
up (which wastes power).  The EC powers up the bay by itself when the
ODD eject button is pressed, and the SATA PHY reports the hotplug.

However, we could also power that SATA link down (and for that matter,
also power down the Ultrabay) if the ODD is left idle for a while with
no disk inside, and use event 0x3006 to know when we need that SATA link
powered back up.

For now, just stop asking for more information when event 0x3006 is
seen, there is no point in pestering users about it anymore.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
2010-02-25 21:28:56 -03:00
Roel Kluin f04d5e012d thinkpad-acpi: wrong thermal attribute_group removed in thermal_exit()
sysfs_remove_group() removed the wrong attribute_group for
thermal_read_mode TPEC_8, ACPI_TMP07 and ACPI_UPDT

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2010-02-16 03:10:10 -05:00
Uwe Kleine-König 9ddc5b6f18 tree-wide: fix typos "ammount" -> "amount"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-05 12:22:40 +01:00
Henrique de Moraes Holschuh ff850c339a thinkpad-acpi: make volume subdriver optional
Allow the user to choose through Kconfig if the Console Audio Control
interface (aka "volume subdriver") should be available or not.

This not only saves some memory, but also allows the thinkpad-acpi
driver to be built-in even if ALSA is modular when the console audio
control interface is not wanted.

This change fixes a build problem that is causing some annoyances, in
a way that doesn't disable the entire driver on kernels without ALSA
support.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Amerigo Wang <amwang@redhat.com>
Cc: Helight Xu <helight.xu@gmail.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-26 22:37:35 -05:00
Henrique de Moraes Holschuh 74c75c1848 thinkpad-acpi: don't fail to load the entire module due to ALSA problems
If we cannot create the ALSA mixer, it is a good reason to fail to
load the volume subdriver, and not to fail to load the entire module.

While at it, add more debugging messages, as the error paths are being
used a lot more than I'd expect, and it is failing to set up the ALSA
mixer on a number of ThinkPads.

Reported-by: Peter Jordan <usernetwork@gmx.info>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-26 22:37:20 -05:00
Henrique de Moraes Holschuh ead510cebc thinkpad-acpi: don't take the first ALSA slot by default
We don't want to be the first soundcard.  We don't want to shift other
soundcards out of the way either, even if they load much later.

Ask ALSA to (by default) load us in one of the last three slots.  This
can be overriden at will using the "index" parameter.

Reported-by: Whoopie <whoopie79@gmx.net>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-26 22:37:08 -05:00
Len Brown 7458bbd044 Merge branch 'thinkpad-2.6.33' into release 2009-12-16 00:00:54 -05:00
Henrique de Moraes Holschuh 5d2eb14d36 thinkpad-acpi: bump version to 0.24
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-16 00:00:11 -05:00
Alexey Dobriyan 887965e657 thinkpad-acpi: convert to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:58:00 -05:00
Henrique de Moraes Holschuh 0d204c34e8 thinkpad-acpi: basic ALSA mixer support (v2)
Add the basic ALSA mixer functionality.  The mixer is event-driven,
and will work fine on IBM ThinkPads.  I expect Lenovo ThinkPads will
cause some trouble with the event interface.

Heavily based on work by Lorne Applebaum <lorne.applebaum@gmail.com>
and ideas from Matthew Garrett <mjg@redhat.com>.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Lorne Applebaum <lorne.applebaum@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:44 -05:00
Henrique de Moraes Holschuh c7ac6291ea thinkpad-acpi: disable volume control
Disable volume control by default.  It can be enabled at module load
time by a module parameter (volume_control=1).

The audio control mixer that thinkpad-acpi interacts with is fully
functional without any drivers, and operated by hotkeys.

The idea behind the console audio control is that the human operator
is the only one that can interact with it.  The ThinkVantage suite in
Windows does not allow any software-based overrides, and only does OSD
(on-screen-display) functions.

The Linux driver will, with the addition of the ALSA interface, try to
follow and enforce the ThinkVantage UI design:

The user is supposed to use the keyboard hotkeys to interact with the
console audio control.  The kernel and the desktop environment is
supposed to cooperate to provide proper user feedback through
on-screen-display functions.

Distros are urged to not to enable volume control by default.
Enabling this must be a local admin's decision.  This is the reason
why there is no Kconfig option.

Keep in mind that all ThinkPads have a normal, main mixer (AC97 or
HDA) for regular software-based audio control.  We are not talking
about that mixer here.

Advanced users are, of course, free to enable volume control and do as
they please.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Lorne Applebaum <lorne.applebaum@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:35 -05:00
Henrique de Moraes Holschuh a112ceee67 thinkpad-acpi: support MUTE-only ThinkPads
Lenovo removed the extra mixer since the T61 and thereabouts.
Newer Lenovo models only have the mute gate function, and leave
the volume control to the HDA mixer.

Until a way to automatically query the firmware about its audio
control capabilities is discovered (there might not be any), use a
white/black list.

We will likely need to ask T60 (old and new model) and Z60/Z61 users
whether they have volume control to populate the black/white list.
Meanwhile, provide a volume_capabilities parameter that can be used to
override the defaults.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Lorne Applebaum <lorne.applebaum@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:26 -05:00
Henrique de Moraes Holschuh 329e4e18df thinkpad-acpi: volume subdriver rewrite
I don't trust the coupled EC writes and SMI calls the current volume
control code does very much, although it is exactly what the IBM DSDTs
seem to do (they never do more than a single step though).

Change the driver to stop issuing SMIs, and just drive the EC directly
to the desired level (DSDTs seem to confirm this will work even on
very old models like the 570 and 600e/x).

We checkpoint directly to NVRAM (this can be turned off) at
suspend/shutdown/driver unload, which from what I can see in tbp,
should also work on every ThinkPad.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Lorne Applebaum <lorne.applebaum@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:17 -05:00
Henrique de Moraes Holschuh 5451a923bb thinkpad-acpi: log initial state of rfkill switches
We already log the initial state of the hardware rfkill switch (WLSW),
might as well log the state of the softswitches as well.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Josip Rodin <joy+kernel@entuzijast.net>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:09 -05:00
Henrique de Moraes Holschuh d89a727aff thinkpad-acpi: sync input device EV_SW initial state
Before we register the input device, sync the input layer EV_SW state
through a call to input_report_switch(), to avoid issuing a gratuitous
event for the initial state of these switches.

This fixes some annoyances caused by the interaction with rfkill and
EV_SW SW_RFKILL_ALL events.

Reported-by: Kevin Locke <kevin@kevinlocke.name>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-15 23:57:00 -05:00
André Goddard Rosa e7d2860b69 tree-wide: convert open calls to remove spaces to skip_spaces() lib function
Makes use of skip_spaces() defined in lib/string.c for removing leading
spaces from strings all over the tree.

It decreases lib.a code size by 47 bytes and reuses the function tree-wide:
   text    data     bss     dec     hex filename
  64688     584     592   65864   10148 (TOTALS-BEFORE)
  64641     584     592   65817   10119 (TOTALS-AFTER)

Also, while at it, if we see (*str && isspace(*str)), we can be sure to
remove the first condition (*str) as the second one (isspace(*str)) also
evaluates to 0 whenever *str == 0, making it redundant. In other words,
"a char equals zero is never a space".

Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below,
and found occurrences of this pattern on 3 more files:
    drivers/leds/led-class.c
    drivers/leds/ledtrig-timer.c
    drivers/video/output.c

@@
expression str;
@@

( // ignore skip_spaces cases
while (*str &&  isspace(*str)) { \(str++;\|++str;\) }
|
- *str &&
isspace(*str)
)

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Julia Lawall <julia@diku.dk>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Neil Brown <neilb@suse.de>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: David Howells <dhowells@redhat.com>
Cc: <linux-ext4@vger.kernel.org>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-15 08:53:32 -08:00
Linus Torvalds 3067e02f8f Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6:
  ACPICA: Update version to 20091112.
  ACPICA: Add additional module-level code support
  ACPICA: Deploy new create integer interface where appropriate
  ACPICA: New internal utility function to create Integer objects
  ACPICA: Add repair for predefined methods that must return sorted lists
  ACPICA: Fix possible fault if return Package objects contain NULL elements
  ACPICA: Add post-order callback to acpi_walk_namespace
  ACPICA: Change package length error message to an info message
  ACPICA: Reduce severity of predefined repair messages, Warning to Info
  ACPICA: Update version to 20091013
  ACPICA: Fix possible memory leak for Scope ASL operator
  ACPICA: Remove possibility of executing _REG methods twice
  ACPICA: Add repair for bad _MAT buffers
  ACPICA: Add repair for bad _BIF/_BIX packages
2009-12-09 19:57:06 -08:00
Henrique de Moraes Holschuh 792979c803 thinkpad-acpi: use input_set_capability
Use input_set_capability() instead of set_bit.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:31 -05:00
Henrique de Moraes Holschuh 9ebd9e8336 thinkpad-acpi: log temperatures on termal alarm (v2)
Log temperatures on any of the EC thermal alarms.  It could be
useful to help tracking down what is happening...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh b09c72259e thinkpad-acpi: expose module parameters
Export the normal (non-command) module paramenters as mode 0444, so
that they will show up in sysfs.

These parameters must not be changed at runtime as a rule, with very
few exceptions.

Reported-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh d112ef95d4 thinkpad-acpi: adopt input device
Properly init the parent field of the input device.  Thanks to Alan
Jenkins, who noted this problem in a different driver.

Reported-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh 6b30eb7d21 thinkpad-acpi: silence bogus complain during rmmod
Fix this bogus warning during module shutdown, when
backlight event reporting is enabled:

"thinkpad_acpi: required events 0x00018000 not enabled!"

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh 347a26860e thinkpad-acpi: issue backlight class events
Take advantage of the new events capabilities of the backlight class to
notify userspace of backlight changes.

This depends on "backlight: Allow drivers to update the core, and
generate events on changes", by Matthew Garrett.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Richard Purdie <rpurdie@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh 90765c6aee thinkpad-acpi: fix some version quirks
Update some of the BIOS/EC version quirks.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh 208b996b6c thinkpad-acpi: preserve rfkill state across suspend/resume
Since the rfkill rework in 2.6.31, the driver is always resuming with
the radios disabled.

Change thinkpad-acpi to ask the firmware to resume with the radios in
the last state.  This fixes the Bluetooth and WWAN rfkill switches.

Note that it means we respect the firmware's oddities.  Should the
user toggle the hardware rfkill switch on and off, it might cause the
radios to resume enabled.

UWB is an unknown quantity since it has nowhere the same level of
firmware support (no control over state storage in NVRAM, for
example), and might need further fixing.  Testers welcome.

This change fixes a regression from 2.6.30.

Reported-by: Jerone Young <jerone.young@canonical.com>
Reported-by: Ian Molton <ian.molton@collabora.co.uk>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Tested-by: Ian Molton <ian.molton@collabora.co.uk>
Cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Henrique de Moraes Holschuh a9f8eacca4 thinkpad-acpi: fix default brightness_mode for R50e/R51
According to a report, the R50e wants EC-based brightness control,
even if it uses an Intel GPU.  The current driver default was reported
to not work at all.

This bug can be worked around by the "brightness_mode=3" module
parameter.

Change the default of the R50e and R51 2xxx models (which use the same
EC firmware, 1V) to TPACPI_BRGHT_Q_EC, but keep TPACPI_BRGHT_Q_ASK set
for now, as I'd like to get more reports.

This fixes a regression caused by commit
59fe4fe34d,
"thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM"

Kernel 2.6.31 also needs this fix.

Reported-by: Ferenc Wagner <wferi@niif.hu>
Tested-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-09 15:45:30 -05:00
Jiri Kosina d014d04386 Merge branch 'for-next' into for-linus
Conflicts:

	kernel/irq/chip.c
2009-12-07 18:36:35 +01:00
André Goddard Rosa af901ca181 tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-12-04 15:39:55 +01:00
Henrique de Moraes Holschuh 275014ae46 thinkpad-acpi: fix detection of old ThinkPads
There is a problem in the quirk tables used by tpacpi_is_fw_known() and
tpacpi_check_outdated_fw(), which causes outdated BIOSes that are lacking
the EC firmware ID DMI field to never match.

This breaks module loading on, e.g.  a T23 with outdated BIOS, and the
module will refuse to load unless the "force_load=1" parameter is given.

Fix the quirk tables so that they can also match the outdated BIOSes,
which in turn will both fix the module loading, and also warn the user
that he is using outdated firmware and should upgrade.

This fixes a serious regression, introduced by commit
e675abafcc, "thinkpad-acpi: be more strict
when detecting a ThinkPad".

http://bugzilla.kernel.org/show_bug.cgi?id=14597

Reported-by: Paul Kimoto <kimoto@lightlink.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Tested-by: Paul Kimoto <kimoto@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-25 00:42:15 -05:00
Roel Kluin 80a8d1228e thinkpad-acpi: fix sign of ERESTARTSYS return
The returned error should be negative

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@kernel.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-25 00:39:21 -05:00
Lin Ming 2263576cfc ACPICA: Add post-order callback to acpi_walk_namespace
The existing interface only has a pre-order callback. This change
adds an additional parameter for a post-order callback which will
be more useful for bus scans. ACPICA BZ 779.

Also update the external calls to acpi_walk_namespace.

http://www.acpica.org/bugzilla/show_bug.cgi?id=779

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-24 21:31:10 -05:00
Henrique de Moraes Holschuh b684a3637e thinkpad-acpi: fix CONFIG_THINKPAD_ACPI_HOTKEY_POLL build problem
Fix this problem when CONFIG_THINKPAD_ACPI_HOTKEY_POLL is undefined:

  CHECK   drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/thinkpad_acpi.c:1968:21: error: not an lvalue
  CC [M]  drivers/platform/x86/thinkpad_acpi.o
drivers/platform/x86/thinkpad_acpi.c: In function 'tpacpi_hotkey_driver_mask_set':
drivers/platform/x86/thinkpad_acpi.c:1968: error: lvalue required as left operand of assignment

Reported-by: Noah Dain <noahdain@gmail.com>
Reported-by: Audrius Kazukauskas <audrius@neutrino.lt>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-27 02:13:06 -04:00
Henrique de Moraes Holschuh 67bcae6ee8 thinkpad-acpi: name event constants
Reduce the number of magic numbers in the driver... note that they
were all explained and documented already.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:49:04 -04:00
Henrique de Moraes Holschuh 8b468c0c85 thinkpad-acpi: add internal hotkey event API
Add an internal API to the driver, to allow subdrivers to request and
receive HKEY 0x1000 events.  This API will be used by the backlight
(brightness up/down) and upcoming ALSA mixer (volume up/down/mute)
subdrivers.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:48:31 -04:00
Henrique de Moraes Holschuh 0d922e3b84 thinkpad-acpi: hotkey event driver update
Update the HKEY event driver to:

1. Handle better the second-gen firmware, which has no HKEY mask
   support but does report FN+F3, FN+F4 and FN+F12 without the need
   for NVRAM polling.

   a) always make the mask-related attributes available in sysfs;
   b) use DMI quirks to detect the second-gen firmware;
   c) properly report that FN+F3, FN+F4 and FN+F12 are enabled,
      and available even on mask-less second-gen firmware;

2. Decouple the issuing of hotkey events towards userspace from
   their reception from the firmware.  ALSA mixer and brightness
   event reporting support will need this feature.

3. Clean up the mess in the hotkey driver a great deal.  It is
   still very convoluted, and wants a full refactoring into a
   proper event API interface, but that is not going to happen
   today.

4. Fully reset firmware interface on resume (restore hotkey
   mask and status).

5. Stop losing polled events for no good reason when changing the
   mask and poll frequencies.  We will still lose them when the
   hotkey_source_mask is changed, as well as any that happened
   between driver suspend and driver resume.

The hotkey subdriver now has the notion of user-space-visible hotkey
event mask, as well as of the set of "hotkey" events the driver needs
(because brightness/volume change reports are not just keypress
reports in most ThinkPad models).

With this rewrite, the ABI level is bumped to 0x020500 should
userspace need to know it is dealing with the updated hotkey
subdriver.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:48:13 -04:00
Henrique de Moraes Holschuh 176dd98523 thinkpad-acpi: drop HKEY event 0x5010
HKEY event 0x5010 is useless to us: old ThinkPads don't issue it.  Newer
ThinkPads won't issue it anymore.  And all ThinkPads issue 0x1010 and
0x1011 events.

Just silently drop it instead of sending it to userspace.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:45:15 -04:00
Henrique de Moraes Holschuh 4be73005e4 thinkpad-acpi: remove uneeded tp_features.hotkey tests in hotkey_exit
hotkey_exit() is only called if hotkey_init() finished sucessfully, or
by direct calls inside hotkey_init().  The tp_features.hotkey test is
always true, and just adds to the confusion, remove it.  Also, avoid
calling hotkey_mask_set() when it won't do anything useful.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:44:25 -04:00
Henrique de Moraes Holschuh 435c47e20b thinkpad-acpi: don't leave ERR_PTR() pointers around
backlight_device_register returns ERR_PTR() in case of problems, and
the current code would leave that ERR_PTR in ibm_backlight_device.

The current code paths won't touch it in that situation, but that could
change.  Make sure to set ibm_backlight_device to NULL in the error
path.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-20 13:43:29 -04:00
Corentin Chary 5f0dadb4bd thinkpad_acpi: fix rfkill memory leak on unload
rfkill_unregister() should always be followed by rfkill_destroy()

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 01:10:34 -04:00
Henrique de Moraes Holschuh de4c8cc7bd thinkpad-acpi: report brightness events when required
Report KEY_BRIGHTNESSUP and KEY_BRIGHTNESSDOWN input events when the
ThinkPad is in "passive brightness control" mode (because either we or
ACPI video touched _BCL), and ACPI video is not processing these
events by itself.

This happens only on Lenovo ThinkPads with ACPI video support, when
operating with the ACPI video driver in acpi_backlight=vendor mode.

Issuing these events is the right thing to do, and will work around
bugzilla #13368, if userspace is properly configured and actively
handles these events.

For other ThinkPads, and when ACPI video is handling brightness
changes, thinkpad-acpi will continue NOT sending KEY_BRIGHTNESS*
events by default.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:54:34 -04:00
Henrique de Moraes Holschuh 230d8cf25a thinkpad-acpi: don't poll by default any of the reserved hotkeys
Init hotkey_source_mask late, so that we can make use of
hotkey_reserved_mask to avoid polling any of the reserved
hotkeys by default.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:54:04 -04:00
Henrique de Moraes Holschuh 20c9aa46f6 thinkpad-acpi: Fix procfs hotkey reset command
echo "reset" > /proc/acpi/ibm/hotkey should do something non-useless,
so instead of setting it to Fn+F2, Fn+F3, Fn+F5, set it to
hotkey_recommended_mask.

It is not like it will survive for much longer, anyway.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:53:50 -04:00
Henrique de Moraes Holschuh 06777be6d8 thinkpad-acpi: deprecate hotkey_bios_mask
Some analysis of the ACPI DSDTs shows that the HKEY pre-enabled mask
is always 0x80c (FN+F3,FN+F4 and FN+F12), which are the hotkeys that
the second gen of HKEY firmware supported (the first gen didn't report
any hotkeys, the second reported these tree hotkeys but had no mask
support, and the third added mask support).

So, this is probably some sort of backwards compatibility with older
versions of the IBM ThinkVantage suite.  We have no use for that, and
I know of exactly ZERO users of that attribute, anyway.  Start the
process of getting rid of it.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:53:34 -04:00
Henrique de Moraes Holschuh db25f16d1d thinkpad-acpi: hotkey poll fixes
Fix some locking, avoid exiting the kthread before kthread_stop() is
called on it, and clean up the hotkey poll routines a little bit.

Also, restore bits in the firmware mask after hotkey_source_mask is
changed.  Without this, we leave events disabled...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:53:04 -04:00
Henrique de Moraes Holschuh e675abafcc thinkpad-acpi: be more strict when detecting a ThinkPad
Use stricter checks to decide that we're running on a supported ThinkPad.
This should remove some possible false positives, although nobody ever
bothered to report any.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:52:52 -04:00
Henrique de Moraes Holschuh 600a99fa3b thinkpad-acpi: firmware version checks
Use the quirk infrastructure to warn of outdated firmware and also of
firmware versions that are known to cause problems.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:52:33 -04:00
Henrique de Moraes Holschuh 6da25bf516 thinkpad-acpi: don't ask about brightness_mode for fw. 1V and 1R
X40 (firmware 1V) and T41 (firmware 1R) have been confirmed to work
well with the new defaults, so we can stop pestering people to confirm
that fact.

For now, whitelist just these two firmware types.  It is best to have
at least one more firmware type confirmed for Radeon 9xxx and Intel
GMA-2 ThinkPads before removing the confirmation requests entirely.

Reported-by: Robert de Rooy <robert.de.rooy@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 00:52:20 -04:00
Henrique de Moraes Holschuh 59fe4fe34d thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM
HBRV-based default selection of backlight control strategy didn't work
well, at least the X41 defines it but doesn't use it and I don't think
it will stop there.

Switch to a white/blacklist.  All models that have HBRV defined have
been included in the list, and initially all ATI GPUs will get
ECNVRAM, and the Intel GPUs will get UCMS_STEP.

Symptoms of incorrect backlight mode selection are:

1. Non-working backlight control through sysfs;

2. Backlight gets reset to the lowest level at every shutdown, reboot
   and when thinkpad-acpi gets unloaded;

This fixes a regression in 2.6.30, bugzilla #13826

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Reported-by: Tobias Diedrich <ranma+kernel@tdiedrich.de>
Cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
2009-08-01 23:55:53 -04:00
Michael Buesch 5b05d4696d thinkpad-acpi: restrict procfs count value to sane upper limit
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-08-01 23:50:40 -04:00
Henrique de Moraes Holschuh 1f6fc2de95 thinkpad-acpi: remove dock and bay subdrivers
The standard ACPI dock driver can handle the hotplug bays and docks of
the ThinkPads just fine (including batteries) as of 2.6.27, and the
code in thinkpad-acpi for the dock and bay subdrivers is currently
broken anyway...

Userspace needs some love to support the two-stage ejection nicely,
but it is simple enough to do through udev rules (you don't even need
HAL) so this wouldn't justify fixing the dock and bay subdrivers,
either.

That leaves warm-swap bays (_EJ3) support for thinkpad-acpi, as well
as support for the weird dock of the model 570, but since such support
has never left the "experimental" stage, it is also not a strong
enough reason to find a way to fix this code.

Users of ThinkPads with warm-swap bays are urged to request that _EJ3
support be added to the regular ACPI dock driver, if such feature is
indeed useful for them.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-08-01 23:46:58 -04:00
Len Brown fbe8cddd2d Merge branches 'acerhdf', 'acpi-pci-bind', 'bjorn-pci-root', 'bugzilla-12904', 'bugzilla-13121', 'bugzilla-13396', 'bugzilla-13533', 'bugzilla-13612', 'c3_lock', 'hid-cleanups', 'misc-2.6.31', 'pdc-leak-fix', 'pnpacpi', 'power_nocheck', 'thinkpad_acpi', 'video' and 'wmi' into release 2009-06-24 01:19:50 -04:00
Alan Jenkins 06d5caf47e rfkill: don't restore software blocked state on persistent devices
The setting of the "persistent" flag is also made more explicit using
a new rfkill_init_sw_state() function, instead of special-casing
rfkill_set_sw_state() when it is called before registration.

Suspend is a bit of a corner case so we try to get away without adding
another hack to rfkill-input - it's going to be removed soon.
If the state does change over suspend, users will simply have to prod
rfkill-input twice in order to toggle the state.

Userspace policy agents will be able to implement a more consistent user
experience.  For example, they can avoid the above problem if they
toggle devices individually.  Then there would be no "global state"
to get out of sync.

Currently there are only two rfkill drivers with persistent soft-blocked
state.  thinkpad-acpi already checks the software state on resume.
eeepc-laptop will require modification.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
CC: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-06-19 11:50:17 -04:00
Henrique de Moraes Holschuh d73772474f thinkpad-acpi: support the second fan on the X61
Support reading the tachometer of the auxiliary fan of a X60/X61.

It was found out by sheer luck, that bit 0 of EC register 0x31
(formely HBRV) selects which fan is active for tachometer readings
through EC 0x84/0x085: 0 for fan1, 1 for fan2.

Many thanks to Christoph Kl??nter, to Whoopie, and to weasel, who
helped confirm that behaviour.

Fan control through EC HFSP applies to both fans equally, regardless
of the state of bit 0 of EC 0x31.  That matches the way the DSDT uses
HFSP.

In order to better support the secondary fan, export a second
tachometer over hwmon, and add defensive measures to make sure we are
reading the correct tachometer.

Support for the second fan is whitelist-based, as I have not found
anything obvious to look for in the DSDT to detect the presence of
the second fan.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-18 01:30:57 -04:00
Henrique de Moraes Holschuh d7880f10c5 thinkpad-acpi: forbid the use of HBRV on Lenovo ThinkPads
Forcing thinkpad-acpi to do EC-based brightness control (HBRV) on a
X61 has very... interesting effects, instead of doing nothing (since
it doesn't have EC-based backlight control), it causes "weirdness" in
the fan tachometer readings, for example.

This means the EC register that used to be HBRV has been reused by
Lenovo for something else, but they didn't remove it from the DSDT.

Make sure the documentation reflects this data, and forbid the user
from forcing the driver to access HBRV on Lenovo ThinkPads.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-18 01:30:35 -04:00
Henrique de Moraes Holschuh 8bf3d4c535 thinkpad-acpi: silence bogus warning when ACPI video is disabled
Make use of acpi_video_backlight_support() also in hotkey_init, to make
sure this doesn't happen:

thinkpad_acpi: This ThinkPad has standard ACPI backlight brightness
               control, supported by the ACPI video driver
thinkpad_acpi: Disabling thinkpad-acpi brightness events by default...
thinkpad_acpi: Standard ACPI backlight interface not available,
               thinkpad_acpi native brightness control enabled
thinkpad_acpi: detected a 16-level brightness capable ThinkPad

Note that this is purely cosmetic, there is absolutely _no_ change in
behaviour.  Those events are sometimes enabled at runtime by userspace, but
the driver never enables them by itself unless someone messed with the
default keymaps.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Reported-by: Jochen Schulz <jrschulz@well-adjusted.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-17 22:49:05 -04:00
Henrique de Moraes Holschuh f21179a47f thinkpad-acpi: enhance led support
Add support for extra LEDs on recent ThinkPads, and avoid registering
with the led class the LEDs which are not available for a given
ThinkPad model.

All non-restricted LEDs are always available through the procfs
interface, as the firmware doesn't care if an attempt is made to
access an invalid LED.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-17 22:48:22 -04:00
Henrique de Moraes Holschuh 60201732f0 thinkpad-acpi: fix BEEP ACPI handler warnings
Some ThinkPads want two arguments for BEEP, while others want just
one, causing ACPICA to log warnings like this:

ACPI Warning (nseval-0177): Excess arguments - method [BEEP] needs 1,
found 2 [20080926]

Deal with it.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-17 22:47:16 -04:00
Henrique de Moraes Holschuh 7d95a3d564 thinkpad-acpi: add quirklist engine
Add a quirklist engine suitable for matching ThinkPad firmware,
and change the code to use it.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-17 22:46:42 -04:00
Henrique de Moraes Holschuh 050df107c4 thinkpad-acpi: store fw version with strict checking
Extend the thinkpad model and firmware identification data with the
release serial number for the BIOS and firmware (when available), as
that is easier to parse and compare than the version strings.

We're going to greatly extend the use of the ThinkPad DMI data through
quirk lists, so it is best to be quite strict and make sure what we
get from DMI is exactly what we expect, otherwise quirk matching may
result in quite insane things.

IBM (and Lenovo, at least for the ThinkPad line) uses this schema for
firmware versioning and model:

Firmware model: Two digits, [0-9A-Z]

Firmware version: AABBCCDD, where
  AA = firmware model, see above
  BB = "ET" for BIOS, "HT" for EC
  CC = release version, two digits, [0-9A-Z],
       "00" < "09" < "0A" < "10" < "A0" < "ZZ"
  DD = "WW"

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-06-17 22:45:30 -04:00
Alan Jenkins b3fa1329ea rfkill: remove set_global_sw_state
rfkill_set_global_sw_state() (previously rfkill_set_default()) will no
longer be exported by the rewritten rfkill core.

Instead, platform drivers which can provide persistent soft-rfkill state
across power-down/reboot should indicate their initial state by calling
rfkill_set_sw_state() before registration.  Otherwise, they will be
initialized to a default value during registration by a set_block call.

We remove existing calls to rfkill_set_sw_state() which happen before
registration, since these had no effect in the old model.  If these
drivers do have persistent state, the calls can be put back (subject
to testing :-).  This affects hp-wmi and acer-wmi.

Drivers with persistent state will affect the global state only if
rfkill-input is enabled.  This is required, otherwise booting with
wireless soft-blocked and pressing the wireless-toggle key once would
have no apparent effect.  This special case will be removed in future
along with rfkill-input, in favour of a more flexible userspace daemon
(see Documentation/feature-removal-schedule.txt).

Now rfkill_global_states[n].def is only used to preserve global states
over EPO, it is renamed to ".sav".

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-06-10 13:28:37 -04:00
Johannes Berg 19d337dff9 rfkill: rewrite
This patch completely rewrites the rfkill core to address
the following deficiencies:

 * all rfkill drivers need to implement polling where necessary
   rather than having one central implementation

 * updating the rfkill state cannot be done from arbitrary
   contexts, forcing drivers to use schedule_work and requiring
   lots of code

 * rfkill drivers need to keep track of soft/hard blocked
   internally -- the core should do this

 * the rfkill API has many unexpected quirks, for example being
   asymmetric wrt. alloc/free and register/unregister

 * rfkill can call back into a driver from within a function the
   driver called -- this is prone to deadlocks and generally
   should be avoided

 * rfkill-input pointlessly is a separate module

 * drivers need to #ifdef rfkill functions (unless they want to
   depend on or select RFKILL) -- rfkill should provide inlines
   that do nothing if it isn't compiled in

 * the rfkill structure is not opaque -- drivers need to initialise
   it correctly (lots of sanity checking code required) -- instead
   force drivers to pass the right variables to rfkill_alloc()

 * the documentation is hard to read because it always assumes the
   reader is completely clueless and contains way TOO MANY CAPS

 * the rfkill code needlessly uses a lot of locks and atomic
   operations in locked sections

 * fix LED trigger to actually change the LED when the radio state
   changes -- this wasn't done before

Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad]
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-06-03 14:06:13 -04:00
Henrique de Moraes Holschuh b57f7e7b83 thinkpad-acpi: bump up version to 0.23
Plenty of high-profile changes, so it deserves a new version number.

Features added since 0.22:
 *  Restrict unsafe LEDs
 *  New race-less brightness control strategy for IBM ThinkPads
 *  Disclose TGID of driver access from userspace (debug)
 *  Warn when deprecated functions are used

Other changes:
 *  Better debug messages in some subdrivers
 *  Removed "hotkey disable" support, since it breaks the driver
 *  Dropped "ibm-acpi" alias

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-18 01:19:54 -04:00
Henrique de Moraes Holschuh 922fe097b1 thinkpad-acpi: simplify module autoloading
Simplify the module autoloading a great deal, by keying to the HID for
the HKEY interface.

Only _really_ ancient IBM ThinkPad models like the 240, 240x and 570
lack the HKEY interface, and they're getting their own trimmed-down
driver one of these days.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-18 01:19:54 -04:00
Henrique de Moraes Holschuh f68f53a217 thinkpad-acpi: fix use of MODULE_AUTHOR
Fix the module to use one instance of MODULE_AUTHOR per author.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-18 01:19:53 -04:00
Henrique de Moraes Holschuh 75bd3bf2ad thinkpad-acpi: fix LED blinking through timer trigger
The set_blink hook code in the LED subdriver would never manage to get
a LED to blink, and instead it would just turn it on.  The consequence
of this is that the "timer" trigger would not cause the LED to blink
if given default parameters.

This problem exists since 2.6.26-rc1.

To fix it, switch the deferred LED work handling to use the
thinkpad-acpi-specific LED status (off/on/blink) directly.

This also makes the code easier to read, and to extend later.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: stable@kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-18 01:19:53 -04:00
Henrique de Moraes Holschuh 406e988bef thinkpad-acpi: silence hotkey enable warning for module parameter
Avoid the WARN() when the procfs handler for hotkey enable is used by
a module parameter.  Instead, urge the user to stop doing that.

Reported-by: Niel Lambrechts <niel.lambrechts@gmail.com>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-18 01:19:53 -04:00
Len Brown 478c6a43fc Merge branch 'linus' into release
Conflicts:
	arch/x86/kernel/cpu/cpufreq/longhaul.c

Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-05 02:14:15 -04:00
Henrique de Moraes Holschuh 0e501834f8 thinkpad-acpi: rework brightness support
Refactor and redesign the brightness control backend...

In order to fix bugzilla #11750...

Add a new brightness control mode: support direct NVRAM checkpointing
of the backlight level (i.e. store directly to NVRAM without the need
for UCMS calls), and use that together with the EC-based control.
Disallow UCMS+EC, thus avoiding races with the SMM firmware.

Switch the models that define HBRV (EC Brightness Value) in the DSDT
to the new mode.  These are: T40-T43, R50-R52, R50e, R51e, X31-X41.

Change the default for all other IBM ThinkPads to UCMS-only.  The
Lenovo models already default to UCMS-only.

Reported-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:53 -04:00
Henrique de Moraes Holschuh 74a60c0f82 thinkpad-acpi: enhanced debugging messages for the fan subdriver
Enhance debugging messages for the fan subdriver.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:53 -04:00
Henrique de Moraes Holschuh 56e2c20094 thinkpad-acpi: enhanced debugging messages for the hotkey subdriver
Enhance debugging messages for the hotkey subdriver.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:53 -04:00
Henrique de Moraes Holschuh bee4cd9b9e thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
Enhance debugging messages for all rfkill subdrivers in thinkpad-acpi.

Also, log a warning if the deprecated sysfs attributes are in use.
These attributes are going to be removed sometime in 2010.

There is an user-visible side-effect: we now coalesce attempts to
enable/disable bluetooth or WWAN in the procfs interface, instead of
hammering the firmware with multiple requests.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:53 -04:00
Henrique de Moraes Holschuh a4d5effcc7 thinkpad-acpi: restrict access to some firmware LEDs
Some of the ThinkPad LEDs indicate critical conditions that can cause
data loss or cause hardware damage when ignored (e.g. force-ejecting
a powered up bay; ignoring a failing battery, or empty battery; force-
undocking with the dock buses still active, etc).

On almost all ThinkPads, LED access is write-only, and the firmware
usually does fire-and-forget signaling on them, so you effectively
lose whatever message the firmware was trying to convey to the user
when you override the LED state, without any chance to restore it.

Restrict access to all LEDs that can convey important alarms, or that
could mislead the user into incorrectly operating the hardware.  This
will make the Lenovo engineers less unhappy about the whole issue.

Allow users that really want it to still control all LEDs, it is the
unaware user that we have to worry about.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 2586d5663d thinkpad-acpi: remove HKEY disable functionality
The HKEY disable functionality basically cripples the entire event
model of the ThinkPad firmware and of the thinkpad-acpi driver.
Remove this functionality from the driver.  HKEY must be enabled at
all times while thinkpad-acpi is loaded, and disabled otherwise.

For sysfs, according to the sysfs ABI and the thinkpad-acpi sysfs
rules of engagement, we will just remove the attributes.  This will be
done in two stages: disable their function now, after two kernel
releases, remove the attributes.

For procfs, we call WARN().  If nothing triggers it, I will simply
remove the enable/disable commands entirely in the future along with
the sysfs attributes.

I don't expect much, if any fallout from this.  There really isn't any
reason to mess with hotkey_enable or with the enable/disable commands
to /proc/acpi/ibm/hotkey, and this has been true for years...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 73a94d86a8 thinkpad-acpi: add new debug helpers and warn of deprecated atts
Add a debug helper that discloses the TGID of the userspace task
attempting to access the driver.  This is highly useful when dealing
with bug reports, since often the user has no idea that some userspace
application is accessing thinkpad-acpi...

Also add a helper to log warnings about sysfs attributes that are
deprecated.

Use the new helpers to issue deprecation warnings for bluetooth_enable
and wwan_enabled, that have been deprecated for a while, now.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 7ff8d62f7f thinkpad-acpi: add missing log levels
Add missing log levels in a standalone commit, to avoid dependencies in
future unrelated changes, just because they wanted to use one of the
missing log levels.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 3dcc2c3b00 thinkpad-acpi: cleanup debug helpers
Fix the vdbg_printk macro definition to be sane when
CONFIG_THINKPAD_ACPI_DEBUG is undefined, and move the mess into a file
section of its own.

This doesn't change anything in the current code, but future code will
need the proper behaviour.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 257bc1cb3e thinkpad-acpi: drop ibm-acpi alias
The driver was renamed two years ago, on 2.6.21.  Drop the old
compatibility alias, we have given everybody quite enough time
to update their configs to the new name.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:52 -04:00
Henrique de Moraes Holschuh 1c762ca438 thinkpad-acpi: update copyright notices
It is that time of the year again...

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-04 03:14:51 -04:00
Linus Torvalds 811158b147 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (28 commits)
  trivial: Update my email address
  trivial: NULL noise: drivers/mtd/tests/mtd_*test.c
  trivial: NULL noise: drivers/media/dvb/frontends/drx397xD_fw.h
  trivial: Fix misspelling of "Celsius".
  trivial: remove unused variable 'path' in alloc_file()
  trivial: fix a pdlfush -> pdflush typo in comment
  trivial: jbd header comment typo fix for JBD_PARANOID_IOFAIL
  trivial: wusb: Storage class should be before const qualifier
  trivial: drivers/char/bsr.c: Storage class should be before const qualifier
  trivial: h8300: Storage class should be before const qualifier
  trivial: fix where cgroup documentation is not correctly referred to
  trivial: Give the right path in Documentation example
  trivial: MTD: remove EOL from MODULE_DESCRIPTION
  trivial: Fix typo in bio_split()'s documentation
  trivial: PWM: fix of #endif comment
  trivial: fix typos/grammar errors in Kconfig texts
  trivial: Fix misspelling of firmware
  trivial: cgroups: documentation typo and spelling corrections
  trivial: Update contact info for Jochen Hein
  trivial: fix typo "resgister" -> "register"
  ...
2009-04-03 15:24:35 -07:00
Alexey Dobriyan 99b7623380 proc 2/2: remove struct proc_dir_entry::owner
Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
->owner, thus not pinning enything, and release it later resulting
in module refcount underflow.

We can keep ->owner and supply it at registration time like ->proc_fops
and ->data.

But this leaves ->owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching ->owner. ->proc_fops is declared as "const" which should give
some thoughts.

->read_proc/->write_proc were just fixed to not require ->owner for
protection.

rmmod'ed directories will be empty and return "." and ".." -- no harm.
And directories with tricky enough readdir and lookup shouldn't be modular.
We definitely don't want such modular code.

Removing ->owner will also make PDE smaller.

So, let's nuke it.

Kudos to Jeff Layton for reminding about this, let's say, oversight.

http://bugzilla.kernel.org/show_bug.cgi?id=12454

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
2009-03-31 01:14:44 +04:00
Nick Andrew 877d03105d trivial: Fix misspelling of firmware
Fix misspelling of firmware.

Signed-off-by: Nick Andrew <nick@nick-andrew.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-30 15:21:59 +02:00
Mathieu Chouquet-Stringer b36a50f92d thinkpad-acpi: fix module autoloading for older models
Looking at the source, there seems to be a missing * to match my DMI
string.  I mean for newer IBM and Lenovo's laptops you match either one
of the following:
MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");

While for older Thinkpads, you do this (for instance):
IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]");

with IBM_BIOS_MODULE_ALIAS being MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW")

Note there's no * terminating the string.  As result, udev doesn't load
anything because modprobe cannot find anything matching this (my
machine actually):

udevtest: run: '/sbin/modprobe dmi:bvnIBM:bvr1IET71WW(2.10):bd06/16/2006:svnIBM:pn236621U:pvrNotAv

Signed-off-by: Mathieu Chouquet-Stringer <mchouque@free.fr>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-16 00:38:24 -04:00
Henrique de Moraes Holschuh aa2fbcec07 ACPI: thinkpad-acpi: bump up version to 0.22
It is about time to bump up the version.

Features added since 0.21:  fan suspend/resume support, preserve radio
state across power off (for some radio types), built-in UWB radio
rfkill support and thermal alarm events support.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:48:24 -05:00
Henrique de Moraes Holschuh 54926ce8d2 ACPI: thinkpad-acpi: handle HKEY event 6030
HKEY event 0x6030 is a helper for Lenovo's Advanced Thermal Management
Windows driver, which is, of course, completely undocumented.

Silence any warnings about it being an unknown alarm, and report it
unmodified for userspace.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:48:03 -05:00
Henrique de Moraes Holschuh 1c2ece758a ACPI: thinkpad-acpi: clean-up fan subdriver quirk
Better document the Unitialized HFSP quirk, and modularize it a bit.
This makes the code flow easier to read and reduces LOC.

Apply the Unitialized HFSP closer to the source (i.e. inside the
get_fan_status()), this fixes a harmless buglet where at driver init
with the quirk active, the user could set the hwmon pwm1 attribute and
switch out of pwm1_mode=2 to pwm1_mode=0 without changing pwm1_mode
directly.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Tino Keitel <tino.keitel@tikei.de>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:47:14 -05:00
Henrique de Moraes Holschuh cb42935898 ACPI: thinkpad-acpi: start the event hunt season
Ask users to tell us about any unhandled events they find.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:46:27 -05:00
Henrique de Moraes Holschuh 106b4e6657 ACPI: thinkpad-acpi: handle HKEY thermal and battery alarms
Handle some HKEY events that are actually firmware alarms.  For
now, we do the simple thing: log specific messages to the log and let
the thinkpad-specific event pass to userspace.

In the future, these events will be migrated to generic notifications
and subsystems.

These alarms are NOT available on all ThinkPads.  E.g. the T43 only
issues 0x6011 and 0x6012.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:45:46 -05:00
Henrique de Moraes Holschuh 3827e7a3fd ACPI: thinkpad-acpi: clean up hotkey_notify()
Clean up the hotkey_notify() handler, which handles the HKEY notifications
from the ACPI firmware.  It was getting too long and deep.

No functional changes.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:40:02 -05:00
Henrique de Moraes Holschuh 7646ea88af ACPI: thinkpad-acpi: use killable instead of interruptible mutexes
Unfortunately, POSIX in all of its braindamage, do not state that userspace has
to deal with EINTR in read/write and friends... so, lesser code just doesn't.

Switch from *_interruptible to *_killable on the sysfs- and procfs-related
mutexes.  This closes this possible can of worms.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:39:35 -05:00
Henrique de Moraes Holschuh 0045c0aa7d ACPI: thinkpad-acpi: add UWB radio support
Add rfkill support for USB UWB radio devices on very recent ThinkPad
laptop models.

The new subdriver is moslty a trimmed down copy of the wwan subdriver.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:36:51 -05:00
Henrique de Moraes Holschuh 90d9d3c79c ACPI: thinkpad-acpi: preserve radio state across shutdown
Store in firmware NVRAM the radio state on machine shutdown for WWAN and
bluetooth.  Also, try to set the initial boot state of these radios as the
rfkill default state for their respective classes.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:36:25 -05:00
Henrique de Moraes Holschuh 153f82207c ACPI: thinkpad-acpi: resume with radios disabled
Instruct the firmware to not enable the radios when resuming.  This
is safer, and the rfkill core will take care to manually enable any
radios that need to be enabled.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:30:29 -05:00
Henrique de Moraes Holschuh a73f30916e ACPI: thinkpad-acpi: debug facility to emulate the rf switches
This code is required to keep the thinkpad-acpi maintainer sane, and
it is disabled by default.

Add a debug facility to simulate an rfkill hardware rocker switch, a
bluetooth rfkill soft-switch, a WWAN rfkill soft-switch on thinkpads.

The simulated switches obviously do not kill any radios in hardware or
firmware (unlike the real one).  They also don't issue deprecated proc
events.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:29:21 -05:00
Kay Sievers e0b36fc5ef ACPI: thinkpad-acpi: struct device - replace bus_id with dev_name(), dev_set_name()
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-15 13:28:26 -05:00
Len Brown d97c0defba Merge branch 'drivers-platform' into release
Conflicts:
	drivers/misc/Kconfig

Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-09 04:56:56 -05:00
Len Brown 41b16dce39 create drivers/platform/x86/ from drivers/misc/
Move x86 platform specific drivers from drivers/misc/
to a new home under drivers/platform/x86/.

The community has been maintaining x86 vendor-specific
platform specific drivers under /drivers/misc/ for a few years.
The oldest ones started life under drivers/acpi.
They moved out of drivers/acpi/ because they don't actually
implement the ACPI specification, but either simply
use ACPI, or implement vendor-specific ACPI extensions.

In the future we anticipate...
drivers/misc/ will go away.
other architectures will create drivers/platform/<arch>

Signed-off-by: Len Brown <len.brown@intel.com>
2008-12-19 04:42:32 -05:00