History log of /linux-master/drivers/platform/x86/toshiba_acpi.c
Revision Date Author Comments
# 0dd50b3e 02-Apr-2024 Hans de Goede <hdegoede@redhat.com>

platform/x86: toshiba_acpi: Silence logging for some events

Stop logging unknown event / unknown keycode messages on suspend /
resume on a Toshiba Portege Z830:

1. The Toshiba Portege Z830 sends a 0x8e event when the power button
is pressed, ignore this.

2. The Toshiba Portege Z830 sends a 0xe00 hotkey event on resume from
suspend, ignore this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240402124351.167152-1-hdegoede@redhat.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


# f5a08ed5 11-May-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

platform/x86: toshiba: constify pointers to hwmon_channel_info

Statically allocated array of pointers to hwmon_channel_info can be made
const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230511175627.282246-4-krzysztof.kozlowski@linaro.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 6c0eb5ba 13-Nov-2022 Dawei Li <set_pte_at@outlook.com>

ACPI: make remove callback of ACPI driver void

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>


# 878a82c2 27-Sep-2022 Armin Wolf <W_Armin@gmx.de>

ACPI: battery: Pass battery hook pointer to hook callbacks

Right now, is impossible for battery hook callbacks
to access instance-specific data, forcing most drivers
to provide some sort of global state. This however is
difficult for drivers which can be instantiated multiple
times and/or are hotplug-capable.

Pass a pointer to the battery hook to those callbacks
for usage with container_of().

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20220927204521.601887-2-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 58900325 20-Sep-2022 Yang Yingliang <yangyingliang@huawei.com>

platform/x86: toshiba_acpi: change turn_on_panel_on_resume to static

turn_on_panel_on_resume is only used in toshiba_acpi.c now, change it
to static.

Fixes: 3cb1f40dfdc3 ("drivers/platform: toshiba_acpi: Call HCI_PANEL_POWER_ON on resume on some models")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220920084434.3739493-1-yangyingliang@huawei.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 8755e675 19-Sep-2022 Yihao Han <hanyihao@vivo.com>

platform/x86: toshiba_acpi: Remove duplicate include

Remove duplicate include in toshiba_acpi.c.

Signed-off-by: Yihao Han <hanyihao@vivo.com>
Link: https://lore.kernel.org/r/20220919111519.19491-1-hanyihao@vivo.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 4b93c6ea 11-Sep-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: toshiba_acpi: Set correct parent for input device.

This solves the input device showing up as a virtual device.

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220911193106.555938-1-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 3cb1f40d 29-Aug-2022 Hans de Goede <hdegoede@redhat.com>

drivers/platform: toshiba_acpi: Call HCI_PANEL_POWER_ON on resume on some models

Some Toshibas have a broken acpi-video interface for brightness control, so
far these have been using a special workaround in drivers/acpi/acpi_video.c
which gets activated by the disable_backlight_sysfs_if module-param/quirks.

The recent x86/acpi backlight refactoring has broken this workaround:
1. This workaround relies on acpi_video_get_backlight_type() returning
acpi_video so that the acpi_video code actually runs; and
2. this relies on the actual native GPU driver to offer the sysfs
backlight interface to userspace.

After the refactor this breaks since the native driver will no
longer register its backlight-device if acpi_video_get_backlight_type()
does not return native and making it return native breaks 1.

Keeping the acpi_video backlight handling on resume active, while not
using it to set the brightness, is necessary because it does a _BCM
call on resume which is necessary to turn the panel back on on resume.

Looking at the DSDT shows that this _BCM call results in a Toshiba
HCI_SET HCI_LCD_BRIGHTNESS call, which turns the panel back on.

This commit makes toshiba_acpi do a HCI_SET HCI_PANEL_POWER_ON call
on resume on the affected models, so that the (now broken)
acpi_video disable_backlight_sysfs_if workaround will no longer
be necessary.

Note this uses HCI_PANEL_POWER_ON instead of HCI_LCD_BRIGHTNESS
to avoid changing the configured brightness level.

Tested-by: Arvid Norlander <lkml@vorpal.se>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 8ef5db9e 02-Sep-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: Battery charge mode in toshiba_acpi (sysfs)

This commit adds the ACPI battery hook which in turns adds the sysfs
entries.

Because the Toshiba laptops only support two modes (eco or normal), which
in testing correspond to 80% and 100% we simply round to the nearest
possible level when set.

It is possible that Toshiba laptops other than the Z830 has different set
points for the charging. If so, a quirk table could be introduced in the
future for this. For now, assume that all laptops that support this feature
work the same way.

Tested on a Toshiba Satellite Z830.

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220902180037.1728546-3-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 89655fbb 02-Sep-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: Battery charge mode in toshiba_acpi (internals)

This commit adds the internal functions to control the Toshiba laptop.

Unlike for example ThinkPads where this control is granular here it is
just off/on. When off it charges to 100%. When on it charges to about 80%.

Controlling this setting is done via HCI register 0x00ba. Setting to value
1 will result in limiting the charing to 80% of the battery capacity,
while setting it to 0 will allow charging to 100%.

Reading the current state is a bit weird, and needs a 1 set in the last
position of the query for whatever reason. In addition, the read may
return 0x8d20 (Data not available) rarely, so a retry mechanism is needed.

According to the Windows program used to control the feature the setting
will not take effect until the battery has been discharged to around 50%.
However, in my testing it takes effect as soon as the charge drops below
80%. On Windows Toshiba branded this feature as "Eco charging".

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220902180037.1728546-2-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# c727ba4c 02-Sep-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: toshiba_acpi: Add fan RPM reading (hwmon interface)

This expands on the previous commit, exporting the fan RPM via hwmon.

This will look something like the following when using the "sensors"
command from lm_sensors:

toshiba_acpi_sensors-acpi-0
Adapter: ACPI interface
fan1: 0 RPM

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220902174018.1720029-3-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# dd193dcd 02-Sep-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: toshiba_acpi: Add fan RPM reading (internals)

This add the internal feature detection and reading function for fan RPM.

The approach is based on tracing ACPI calls using AMLI (a tracer/debugger
built into ACPI.sys) while using the Windows cooling self-test software.

The call used is {HCI_GET, 0x45, 0, 1, 0, 0} which returns:
{0x0, 0x45, fan_rpm, probably_max_rpm, 0x0, 0x0}

What is probably the max RPM is not currently used.

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220902174018.1720029-2-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# a2ed70d0 04-Jun-2022 Hans de Goede <hdegoede@redhat.com>

platform/x86: toshiba_acpi: Stop using acpi_video_set_dmi_backlight_type()

acpi_video_set_dmi_backlight_type() is troublesome because it may end up
getting called after other backlight drivers have already called
acpi_video_get_backlight_type() resulting in the other drivers
already being registered even though they should not.

In case of the acpi_video backlight, acpi_video_set_dmi_backlight_type()
actually calls acpi_video_unregister_backlight() since that is often
probed earlier, leading to userspace seeing the acpi_video0 class
device being briefly available, leading to races in userspace where
udev probe-rules try to access the device and it is already gone.

In case of toshiba_acpi there are no DMI quirks to move to
acpi/video_detect.c, but it also (ab)uses it for transflective
displays. Adding transflective display support to video_detect.c would
be quite involved. But luckily there are only 2 known models with
a transflective display, so we can just add DMI quirks for those.

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 4058ea22 21-Aug-2022 Arvid Norlander <lkml@vorpal.se>

platform/x86: toshiba_acpi: Fix ECO LED control on Toshiba Z830

The toshiba_acpi driver checks for TOS_INPUT_DATA_ERROR and tries a
different format. On the Z830 the error returned is TOS_NOT_SUPPORTED
though the different format still works. Allow either error.

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220821200821.1837460-2-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 46ecf720 10-May-2022 Minghao Chi <chi.minghao@zte.com.cn>

platform/x86: toshiba_acpi: use kobj_to_dev()

Use kobj_to_dev() instead of open-coding it.

Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220511021638.1488650-1-chi.minghao@zte.com.cn
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 359745d7 21-Jan-2022 Muchun Song <songmuchun@bytedance.com>

proc: remove PDE_DATA() completely

Remove PDE_DATA() completely and replace it with pde_data().

[akpm@linux-foundation.org: fix naming clash in drivers/nubus/proc.c]
[akpm@linux-foundation.org: now fix it properly]

Link: https://lkml.kernel.org/r/20211124081956.87711-2-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 28e36712 02-Jun-2021 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard()

The error code is missing in this code scenario, add the error code
'-EINVAL' to the return value 'error'.

Eliminate the follow smatch warning:

drivers/platform/x86/toshiba_acpi.c:2834 toshiba_acpi_setup_keyboard()
warn: missing error code 'error'.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1622628348-87035-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 2a72c46a 21-Nov-2020 Kaixu Xia <kaixuxia@tencent.com>

platform/x86: toshiba_acpi: Fix the wrong variable assignment

The commit 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up
variable declaration") cleans up variable declaration in
video_proc_write(). Seems it does the variable assignment in the
wrong place, this results in dead code and changes the source code
logic. Fix it by doing the assignment at the beginning of the funciton.

Fixes: 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up variable declaration")
Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Link: https://lore.kernel.org/r/1606024177-16481-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# 5af8be6b 21-Nov-2020 Kaixu Xia <kaixuxia@tencent.com>

platform/x86: toshiba_acpi: Fix the wrong variable assignment

The commit 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up
variable declaration") cleans up variable declaration in
video_proc_write(). Seems it does the variable assignment in the
wrong place, this results in dead code and changes the source code
logic. Fix it by doing the assignment at the beginning of the funciton.

Fixes: 78429e55e4057 ("platform/x86: toshiba_acpi: Clean up variable declaration")
Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Link: https://lore.kernel.org/r/1606024177-16481-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

treewide: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# 78289b4a 03-Jun-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: core: pass parent device as parameter during allocation

The change passes the parent device to the iio_device_alloc() call. This
also updates the devm_iio_device_alloc() call to consider the device object
as the parent device by default.

Having it passed like this, should ensure that any IIO device object
already has a device object as parent, allowing for neater control, like
passing the 'indio_dev' object for other stuff [like buffers/triggers/etc],
and potentially creating iiom_xxx(indio_dev) functions.

With this patch, only the 'drivers/platform/x86/toshiba_acpi.c' needs an
update to pass the parent object as a parameter.

In the next patch all devm_iio_device_alloc() calls will be handled.

Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 409f3aed 07-May-2020 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

platform/x86: toshiba_acpi: Drop duplicate check for led_classdev_unregister()

led_classdev_unregister() already has the similar check, so,
drop a duplicate in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# 97a32539 03-Feb-2020 Alexey Dobriyan <adobriyan@gmail.com>

proc: convert everything to "struct proc_ops"

The most notable change is DEFINE_SHOW_ATTRIBUTE macro split in
seq_file.h.

Conversion rule is:

llseek => proc_lseek
unlocked_ioctl => proc_ioctl

xxx => proc_xxx

delete ".owner = THIS_MODULE" line

[akpm@linux-foundation.org: fix drivers/isdn/capi/kcapi_proc.c]
[sfr@canb.auug.org.au: fix kernel/sched/psi.c]
Link: http://lkml.kernel.org/r/20200122180545.36222f50@canb.auug.org.au
Link: http://lkml.kernel.org/r/20191225172546.GB13378@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 9ab65aff 19-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 7

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 as published by
the free software foundation either version 2 of the license or at
your option any later version 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 the full
gnu general public license is included in this distribution in the
file called copying

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 9 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154041.244154651@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c2e2a618 06-Jul-2018 Randy Dunlap <rdunlap@infradead.org>

platform/x86: toshiba_acpi: Fix defined but not used build warnings

Fix a build warning in toshiba_acpi.c when CONFIG_PROC_FS is not enabled
by marking the unused function as __maybe_unused.

../drivers/platform/x86/toshiba_acpi.c:1685:12: warning: 'version_proc_show' defined but not used [-Wunused-function]

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Azael Avalos <coproscefalo@gmail.com>
Cc: platform-driver-x86@vger.kernel.org
Cc: Andy Shevchenko <andy@infradead.org>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>


# 147288e6 15-Jun-2018 Azael Avalos <coproscefalo@gmail.com>

platform/x86: toshiba_acpi: Update KBD backlight LED on second gen laptops

Second generation keyboard backlight (type 2) laptops can switch
on the keyboard LED on their own via hardware/firmware, but the
LED subsystem is unaware of such change since the LED interface
was only being created on first generation keyboard backlight
(type 1) laptops.

This patch creates the LED interface for second gen keyboards
and calls the *_hw_changed API whenever userspace changes the
state of the keyboard backlight LED.

While we are at it, remove an unneeded asignment to the acpi_dev
struct under *_kbd_bl_work, and also update the kbd_event_generated
variable in the main toshiba struct instead of the global struct.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
[dvhart: correct int* and int compare with dev->kbd_mode]
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>


# 3f3942ac 15-May-2018 Christoph Hellwig <hch@lst.de>

proc: introduce proc_create_single{,_data}

Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig <hch@lst.de>


# 2a9e7f2f 23-Jul-2017 Jonathan Cameron <jic23@kernel.org>

platform/x86: toshiba_acpi: drop assignment of iio_info.driver_module

This is now handled by use of a macro for device registration. The field
in iio_info will be going away shortly as it is no longer used.

Cc: <platform-driver-x86@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Azael Avalos <coproscefalo@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>


# 44bd76d0 11-Jul-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

platform/x86: toshiba_acpi: constify attribute_group structures.

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
26360 1072 24 27456 6b40 drivers/platform/x86/toshiba_acpi.o

File size After adding 'const':
text data bss dec hex filename
26424 1008 24 27456 6b40 drivers/platform/x86/toshiba_acpi.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>


# f0ee1a6d 06-May-2017 Geliang Tang <geliangtang@gmail.com>

platform/x86: toshiba_acpi: use memdup_user_nul

Use memdup_user_nul() helper instead of open-coding to simplify the
code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# db8f95d0 09-Mar-2017 Michał Kępień <kernel@kempniu.pl>

platform/x86: toshiba_acpi: remove sparse_keymap_free() calls

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().

Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# fa1bc2a0 29-Aug-2016 Azael Avalos <coproscefalo@gmail.com>

platform/x86: toshiba_acpi: Fix typo in *_cooling_method_set function

This patch simply fixes a typo in the error string printed in
the *_cooling_method_set function.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 513ee146 29-Aug-2016 Azael Avalos <coproscefalo@gmail.com>

platform/x86: toshiba_acpi: Change error checking logic from TCI functions

Currently the success/error checking logic is intermixed, making the
code a bit cumbersome to understand.

This patch changes the affected functions to first check for errors
and take appropriate actions, then check for the supported features.

This patch also separates the error check from the acpi_status and
the tci_raw function call error check, as those two are completely
unrelated and were nested in if/else statements.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 78429e55 29-Aug-2016 Azael Avalos <coproscefalo@gmail.com>

platform/x86: toshiba_acpi: Clean up variable declaration

This patch moves all the multiple line variable declaration to a
single line declaration (except variables being initialized)
following the reverse tree order, to conform to the practices
of the kernel.

[dvhart: corrected a couple minor inconsistencies in declaration ordering]

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 95d16d81 27-Jun-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Bump driver version and update copyright year

After several fixes, and added support for more features (WWAN,
Cooling Method and IIO accelometer axis data), bump the driver
version to 0.24.

Also update the copyright year.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 2fd67884 27-Jun-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove the position sysfs entry

Now that we have proper support for the acceleromeer under the IIO
subsystem, the _position_ sysfs file is now deprecated.

This patch removes all code related to the position sysfs entry.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 98010f1e 27-Jun-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add IIO interface for accelerometer axis data

This patch adds the accelerometer axis data to the IIO subsystem.

Currently reporting the X, Y and Z values, as no other data can be
queried given the fact that the accelerometer chip itself is hidden
behind the Toshiba proprietary interface.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# a30b8f81 22-Apr-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix regression caused by hotkey enabling value

Commit 52cbae0127ad ("toshiba_acpi: Change default Hotkey enabling value")
changed the hotkeys enabling value, as it was the same value Windows uses,
however, it turns out that the value tells the EC that the driver will now
take care of the hardware events like the physical RFKill switch or the
pointing device toggle button.

This patch reverts such commit by changing the default hotkey enabling
value to 0x09, which enables hotkey events only, making the hardware
buttons working again.

Fixes bugs 113331 and 114941.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 7faa6a37 25-Jan-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add a module parameter to disable hotkeys registration

Some laptop models have working hotkeys without the need of the driver
to activate them.

This patch adds a module parameter to tell the driver not to register
the hotkeys.

The new parameter is useful in DE less installations or where the DE
does not handle the hotkeys (see bug 99501).

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# b1009b91 25-Jan-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add sysfs entries for the Cooling Method feature

This patch adds the sysfs entry

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 763ff32f 25-Jan-2016 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for cooling method feature

This patch adds support to query and set the "Cooling Method" feature,
which basically changes how the system fan behaves, depending on the
supported cooling methods.

Depending on the laptop model, these are the (so far...) available
cooling methods:
- Maximum Performance
- Performance
- Battery Optimized

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 65e3cf9c 23-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix keyboard backlight sysfs entries not being updated

Certain Toshiba models with the second generation keyboard backlight
(type 2) do not generate the keyboard backlight changed event (0x92),
and thus, the sysfs entries are never being updated.

This patch adds a workquee and a global boolean variable to address
the issue.

For those models that do generate the event, the sysfs entries are
being updated via the *notify function and the boolean is set to
true to avoid a second call to update the entries.

For those models that do not generate the event, the workquee is
used to update the sysfs entries and also to emulate the event via
netlink, to make userspace aware of such change.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 2fdde834 23-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add WWAN RFKill support

A previuos patch added WWAN support to the driver, allowing to query
and set the device status.

This patch adds RFKill support for the recently introduced WWAN device,
making use of the WWAN and *wireless_status functions to query the
killswitch and (de)activate the device accordingly to its status.

Signed-off-by: Fabian Koester <fabian.koester@bringnow.com>
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 6873f46a 23-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for WWAN devices

Toshiba laptops with WWAN devices installed cannot use the device unless
it is attached and powered, similar to how Toshiba Bluetooth devices
work.

This patch adds support to WWAN devices, introducing three functions,
one to query the overall status of the wireless devices (RFKill, WLAN,
BT, WWAN), the second queries WWAN support, and finally the third
(de)activates the device.

Signed-off-by: Fabian Koester <fabian.koester@bringnow.com>
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>ZZ
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# bae5336f 15-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix blank screen at boot if transflective backlight is supported

If transflective backlight is supported and the brightness is zero
(lowest brightness level), the set_lcd_brightness function will activate
the transflective backlight, making the LCD appear to be turned off.

This patch fixes the issue by incrementing the brightness level, and
by doing so, avoiding the activation of the tranflective backlight.

Cc: <stable@vger.kernel.org> # 4.3+
Reported-and-tested-by: Fabian Koester <fabian.koester@bringnow.com>
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 13ae84f9 15-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Propagate the hotkey value via genetlink

The driver uses genetlink to inform userspace of events generated by
the system, but the data passed is always zero as there is no data to
pass, except for the hotkey event.

This patch propagates the hotkey value via genetlink so userspace can
make use of it.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# d2f20619 04-Nov-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Initialize hotkey_event_type variable

Commit 53147b6cabee5e8d1997b5682fcc0c3b72ddf9c2 ("toshiba_acpi: Fix
hotkeys registration on some toshiba models") fixed an issue on some
laptops regarding hotkeys registration, however, if failed to address
the initialization of the hotkey_event_type variable, and thus, it can
lead to potential unwanted effects as the variable is being checked.

This patch initializes such variable to avoid such unwanted effects.

Cc: <stable@vger.kernel.org> # 4.1+
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 10e6aaab 18-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove unneeded u32 variables from *setup_keyboard

The function toshiba_acpi_setup_keyboard currently has two u32 variables
used to store the Hotkey Event Type and the result of the HCI_SYSTEM_EVENT
query.

This patch removes those two variables, as we already have a global
variable named "hotkey_event_type" and the result of the HCI_SYSTEM_EVENT
query can be checked directly from the function.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 0b498201 09-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add 0x prefix to available_kbd_modes_show function

This patch adds the 0x prefix to the values printed by such function, the
values are already being printed in hex, but without the prefix, causing
confusion, even though the file under Documentation/ABI clearly states
that hey are hex values.

Simply add the 0x prefix to avoid such confusion.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 52cbae01 09-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change default Hotkey enabling value

The driver currently uses the hotkey enabling value of 0x09 to enable
hotkey events, but windows uses a different value (0x01).

All Toshiba laptops accept the following "hotkey" parameters:
0x01 - Enable hotkey and system events.
0x03 - Enable system events only.
0x09 - Enable hotkey events only.
0x0b - Disable (hotkey and system) events.

This patch changes the default hotkey enabling value from 0x09 to 0x01,
enabling both the hotkey and system events.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# b116fd00 09-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Unify hotkey enabling functions

Currently the driver has two functions enabling hotkeys support,
but these two functions can be merged into one.

This patch merges these two functions, moving some checks to the
*enable_hotkeys function, simplifying code in the process.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 53147b6c 09-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix hotkeys registration on some toshiba models

Commit a2b3471b5b13 ("toshiba_acpi: Use the Hotkey Event Type function
for keymap choosing") changed the *setup_keyboard function to query for
the Hotkey Event Type to help choose the correct keymap, but turns out
that here are certain Toshiba models out there not implementing this
feature, and thus, failing to continue the input device registration and
leaving such laptops without hotkey support.

This patch changes such check, and instead of returning an error if
the Hotkey Event Type is not present, we simply inform userspace about it,
changing the message printed from err to notice, making the function
responsible for registering the input device to continue.

This issue was found on a Toshiba Portege Z30-B, but there might be
some other models out there affected by this regression as well.

Cc: <stable@vger.kernel.org> # 4.1+
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# cf680eae 09-Sep-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix USB Sleep and Music always disabled

Commit e1a949c1b988 ("toshiba_acpi: Refactor *{get, set} functions return
value") made changes on the return type of the HCI/SCI functions, but a
typo on the USB Sleep and Music code is always reporting non existent
support for such feature.

This patch corrects the typo, changing an assignment to a comparison,
making the laptops with actual support for such feature to work again.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 495078f8 31-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Bump driver version to 0.23

Given that some features were added (/dev/toshiba_acpi device), some
clean-ups and minor (cosmetic) changes all over the driver code, bump
the driver version to 0.23 to reflect these overall changes.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# a6b5354f 31-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove unnecessary checks and returns in HCI/SCI functions

A previous patch added explicit feature checks for support, *SUCCESS*
and *FAILURE to the HCI/SCI *{get, set} functions.

This patch removes some unnedded checks to the driver HCI/SCI
functions given that the default error return value is now set to
-EIO, there is no need to check for other error values other than
the ones currently checking for.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# e1a949c1 31-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Refactor *{get, set} functions return value

This patch refactors the return value of the driver *{get, set}
functions, since the driver default error value is -EIO.

All the functions now check for TOS_FAILURE, TOS_NOT_SUPPORTED and
TOS_SUCCESS.

On TOS_FAILURE a pr_err message is printed informing the user of the
error (no change was made to this, except the check was added to the
functions not checking for this).

On TOS_NOT_SUPPORTED we now return -ENODEV immediately (some
functions were returning -EIO and some other were not checking)

On TOS_SUCCESS* we now return 0 (as a side effect, a new success value
was added, since some functions return one instead of zero to
indicate success).

As a special case, the LED functions now check for *FAILURE on
*set, and check for TOS_FAILURE and TOS_SUCCESS on *get with their
"default" return value set to LED_OFF.

Also the {lcd, video}_proc* functions were adapted to reflect these
changes to their parent HCI functions.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 0409cbce 31-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove "*not supported" feature prints

Currently the driver prints "*not supported" if any of the features
queried are in fact not supported, let us print the available
features instead.

This patch removes all instances pr_info printing "*not supported",
and add a new function called "print_supported_features", which will
print the available laptop features.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# ea215a3f 31-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change *available functions return type

This patch changes the *available functions return type from int to
void.

The checks for support of their respective features are done inside
such functions and there was no need to return anything as we can
flag the queried feature as supported inside these functions.

The code was adapted accordingly to these changes and two new
variables were created and another was changed from uint to bool.

Also, the function toshiba_acceleremoter_supported was renamed to
toshiba_accelerometer_available to maintain the naming consistency on
the driver.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 3e07e5ba 27-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add set_fan_status function

This patch adds a new function named "set_fan_status" to complement
its get* counterpart, as well as to avoid code duplication between
"fan_proc_write" and "fan_store".

Also, both functions (get*, set*) are now checking for TOS_FAILURE,
TOS_NOT_SUPPORTED and TOS_SUCCESS (to be on par with the rest of the
HCI/SCI functions), printing an error message, returning -ENODEV and
zero respectively.

The proc and sysfs functions were updated to reflect these changes as
well, returning -EIO for proc, and propagating the error value on the
sysfs functions.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 1e574dbf 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change some variables to avoid warnings from ninja-check

This patch changes some variables to avoid warnings from ninja-check.

We are basically moving some variables inside the conditionals where
such variables are being used, and we are checking the returned values
of some others.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# d50c9005 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Reorder toshiba_acpi_alt_keymap entries

This patch simply reorders the entries found in the new keymap by
ascending order, this is simply a cosmetic change, no functionality
was modified.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# d7e4f2e2 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove unused wireless defines

Commit 2b74103547b4 ("toshiba_acpi: Remove bluetooth rfkill code")
removed bluetooth related code, however, the wireless defines were
not removed and are unused.

This patch simply removes those defines as there is no code using
them.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 695f6060 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Transflective backlight updates

This patch changes the tr function second parameter from bool to u32,
to be on par with the rest of the TCI functions of the driver, and the
code was updated accordingly.

Also, the check for translective support was moved to the *add
function, as the {__get, set}_lcd_brightness functions make use of it.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# a88bc06e 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Avoid registering input device on WMI event laptops

Commit f11f999e9890 ("toshiba_acpi: Refuse to load on machines with
buggy INFO implementations") denied loading on laptops with a WMI Event
GUID given that such laptops manage the hotkeys via that interface,
however, such laptops have a working Toshiba Configuration Interface
(TCI), and thus, such commit denied several supported features.

This patch avoids registering the input device and ignores all hotkey
events on laptops with such WMI Event GUID, making the supported
features found in those laptops to work.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# fc5462f8 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add /dev/toshiba_acpi device

There were previous attempts to "merge" the toshiba SMM module to the
toshiba_acpi one, they were trying to imitate what the old toshiba
module does, however, some models (TOS1900 devices) come with a
"crippled" implementation and do not provide all the "features" a
"genuine" Toshiba BIOS does.

This patch adds a new device called toshiba_acpi, which aim is to
enable userspace to access the SMM on Toshiba laptops via ACPI calls.

Creating a new convenience _IOWR command to access the SCI functions
by opening/closing the SCI internally to avoid buggy BIOS, while at
the same time providing backwards compatibility.

Older programs (and new) who wish to access the SMM on newer models
can do it by pointing their path to /dev/toshiba_acpi (instead of
/dev/toshiba) as the toshiba.h header was modified to reflect these
changes as well as adds all the toshiba_acpi paths and command,
however, it is strongly recommended to use the new IOCTL for any
SCI command to avoid any buggy BIOS.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 7deef550 22-Jul-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Adapt /proc/acpi/toshiba/keys to TOS1900 devices

Since the introduction of TOS1900 devices support to the driver, the
"keys" entry under the proc directory was broken, given that it only
handled TOS620X devices accordingly.

This patch adapts the code to show the hotkey values of TOS1900
devices too, and in case some programs are still using that interface,
hotkeys reporting should now work on these devices.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 234b7cf8 16-Jun-2015 Hans de Goede <hdegoede@redhat.com>

toshiba-acpi: Port to new backlight interface selection API

Port the backlight selection logic to the new backlight interface
selection API.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Azael Avalos <coproscefalo@gmail.com>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 63ba3e28 06-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Bump driver version to 0.22

This patch simply bumps the driver version to 0.22, as significant
changes were made to the driver, such as cleanups, updated events,
keymap handling, fixes and the bluetooth rfkill code removal.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 8baec45d 06-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove TOS_FAILURE check from some functions

This patch removes the check for TOS_FAILURE whenever we are using
the tci_raw function call, as that code is only returned by the
{hci, sci}_{read, write} functions and never by the tci_raw, and
thus making that check irrelevant.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 3f75bbe9 06-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Comments cleanup

This patch simply does some misc cleanup to comments, mainly
capitalizes some left over comments from a previous clean up and
adds some comments at the beginning of some feature function calls,
as well as some misc changes to some comments.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# d37782bd 06-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Rename hci_{read, write}1 functions

This patch simply renames the hci_{read, write}1 functions to
hci_{read, write}.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 3b876000 06-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove no longer needed hci_{read, write}2 functions

This patch removes the hci_{read, write}2 functions from the driver,
and the toshiba_hotkey_event_type_get function was adapted to use the
tci_raw function.

The hci_write2 function was only used by the bluetooth rfkill code,
but since its removal, it was causing build warnings, and the
hci_read2 function was only used by the toshiba_hotkey_event_type_get
function.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 2b741035 03-May-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Remove bluetooth rfkill code

This patch removes all bluetooth rfkill related code residing in
the toshiba_acpi driver.

Separate patches will add (and adapt) the code to toshiba_bluetooth
(where it belongs).

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 358d6a2c 20-Apr-2015 Hans de Goede <hdegoede@redhat.com>

toshiba_acpi: Do not register vendor backlight when acpi_video bl is available

commit a39f46df33c6 ("toshiba_acpi: Fix regression caused by backlight extra
check code") causes the backlight to no longer work on the Toshiba Z30,
reverting that commit fixes this but restores the original issue fixed
by that commit.

Looking at the toshiba_acpi backlight code for a fix for this I noticed that
the toshiba code is the only code under platform/x86 which unconditionally
registers a vendor acpi backlight interface, without checking for acpi_video
backlight support first.

This commit adds the necessary checks bringing toshiba_acpi in line with the
other drivers, and fixing the Z30 regression without needing to revert the
commit causing it.

Chances are that there will be some Toshiba models which have a non working
acpi-video implementation while the toshiba vendor backlight interface does
work, this commit adds an empty dmi_id table where such systems can be added,
this is identical to how other drivers handle such systems.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1206036
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=86521
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-and-tested-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# bb26f189 02-Apr-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix pr_* messages from USB Sleep Functions

This patch fixes the messages displayed by the USB Sleep Functions,
they were printing wrong messages not associated to the feature
currently queried.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# c8c91842 02-Apr-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Update and fix USB Sleep and Charge modes

This patch fixes the USB Sleep and Charge mode on certain models
where the value returned by the BIOS is different, and thus, making
this feature not to work for those models.

Also, the "Typical" charging mode was added as a supported mode.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# fb42d1f4 20-Mar-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix the enabling of the Special Functions

Some Toshiba laptops with the "Special Functions" feature enabled
fail to properly enable such feature unless a specific value is
used to enable the hotkey events.

This patch adds a new function called "*_enable_special_functions",
that simply makes a call to the HCI_HOTKEY_EVENT call, but this time
we are using a different parameter to make the "Special Functions"
mode work as expected.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# a2b3471b 20-Mar-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Use the Hotkey Event Type function for keymap choosing

With the previous patch adding support to "Hotkey Event Type", we can
now use the type to distinguish which keymap to use.

This patch changes the toshiba_acpi_setup_keyboard function to make
use of the hotkey event type to choose the correct keymap without the
need to use the DMI matching list.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 56e6b353 20-Mar-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add Hotkey Event Type function and definitions

This patch adds support to query the "Hotkey Event Type" the system
supports.

There are two main event types (so far), 0x10 and 0x11, with the
first being all those laptops that have the old keyboard layout, and
the latter all those new laptops with the new keyboard layout.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# bab09e23 06-Mar-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Update events in toshiba_acpi_notify

This patch adds a few more events sent to TOSXXXX devices, some of
them are already identified, while some others simply print a message
informing the type of event received.

Also, a netlink event is generated so that userspace apps, daemons,
etc. act accordingly to these events.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# c57c0fa4 11-Feb-2015 Darren Hart <dvhart@linux.intel.com>

toshiba_acpi: Cleanup GPL header

Remove the Free Software Foundation street address paragraph and
reference COPYING.

Remove an empty TODO block.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# e0769fe6 11-Feb-2015 Darren Hart <dvhart@linux.intel.com>

toshiba_acpi: Cleanup comment blocks and capitalization

Ensure multiline comments start with /* and */ each on its own line.
Capitalize the first word of comments.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 0c3c0f10 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Make use of DEVICE_ATTR_{RO, RW} macros

This patch makes use of the DEVICE_ATTR_{RO, RW} macros to simplify
sysfs attributes declarations.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 9d309848 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Drop the toshiba_ prefix from sysfs function names

This patch removes the toshiba_ prefix from all the sysfs function
names and adapted the code according to coding style.

Also a few functions were renamed to match the sysfs entry, as this
patch is a preparation for the next patch to switch to
DEVICE_ATTR_{RO, RW, WO} macros.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 9bd1213b 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Move sysfs function and struct declarations further down

Commit 93f8c16d635e ("toshiba_acpi: Support new keyboard backlight
type") moved all the sysfs structs and function declarations further
up in order to make use of sysfs_update_group, however,
commit 805469053ba9 ("toshiba_acpi: Add keyboard backlight mode
change event") made use of that function unnecesary.

This patch moves all the sysfs structs and function declarations
further down, making the file shorther in lines and more readable.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# b5163992 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Clean file according to coding style

This patch simply cleans the the driver out of 2 errors and 17
warnings according to "checkpatch -f", no functionality was changed,
simply a cleanup.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 7216d702 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Bump version number to 0.21

Several new features were added on previous patches, so lets bump up
the driver version.

And also, update the copyright year.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 17fe4b3d 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support to enable/disable USB 3

Toshiba laptops that come with USB 3 ports have a feature that lets
them disable USB 3 functionality and act as a regular USB 2 port, and
thus, saving power.

This patch adds support to that feature, by creating a sysfs entry
named "usb_three", acceptig only two parameters, 0 to disable the
USB 3 (acting as a USB 2) and 1 to enable it, however, a reboot is
needed everytime this is toggled.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 35d53cea 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for Panel Power ON

Toshiba laptops come with a feature called "Panel Open - Power ON",
which makes the laptop turn on whenever the LID is opened.

This patch adds support for such feature, by creating a sysfs entry
named "panel_power_on", accepting only two values, 0 to disable and
1 to enable such feature, however, a reboot is needed on every mode
change.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# bae84195 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for Keyboard functions mode

Recent Toshiba laptops that come with the new keyboard layout have
the Special Functions (hotkeys) enabled by default, which, in order to
access the F{1-12} keys, you need to press the FN-F{1-12} key to
access such key.

This patch adds support to toggle the Keyboard Functions operation
mode by creating the sysfs entry "kbd_functions_keys", accepting only
two parameters, 0 to set the "Normal Operation" mode and 1 to set the
"Special Functions" mode, however, everytime the mode is toggled, a
restart is needed.

In the "Normal Operation" mode, the F{1-12} keys are as usual and
the hotkeys are accessed via FN-F{1-12}.

In the "Special Functions" mode, the F{1-12} keys trigger the hotkey
and the F{1-12} keys are accessed via FN-F{1-12}.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 94477d4c 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add fan entry to sysfs

This patch adds a fan entry to sysfs, enabling the user to get and
set the fan status.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# c6c68ff8 10-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add version entry to sysfs

This patch adds a new entry to the sysfs, showing the version of the
driver.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 98fc4ec6 09-Feb-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Make toshiba_eco_mode_available more robust

Some Toshiba laptops do not come with the ECO led installed, however,
the driver is registering support for it when it should not.

This patch makes the toshiba_eco_mode_available function more robust
in detecting ECO led capabilities, not registering the led on laptops
that do not support it and registering the led when it really does.

The ECO led function now returns 0x8e00 (Not Installed) by querying
with in[3] = 0, whenever theres no physical LED installed, and
returning 0x8300 (Input Data Error) when it is, however, there are
some BIOSes that have stub function calls not returning anything and
and the LED device was being registered too, hence the change of the
default return value from 1 to 0.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>

Minor comment update, fixed a whitespace error, s/truly/actual/.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# fa465739 18-Jan-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add a check for TOS_NOT_SUPPORTED in the sci_open function

This was "toshiba_acpi: Change sci_open function return value"

Some Toshiba laptops have "poorly implemented" SCI calls on their
BIOSes and are not checking for sci_{open, close} calls, therefore,
the sci_open function is failing and making some of the supported
features unavailable (kbd backlight, touchpad, illumination, etc.).

This patch checks whether we receive TOS_NOT_SUPPORTED and returns
1, making the supported features work on such laptops.

In the case that some laptops really do not support the SCI, all the
SCI dependent functions check for TOS_NOT_SUPPORTED, and thus, not
registering support for the queried feature.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 172ce0a9 18-Jan-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for USB Sleep and Music

Newer Toshiba laptops now come with a feature called USB Sleep and
Music, where the laptop speakers remain powered and the line-in jack
is used to connect an external device to use the laptop speakers when
the computer is asleep or turned off.

This patchs adds support to such feature, by creating a sysfs entry
named "usb_sleep_music", accepting only two values, 0 to disable and
1 to enable.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# bb3fe01f 18-Jan-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for USB Rapid Charge

Newer Toshiba laptops equipped with USB 3.0 ports now have the
functionality of rapid charging devices connected to their USB hubs.

This patch adds support to use such feature by creating a sysfs entry
named "usb_rapid_charge", accepting only two values, 0 to disable and
1 to enable, however, the machine needs a restart everytime the
function is toggled.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 182bcaa5 18-Jan-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for USB Sleep functions under battery

Toshiba laptops supporting USB Sleep and Charge also come with a
feature called "USB functions under battery", which what it does when
enabled, is allows the USB Sleep functions when the computer is under
battery power.

This patch adds support to that function, creating a sysfs entry
named "sleep_functions_on_battery", accepting values from 0-100,
where zero disables the function and 1-100 sets the battery level at
which point the USB Sleep functions will be disabled, and printing
the current state of the functon and also the battery level currently
set.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# e26ffe51 18-Jan-2015 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add support for USB Sleep and Charge function

Newer Toshiba models now come with a feature called Sleep and Charge,
where the computer USB ports remain powered when the computer is
asleep or turned off.

This patch adds support to such feature, creating a sysfs entry
called "usb_sleep_charge" to set the desired charging mode or to
disable it.

The sysfs entry accepts three parameters, 0, 1 and 2, beign disabled,
alternate and auto respectively.

The auto mode stands for USB conformant devices (which most are), and
the alternate mode stands for those non USB conformant devices that
require more power.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 80546905 04-Dec-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add keyboard backlight mode change event

A previous patch added support to handle more events.

This patch adds support to update the sysfs group whenever we receive
a 0x92 event, which indicates a change in the keyboard backlight mode,
removing the update group code from toshiba_kbd_bl_mode_store, as it is
no longer needed there.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 71454d78 04-Dec-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change notify funtion to handle more events

Currently the function toshiba_acpi_notify only takes care of hotkeys,
however, the TOSXXXX devices receive more events that can be useful.

This patch changes the function to be able to handle more events,
and in the process, move all hotkey related code residing in it to
a new function called toshiba_acpi_process_hotkeys.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 1f28f290 04-Dec-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Move hotkey enabling code to its own function

The hotkey enabling code is being used by *_setup_keyboard and also by
*_resume.

This patch creates a new function called toshiba_acpi_enable_hotkeys to
be used by these two functions to avoid duplicating code.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 63a9e016 09-Nov-2014 Ondrej Zary <linux@rainbow-software.org>

toshiba-acpi: Add missing ID (TOS6207)

toshiba-acpi was always missing TOS6207 ID so it did not load automatically
on some laptops (such as Portege R100). But it worked fine if loaded manually.
Commit 135740de7764 ("toshiba_acpi: Convert to use acpi_driver") broke that
and the driver does not work even when loaded manually since then.

Add TOS6207 ID to fix it.

Tested on Toshiba Portege R100.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 00981810 24-Nov-2014 Markus Elfring <elfring@users.sourceforge.net>

platform: x86: Deletion of checks before backlight_device_unregister()

The backlight_device_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
For msi-wmi.c:
Acked-by: Anisse Astier <anisse@astier.eu>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# a39f46df 24-Nov-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix regression caused by backlight extra check code

Bug 86521 uncovered that some TOS6208 devices also return
non zero values on a write call to the backlight method,
thus getting caught and bailed out by the extra check code.

This patch changes the set_lcd_brightness function to its
"original" state by just adapting it to the new function
format.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 98280374 17-Oct-2014 Giedrius Statkevičius <giedriuswork@gmail.com>

drivers: platform: change 0x20 to I8042_STR_AUXDATA in i8042 filters

Instead of using a magic constant 0x20 in some drivers to get data only
from the KBC port we should use the constant defined in i8042.h with
the same value. Also, this makes these drivers uniform with what
constant the only other filter function uses in
drivers/input/misc/ideapad_slidebar.c.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# b1bde689 23-Oct-2014 Aaron Lu <aaron.lu@intel.com>

toshiba_acpi: Add Toshiba TECRA A50-A to the alt keymap dmi list

As bug #72551, the Toshiba TECRA A50-A series models also come with the
new keymap layout as found out by Azael Avalos, so add it to the dmi
table.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=76971
Reported-and-tested-by: Blindekinder <rafael.raccuia@blindekinder.com>
Cc: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# eabde0fa 04-Oct-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Adapt kbd_bl_timeout_store to the new kbd type

With the introduction of the new keyboard backlight
implementation, the *_timeout_store function is
broken, as it only supports the first kbd_type.

This patch adapts such function for the new kbd_type,
as well as converts from using sscanf to kstrtoint.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 893f3f62 29-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change HCI/SCI functions return code type

Currently the HCI/SCI read/write functions are returning
the status of the ACPI call and also assigning the
returned value of the HCI/SCI function, however, only
the HCI/SCI status is being checked.

This patch changes such functions, returning the value
of the HCI/SCI function instead of the ACPI call status,
eliminating one parameter, and returning something
useful that indeed is being checked.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 1864bbc2 29-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Unify return codes prefix from HCI/SCI to TOS

The return codes are split in between HCI/SCI prefixes,
but they are shared (used) by both interfaces, mixing
hci_read/write calls with SCI_* return codes, and
sci_read/write calls with HCI_* ones.

This patch changes the prefix of the return codes
definitions, dropping the HCI/SCI naming and instead
replacing it with TOS (for TOShiba).

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 258c5903 29-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Rename hci_raw to tci_raw

The function name hci_raw was used before to reflect
a raw (read/write) call to Toshiba's Hardware
Configuration Interface (HCI), however, since the
introduction of the System Configuration Interface
(SCI), that "name" no longer applies.

This patch changes the name of that function to
tci_raw (for Toshiba Configuration Interface), and
change the comments about it.

Also, the HCI_WORDS definition was changed to TCI_RAW,
to better reflect that we're no longer using pure HCI
calls, but a combination of HCI and SCI, which form
part of the Toshiba Configuration Interface.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 93f8c16d 12-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Support new keyboard backlight type

Newer Toshiba models now come with a new (and different) keyboard
backlight implementation with three modes of operation: TIMER,
ON and OFF, and the LED is now controlled internally by the firmware.

This patch adds support for that type of backlight, changing the
existing code to accomodate the new implementation.

The timeout value range is now 1-60 seconds, and the accepted
modes are now: 1 (FN-Z), 2 (AUTO or TIMER), 8 (ON) and 10 (OFF),
this adds two new entries kbd_type and available_kbd_modes,
the first shows the keyboard type and the latter shows the
supported modes depending on the keyboard type.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# c8a41669 10-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Change touchpad store to check for invalid values

The function toshiba_touchpad_store is not checking
for invalid values and simply returns silently.

This patch checks for invalid values and returns accordingly.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 12962878 05-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Fix illumination not available on certain models

Some Toshiba models with illumination support set a different
value on the returned codes, thus not allowing the illumination
LED to be registered, where it should be.

This patch removes a check from toshiba_illumination_available
function to allow such models to register the illumination LED.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 408a5d13 05-Sep-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Additional hotkey scancodes

Appart from reporting hotkeys, the INFO method is used
as a system wide event notifier for hardware or
software changes.

This patch adds additional "events" to the keymap list,
ignored by now, until we find them a good use.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# aeaac098 03-Sep-2014 Dan Carpenter <dan.carpenter@oracle.com>

toshiba_acpi: fix and cleanup toshiba_kbd_bl_mode_store()

The current code just returns -EINVAL because mode can't be equal to
both 1 and 2.

Also this function is messy so I have cleaned it up:
1) Remove initializers like "int time = -1". Initializing variables to
garbage values turns off GCC's uninitialized variable warnings so it
can lead to bugs.
2) Use kstrtoint() instead of sscanf().
3) Use SCI_KBD_MODE_FNZ and SCI_KBD_MODE_AUTO instead of magic numbers 1
and 2.
4) Don't check for "mode == -1" because that can't happen.
5) Preserve the error code from toshiba_kbd_illum_status_set().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# e7fdb762 02-Sep-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

platform/x86: toshiba: re-enable acpi hotkeys after suspend to disk

On the Toshiba Tecra Z40, after a suspend-to-disk, some FN hotkeys
driven by toshiba_acpi are not functional.

Calling the ACPI object ENAB on resume makes them back alive.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>


# 8039aabb 20-Aug-2014 Matthew Garrett <matthew.garrett@nebula.com>

Revert "platform/x86/toshiba-apci.c possible bad if test?"

This reverts commit bdc3ae7221213963f438faeaa69c8b4a2195f491.

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# e6efad7f 04-Aug-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add Qosmio X75-A to the alt keymap dmi list

The Toshiba Qosmio X75-A series models also come with
the new keymap layout.

This patch adds this model to the alt_keymap_dmi list,
along with an extra key found on these models.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# f6aac652 04-Aug-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add extra check to backlight code

Some Toshiba models (most notably Qosmios) come with an
incomplete backlight method where the AML code doesn't
check for write or read commands and always returns
HCI_SUCCESS and the actual brightness (and in some
cases the max brightness), thus allowing the backlight
interface to be registered without write support.

This patch changes the set_lcd_brightness function,
checking the returned values for values greater than
zero to avoid registering a broken backlight interface.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# bdc3ae72 12-Jun-2014 Nick <xerofoify@gmail.com>

platform/x86/toshiba-apci.c possible bad if test?

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# fe808bfb 29-Apr-2014 Takashi Iwai <tiwai@suse.de>

toshiba_acpi: Add alternative keymap support for Satellite M840

Toshiba Satellite M840 laptop has a complete different keymap although
it's bound with the same ACPI ID "TOS1900". This patch provides an
alternative keymap specific to this machine by identifying via DMI
matching. The keymap table doesn't fill all entries that were used
before since some keys aren't found on this machine at all.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=69761
Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=812209
Reported-and-tested-by: Federico Vecchiarelli <fedev@gmx.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# ea6b31f4 04-Apr-2014 Matthew Garrett <matthew.garrett@nebula.com>

toshiba_acpi: Fix whitespace

Tidy up whitespace introduced by the previous patchset

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 548c4306 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Update version and copyright info

Given that some new features were added to the
driver, bump its version to 0.20 and add myself
to the copyright list for these new features
that were added.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 5a2813e9 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add accelerometer support

Recent Toshiba laptops now come equiped with a built in
accelerometer (TOS620A) device, but such device does not
expose the axes information, however, HCI calls 0x006d
and 0x00a6 can be used to query such info.

This patch adds support to read the axes values by
exposing them through the _position_ sysfs file.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# def6c4e2 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add ECO mode led support

Newer Toshiba laptops now come with a feature called
ECO Mode, where the system is put in low power consupmtion
state and a green (world shaped with leaves) icon illuminates
indicating that the system is in such power state.

This patch adds support to turn on/off the ECO led by
creating and registering the toshiba::eco_mode led.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 9d8658ac 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add touchpad enable/disable support-

Toshiba laptops have two ways of letting userspace
know the touchpad has changed state, one with a
button on top of the touchpad that simply emmits
scancodes whenever enabled/disabled, and another one
by pressing Fn-F9 (touchpad toggle) hotkey.

This patch adds support to enable/disable the touchpad
by exposing the _touchpad_ file in sysfs that simply
makes a call to a SCI register, imitating what
Toshiba provided software does on Windows.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 360f0f39 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add keyboard backlight support

Toshiba laptops equiped with an illuminated keyboard
can operate in two different modes: Auto and FN-Z.

The Auto mode turns on the led on keystrokes and
automatically turns it off after some (configurable)
time the last key was pressed.

The FN-Z mode is used to toggle the keyboard led on/off
by userspace.

This patch adds support to set the desired KBD mode and
timeout via sysfs, creates and registers toshiba::kbd_backlight
led device whenever the mode is set to FN-Z.

The acceptable values for mode are: 1 (Auto) and 2 (Fn-Z)
The time values range are: 1-60 seconds

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# fdb79081 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Adapt Illumination code to use SCI

Change the toshiba_illumination_* code to use the
newly introduced SCI functions, making the code
more robust in detecting Illumination capabilities
properly, since it was only opening the SCI and
the return value was never checked for errors or
actual Illumination support.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 84a6273f 25-Mar-2014 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Add System Configuration Interface

SCI stands for System Configuration Interface,
which aim is to conceal differences in hardware
between different models.

This patch introduces four new calls: sci_open,
sci_close, sci_read and sci_write, along with
its definitions and return codes which will be
used by later patches.

More information about the SCI can be found at
Jonathan Buzzard's website [1].

[1] http://www.buzzard.me.uk/toshiba/docs.html

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# fec278a1 14-Jan-2014 Unai Uribarri <unaiur@gmail.com>

toshiba_acpi: Support RFKILL hotkey scancode

This scancode is used in new 2013 models like Satellite P75-A7200.

Signed-off-by: Unai Uribarri <unaiur@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>


# 8b48463f 02-Dec-2013 Lv Zheng <lv.zheng@intel.com>

ACPI: Clean up inclusions of ACPI header files

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>


# b222cca6 23-Oct-2013 Joe Perches <joe@perches.com>

platform:x86: Remove OOM message after input_allocate_device

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>


# 74facaf7 02-Sep-2013 Zhang Rui <rui.zhang@intel.com>

toshiba_acpi: convert acpi_evaluate_object() to acpi_evaluate_integer()

acpi_evaluate_integer() is an ACPI API introduced to evaluate an
ACPI control method that is known to have an integer return value.
This API can simplify the code because the calling function does not need to
use the specified acpi_buffer structure required by acpi_evaluate_object();

Convert acpi_evaluate_object() to acpi_evaluate_integer()
in drivers/platform/x86/toshiba_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# e2e19606 02-Sep-2013 Zhang Rui <rui.zhang@intel.com>

toshiba_acpi: convert acpi_get_handle() to acpi_has_method()

acpi_has_method() is a new ACPI API introduced to check
the existence of an ACPI control method.

It can be used to replace acpi_get_handle() in the case that
1. the calling function doesn't need the ACPI handle of the control method.
and
2. the calling function doesn't care the reason why the method is unavailable.

Convert acpi_get_handle() to acpi_has_method()
in drivers/platform/x86/toshiba_acpi.c in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 619400da 02-Sep-2013 Zhang Rui <rui.zhang@intel.com>

toshiba_acpi: convert acpi_evaluate_object() to acpi_execute_simple_method()

acpi_execute_simple_method() is a new ACPI API introduced to invoke
an ACPI control method that has single integer parameter and no return value.

Convert acpi_evaluate_object() to acpi_execute_simple_method()
in drivers/platform/x86/toshiba_acpi.c

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# d9dda78b 31-Mar-2013 Al Viro <viro@zeniv.linux.org.uk>

procfs: new helper - PDE_DATA(inode)

The only part of proc_dir_entry the code outside of fs/proc
really cares about is PDE(inode)->data. Provide a helper
for that; static inline for now, eventually will be moved
to fs/proc, along with the knowledge of struct proc_dir_entry
layout.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 496ad9aa 23-Jan-2013 Al Viro <viro@zeniv.linux.org.uk>

new helper: file_inode(file)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 51fac838 23-Jan-2013 Rafael J. Wysocki <rafael.j.wysocki@intel.com>

ACPI: Remove useless type argument of driver .remove() operation

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>


# b859f159 21-Dec-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Drivers: platform: x86: remove __dev* attributes.

CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
markings need to be removed.

This change removes the use of __devinit, __devexit_p, __devinitdata,
__devinitconst, and __devexit from these drivers.

Based on patches originally written by Bill Pemberton, but redone by me
in order to handle some of the coding style issues better, by hand.

Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Joey Lee <jlee@novell.com>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Peter Feuerer <peter@piie.net>
Cc: Corentin Chary <corentin.chary@gmail.com>
Cc: Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
Cc: Robert Gerlach <khnz@gmx.de>
Cc: Ike Panhc <ike.pan@canonical.com>
Cc: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3567a4e2 09-Aug-2012 Rafael J. Wysocki <rjw@rjwysocki.net>

platform / x86 / PM: Fix unused function warnings for CONFIG_PM_SLEEP

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>


# 43d2fd3b 27-Jun-2012 Rafael J. Wysocki <rjw@rjwysocki.net>

toshiba_acpi: Use struct dev_pm_ops for power management

Make the toshiba_acpi 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>


# 17621e11 27-Jun-2012 Rafael J. Wysocki <rjw@rjwysocki.net>

ACPI / PM: Drop pm_message_t argument from device suspend callback

None of the drivers implementing the ACPI device suspend callback
uses the pm_message_t argument of it, so this argument may be dropped
entirely from that callback. This will simplify switching the ACPI
bus type to PM handling based on struct dev_pm_ops.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>


# 53039f22 01-Jun-2012 Matthew Garrett <mjg@redhat.com>

toshiba_acpi: Fix mis-merge

I managed to screw up the various backlight changes and ended up memsetting
the props structure after it had already been populated. This should fix it.

Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 121b7b0d 05-Apr-2012 Akio Idehara <zbe64533@gmail.com>

toshiba_acpi: Add support for transflective LCD

Some Toshiba laptops have the transflective LCD and toshset
can control its backlight state. I brought this feature to the
mainline. To support transflective LCD, it's implemented by
adding an extra level to the backlight and having 0 change to
transflective mode. It was tested on a Toshiba Portege R500.

Signed-off-by: Akio Idehara <zbe64533@gmail.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 62cce752 19-Apr-2012 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Only register backlight device when interface is read/write

Currently the backlight device is registered unconditionally, but many
(probably most) Toshibas either don't support HCI_LCD_BRIGHTNESS or only
support reading from it. This patch adds a test of HCI_LCD_BRIGHTNESS
during initialization and only registers the backlight device if this
interface supports both reads and writes.

Cc: Akio Idehara <zbe64533@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# f5f4fd45 29-May-2012 Corentin Chary <corentin.chary@gmail.com>

backlight: initialize struct backlight_properties properly

In all these files, the .power field was never correctly initialized.

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f11f999e 18-Jan-2012 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Refuse to load on machines with buggy INFO implementations

Several Satellite models have a buggy implementation of the INFO method
that causes ACPI exceptions when executed:

ACPI Error: Result stack is empty! State=ffff88012d70f800 (20110413/dswstate-98)
ACPI Exception: AE_AML_NO_RETURN_VALUE, Missing or null operand (20110413/dsutils-646)
ACPI Exception: AE_AML_NO_RETURN_VALUE, While creating Arg 0 (20110413/dsutils-763)
ACPI Error: Method parse/execution failed [\_SB_.VALZ.GETE] (Node ffff880131175eb0), AE_AML_NO_RETURN_VALUE (20110413/psparse-536)
ACPI Error: Method parse/execution failed [\_SB_.VALZ.INFO] (Node ffff880131175ed8), AE_AML_NO_RETURN_VALUE (20110413/psparse-536)
toshiba_acpi: ACPI INFO method execution failed
toshiba_acpi: Failed to query hotkey event

All known machines with this implementation also have a WMI interface
with event GUID 59142400-C6A3-40FA-BADB-8A2652834100 which is not seen
on any other models. Refuse to load toshiba_acpi on machines with this
guid.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# af502837 18-Jan-2012 Azael Avalos <coproscefalo@gmail.com>

toshiba_acpi: Support additional hotkey scancodes

These scancodes are used by many of the models now supported with
the addition of TOS1900 device support.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 29cd293f 18-Jan-2012 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Support alternate hotkey interfaces

There are two types of problems that prevent hotkeys from working
on many of the machines supported by toshiba_acpi. The first of
these is the lack of a functioning SCI for hotkey events. For these
machines it is possible to filter the Fn keypresses from the
keyboard and generate a notification by executing the ACPI NTFY
method.

The second problem is a lack of support for HCI_SYSTEM_EVENT, which
is used for reading the hotkey scancodes. On these machines the
scancodes can be read by executing the ACPI NTFY method.

This patch fixes both problems by installing an i8042 filter when
the NTFY method is present to generate notifications and by
detecting which of INFO or HCI_SYSTEM_EVENT is supported for
reading scancodes. If neither method of reading scancodes is
supported, the hotkey input device is not registered.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 592b746c 15-Jan-2012 Dan Carpenter <dan.carpenter@oracle.com>

toshiba_acpi: make one-bit bitfields unsigned

This doesn't change how the code works, but it silences a Sparse
complaint:
drivers/platform/x86/toshiba_acpi.c:121:37: error: dubious one-bit signed bitfield

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 11948b93 16-Nov-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Fix machines that don't support HCI_SYSTEM_EVENT

The Satellite C670-10V generates notifications for hotkeys but does
not support HCI_SYSTEM_EVENT. As a result when a hotkey is pressed
it gets stuck in an infinite loop in toshiba_acpi_notify. To fix
this, detect whether or not HCI_SYSTEM_EVENT is supported up-front
and don't try to read system events if it isn't supported. In
addition, limit the number of retries when reading HCI_SYSTEM_EVENT
fails so that this loop cannot run unbounded.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# ac2dad88 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Initialize brightness in backlight device

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 36d03f93 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Don't add devices for unsupported features

Test for features up-front to determine whether or not they are
supported, and avoid creating devices and proc files for
unsupported features.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# a540d6b5 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Support SPFC as an HCI method

Some Toshiba models, notably those with the TOS1900 device, use
the SPFC method for HCI calls instead of GHCI. Test for this method
if GHCI isn't found, and if it exists use it for all HCI calls.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 6e02cc7e 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Use handle for HCI calls

Now that we're using an acpi driver we already have a handle to
the namespace of the HCI call, so there's no need to test various
paths to the HCI call or even be aware of the path at all.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 32bcd5cb 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Fix up return codes

Many routines are returning success on failure, and those that are
indicating failure frequently return incorrect error codes. Fix
these up throughout the driver.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 135740de 20-Sep-2011 Seth Forshee <seth.forshee@canonical.com>

toshiba_acpi: Convert to use acpi_driver

Changes toshiba_acpi to register an acpi driver and eliminates the
platform device it was using. Also eliminates most global
variables, moving them into toshiba_acpi_dev, along with some
other miscellaneous fixes and cleanup.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 7e33460d 29-Mar-2011 Joe Perches <joe@perches.com>

toshiba: Convert printks to pr_<level>

Add pr_fmt.
Remove local MY_<foo> #defines.
Convert printks to pr_<level>.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# bb7ca747 22-Mar-2011 Matthew Garrett <mjg@redhat.com>

backlight: add backlight type

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>


# a49010f5 26-Oct-2010 Jon Dowland <jmtd@debian.org>

toshiba_acpi.c: Add key_entry for a lone FN keypress

A lone FN key press on a Toshiba Portégé R700 without another key in
conjunction results in an ACPI event and a spurious error message on
the console.

Add a key entry to map this event to a KEY_FN keypress. This prevents
the console message.

Signed-off-by: Jon Dowland <jmtd@debian.org>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# acc2472e 16-Nov-2010 Lionel Debroux <lionel_debroux@yahoo.fr>

backlight: constify backlight_ops

backlight_device_register has been expecting a const "ops" argument, and using
it as such, since 9905a43b2d563e6f89e4c63c4278ada03f2ebb14. Let's make the
remaining backlight_ops instances const.

Inspired by hunks of the grsecurity patch, updated for newer kernels.

Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 384a7cd9 04-Aug-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

toshiba-acpi - switch to using sparse keymap

Instead of implementing its own version of keymap hanlding switch over
to using sparse keymap library.

Also, install notify handler only after we allocated input device,
otherwise we may risk getting event too early and crash. Similarly,
notify handler should be removed before we unregister input device.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 6c3f6e6c 29-Jul-2010 Pierre Ducroquet <pinaraf@pinaraf.info>

toshiba-acpi: Add support for Toshiba Illumination.

Add support for Toshiba Illumination. This is a set of LEDs installed on
some Toshiba laptops. It is controlled through ACPI, the commands has been
found through reverse engineering. It has been tested on a Toshiba Qosmio
G50-122.

Signed-off-by: Pierre Ducroquet <pinaraf@pinaraf.info>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# f8ef3aec 20-Jul-2010 Axel Lin <axel.lin@gmail.com>

toshiba_acpi: rename add_device() and remove_device() to create_toshiba_proc_entries() and remove_toshiba_proc_entries()

To improve readability rename add_device() to
create_toshiba_proc_entries() and rename remove_device() to
remove_toshiba_proc_entries().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Márton Németh <nm127@freemail.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# 1bd1ca1f 20-Jul-2010 Axel Lin <axel.lin@gmail.com>

toshiba_acpi: make remove_device() and add_device() void

remove_device() and add_device() are not related to ACPI APIs, it does not
make sense to return acpi_status for both functions.

Current implementation of add_device() always AE_OK, thus the return value
checking for add_device() always return false for ACPI_FAILURE(status).
This patch makes add_device() to be void and remove the unnecessary return
value checking.

remove_proc_entry() won't fail, thus change remove_device() to be void.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Márton Németh <nm127@freemail.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matthew Garrett <mjg@redhat.com>


# ae42f234 15-Jul-2010 Matthew Garrett <mjg@redhat.com>

toshiba-acpi: Add an extra couple of keys

Thomas Bächler reports that his machine generates two keycodes for zooming
in and out. Add these to the default keymap.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Cc: Thomas Bächler <thomas@archlinux.org>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

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>


# a19a6ee6 17-Feb-2010 Matthew Garrett <mjg@redhat.com>

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>


# 58b93995 08-Mar-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: scancode in get/set_keycodes should be unsigned

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>


# b466301b 01-Mar-2010 Frans Pop <elendil@planet.nl>

toshiba-acpi: fix multimedia keys on some machines

Some Toshibas only send ACPI events on key down, not key release. Ignore
any release events and send key down and key up events on every ACPI key
down event.

Signed-off-by: Frans Pop <elendil@planet.nl>


# 6335e4d5 25-Feb-2010 Matthew Garrett <mjg@redhat.com>

toshiba_acpi: Add full hotkey support

Calling the ENAB method on Toshiba laptops results in notifications being
sent when laptop hotkeys are pressed. This patch simply calls that method
and sets up an input device if it's successful.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>


# 936c8bcd 21-Dec-2009 Alexey Dobriyan <adobriyan@gmail.com>

toshiba_acpi: convert to seq_file

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>


# 82e7784f 06-Aug-2009 Jiri Slaby <jirislaby@kernel.org>

toshiba_acpi: return on a fail path

Return from bt_rfkill_poll() when hci_get_radio_state() fails.

value is invalid in that case and should not be assigned to the rfkill
state.

This also fixes a double unlock bug.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>


# 19d337df 02-Jun-2009 Johannes Berg <johannes@sipsolutions.net>

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>


# 621cac85 27-Mar-2009 Johannes Berg <johannes@sipsolutions.net>

rfkill: remove user_claim stuff

Almost all drivers do not support user_claim, so remove it
completely and always report -EOPNOTSUPP to userspace. Since
userspace cannot really drive rfkill _anyway_ (due to the
odd restrictions imposed by the documentation) having this
code is just pointless.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>


# 99b76233 25-Mar-2009 Alexey Dobriyan <adobriyan@gmail.com>

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>


# b4f9fe12 11-Dec-2008 Len Brown <len.brown@intel.com>

ACPI: move wmi, asus_acpi, toshiba_acpi to drivers/platform/x86

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>