Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v4.9-1' of git://git.infradead.org/us…
Browse files Browse the repository at this point in the history
…ers/dvhart/linux-platform-drivers-x86

Pull x86 platform drivers updates from Darren Hart:
 "Cleanups, refactoring, and a couple bug fixes.

  intel_pmc_core:
   - avoid boot time warning for !CONFIG_DEBUGFS_FS

  intel_pmc_ipc:
   - Convert to use platform_device_register_full

  asus-wmi:
   - Filter buggy scan codes on ASUS Q500A

  toshiba_bluetooth:
   - Decouple an error checking status code

  toshiba_haps:
   - Change logging level from info to debug
   - Split ACPI and HDD protection error handling

  asus-laptop:
   - get rid of parse_arg()

  asus-wmi:
   - fix asus ux303ub brightness issue

  toshiba_acpi:
   - Fix typo in *_cooling_method_set function
   - Change error checking logic from TCI functions
   - Clean up variable declaration"

* tag 'platform-drivers-x86-v4.9-1' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86:
  platform/x86: intel_pmc_core: avoid boot time warning for !CONFIG_DEBUGFS_FS
  platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full
  platform/x86: asus-wmi: Filter buggy scan codes on ASUS Q500A
  platform/x86: toshiba_bluetooth: Decouple an error checking status code
  platform/x86: toshiba_haps: Change logging level from info to debug
  platform/x86: toshiba_haps: Split ACPI and HDD protection error handling
  platform/x86: asus-laptop: get rid of parse_arg()
  platform/x86: asus-wmi: fix asus ux303ub brightness issue
  platform/x86: toshiba_acpi: Fix typo in *_cooling_method_set function
  platform/x86: toshiba_acpi: Change error checking logic from TCI functions
  platform/x86: toshiba_acpi: Clean up variable declaration
  • Loading branch information
Linus Torvalds committed Oct 13, 2016
2 parents e3799a2 + 127595e commit 44dc8c9
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 230 deletions.
77 changes: 36 additions & 41 deletions drivers/platform/x86/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,30 +932,19 @@ static ssize_t infos_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(infos);

static int parse_arg(const char *buf, unsigned long count, int *val)
{
if (!count)
return 0;
if (count > 31)
return -EINVAL;
if (sscanf(buf, "%i", val) != 1)
return -EINVAL;
return count;
}

static ssize_t sysfs_acpi_set(struct asus_laptop *asus,
const char *buf, size_t count,
const char *method)
{
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv <= 0)
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;

if (write_acpi_int(asus->handle, method, value))
return -ENODEV;
return rv;
return count;
}

/*
Expand All @@ -975,15 +964,17 @@ static ssize_t ledd_store(struct device *dev, struct device_attribute *attr,
struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0) {
if (write_acpi_int(asus->handle, METHOD_LEDD, value)) {
pr_warn("LED display write failed\n");
return -ENODEV;
}
asus->ledd_status = (u32) value;
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;

if (write_acpi_int(asus->handle, METHOD_LEDD, value)) {
pr_warn("LED display write failed\n");
return -ENODEV;
}
return rv;

asus->ledd_status = (u32) value;
return count;
}
static DEVICE_ATTR_RW(ledd);

Expand Down Expand Up @@ -1148,10 +1139,12 @@ static ssize_t display_store(struct device *dev, struct device_attribute *attr,
struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0)
asus_set_display(asus, value);
return rv;
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;

asus_set_display(asus, value);
return count;
}
static DEVICE_ATTR_WO(display);

Expand Down Expand Up @@ -1190,11 +1183,12 @@ static ssize_t ls_switch_store(struct device *dev,
struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0)
asus_als_switch(asus, value ? 1 : 0);
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;

return rv;
asus_als_switch(asus, value ? 1 : 0);
return count;
}
static DEVICE_ATTR_RW(ls_switch);

Expand All @@ -1219,14 +1213,15 @@ static ssize_t ls_level_store(struct device *dev, struct device_attribute *attr,
struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0) {
value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
/* 0 <= value <= 15 */
asus_als_level(asus, value);
}
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;

value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
/* 0 <= value <= 15 */
asus_als_level(asus, value);

return rv;
return count;
}
static DEVICE_ATTR_RW(ls_level);

Expand Down Expand Up @@ -1301,14 +1296,14 @@ static ssize_t gps_store(struct device *dev, struct device_attribute *attr,
int rv, value;
int ret;

rv = parse_arg(buf, count, &value);
if (rv <= 0)
return -EINVAL;
rv = kstrtoint(buf, 0, &value);
if (rv < 0)
return rv;
ret = asus_gps_switch(asus, !!value);
if (ret)
return ret;
rfkill_set_sw_state(asus->gps.rfkill, !value);
return rv;
return count;
}
static DEVICE_ATTR_RW(gps);

Expand Down
58 changes: 58 additions & 0 deletions drivers/platform/x86/asus-nb-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/input/sparse-keymap.h>
#include <linux/fb.h>
#include <linux/dmi.h>
#include <linux/i8042.h>

#include "asus-wmi.h"

Expand Down Expand Up @@ -55,10 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value");

static struct quirk_entry *quirks;

static bool asus_q500a_i8042_filter(unsigned char data, unsigned char str,
struct serio *port)
{
static bool extended;
bool ret = false;

if (str & I8042_STR_AUXDATA)
return false;

if (unlikely(data == 0xe1)) {
extended = true;
ret = true;
} else if (unlikely(extended)) {
extended = false;
ret = true;
}

return ret;
}

static struct quirk_entry quirk_asus_unknown = {
.wapf = 0,
};

static struct quirk_entry quirk_asus_q500a = {
.i8042_filter = asus_q500a_i8042_filter,
};

/*
* For those machines that need software to control bt/wifi status
* and can't adjust brightness through ACPI interface
Expand Down Expand Up @@ -87,13 +112,26 @@ static struct quirk_entry quirk_no_rfkill_wapf4 = {
.no_rfkill = true,
};

static struct quirk_entry quirk_asus_ux303ub = {
.wmi_backlight_native = true,
};

static int dmi_matched(const struct dmi_system_id *dmi)
{
quirks = dmi->driver_data;
return 1;
}

static const struct dmi_system_id asus_quirks[] = {
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. Q500A",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
},
.driver_data = &quirk_asus_q500a,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. U32U",
Expand Down Expand Up @@ -351,11 +389,22 @@ static const struct dmi_system_id asus_quirks[] = {
},
.driver_data = &quirk_no_rfkill,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. UX303UB",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
},
.driver_data = &quirk_asus_ux303ub,
},
{},
};

static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
{
int ret;

quirks = &quirk_asus_unknown;
dmi_check_system(asus_quirks);

Expand All @@ -367,6 +416,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
quirks->wapf = wapf;
else
wapf = quirks->wapf;

if (quirks->i8042_filter) {
ret = i8042_install_filter(quirks->i8042_filter);
if (ret) {
pr_warn("Unable to install key filter\n");
return;
}
pr_info("Using i8042 filter function for receiving events\n");
}
}

static const struct key_entry asus_nb_wmi_keymap[] = {
Expand Down
3 changes: 3 additions & 0 deletions drivers/platform/x86/asus-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,9 @@ static int asus_wmi_add(struct platform_device *pdev)
if (asus->driver->quirks->wmi_backlight_power)
acpi_video_set_dmi_backlight_type(acpi_backlight_vendor);

if (asus->driver->quirks->wmi_backlight_native)
acpi_video_set_dmi_backlight_type(acpi_backlight_native);

if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
err = asus_wmi_backlight_init(asus);
if (err && err != -ENODEV)
Expand Down
5 changes: 5 additions & 0 deletions drivers/platform/x86/asus-wmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define _ASUS_WMI_H_

#include <linux/platform_device.h>
#include <linux/i8042.h>

#define ASUS_WMI_KEY_IGNORE (-1)
#define ASUS_WMI_BRN_DOWN 0x20
Expand All @@ -43,6 +44,7 @@ struct quirk_entry {
bool scalar_panel_brightness;
bool store_backlight_power;
bool wmi_backlight_power;
bool wmi_backlight_native;
int wapf;
/*
* For machines with AMD graphic chips, it will send out WMI event
Expand All @@ -51,6 +53,9 @@ struct quirk_entry {
* and let the ACPI interrupt to send out the key event.
*/
int no_display_toggle;

bool (*i8042_filter)(unsigned char data, unsigned char str,
struct serio *serio);
};

struct asus_wmi_driver {
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/intel_pmc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
struct dentry *dir, *file;

dir = debugfs_create_dir("pmc_core", NULL);
if (IS_ERR_OR_NULL(dir))
if (!dir)
return -ENOMEM;

pmcdev->dbgfs_dir = dir;
Expand Down
Loading

0 comments on commit 44dc8c9

Please sign in to comment.