summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/panasonic-laptop.c
AgeCommit message (Collapse)Author
2022-11-23ACPI: make remove callback of ACPI driver voidDawei Li
For bus-based driver, device removal is implemented as: 1 device_remove()-> 2 bus->remove()-> 3 driver->remove() Driver core needs no inform from callee(bus driver) about the result of remove callback. In that case, commit fc7a6209d571 ("bus: Make remove callback return void") forces bus_type::remove be void-returned. Now we have the situation that both 1 & 2 of calling chain are void-returned, so it does not make much sense for 3(driver->remove) to return non-void to its caller. So the basic idea behind this change is making remove() callback of any bus-based driver to be void-returned. This change, for itself, is for device drivers based on acpi-bus. Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Lee Jones <lee@kernel.org> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dawei Li <set_pte_at@outlook.com> Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for drivers/platform/surface/* Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-10-03platform/x86: use PLATFORM_DEVID_NONE instead of -1Barnabás Pőcze
Use the `PLATFORM_DEVID_NONE` constant instead of hard-coding -1 when creating a platform device. No functional changes are intended. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20220930104857.2796923-1-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-06-28platform/x86: panasonic-laptop: Use acpi_video_get_backlight_type()Hans de Goede
Use acpi_video_get_backlight_type() to determine if we should register the panasonic specific backlight interface. To avoid registering this on systems where the ACPI or GPU native backlight control methods should be used instead. Tested-by: Stefan Seyfried <seife+kernel@b1-systems.com> Tested-by: Kenneth Chan <kenneth.t.chan@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-8-hdegoede@redhat.com
2022-06-28platform/x86: panasonic-laptop: filter out duplicate volume up/down/mute ↵Hans de Goede
keypresses On some Panasonic models the volume up/down/mute keypresses get reported both through the Panasonic ACPI HKEY interface as well as through the atkbd device. Filter out the atkbd scan-codes for these to avoid reporting presses twice. Note normally we would leave the filtering of these to userspace by mapping the scan-codes to KEY_UNKNOWN through /lib/udev/hwdb.d/60-keyboard.hwdb. However in this case that would cause regressions since we were filtering the Panasonic ACPI HKEY events before, so filter these in the kernel. Fixes: ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug") Reported-and-tested-by: Stefan Seyfried <seife+kernel@b1-systems.com> Reported-and-tested-by: Kenneth Chan <kenneth.t.chan@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-7-hdegoede@redhat.com
2022-06-28platform/x86: panasonic-laptop: don't report duplicate brightness key-pressesHans de Goede
The brightness key-presses might also get reported by the ACPI video bus, check for this and in this case don't report the presses to avoid reporting 2 presses for a single key-press. Fixes: ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug") Reported-and-tested-by: Stefan Seyfried <seife+kernel@b1-systems.com> Reported-and-tested-by: Kenneth Chan <kenneth.t.chan@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-6-hdegoede@redhat.com
2022-06-28platform/x86: panasonic-laptop: revert "Resolve hotkey double trigger bug"Hans de Goede
In hindsight blindly throwing away most of the key-press events is not a good idea. So revert commit ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug"). Fixes: ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug") Reported-and-tested-by: Stefan Seyfried <seife+kernel@b1-systems.com> Reported-and-tested-by: Kenneth Chan <kenneth.t.chan@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-5-hdegoede@redhat.com
2022-06-28platform/x86: panasonic-laptop: sort includes alphabeticallyHans de Goede
Sort includes alphabetically, small cleanup patch in preparation of further changes. Fixes: ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-4-hdegoede@redhat.com
2022-06-28platform/x86: panasonic-laptop: de-obfuscate button codesStefan Seyfried
In the definition of panasonic_keymap[] the key codes are given in decimal, later checks are done with hexadecimal values, which does not help in understanding the code. Additionally use two helper variables to shorten the code and make the logic more obvious. Fixes: ed83c9171829 ("platform/x86: panasonic-laptop: Resolve hotkey double trigger bug") Signed-off-by: Stefan Seyfried <seife+kernel@b1-systems.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220624112340.10130-3-hdegoede@redhat.com
2021-10-19platform/x86: panasonic-laptop: Replace snprintf in show functions with ↵Qing Wang
sysfs_emit show() must not use snprintf() when formatting the value to be returned to user space. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit instead of scnprintf or sprintf makes more sense. Signed-off-by: Qing Wang <wangqing@vivo.com> Link: https://lore.kernel.org/r/1634280641-4862-1-git-send-email-wangqing@vivo.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-04-07platform/x86: panasonic-laptop: remove redundant assignment of variable resultColin Ian King
The variable result is being assigned a value that is never read and it is being updated later with a new value. The assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210326192022.623001-1-colin.king@canonical.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Add sysfs attributes for firmware brightness ↵Kenneth Chan
registers Panasonic laptops (at least from CF-W4 onwards) have dedicated firmware registers for saving ac/dc and current brightness. They are a bit confusing so here's some explanations: AC_MIN_BRIGHT, AC_MAX_BRIGHT, DC_MIN_BRIGHT, DC_MAX_BRIGHT: Read-only. Values: 0x01 and 0x15 respectively. AC_CUR_BRIGHT, DC_CUR_BRIGHT: Read-Write. 0x00-0xFF. Store user-defined AC/DC brightness. However, they do not represent current brightness so they should be named AC_BRIGHT and DC_BRIGHT instead. CUR_BRIGHT (present since CF-W4): Read-Write. 0x00-0xFF. It sets the current brightness. It won't update itself if brightness is changed via other means, e.g. acpi_video0. Another CUR_BRIGHT (added since CF-W5): Read-Write. 0x01-0x15. Its value always synchronizes with current brightness. Not implemented in this version. Currently the backlight API interacts with AC_CUR_BRIGHT (probably because it's the only bl register available in earlier models?). This patch adds sysfs attributes for AC_CUR_BRIGHT, DC_CUR_BRIGHT and CUR_BRIGHT. It also fixes the error of https://lkml.org/lkml/2020/8/19/1264. PS: I think the backlight API should interact with CUR_BRIGHT instead of AC_CUR_BRIGHT. But it involves complications like mapping between 0x01-0x15 or 0x00-0x14 (the backlight API) and 0x00-0xFF (CUR_BRIGHT). I'll leave the discussion for a later version. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-10-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Add support for battery charging threshold ↵Kenneth Chan
(eco mode) Add battery charging threshold (aka ECO mode) support. NOTE: The state of ECO mode is persistent until the next POST cycle which reset it to previous state. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-9-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Resolve hotkey double trigger bugKenneth Chan
Sometimes double ACPI events are triggered for brightness, vol and mute hotkeys. This patch fixes it. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-8-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Add write support to muteKenneth Chan
Add write support to the mute platform device Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-7-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Fix sticky key init bugKenneth Chan
The return value of the sticky key on some models (e.g. CF-W5) do not reflect its state. How to retrieve its state from firmware is unknown. The safest bet is to reset it at module init and store its state in pcc struct. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-6-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Fix naming of platform files for consistency ↵Kenneth Chan
with other modules Change platform device function names for consistency with other modules Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-5-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Split MODULE_AUTHOR() by one author per ↵Kenneth Chan
macro call In reply to https://lkml.org/lkml/2020/8/19/186 to split MODULE_AUTHOR() per macro call. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-4-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Replace ACPI prints with pr_*() macrosKenneth Chan
Replace ACPI prints with pr_*() macros for consistency with other platform devices. Clean up obsolete ACPI_HOTKEY_COMPONENT code. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-3-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-11-10platform/x86: panasonic-laptop: Add support for optical driver power in Y ↵Kenneth Chan
and W series The physical optical drive switch is present in Y and W series that switches on the drive but fails to turn it off. The idea is to be able to toggle the drive power by software and/or hardware. This patch merges Martin Lucina <mato@kotelna.sk>'s work that took care of the software part. Code is also added for the physical switch to power off the drive. Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-2-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 392Thomas Gleixner
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as publicshed by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 59 temple place suite 330 boston ma 02111 1307 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 1 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190531081038.107748302@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-12treewide: kzalloc() -> kcalloc()Kees Cook
The kzalloc() function has a 2-factor argument form, kcalloc(). This patch replaces cases of: kzalloc(a * b, gfp) with: kcalloc(a * b, gfp) as well as handling cases of: kzalloc(a * b * c, gfp) with: kzalloc(array3_size(a, b, c), gfp) as it's slightly less ugly than: kzalloc_array(array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: kzalloc(4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( kzalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kzalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kzalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(__u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(char) * COUNT + COUNT , ...) | kzalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kzalloc + kcalloc ( - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( kzalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( kzalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( kzalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( kzalloc(C1 * C2 * C3, ...) | kzalloc( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kzalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( kzalloc(sizeof(THING) * C2, ...) | kzalloc(sizeof(TYPE) * C2, ...) | kzalloc(C1 * C2 * C3, ...) | kzalloc(C1 * C2, ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - (E1) * E2 + E1, E2 , ...) | - kzalloc + kcalloc ( - (E1) * (E2) + E1, E2 , ...) | - kzalloc + kcalloc ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2017-07-11platform/x86: panasonic-laptop: constify attribute_group structures.Arvind Yadav
attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 2505 600 4 3109 c25 drivers/platform/x86/panasonic-laptop.o File size After adding 'const': text data bss dec hex filename 2569 536 4 3109 c25 drivers/platform/x86/panasonic-laptop.o Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
2017-06-13platform/x86: panasonic-laptop: remove unused codeAlex Hung
The struct pcc_keyinput is not used in panasonic-laptop and in anywhere in kernel, and it can be removed. Signed-off-by: Alex Hung <alex.hung@canonical.com> Acked-by: Harald Welte <laforge@gnumonks.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-03-14platform/x86: panasonic-laptop: remove sparse_keymap_free() callsMichał Kępień
As sparse_keymap_setup() now uses a managed memory allocation for the keymap copy it creates, the latter is freed automatically. Remove all calls to sparse_keymap_free(). As this reduces acpi_pcc_destroy_input() to one line, replace all calls to that function with direct calls to input_unregister_device(). Signed-off-by: Michał Kępień <kernel@kempniu.pl> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2016-12-13platform/x86: Use ACPI_FAILURE at appropriate placesAxel Lin
Use ACPI_FAILURE() to replace !ACPI_SUCCESS(), this avoid !! operations. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2014-04-06Fix sleep / suspend keys for Toughbook CF-51Stefan Seyfried
Hi all, my panasonic cf-51 does no longer react to the suspend and hibernate keys. I cannot tell when this started since I no longer use the machine on a daily basis, but I suspect it started when userspace switched from using /proc/acpi/event to the input layer, wich was quite some time ago ;-) Today I investigated the issue and found that the firmware simply does not generate any event on "key down" for those keys, but only on "key up". The attached patch works around the problem. Best regards, Stefan -- Stefan Seyfried Linux Consultant & Developer -- GPG Key: 0x731B665B B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 >From 7c96fee748cfd3e64732a7ac142f5dea07d7379f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried <seife+kernel@b1-systems.com> Date: Sun, 2 Mar 2014 17:50:01 +0100 Subject: [PATCH] panasonic-laptop: fix sleep keys on CF-51 At least on my CF-51, both sleep and hibernate keys do not generate "key down" events, only "key up". Because of this, the input layer does ignore both keys. The work around is to generate a key down event before the key up. To avoid double events on non-broken firmware, this is only done if no key down is ever seen for those keys. Signed-off-by: Stefan Seyfried <seife+kernel@b1-systems.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
2014-01-12Merge branch 'acpi-cleanup'Rafael J. Wysocki
* acpi-cleanup: (22 commits) ACPI / tables: Return proper error codes from acpi_table_parse() and fix comment. ACPI / tables: Check if id is NULL in acpi_table_parse() ACPI / proc: Include appropriate header file in proc.c ACPI / EC: Remove unused functions and add prototype declaration in internal.h ACPI / dock: Include appropriate header file in dock.c ACPI / PCI: Include appropriate header file in pci_link.c ACPI / PCI: Include appropriate header file in pci_slot.c ACPI / EC: Mark the function acpi_ec_add_debugfs() as static in ec_sys.c ACPI / NVS: Include appropriate header file in nvs.c ACPI / OSL: Mark the function acpi_table_checksum() as static ACPI / processor: initialize a variable to silence compiler warning ACPI / processor: use ACPI_COMPANION() to get ACPI device ACPI: correct minor typos ACPI / sleep: Drop redundant acpi_disabled check ACPI / dock: Drop redundant acpi_disabled check ACPI / table: Replace '1' with specific error return values ACPI: remove trailing whitespace ACPI / IBFT: Fix incorrect <acpi/acpi.h> inclusion in iSCSI boot firmware module ACPI / i915: Fix incorrect <acpi/acpi.h> inclusions via <linux/acpi_io.h> SFI / ACPI: Fix warnings reported during builds with W=1 ... Conflicts: drivers/acpi/nvs.c drivers/hwmon/asus_atk0110.c
2013-12-07ACPI: Clean up inclusions of ACPI header filesLv Zheng
Replace direct inclusions of <acpi/acpi.h>, <acpi/acpi_bus.h> and <acpi/acpi_drivers.h>, which are incorrect, with <linux/acpi.h> inclusions and remove some inclusions of those files that aren't necessary. First of all, <acpi/acpi.h>, <acpi/acpi_bus.h> and <acpi/acpi_drivers.h> should not be included directly from any files that are built for CONFIG_ACPI unset, because that generally leads to build warnings about undefined symbols in !CONFIG_ACPI builds. For CONFIG_ACPI set, <linux/acpi.h> includes those files and for CONFIG_ACPI unset it provides stub ACPI symbols to be used in that case. Second, there are ordering dependencies between those files that always have to be met. Namely, it is required that <acpi/acpi_bus.h> be included prior to <acpi/acpi_drivers.h> so that the acpi_pci_root declarations the latter depends on are always there. And <acpi/acpi.h> which provides basic ACPICA type declarations should always be included prior to any other ACPI headers in CONFIG_ACPI builds. That also is taken care of including <linux/acpi.h> as appropriate. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Matthew Garrett <mjg59@srcf.ucam.org> Cc: Tony Luck <tony.luck@intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> (drivers/pci stuff) Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> (Xen stuff) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-11-20platform:x86: Remove OOM message after input_allocate_deviceJoe Perches
Emitting an OOM message isn't necessary after input_allocate_device as there's a generic OOM and a dump_stack already done. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
2013-09-05platform/x86: panasonic-laptop: reuse module_acpi_driverAndy Shevchenko
There is a macro to register and unregister modules in simple cases, Let's use it and clean up the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
2013-07-15ACPI: Remove the old /proc/acpi/event interfaceThomas Renninger
It is quite some time that this one has been deprecated. Get rid of it. Should some really important user be overseen, it may be reverted and the userspace program worked on first, but it is time to do something to get rid of this old stuff... Signed-off-by: Thomas Renninger <trenn@suse.de> Acked-by: Matthew Garrett <matthew.garrett@nebula.com> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-01-26ACPI: Remove useless type argument of driver .remove() operationRafael J. Wysocki
The second argument of ACPI driver .remove() operation is only used by the ACPI processor driver and the value passed to that driver through it is always available from the given struct acpi_device object's removal_type field. For this reason, the second ACPI driver .remove() argument is in fact useless, so drop it. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Jiang Liu <jiang.liu@huawei.com> Acked-by: Toshi Kani <toshi.kani@hp.com> Acked-by: Yinghai Lu <yinghai@kernel.org>
2012-08-10platform / x86 / PM: Fix unused function warnings for CONFIG_PM_SLEEPRafael J. Wysocki
According to compiler warnings, quite some suspend/resume functions in platform x86 drivers are not used for CONFIG_PM_SLEEP unset, so add #ifdefs to prevent them from being built in that case. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
2012-07-01panasonic-laptop: Use struct dev_pm_ops for power managementRafael J. Wysocki
Make the panasonic-laptop driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct acpi_device_ops. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
2012-03-12panasonic-laptop: avoid overflow in acpi_pcc_hotkey_add()Xi Wang
num_sifr could go negative since acpi_pcc_get_sqty() returns -EINVAL on error. Then it could bypass the sanity check (num_sifr > 255). The subsequent call to kzalloc() would allocate a small buffer, leading to a memory corruption. Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
2011-03-22backlight: add backlight typeMatthew Garrett
There may be multiple ways of controlling the backlight on a given machine. Allow drivers to expose the type of interface they are providing, making it possible for userspace to make appropriate policy decisions. Signed-off-by: Matthew Garrett <mjg@redhat.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: David Airlie <airlied@linux.ie> Cc: Alex Deucher <alexdeucher@gmail.com> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Len Brown <lenb@kernel.org> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-10-21panasonic-laptop: Simplify calls to acpi_pcc_retrieve_biosdataJean Delvare
Function acpi_pcc_retrieve_biosdata is always called with parameters (pcc, pcc->sinf), so we can drop the second parameter. It was dangerous to pass the sinf array separately anyway, as its length is checked as pcc->num_sifr, which pretty much assumed it was pcc->sinf (or at least had the same size.) This change makes the code slightly more compact and thus marginally faster. Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Harald Welte <laforge@gnumonks.org> Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-10-21panasonic-laptop: Handle errors properly if they happenJean Delvare
acpi_pcc_retrieve_biosdata() returns success instead of error if HKEY.SINF is invalid. Fix this. Furthermore, if acpi_pcc_retrieve_biosdata() returns an error during device addition, initialization is properly reverted but value 0 is returned, which means success. This would cause a crash when later using or removing the device, so fix this too. Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Harald Welte <laforge@gnumonks.org> Cc: Bruno Premont <bonbons@linux-vserver.org> Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-10-21panasonic-laptop - switch to using sparse keymap libraryDmitry Torokhov
nstead of implementing its own version of keymap hanlding switch over to using sparse keymap library. Cc: Harald Welte <laforge@gnumonks.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-08-03panasonic-laptop: fix acpi_pcc_write_sset return valueAxel Lin
In current implementation, acpi_pcc_write_sset return 1 if write is successful, 0 if write is failed. But all the callers consider acpi_pcc_write_sset return 0 if write is successful and return negtive if write is failed. This patch changes the implementation of acpi_pcc_write_sset to return 0 if write is successful, -EIO if write is failed. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo
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-16backlight: panasonic-laptop - Fix incomplete registration failure handlingBruno Prémont
Properly return backlight registration error to parent. Mark struct backlight_ops as const. Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org> Acked-by: Harald Welte <laforge@gnumonks.org> (registration failure) Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-16backlight: Allow properties to be passed at registrationMatthew Garrett
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-08Input: scancode in get/set_keycodes should be unsignedDmitry Torokhov
The HID layer has some scan codes of the form 0xffbc0000 for logitech devices which do not work if scancode is typed as signed int, so we need to switch to unsigned it instead. While at it keycode being signed does not make much sense either. Acked-by: Márton Németh <nm127@freemail.hu> Acked-by: Matthew Garrett <mjg@redhat.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
2009-04-07Merge branches 'release', 'APERF', 'ARAT', 'misc', 'kelvin', 'device-lock' ↵Len Brown
and 'bjorn.notify' into release
2009-04-07panasonic-laptop: use .notify method instead of installing handler directlyBjorn Helgaas
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: Harald Welte <laforge@gnumonks.org> Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-07NULL noise: drivers/platform/x86/panasonic-laptop.cHannes Eder
Fix this sparse warning: drivers/platform/x86/panasonic-laptop.c:273:70: warning: Using plain integer as NULL pointer Signed-off-by: Hannes Eder <hannes@hanneseder.net> Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-03panasonic-laptop: use snprintf with PAGE_SIZE in sysfs attributesHarald Welte
Instead of just sprintf() into the page-sized buffer provided by the sysfs/device_attribute API, we use snprintf with PAGE_SIZE as an additional safeguard. Signed-off-by: Martin Lucina <mato@kotelna.sk> Signed-off-by: Harald Welte <laforge@gnumonks.org> Signed-off-by: Len Brown <len.brown@intel.com>
2009-04-03panasonic-laptop: Fix autoloadingHarald Welte
This patch adds MODULE_DEVICE_TABLE() to panasonic-laptop.c in order to ensure automatic loading of the module on systems with the respective "MAT*" ACPI devices. Signed-off-by: Martin Lucina <mato@kotelna.sk> Signed-off-by: Harald Welte <laforge@gnumonks.org> Signed-off-by: Len Brown <len.brown@intel.com>
2009-01-17panasonic-laptop: fix X[ ARRAY_SIZE(X) ]Roel Kluin
Ensure pcc->keymap[ ARRAY_SIZE(pcc->keymap) ] does not occur. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>