aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/wmi.c
Commit message (Collapse)AuthorAgeFilesLines
* WMI: properly cleanup devices to avoid crashesDmitry Torokhov2011-11-111-1/+5
| | | | | | | | | | | | | | | | commit 023b9565972a4a5e0f01b9aa32680af6e9b5c388 upstream. We need to remove devices that we destroy from the list, otherwise we'll crash if there are more than one "_WDG" methods in DSDT. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=32052 Tested-by: Ilya Tumaykin <librarian_rus@yahoo.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* wmi: Removed trailing whitespace from logging message.Joe Perches2011-05-271-5/+5
| | | | | | | Just neatening. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: return error if wmi_create_device() failsDan Carpenter2011-01-071-1/+1
| | | | | | | | | | The break resets the retval to 0 but we want to return an error code. This was introduced in c64eefd48c4 "WMI: embed struct device directly into wmi_block" Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: Dmitry Torokhov <dtor@mail.ru>
* WMI: Cater for multiple events with same GUIDColin King2011-01-071-61/+72
| | | | | | | | | | | | | | | WMI data blocks can contain WMI events with the same GUID but with different notifiy_ids, for example volume up/down hotkeys. This patch enables a single event handler to be registered and unregistered against all events with same GUID but different notify_ids. Since an event handler is passed the notify_id of an event it can can differentiate between the different events. The patch also ensures we only register and unregister a device per unique GUID. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* wmi: use memcmp instead of strncmp to compare GUIDsThadeu Lima de Souza Cascardo2010-12-061-1/+1
| | | | | | | | | | | | | | | While looking for the duplicates in /sys/class/wmi/, I couldn't find them. The code that looks for duplicates uses strncmp in a binary GUID, which may contain zero bytes. The right function is memcmp, which is also used in another section of wmi code. It was finding 49142400-C6A3-40FA-BADB-8A2652834100 as a duplicate of 39142400-C6A3-40FA-BADB-8A2652834100. Since the first byte is the fourth printed, they were found as equal by strncmp. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> Signed-off-by: Matthew Garrett <mjg@redhat.com> Cc: stable@kernel.org
* WMI: embed struct device directly into wmi_blockDmitry Torokhov2010-10-211-111/+65
| | | | | | | | | | Instead of creating wmi_blocks and then register corresponding devices on a separate pass do it all in one shot, since lifetime rules for both objects are the same. This also takes care of leaking devices when device_create fails for one of them. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: make use of class device's attributresDmitry Torokhov2010-10-211-8/+7
| | | | | | | | Instead of adding modalias attribute manually set it up as class's device attribute so driver core will create and remove it for us. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: use pr_err() and friendsDmitry Torokhov2010-10-211-35/+29
| | | | | | | This makes source more concise and easier to read. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: use separate list head for storing wmi blocksDmitry Torokhov2010-10-211-11/+9
| | | | | | | | Do not abuse wmi_block structure to hold the head of list of blocks, use separate list_head for that. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: simplify handling of returned WMI blocks in parse_wdg()Dmitry Torokhov2010-10-211-11/+4
| | | | | | | | | There is no reason why we allocate memory and copy data into an intermediate buffer, it is not like we are working with data coming from userspace. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: fix potential NULL pointer dereferenceDmitry Torokhov2010-10-211-0/+2
| | | | | Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: do not leak memory in parse_wdg()Dmitry Torokhov2010-10-211-2/+4
| | | | | | | | If we _WDG returned object that is not buffer we were forgetting to free memory allocated for that object. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: fix wmi_gtoa() to actully terminate the stringDmitry Torokhov2010-10-211-1/+1
| | | | | | | Courtesy of sparse... Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: free wmi blocks when parse_wdg() failsDmitry Torokhov2010-10-211-10/+15
| | | | | Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* WMI: remove EC region handler when _WDG parsing failsDmitry Torokhov2010-10-211-2/+7
| | | | | | | | Driver initialization was forgetting to remove EC address space handler in cases when parse_wdg() method failed. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* platform: x86: throw away custom methodsAndy Shevchenko2010-10-211-18/+6
| | | | | | | | | | In 2.6.35 the hex_to_bin() was introduced. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Carlos Corbacho <carlos@strangeworlds.co.uk> Cc: Matthew Garrett <mjg@redhat.com> Cc: platform-driver-x86@vger.kernel.org Signed-off-by: Matthew Garrett <mjg@redhat.com>
* X86 platform driver: Fix section mismatch in wmi.cThomas Renninger2010-08-031-2/+2
| | | | | | | | | | | | | The .add function must not be declared __init. 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 Signed-off-by: Matthew Garrett <mjg@redhat.com>
* wmi: fix a memory leak in wmi_notify_debugAxel Lin2010-08-031-1/+7
| | | | | | | | | | | | | | | | When acpi_evaluate_object() is passed ACPI_ALLOCATE_BUFFER, the caller must kfree the returned buffer if AE_OK is returned. The callers of wmi_get_event_data() pass ACPI_ALLOCATE_BUFFER, and thus must check its return value before accessing or kfree() on the buffer. This patch adds return value checking for wmi_get_event_data() and adds a missing kfree(obj) in the end of wmi_notify_debug Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* wmi: fix memory leak in parse_wdgAxel Lin2010-08-031-5/+11
| | | | | | | This patch properly kfree out.pointer and gblock in error path. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* X86 platfrom wmi: Add debug facility to dump WMI data in a readable wayThomas Renninger2010-05-201-0/+35
| | | | | | | | | Signed-off-by: Thomas Renninger <trenn@suse.de> CC: platform-driver-x86@vger.kernel.org CC: mjg59@srcf.ucam.org CC: corentin.chary@gmail.com Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* X86 platform wmi: Also log GUID string when an event happens and debug is setThomas Renninger2010-05-201-0/+6
| | | | | | | | | | | | | Output in log with debug=1: ACPI: WMI: DEBUG Event INTEGER_TYPE - 65535 ACPI: WMI: DEBUG Event GUID: CC1A61AC-4256-41A3-B9E0-05A445ADE2F5 Signed-off-by: Thomas Renninger <trenn@suse.de> CC: platform-driver-x86@vger.kernel.org CC: mjg59@srcf.ucam.org CC: corentin.chary@gmail.com Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* X86 platform wmi: Introduce debug param to log all WMI eventsThomas Renninger2010-05-201-8/+50
| | | | | | | | | | | | | | | | | | | | To give people easily an idea what could be WMI driven on their system. Introduces: wmi.debug=[01] Tested on an acer: ACPI: WMI: DEBUG Event INTEGER_TYPE - 65535 Situation where a driver registers for specific event and debug handler gets overridden and set again if the registering driver gets unloaded again is untested, but should work. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: platform-driver-x86@vger.kernel.org CC: mjg59@srcf.ucam.org CC: corentin.chary@gmail.com Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Matthew Garrett <mjg@redhat.com>
* drivers/platform/x86: Use kmemdupJulia Lawall2010-05-201-3/+1
| | | | | | | | | | | | | | | | | | | | | | Use kmemdup when some other buffer is immediately copied into the allocated region. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk>
* include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo2010-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ACPI: replace acpi_integer by u64Lin Ming2010-01-281-2/+2
| | | | | | | | acpi_integer is now obsolete and removed from the ACPICA code base, replaced by u64. Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
* ACPI: WMI: Survive BIOS with duplicate GUIDsCarlos Corbacho2009-12-301-0/+30
| | | | | | | | | | | | | | | It would appear that in BIOS's with nVidia hooks, the GUID 05901221-D566-11D1-B2F0-00A0C9062910 is duplicated. For now, the simplest solution is to just ignore any duplicate GUIDs. These particular hooks are not currently supported/ used in the kernel, so whoever does that can figure out what the 'right' solution should be (if there's a better one). http://bugzilla.kernel.org/show_bug.cgi?id=14846 Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Reported-by: Larry Finger <Larry.Finger@lwfinger.net> Reported-by: Oldřich Jedlička <oldium.pro@seznam.cz> Signed-off-by: Len Brown <len.brown@intel.com>
* wmi: check find_guid() return value to prevent oopsPaul Rolland2009-12-301-4/+2
| | | | | Signed-off-by: Paul Rolland <rol@as2917.net> Signed-off-by: Len Brown <len.brown@intel.com>
* wmi: Free the allocated acpi objects through wmi_get_event_dataAnisse Astier2009-12-241-2/+2
| | | | | | | | | | | | These function allocate an acpi object by calling wmi_get_event_data, which then calls acpi_evaluate_object, and it is not freed afterwards. And kernel doc is fixed for parameters of wmi_get_event_data. Signed-off-by: Anisse Astier <anisse@astier.eu> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Len Brown <len.brown@intel.com>
* wmi: Add support for module autoloadingMatthew Garrett2009-11-051-2/+173
| | | | | | | | | | | | | | WMI provides interface-specific GUIDs that are exported from modules as modalises, but the core currently generates no events to trigger module loading. This patch adds support for registering devices for each WMI GUID and generating the appropriate uevent. Based heavily on a patch by Carlos Corbacho (<carlos@strangeworlds.co.uk>). Signed-off-by: Matthew Garrett <mjg@redhat.com> Tested-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Len Brown <len.brown@intel.com>
* ACPI: Move definition of PREFIX from acpi_bus.h to internal..hLen Brown2009-08-281-1/+0
| | | | | | | | | | | | | Linux/ACPI core files using internal.h all PREFIX "ACPI: ", however, not all ACPI drivers use/want it -- and they should not have to #undef PREFIX to define their own. Add GPL commment to internal.h while we are there. This does not change any actual console output, asside from a whitespace fix. Signed-off-by: Len Brown <len.brown@intel.com>
* wmi: fix kernel panic when stack protection enabled.Costantino Leandro2009-08-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Kernel panic arise when stack protection is enabled, since strncat will add a null terminating byte '\0'; So in functions like this one (wmi_query_block): char wc[4]="WC"; .... strncat(method, block->object_id, 2); ... the length of wc should be n+1 (wc[5]) or stack protection fault will arise. This is not noticeable when stack protection is disabled,but , isn't good either. Config used: [CONFIG_CC_STACKPROTECTOR_ALL=y, CONFIG_CC_STACKPROTECTOR=y] Panic Trace ------------ .... stack-protector: kernel stack corrupted in : fa7b182c 2.6.30-rc8-obelisco-generic call_trace: [<c04a6c40>] ? panic+0x45/0xd9 [<c012925d>] ? __stack_chk_fail+0x1c/0x40 [<fa7b182c>] ? wmi_query_block+0x15a/0x162 [wmi] [<fa7b182c>] ? wmi_query_block+0x15a/0x162 [wmi] [<fa7e7000>] ? acer_wmi_init+0x00/0x61a [acer_wmi] [<fa7e7135>] ? acer_wmi_init+0x135/0x61a [acer_wmi] [<c0101159>] ? do_one_initcall+0x50+0x126 Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13514 Signed-off-by: Costantino Leandro <lcostantino@gmail.com> Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Cc: Len Brown <len.brown@intel.com> Cc: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* ACPI: WMI: use .notify method instead of installing handler directlyBjorn Helgaas2009-04-071-12/+3
| | | | | | | | | | This patch adds a .notify() method. The presence of .notify() causes Linux/ACPI to manage event handlers and notify handlers on our behalf, so we don't have to install and remove them ourselves. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Len Brown <len.brown@intel.com>
* acpi-wmi: unsigned cannot be less than 0Roel Kluin2009-03-161-1/+1
| | | | | | | | | | | | | include/linux/pci-acpi.h:74: typedef u32 acpi_status; result is unsigned, so an error returned by acpi_bus_register_driver() will not be noticed. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Len Brown <len.brown@intel.com>
* ACPI: move wmi, asus_acpi, toshiba_acpi to drivers/platform/x86Len Brown2008-12-191-0/+747
These are platform specific drivers that happen to use ACPI, while drivers/acpi/ is for code that implements ACPI itself. Signed-off-by: Len Brown <len.brown@intel.com>