Commit 44dc8c9d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v4.9-1' of...

Merge tag 'platform-drivers-x86-v4.9-1' of git://git.infradead.org/users/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
parents e3799a21 127595ed
...@@ -932,30 +932,19 @@ static ssize_t infos_show(struct device *dev, struct device_attribute *attr, ...@@ -932,30 +932,19 @@ static ssize_t infos_show(struct device *dev, struct device_attribute *attr,
} }
static DEVICE_ATTR_RO(infos); 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, static ssize_t sysfs_acpi_set(struct asus_laptop *asus,
const char *buf, size_t count, const char *buf, size_t count,
const char *method) const char *method)
{ {
int rv, value; int rv, value;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv <= 0) if (rv < 0)
return rv; return rv;
if (write_acpi_int(asus->handle, method, value)) if (write_acpi_int(asus->handle, method, value))
return -ENODEV; return -ENODEV;
return rv; return count;
} }
/* /*
...@@ -975,15 +964,17 @@ static ssize_t ledd_store(struct device *dev, struct device_attribute *attr, ...@@ -975,15 +964,17 @@ static ssize_t ledd_store(struct device *dev, struct device_attribute *attr,
struct asus_laptop *asus = dev_get_drvdata(dev); struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value; int rv, value;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv > 0) { if (rv < 0)
if (write_acpi_int(asus->handle, METHOD_LEDD, value)) { return rv;
pr_warn("LED display write failed\n");
return -ENODEV; if (write_acpi_int(asus->handle, METHOD_LEDD, value)) {
} pr_warn("LED display write failed\n");
asus->ledd_status = (u32) value; return -ENODEV;
} }
return rv;
asus->ledd_status = (u32) value;
return count;
} }
static DEVICE_ATTR_RW(ledd); static DEVICE_ATTR_RW(ledd);
...@@ -1148,10 +1139,12 @@ static ssize_t display_store(struct device *dev, struct device_attribute *attr, ...@@ -1148,10 +1139,12 @@ static ssize_t display_store(struct device *dev, struct device_attribute *attr,
struct asus_laptop *asus = dev_get_drvdata(dev); struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value; int rv, value;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv > 0) if (rv < 0)
asus_set_display(asus, value); return rv;
return rv;
asus_set_display(asus, value);
return count;
} }
static DEVICE_ATTR_WO(display); static DEVICE_ATTR_WO(display);
...@@ -1190,11 +1183,12 @@ static ssize_t ls_switch_store(struct device *dev, ...@@ -1190,11 +1183,12 @@ static ssize_t ls_switch_store(struct device *dev,
struct asus_laptop *asus = dev_get_drvdata(dev); struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value; int rv, value;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv > 0) if (rv < 0)
asus_als_switch(asus, value ? 1 : 0); return rv;
return rv; asus_als_switch(asus, value ? 1 : 0);
return count;
} }
static DEVICE_ATTR_RW(ls_switch); static DEVICE_ATTR_RW(ls_switch);
...@@ -1219,14 +1213,15 @@ static ssize_t ls_level_store(struct device *dev, struct device_attribute *attr, ...@@ -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); struct asus_laptop *asus = dev_get_drvdata(dev);
int rv, value; int rv, value;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv > 0) { if (rv < 0)
value = (0 < value) ? ((15 < value) ? 15 : value) : 0; return rv;
/* 0 <= value <= 15 */
asus_als_level(asus, value); 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); static DEVICE_ATTR_RW(ls_level);
...@@ -1301,14 +1296,14 @@ static ssize_t gps_store(struct device *dev, struct device_attribute *attr, ...@@ -1301,14 +1296,14 @@ static ssize_t gps_store(struct device *dev, struct device_attribute *attr,
int rv, value; int rv, value;
int ret; int ret;
rv = parse_arg(buf, count, &value); rv = kstrtoint(buf, 0, &value);
if (rv <= 0) if (rv < 0)
return -EINVAL; return rv;
ret = asus_gps_switch(asus, !!value); ret = asus_gps_switch(asus, !!value);
if (ret) if (ret)
return ret; return ret;
rfkill_set_sw_state(asus->gps.rfkill, !value); rfkill_set_sw_state(asus->gps.rfkill, !value);
return rv; return count;
} }
static DEVICE_ATTR_RW(gps); static DEVICE_ATTR_RW(gps);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/input/sparse-keymap.h> #include <linux/input/sparse-keymap.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/i8042.h>
#include "asus-wmi.h" #include "asus-wmi.h"
...@@ -55,10 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value"); ...@@ -55,10 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value");
static struct quirk_entry *quirks; 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 = { static struct quirk_entry quirk_asus_unknown = {
.wapf = 0, .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 * For those machines that need software to control bt/wifi status
* and can't adjust brightness through ACPI interface * and can't adjust brightness through ACPI interface
...@@ -87,6 +112,10 @@ static struct quirk_entry quirk_no_rfkill_wapf4 = { ...@@ -87,6 +112,10 @@ static struct quirk_entry quirk_no_rfkill_wapf4 = {
.no_rfkill = true, .no_rfkill = true,
}; };
static struct quirk_entry quirk_asus_ux303ub = {
.wmi_backlight_native = true,
};
static int dmi_matched(const struct dmi_system_id *dmi) static int dmi_matched(const struct dmi_system_id *dmi)
{ {
quirks = dmi->driver_data; quirks = dmi->driver_data;
...@@ -94,6 +123,15 @@ static int dmi_matched(const struct dmi_system_id *dmi) ...@@ -94,6 +123,15 @@ static int dmi_matched(const struct dmi_system_id *dmi)
} }
static const struct dmi_system_id asus_quirks[] = { 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, .callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. U32U", .ident = "ASUSTeK COMPUTER INC. U32U",
...@@ -351,11 +389,22 @@ static const struct dmi_system_id asus_quirks[] = { ...@@ -351,11 +389,22 @@ static const struct dmi_system_id asus_quirks[] = {
}, },
.driver_data = &quirk_no_rfkill, .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) static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
{ {
int ret;
quirks = &quirk_asus_unknown; quirks = &quirk_asus_unknown;
dmi_check_system(asus_quirks); dmi_check_system(asus_quirks);
...@@ -367,6 +416,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver) ...@@ -367,6 +416,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
quirks->wapf = wapf; quirks->wapf = wapf;
else else
wapf = quirks->wapf; 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[] = { static const struct key_entry asus_nb_wmi_keymap[] = {
......
...@@ -2084,6 +2084,9 @@ static int asus_wmi_add(struct platform_device *pdev) ...@@ -2084,6 +2084,9 @@ static int asus_wmi_add(struct platform_device *pdev)
if (asus->driver->quirks->wmi_backlight_power) if (asus->driver->quirks->wmi_backlight_power)
acpi_video_set_dmi_backlight_type(acpi_backlight_vendor); 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) { if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
err = asus_wmi_backlight_init(asus); err = asus_wmi_backlight_init(asus);
if (err && err != -ENODEV) if (err && err != -ENODEV)
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define _ASUS_WMI_H_ #define _ASUS_WMI_H_
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/i8042.h>
#define ASUS_WMI_KEY_IGNORE (-1) #define ASUS_WMI_KEY_IGNORE (-1)
#define ASUS_WMI_BRN_DOWN 0x20 #define ASUS_WMI_BRN_DOWN 0x20
...@@ -43,6 +44,7 @@ struct quirk_entry { ...@@ -43,6 +44,7 @@ struct quirk_entry {
bool scalar_panel_brightness; bool scalar_panel_brightness;
bool store_backlight_power; bool store_backlight_power;
bool wmi_backlight_power; bool wmi_backlight_power;
bool wmi_backlight_native;
int wapf; int wapf;
/* /*
* For machines with AMD graphic chips, it will send out WMI event * For machines with AMD graphic chips, it will send out WMI event
...@@ -51,6 +53,9 @@ struct quirk_entry { ...@@ -51,6 +53,9 @@ struct quirk_entry {
* and let the ACPI interrupt to send out the key event. * and let the ACPI interrupt to send out the key event.
*/ */
int no_display_toggle; int no_display_toggle;
bool (*i8042_filter)(unsigned char data, unsigned char str,
struct serio *serio);
}; };
struct asus_wmi_driver { struct asus_wmi_driver {
......
...@@ -100,7 +100,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev) ...@@ -100,7 +100,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
struct dentry *dir, *file; struct dentry *dir, *file;
dir = debugfs_create_dir("pmc_core", NULL); dir = debugfs_create_dir("pmc_core", NULL);
if (IS_ERR_OR_NULL(dir)) if (!dir)
return -ENOMEM; return -ENOMEM;
pmcdev->dbgfs_dir = dir; pmcdev->dbgfs_dir = dir;
......
...@@ -522,48 +522,36 @@ static struct resource telemetry_res[] = { ...@@ -522,48 +522,36 @@ static struct resource telemetry_res[] = {
static int ipc_create_punit_device(void) static int ipc_create_punit_device(void)
{ {
struct platform_device *pdev; struct platform_device *pdev;
int ret; const struct platform_device_info pdevinfo = {
.parent = ipcdev.dev,
pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1); .name = PUNIT_DEVICE_NAME,
if (!pdev) { .id = -1,
dev_err(ipcdev.dev, "Failed to alloc punit platform device\n"); .res = punit_res_array,
return -ENOMEM; .num_res = ARRAY_SIZE(punit_res_array),
} };
pdev->dev.parent = ipcdev.dev; pdev = platform_device_register_full(&pdevinfo);
ret = platform_device_add_resources(pdev, punit_res_array, if (IS_ERR(pdev))
ARRAY_SIZE(punit_res_array)); return PTR_ERR(pdev);
if (ret) {
dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
goto err;
}
ret = platform_device_add(pdev);
if (ret) {
dev_err(ipcdev.dev, "Failed to add punit platform device\n");
goto err;
}
ipcdev.punit_dev = pdev; ipcdev.punit_dev = pdev;
return 0; return 0;
err:
platform_device_put(pdev);
return ret;
} }
static int ipc_create_tco_device(void) static int ipc_create_tco_device(void)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct resource *res; struct resource *res;
int ret; const struct platform_device_info pdevinfo = {
.parent = ipcdev.dev,
pdev = platform_device_alloc(TCO_DEVICE_NAME, -1); .name = TCO_DEVICE_NAME,
if (!pdev) { .id = -1,
dev_err(ipcdev.dev, "Failed to alloc tco platform device\n"); .res = tco_res,
return -ENOMEM; .num_res = ARRAY_SIZE(tco_res),
} .data = &tco_info,
.size_data = sizeof(tco_info),
pdev->dev.parent = ipcdev.dev; };
res = tco_res + TCO_RESOURCE_ACPI_IO; res = tco_res + TCO_RESOURCE_ACPI_IO;
res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET; res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET;
...@@ -577,45 +565,26 @@ static int ipc_create_tco_device(void) ...@@ -577,45 +565,26 @@ static int ipc_create_tco_device(void)
res->start = ipcdev.gcr_base + TCO_PMC_OFFSET; res->start = ipcdev.gcr_base + TCO_PMC_OFFSET;
res->end = res->start + TCO_PMC_SIZE - 1; res->end = res->start + TCO_PMC_SIZE - 1;
ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res)); pdev = platform_device_register_full(&pdevinfo);
if (ret) { if (IS_ERR(pdev))
dev_err(ipcdev.dev, "Failed to add tco platform resources\n"); return PTR_ERR(pdev);
goto err;
}
ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info));
if (ret) {
dev_err(ipcdev.dev, "Failed to add tco platform data\n");
goto err;
}
ret = platform_device_add(pdev);
if (ret) {
dev_err(ipcdev.dev, "Failed to add tco platform device\n");
goto err;
}
ipcdev.tco_dev = pdev; ipcdev.tco_dev = pdev;
return 0; return 0;
err:
platform_device_put(pdev);
return ret;
} }
static int ipc_create_telemetry_device(void) static int ipc_create_telemetry_device(void)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct resource *res; struct resource *res;
int ret; const struct platform_device_info pdevinfo = {
.parent = ipcdev.dev,
pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1); .name = TELEMETRY_DEVICE_NAME,
if (!pdev) { .id = -1,
dev_err(ipcdev.dev, .res = telemetry_res,
"Failed to allocate telemetry platform device\n"); .num_res = ARRAY_SIZE(telemetry_res),
return -ENOMEM; };
}
pdev->dev.parent = ipcdev.dev;
res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM; res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM;
res->start = ipcdev.telem_punit_ssram_base; res->start = ipcdev.telem_punit_ssram_base;
...@@ -625,26 +594,13 @@ static int ipc_create_telemetry_device(void) ...@@ -625,26 +594,13 @@ static int ipc_create_telemetry_device(void)
res->start = ipcdev.telem_pmc_ssram_base; res->start = ipcdev.telem_pmc_ssram_base;
res->end = res->start + ipcdev.telem_pmc_ssram_size - 1; res->end = res->start + ipcdev.telem_pmc_ssram_size - 1;
ret = platform_device_add_resources(pdev, telemetry_res, pdev = platform_device_register_full(&pdevinfo);
ARRAY_SIZE(telemetry_res)); if (IS_ERR(pdev))
if (ret) { return PTR_ERR(pdev);
dev_err(ipcdev.dev,
"Failed to add telemetry platform resources\n");
goto err;
}
ret = platform_device_add(pdev);
if (ret) {
dev_err(ipcdev.dev,
"Failed to add telemetry platform device\n");
goto err;
}
ipcdev.telemetry_dev = pdev; ipcdev.telemetry_dev = pdev;
return 0; return 0;
err:
platform_device_put(pdev);
return ret;
} }
static int ipc_create_pmc_devices(void) static int ipc_create_pmc_devices(void)
......
This diff is collapsed.
...@@ -80,7 +80,9 @@ static int toshiba_bluetooth_present(acpi_handle handle) ...@@ -80,7 +80,9 @@ static int toshiba_bluetooth_present(acpi_handle handle)
if (ACPI_FAILURE(result)) { if (ACPI_FAILURE(result)) {
pr_err("ACPI call to query Bluetooth presence failed\n"); pr_err("ACPI call to query Bluetooth presence failed\n");
return -ENXIO; return -ENXIO;
} else if (!bt_present) { }
if (!bt_present) {
pr_info("Bluetooth device not present\n"); pr_info("Bluetooth device not present\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -59,7 +59,7 @@ static int toshiba_haps_protection_level(acpi_handle handle, int level) ...@@ -59,7 +59,7 @@ static int toshiba_haps_protection_level(acpi_handle handle, int level)
return -EIO; return -EIO;
} }
pr_info("HDD protection level set to: %d\n", level); pr_debug("HDD protection level set to: %d\n", level);
return 0; return 0;
} }
...@@ -141,7 +141,7 @@ static struct attribute_group haps_attr_group = { ...@@ -141,7 +141,7 @@ static struct attribute_group haps_attr_group = {
*/ */
static void toshiba_haps_notify(struct acpi_device *device, u32 event) static void toshiba_haps_notify(struct acpi_device *device, u32 event)
{ {
pr_info("Received event: 0x%x", event); pr_debug("Received event: 0x%x", event);
acpi_bus_generate_netlink_event(device->pnp.device_class, acpi_bus_generate_netlink_event(device->pnp.device_class,
dev_name(&device->dev), dev_name(&device->dev),
...@@ -168,9 +168,13 @@ static int toshiba_haps_available(acpi_handle handle) ...@@ -168,9 +168,13 @@ static int toshiba_haps_available(acpi_handle handle)
* A non existent device as well as having (only) * A non existent device as well as having (only)
* Solid State Drives can cause the call to fail. * Solid State Drives can cause the call to fail.
*/ */
status = acpi_evaluate_integer(handle, "_STA", NULL, status = acpi_evaluate_integer(handle, "_STA", NULL, &hdd_present);
&hdd_present); if (ACPI_FAILURE(status)) {
if (ACPI_FAILURE(status) || !hdd_present) { pr_err("ACPI call to query HDD protection failed\n");
return 0;
}
if (!hdd_present) {
pr_info("HDD protection not available or using SSD\n"); pr_info("HDD protection not available or using SSD\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment