Commit 065f3e49 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v4.11-2' of git://git.infradead.org/linux-platform-drivers-x86

Pull x86 platform driver updates from Darren Hart:
 "Asus fixes for the airplane LED and a long awaited fujitsu cleanup.

  asus-wmi:
   - Remove quirk_no_rfkill
   - Detect quirk_no_rfkill from the DSDT

  fujitsu-laptop:
   - remove redundant MODULE_ALIAS entries
   - autodetect LCD interface on all models
   - simplify acpi_bus_register_driver() error handling
   - remove redundant forward declarations
   - replace numeric values with constants
   - rename FUNC_RFKILL to FUNC_FLAGS
   - make platform-related variables match naming convention
   - replace "hotkey" with "laptop" in symbol names
   - clearly denote backlight-related symbols"

* tag 'platform-drivers-x86-v4.11-2' of git://git.infradead.org/linux-platform-drivers-x86:
  platform/x86: asus-wmi: Remove quirk_no_rfkill
  platform/x86: asus-wmi: Detect quirk_no_rfkill from the DSDT
  platform/x86: fujitsu-laptop: remove redundant MODULE_ALIAS entries
  platform/x86: fujitsu-laptop: autodetect LCD interface on all models
  platform/x86: fujitsu-laptop: simplify acpi_bus_register_driver() error handling
  platform/x86: fujitsu-laptop: remove redundant forward declarations
  platform/x86: fujitsu-laptop: replace numeric values with constants
  platform/x86: fujitsu-laptop: rename FUNC_RFKILL to FUNC_FLAGS
  platform/x86: fujitsu-laptop: make platform-related variables match naming convention
  platform/x86: fujitsu-laptop: replace "hotkey" with "laptop" in symbol names
  platform/x86: fujitsu-laptop: clearly denote backlight-related symbols
parents ce70df08 d1c4e9bf
...@@ -103,15 +103,6 @@ static struct quirk_entry quirk_asus_x200ca = { ...@@ -103,15 +103,6 @@ static struct quirk_entry quirk_asus_x200ca = {
.wapf = 2, .wapf = 2,
}; };
static struct quirk_entry quirk_no_rfkill = {
.no_rfkill = true,
};
static struct quirk_entry quirk_no_rfkill_wapf4 = {
.wapf = 4,
.no_rfkill = true,
};
static struct quirk_entry quirk_asus_ux303ub = { static struct quirk_entry quirk_asus_ux303ub = {
.wmi_backlight_native = true, .wmi_backlight_native = true,
}; };
...@@ -194,7 +185,7 @@ static const struct dmi_system_id asus_quirks[] = { ...@@ -194,7 +185,7 @@ static const struct dmi_system_id asus_quirks[] = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"), DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"),
}, },
.driver_data = &quirk_no_rfkill_wapf4, .driver_data = &quirk_asus_wapf4,
}, },
{ {
.callback = dmi_matched, .callback = dmi_matched,
...@@ -203,7 +194,7 @@ static const struct dmi_system_id asus_quirks[] = { ...@@ -203,7 +194,7 @@ static const struct dmi_system_id asus_quirks[] = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"), DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"),
}, },
.driver_data = &quirk_no_rfkill_wapf4, .driver_data = &quirk_asus_wapf4,
}, },
{ {
.callback = dmi_matched, .callback = dmi_matched,
...@@ -367,42 +358,6 @@ static const struct dmi_system_id asus_quirks[] = { ...@@ -367,42 +358,6 @@ static const struct dmi_system_id asus_quirks[] = {
}, },
.driver_data = &quirk_asus_x200ca, .driver_data = &quirk_asus_x200ca,
}, },
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. X555UB",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"),
},
.driver_data = &quirk_no_rfkill,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. N552VW",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "N552VW"),
},
.driver_data = &quirk_no_rfkill,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. U303LB",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "U303LB"),
},
.driver_data = &quirk_no_rfkill,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. Z550MA",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "Z550MA"),
},
.driver_data = &quirk_no_rfkill,
},
{ {
.callback = dmi_matched, .callback = dmi_matched,
.ident = "ASUSTeK COMPUTER INC. UX303UB", .ident = "ASUSTeK COMPUTER INC. UX303UB",
......
...@@ -159,6 +159,8 @@ MODULE_LICENSE("GPL"); ...@@ -159,6 +159,8 @@ MODULE_LICENSE("GPL");
#define USB_INTEL_XUSB2PR 0xD0 #define USB_INTEL_XUSB2PR 0xD0
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
struct bios_args { struct bios_args {
u32 arg0; u32 arg0;
u32 arg1; u32 arg1;
...@@ -2051,6 +2053,16 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) ...@@ -2051,6 +2053,16 @@ static int asus_wmi_fan_init(struct asus_wmi *asus)
return 0; return 0;
} }
static bool ashs_present(void)
{
int i = 0;
while (ashs_ids[i]) {
if (acpi_dev_found(ashs_ids[i++]))
return true;
}
return false;
}
/* /*
* WMI Driver * WMI Driver
*/ */
...@@ -2095,7 +2107,11 @@ static int asus_wmi_add(struct platform_device *pdev) ...@@ -2095,7 +2107,11 @@ static int asus_wmi_add(struct platform_device *pdev)
if (err) if (err)
goto fail_leds; goto fail_leds;
if (!asus->driver->quirks->no_rfkill) { asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result);
if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
asus->driver->wlan_ctrl_by_user = 1;
if (!(asus->driver->wlan_ctrl_by_user && ashs_present())) {
err = asus_wmi_rfkill_init(asus); err = asus_wmi_rfkill_init(asus);
if (err) if (err)
goto fail_rfkill; goto fail_rfkill;
...@@ -2134,10 +2150,6 @@ static int asus_wmi_add(struct platform_device *pdev) ...@@ -2134,10 +2150,6 @@ static int asus_wmi_add(struct platform_device *pdev)
if (err) if (err)
goto fail_debugfs; goto fail_debugfs;
asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result);
if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
asus->driver->wlan_ctrl_by_user = 1;
return 0; return 0;
fail_debugfs: fail_debugfs:
......
...@@ -39,7 +39,6 @@ struct key_entry; ...@@ -39,7 +39,6 @@ struct key_entry;
struct asus_wmi; struct asus_wmi;
struct quirk_entry { struct quirk_entry {
bool no_rfkill;
bool hotplug_wireless; bool hotplug_wireless;
bool scalar_panel_brightness; bool scalar_panel_brightness;
bool store_backlight_power; bool store_backlight_power;
......
...@@ -78,18 +78,18 @@ ...@@ -78,18 +78,18 @@
#define FUJITSU_LCD_N_LEVELS 8 #define FUJITSU_LCD_N_LEVELS 8
#define ACPI_FUJITSU_CLASS "fujitsu" #define ACPI_FUJITSU_CLASS "fujitsu"
#define ACPI_FUJITSU_HID "FUJ02B1" #define ACPI_FUJITSU_BL_HID "FUJ02B1"
#define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" #define ACPI_FUJITSU_BL_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver"
#define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" #define ACPI_FUJITSU_BL_DEVICE_NAME "Fujitsu FUJ02B1"
#define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3" #define ACPI_FUJITSU_LAPTOP_HID "FUJ02E3"
#define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" #define ACPI_FUJITSU_LAPTOP_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver"
#define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3" #define ACPI_FUJITSU_LAPTOP_DEVICE_NAME "Fujitsu FUJ02E3"
#define ACPI_FUJITSU_NOTIFY_CODE1 0x80 #define ACPI_FUJITSU_NOTIFY_CODE1 0x80
/* FUNC interface - command values */ /* FUNC interface - command values */
#define FUNC_RFKILL 0x1000 #define FUNC_FLAGS 0x1000
#define FUNC_LEDS 0x1001 #define FUNC_LEDS 0x1001
#define FUNC_BUTTONS 0x1002 #define FUNC_BUTTONS 0x1002
#define FUNC_BACKLIGHT 0x1004 #define FUNC_BACKLIGHT 0x1004
...@@ -97,6 +97,11 @@ ...@@ -97,6 +97,11 @@
/* FUNC interface - responses */ /* FUNC interface - responses */
#define UNSUPPORTED_CMD 0x80000000 #define UNSUPPORTED_CMD 0x80000000
/* FUNC interface - status flags */
#define FLAG_RFKILL 0x020
#define FLAG_LID 0x100
#define FLAG_DOCK 0x200
#if IS_ENABLED(CONFIG_LEDS_CLASS) #if IS_ENABLED(CONFIG_LEDS_CLASS)
/* FUNC interface - LED control */ /* FUNC interface - LED control */
#define FUNC_LED_OFF 0x1 #define FUNC_LED_OFF 0x1
...@@ -136,7 +141,7 @@ ...@@ -136,7 +141,7 @@
#endif #endif
/* Device controlling the backlight and associated keys */ /* Device controlling the backlight and associated keys */
struct fujitsu_t { struct fujitsu_bl {
acpi_handle acpi_handle; acpi_handle acpi_handle;
struct acpi_device *dev; struct acpi_device *dev;
struct input_dev *input; struct input_dev *input;
...@@ -150,12 +155,12 @@ struct fujitsu_t { ...@@ -150,12 +155,12 @@ struct fujitsu_t {
unsigned int brightness_level; unsigned int brightness_level;
}; };
static struct fujitsu_t *fujitsu; static struct fujitsu_bl *fujitsu_bl;
static int use_alt_lcd_levels = -1; static int use_alt_lcd_levels = -1;
static int disable_brightness_adjust = -1; static int disable_brightness_adjust = -1;
/* Device used to access other hotkeys on the laptop */ /* Device used to access hotkeys and other features on the laptop */
struct fujitsu_hotkey_t { struct fujitsu_laptop {
acpi_handle acpi_handle; acpi_handle acpi_handle;
struct acpi_device *dev; struct acpi_device *dev;
struct input_dev *input; struct input_dev *input;
...@@ -163,17 +168,15 @@ struct fujitsu_hotkey_t { ...@@ -163,17 +168,15 @@ struct fujitsu_hotkey_t {
struct platform_device *pf_device; struct platform_device *pf_device;
struct kfifo fifo; struct kfifo fifo;
spinlock_t fifo_lock; spinlock_t fifo_lock;
int rfkill_supported; int flags_supported;
int rfkill_state; int flags_state;
int logolamp_registered; int logolamp_registered;
int kblamps_registered; int kblamps_registered;
int radio_led_registered; int radio_led_registered;
int eco_led_registered; int eco_led_registered;
}; };
static struct fujitsu_hotkey_t *fujitsu_hotkey; static struct fujitsu_laptop *fujitsu_laptop;
static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
#if IS_ENABLED(CONFIG_LEDS_CLASS) #if IS_ENABLED(CONFIG_LEDS_CLASS)
static enum led_brightness logolamp_get(struct led_classdev *cdev); static enum led_brightness logolamp_get(struct led_classdev *cdev);
...@@ -222,8 +225,6 @@ static struct led_classdev eco_led = { ...@@ -222,8 +225,6 @@ static struct led_classdev eco_led = {
static u32 dbg_level = 0x03; static u32 dbg_level = 0x03;
#endif #endif
static void acpi_fujitsu_notify(struct acpi_device *device, u32 event);
/* Fujitsu ACPI interface function */ /* Fujitsu ACPI interface function */
static int call_fext_func(int cmd, int arg0, int arg1, int arg2) static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
...@@ -239,7 +240,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2) ...@@ -239,7 +240,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
unsigned long long value; unsigned long long value;
acpi_handle handle = NULL; acpi_handle handle = NULL;
status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle); status = acpi_get_handle(fujitsu_laptop->acpi_handle, "FUNC", &handle);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
vdbg_printk(FUJLAPTOP_DBG_ERROR, vdbg_printk(FUJLAPTOP_DBG_ERROR,
"FUNC interface is not present\n"); "FUNC interface is not present\n");
...@@ -300,9 +301,9 @@ static int radio_led_set(struct led_classdev *cdev, ...@@ -300,9 +301,9 @@ static int radio_led_set(struct led_classdev *cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
if (brightness >= LED_FULL) if (brightness >= LED_FULL)
return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON); return call_fext_func(FUNC_FLAGS, 0x5, RADIO_LED_ON, RADIO_LED_ON);
else else
return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0); return call_fext_func(FUNC_FLAGS, 0x5, RADIO_LED_ON, 0x0);
} }
static int eco_led_set(struct led_classdev *cdev, static int eco_led_set(struct led_classdev *cdev,
...@@ -346,7 +347,7 @@ static enum led_brightness radio_led_get(struct led_classdev *cdev) ...@@ -346,7 +347,7 @@ static enum led_brightness radio_led_get(struct led_classdev *cdev)
{ {
enum led_brightness brightness = LED_OFF; enum led_brightness brightness = LED_OFF;
if (call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0) & RADIO_LED_ON) if (call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON)
brightness = LED_FULL; brightness = LED_FULL;
return brightness; return brightness;
...@@ -373,10 +374,10 @@ static int set_lcd_level(int level) ...@@ -373,10 +374,10 @@ static int set_lcd_level(int level)
vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
level); level);
if (level < 0 || level >= fujitsu->max_brightness) if (level < 0 || level >= fujitsu_bl->max_brightness)
return -EINVAL; return -EINVAL;
status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBLL", &handle);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n");
return -ENODEV; return -ENODEV;
...@@ -398,10 +399,10 @@ static int set_lcd_level_alt(int level) ...@@ -398,10 +399,10 @@ static int set_lcd_level_alt(int level)
vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
level); level);
if (level < 0 || level >= fujitsu->max_brightness) if (level < 0 || level >= fujitsu_bl->max_brightness)
return -EINVAL; return -EINVAL;
status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle); status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBL2", &handle);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
return -ENODEV; return -ENODEV;
...@@ -421,19 +422,19 @@ static int get_lcd_level(void) ...@@ -421,19 +422,19 @@ static int get_lcd_level(void)
vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n"); vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n");
status = status = acpi_evaluate_integer(fujitsu_bl->acpi_handle, "GBLL", NULL,
acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); &state);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return 0; return 0;
fujitsu->brightness_level = state & 0x0fffffff; fujitsu_bl->brightness_level = state & 0x0fffffff;
if (state & 0x80000000) if (state & 0x80000000)
fujitsu->brightness_changed = 1; fujitsu_bl->brightness_changed = 1;
else else
fujitsu->brightness_changed = 0; fujitsu_bl->brightness_changed = 0;
return fujitsu->brightness_level; return fujitsu_bl->brightness_level;
} }
static int get_max_brightness(void) static int get_max_brightness(void)
...@@ -443,14 +444,14 @@ static int get_max_brightness(void) ...@@ -443,14 +444,14 @@ static int get_max_brightness(void)
vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n"); vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n");
status = status = acpi_evaluate_integer(fujitsu_bl->acpi_handle, "RBLL", NULL,
acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state); &state);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return -1; return -1;
fujitsu->max_brightness = state; fujitsu_bl->max_brightness = state;
return fujitsu->max_brightness; return fujitsu_bl->max_brightness;
} }
/* Backlight device stuff */ /* Backlight device stuff */
...@@ -483,7 +484,7 @@ static int bl_update_status(struct backlight_device *b) ...@@ -483,7 +484,7 @@ static int bl_update_status(struct backlight_device *b)
return ret; return ret;
} }
static const struct backlight_ops fujitsubl_ops = { static const struct backlight_ops fujitsu_bl_ops = {
.get_brightness = bl_get_brightness, .get_brightness = bl_get_brightness,
.update_status = bl_update_status, .update_status = bl_update_status,
}; };
...@@ -511,7 +512,7 @@ show_brightness_changed(struct device *dev, ...@@ -511,7 +512,7 @@ show_brightness_changed(struct device *dev,
int ret; int ret;
ret = fujitsu->brightness_changed; ret = fujitsu_bl->brightness_changed;
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -539,7 +540,7 @@ static ssize_t store_lcd_level(struct device *dev, ...@@ -539,7 +540,7 @@ static ssize_t store_lcd_level(struct device *dev,
int level, ret; int level, ret;
if (sscanf(buf, "%i", &level) != 1 if (sscanf(buf, "%i", &level) != 1
|| (level < 0 || level >= fujitsu->max_brightness)) || (level < 0 || level >= fujitsu_bl->max_brightness))
return -EINVAL; return -EINVAL;
if (use_alt_lcd_levels) if (use_alt_lcd_levels)
...@@ -567,9 +568,9 @@ static ssize_t ...@@ -567,9 +568,9 @@ static ssize_t
show_lid_state(struct device *dev, show_lid_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (!(fujitsu_hotkey->rfkill_supported & 0x100)) if (!(fujitsu_laptop->flags_supported & FLAG_LID))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x100) if (fujitsu_laptop->flags_state & FLAG_LID)
return sprintf(buf, "open\n"); return sprintf(buf, "open\n");
else else
return sprintf(buf, "closed\n"); return sprintf(buf, "closed\n");
...@@ -579,9 +580,9 @@ static ssize_t ...@@ -579,9 +580,9 @@ static ssize_t
show_dock_state(struct device *dev, show_dock_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (!(fujitsu_hotkey->rfkill_supported & 0x200)) if (!(fujitsu_laptop->flags_supported & FLAG_DOCK))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x200) if (fujitsu_laptop->flags_state & FLAG_DOCK)
return sprintf(buf, "docked\n"); return sprintf(buf, "docked\n");
else else
return sprintf(buf, "undocked\n"); return sprintf(buf, "undocked\n");
...@@ -591,9 +592,9 @@ static ssize_t ...@@ -591,9 +592,9 @@ static ssize_t
show_radios_state(struct device *dev, show_radios_state(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (!(fujitsu_hotkey->rfkill_supported & 0x20)) if (!(fujitsu_laptop->flags_supported & FLAG_RFKILL))
return sprintf(buf, "unknown\n"); return sprintf(buf, "unknown\n");
if (fujitsu_hotkey->rfkill_state & 0x20) if (fujitsu_laptop->flags_state & FLAG_RFKILL)
return sprintf(buf, "on\n"); return sprintf(buf, "on\n");
else else
return sprintf(buf, "killed\n"); return sprintf(buf, "killed\n");
...@@ -607,7 +608,7 @@ static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store); ...@@ -607,7 +608,7 @@ static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store); static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store); static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
static struct attribute *fujitsupf_attributes[] = { static struct attribute *fujitsu_pf_attributes[] = {
&dev_attr_brightness_changed.attr, &dev_attr_brightness_changed.attr,
&dev_attr_max_brightness.attr, &dev_attr_max_brightness.attr,
&dev_attr_lcd_level.attr, &dev_attr_lcd_level.attr,
...@@ -617,11 +618,11 @@ static struct attribute *fujitsupf_attributes[] = { ...@@ -617,11 +618,11 @@ static struct attribute *fujitsupf_attributes[] = {
NULL NULL
}; };
static struct attribute_group fujitsupf_attribute_group = { static struct attribute_group fujitsu_pf_attribute_group = {
.attrs = fujitsupf_attributes .attrs = fujitsu_pf_attributes
}; };
static struct platform_driver fujitsupf_driver = { static struct platform_driver fujitsu_pf_driver = {
.driver = { .driver = {
.name = "fujitsu-laptop", .name = "fujitsu-laptop",
} }
...@@ -630,39 +631,30 @@ static struct platform_driver fujitsupf_driver = { ...@@ -630,39 +631,30 @@ static struct platform_driver fujitsupf_driver = {
static void __init dmi_check_cb_common(const struct dmi_system_id *id) static void __init dmi_check_cb_common(const struct dmi_system_id *id)
{ {
pr_info("Identified laptop model '%s'\n", id->ident); pr_info("Identified laptop model '%s'\n", id->ident);
if (use_alt_lcd_levels == -1) {
if (acpi_has_method(NULL,
"\\_SB.PCI0.LPCB.FJEX.SBL2"))
use_alt_lcd_levels = 1;
else
use_alt_lcd_levels = 0;
vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
"%i\n", use_alt_lcd_levels);
}
} }
static int __init dmi_check_cb_s6410(const struct dmi_system_id *id) static int __init dmi_check_cb_s6410(const struct dmi_system_id *id)
{ {
dmi_check_cb_common(id); dmi_check_cb_common(id);
fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ fujitsu_bl->keycode1 = KEY_SCREENLOCK; /* "Lock" */
fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ fujitsu_bl->keycode2 = KEY_HELP; /* "Mobility Center" */
return 1; return 1;
} }
static int __init dmi_check_cb_s6420(const struct dmi_system_id *id) static int __init dmi_check_cb_s6420(const struct dmi_system_id *id)
{ {
dmi_check_cb_common(id); dmi_check_cb_common(id);
fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ fujitsu_bl->keycode1 = KEY_SCREENLOCK; /* "Lock" */
fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ fujitsu_bl->keycode2 = KEY_HELP; /* "Mobility Center" */
return 1; return 1;
} }
static int __init dmi_check_cb_p8010(const struct dmi_system_id *id) static int __init dmi_check_cb_p8010(const struct dmi_system_id *id)
{ {
dmi_check_cb_common(id); dmi_check_cb_common(id);
fujitsu->keycode1 = KEY_HELP; /* "Support" */ fujitsu_bl->keycode1 = KEY_HELP; /* "Support" */
fujitsu->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */ fujitsu_bl->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */
fujitsu->keycode4 = KEY_WWW; /* "Internet" */ fujitsu_bl->keycode4 = KEY_WWW; /* "Internet" */
return 1; return 1;
} }
...@@ -693,7 +685,7 @@ static const struct dmi_system_id fujitsu_dmi_table[] __initconst = { ...@@ -693,7 +685,7 @@ static const struct dmi_system_id fujitsu_dmi_table[] __initconst = {
/* ACPI device for LCD brightness control */ /* ACPI device for LCD brightness control */
static int acpi_fujitsu_add(struct acpi_device *device) static int acpi_fujitsu_bl_add(struct acpi_device *device)
{ {
int state = 0; int state = 0;
struct input_dev *input; struct input_dev *input;
...@@ -702,22 +694,22 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -702,22 +694,22 @@ static int acpi_fujitsu_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
fujitsu->acpi_handle = device->handle; fujitsu_bl->acpi_handle = device->handle;
sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME); sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_BL_DEVICE_NAME);
sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
device->driver_data = fujitsu; device->driver_data = fujitsu_bl;
fujitsu->input = input = input_allocate_device(); fujitsu_bl->input = input = input_allocate_device();
if (!input) { if (!input) {
error = -ENOMEM; error = -ENOMEM;
goto err_stop; goto err_stop;
} }
snprintf(fujitsu->phys, sizeof(fujitsu->phys), snprintf(fujitsu_bl->phys, sizeof(fujitsu_bl->phys),
"%s/video/input0", acpi_device_hid(device)); "%s/video/input0", acpi_device_hid(device));
input->name = acpi_device_name(device); input->name = acpi_device_name(device);
input->phys = fujitsu->phys; input->phys = fujitsu_bl->phys;
input->id.bustype = BUS_HOST; input->id.bustype = BUS_HOST;
input->id.product = 0x06; input->id.product = 0x06;
input->dev.parent = &device->dev; input->dev.parent = &device->dev;
...@@ -730,7 +722,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -730,7 +722,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
if (error) if (error)
goto err_free_input_dev; goto err_free_input_dev;
error = acpi_bus_update_power(fujitsu->acpi_handle, &state); error = acpi_bus_update_power(fujitsu_bl->acpi_handle, &state);
if (error) { if (error) {
pr_err("Error reading power state\n"); pr_err("Error reading power state\n");
goto err_unregister_input_dev; goto err_unregister_input_dev;
...@@ -740,7 +732,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -740,7 +732,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
acpi_device_name(device), acpi_device_bid(device), acpi_device_name(device), acpi_device_bid(device),
!device->power.state ? "on" : "off"); !device->power.state ? "on" : "off");
fujitsu->dev = device; fujitsu_bl->dev = device;
if (acpi_has_method(device->handle, METHOD_NAME__INI)) { if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
...@@ -750,6 +742,15 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -750,6 +742,15 @@ static int acpi_fujitsu_add(struct acpi_device *device)
pr_err("_INI Method failed\n"); pr_err("_INI Method failed\n");
} }
if (use_alt_lcd_levels == -1) {
if (acpi_has_method(NULL, "\\_SB.PCI0.LPCB.FJEX.SBL2"))
use_alt_lcd_levels = 1;
else
use_alt_lcd_levels = 0;
vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as %i\n",
use_alt_lcd_levels);
}
/* do config (detect defaults) */ /* do config (detect defaults) */
use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
...@@ -758,7 +759,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -758,7 +759,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
use_alt_lcd_levels, disable_brightness_adjust); use_alt_lcd_levels, disable_brightness_adjust);
if (get_max_brightness() <= 0) if (get_max_brightness() <= 0)
fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; fujitsu_bl->max_brightness = FUJITSU_LCD_N_LEVELS;
get_lcd_level(); get_lcd_level();
return 0; return 0;
...@@ -772,38 +773,38 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -772,38 +773,38 @@ static int acpi_fujitsu_add(struct acpi_device *device)
return error; return error;
} }
static int acpi_fujitsu_remove(struct acpi_device *device) static int acpi_fujitsu_bl_remove(struct acpi_device *device)
{ {
struct fujitsu_t *fujitsu = acpi_driver_data(device); struct fujitsu_bl *fujitsu_bl = acpi_driver_data(device);
struct input_dev *input = fujitsu->input; struct input_dev *input = fujitsu_bl->input;
input_unregister_device(input); input_unregister_device(input);
fujitsu->acpi_handle = NULL; fujitsu_bl->acpi_handle = NULL;
return 0; return 0;
} }
/* Brightness notify */ /* Brightness notify */
static void acpi_fujitsu_notify(struct acpi_device *device, u32 event) static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
{ {
struct input_dev *input; struct input_dev *input;
int keycode; int keycode;
int oldb, newb; int oldb, newb;
input = fujitsu->input; input = fujitsu_bl->input;
switch (event) { switch (event) {
case ACPI_FUJITSU_NOTIFY_CODE1: case ACPI_FUJITSU_NOTIFY_CODE1:
keycode = 0; keycode = 0;
oldb = fujitsu->brightness_level; oldb = fujitsu_bl->brightness_level;
get_lcd_level(); get_lcd_level();
newb = fujitsu->brightness_level; newb = fujitsu_bl->brightness_level;
vdbg_printk(FUJLAPTOP_DBG_TRACE, vdbg_printk(FUJLAPTOP_DBG_TRACE,
"brightness button event [%i -> %i (%i)]\n", "brightness button event [%i -> %i (%i)]\n",
oldb, newb, fujitsu->brightness_changed); oldb, newb, fujitsu_bl->brightness_changed);
if (oldb < newb) { if (oldb < newb) {
if (disable_brightness_adjust != 1) { if (disable_brightness_adjust != 1) {
...@@ -840,7 +841,7 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event) ...@@ -840,7 +841,7 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
/* ACPI device for hotkey handling */ /* ACPI device for hotkey handling */
static int acpi_fujitsu_hotkey_add(struct acpi_device *device) static int acpi_fujitsu_laptop_add(struct acpi_device *device)
{ {
int result = 0; int result = 0;
int state = 0; int state = 0;
...@@ -851,42 +852,42 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -851,42 +852,42 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
if (!device) if (!device)
return -EINVAL; return -EINVAL;
fujitsu_hotkey->acpi_handle = device->handle; fujitsu_laptop->acpi_handle = device->handle;
sprintf(acpi_device_name(device), "%s", sprintf(acpi_device_name(device), "%s",
ACPI_FUJITSU_HOTKEY_DEVICE_NAME); ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
device->driver_data = fujitsu_hotkey; device->driver_data = fujitsu_laptop;
/* kfifo */ /* kfifo */
spin_lock_init(&fujitsu_hotkey->fifo_lock); spin_lock_init(&fujitsu_laptop->fifo_lock);
error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int), error = kfifo_alloc(&fujitsu_laptop->fifo, RINGBUFFERSIZE * sizeof(int),
GFP_KERNEL); GFP_KERNEL);
if (error) { if (error) {
pr_err("kfifo_alloc failed\n"); pr_err("kfifo_alloc failed\n");
goto err_stop; goto err_stop;
} }
fujitsu_hotkey->input = input = input_allocate_device(); fujitsu_laptop->input = input = input_allocate_device();
if (!input) { if (!input) {
error = -ENOMEM; error = -ENOMEM;
goto err_free_fifo; goto err_free_fifo;
} }
snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys), snprintf(fujitsu_laptop->phys, sizeof(fujitsu_laptop->phys),
"%s/video/input0", acpi_device_hid(device)); "%s/video/input0", acpi_device_hid(device));
input->name = acpi_device_name(device); input->name = acpi_device_name(device);
input->phys = fujitsu_hotkey->phys; input->phys = fujitsu_laptop->phys;
input->id.bustype = BUS_HOST; input->id.bustype = BUS_HOST;
input->id.product = 0x06; input->id.product = 0x06;
input->dev.parent = &device->dev; input->dev.parent = &device->dev;
set_bit(EV_KEY, input->evbit); set_bit(EV_KEY, input->evbit);
set_bit(fujitsu->keycode1, input->keybit); set_bit(fujitsu_bl->keycode1, input->keybit);
set_bit(fujitsu->keycode2, input->keybit); set_bit(fujitsu_bl->keycode2, input->keybit);
set_bit(fujitsu->keycode3, input->keybit); set_bit(fujitsu_bl->keycode3, input->keybit);
set_bit(fujitsu->keycode4, input->keybit); set_bit(fujitsu_bl->keycode4, input->keybit);
set_bit(fujitsu->keycode5, input->keybit); set_bit(fujitsu_bl->keycode5, input->keybit);
set_bit(KEY_TOUCHPAD_TOGGLE, input->keybit); set_bit(KEY_TOUCHPAD_TOGGLE, input->keybit);
set_bit(KEY_UNKNOWN, input->keybit); set_bit(KEY_UNKNOWN, input->keybit);
...@@ -894,7 +895,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -894,7 +895,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
if (error) if (error)
goto err_free_input_dev; goto err_free_input_dev;
error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state); error = acpi_bus_update_power(fujitsu_laptop->acpi_handle, &state);
if (error) { if (error) {
pr_err("Error reading power state\n"); pr_err("Error reading power state\n");
goto err_unregister_input_dev; goto err_unregister_input_dev;
...@@ -904,7 +905,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -904,7 +905,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
acpi_device_name(device), acpi_device_bid(device), acpi_device_name(device), acpi_device_bid(device),
!device->power.state ? "on" : "off"); !device->power.state ? "on" : "off");
fujitsu_hotkey->dev = device; fujitsu_laptop->dev = device;
if (acpi_has_method(device->handle, METHOD_NAME__INI)) { if (acpi_has_method(device->handle, METHOD_NAME__INI)) {
vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
...@@ -920,27 +921,27 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -920,27 +921,27 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
; /* No action, result is discarded */ ; /* No action, result is discarded */
vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
fujitsu_hotkey->rfkill_supported = fujitsu_laptop->flags_supported =
call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0); call_fext_func(FUNC_FLAGS, 0x0, 0x0, 0x0);
/* Make sure our bitmask of supported functions is cleared if the /* Make sure our bitmask of supported functions is cleared if the
RFKILL function block is not implemented, like on the S7020. */ RFKILL function block is not implemented, like on the S7020. */
if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD) if (fujitsu_laptop->flags_supported == UNSUPPORTED_CMD)
fujitsu_hotkey->rfkill_supported = 0; fujitsu_laptop->flags_supported = 0;
if (fujitsu_hotkey->rfkill_supported) if (fujitsu_laptop->flags_supported)
fujitsu_hotkey->rfkill_state = fujitsu_laptop->flags_state =
call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0);
/* Suspect this is a keymap of the application panel, print it */ /* Suspect this is a keymap of the application panel, print it */
pr_info("BTNI: [0x%x]\n", call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0)); pr_info("BTNI: [0x%x]\n", call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
#if IS_ENABLED(CONFIG_LEDS_CLASS) #if IS_ENABLED(CONFIG_LEDS_CLASS)
if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
result = led_classdev_register(&fujitsu->pf_device->dev, result = led_classdev_register(&fujitsu_bl->pf_device->dev,
&logolamp_led); &logolamp_led);
if (result == 0) { if (result == 0) {
fujitsu_hotkey->logolamp_registered = 1; fujitsu_laptop->logolamp_registered = 1;
} else { } else {
pr_err("Could not register LED handler for logo lamp, error %i\n", pr_err("Could not register LED handler for logo lamp, error %i\n",
result); result);
...@@ -949,10 +950,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -949,10 +950,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
(call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
result = led_classdev_register(&fujitsu->pf_device->dev, result = led_classdev_register(&fujitsu_bl->pf_device->dev,
&kblamps_led); &kblamps_led);
if (result == 0) { if (result == 0) {
fujitsu_hotkey->kblamps_registered = 1; fujitsu_laptop->kblamps_registered = 1;
} else { } else {
pr_err("Could not register LED handler for keyboard lamps, error %i\n", pr_err("Could not register LED handler for keyboard lamps, error %i\n",
result); result);
...@@ -966,10 +967,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -966,10 +967,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
* that an RF LED is present. * that an RF LED is present.
*/ */
if (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) & BIT(24)) { if (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) & BIT(24)) {
result = led_classdev_register(&fujitsu->pf_device->dev, result = led_classdev_register(&fujitsu_bl->pf_device->dev,
&radio_led); &radio_led);
if (result == 0) { if (result == 0) {
fujitsu_hotkey->radio_led_registered = 1; fujitsu_laptop->radio_led_registered = 1;
} else { } else {
pr_err("Could not register LED handler for radio LED, error %i\n", pr_err("Could not register LED handler for radio LED, error %i\n",
result); result);
...@@ -983,10 +984,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -983,10 +984,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
*/ */
if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) && if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) &&
(call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) { (call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) {
result = led_classdev_register(&fujitsu->pf_device->dev, result = led_classdev_register(&fujitsu_bl->pf_device->dev,
&eco_led); &eco_led);
if (result == 0) { if (result == 0) {
fujitsu_hotkey->eco_led_registered = 1; fujitsu_laptop->eco_led_registered = 1;
} else { } else {
pr_err("Could not register LED handler for eco LED, error %i\n", pr_err("Could not register LED handler for eco LED, error %i\n",
result); result);
...@@ -1002,47 +1003,47 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -1002,47 +1003,47 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
err_free_input_dev: err_free_input_dev:
input_free_device(input); input_free_device(input);
err_free_fifo: err_free_fifo:
kfifo_free(&fujitsu_hotkey->fifo); kfifo_free(&fujitsu_laptop->fifo);
err_stop: err_stop:
return error; return error;
} }
static int acpi_fujitsu_hotkey_remove(struct acpi_device *device) static int acpi_fujitsu_laptop_remove(struct acpi_device *device)
{ {
struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device); struct fujitsu_laptop *fujitsu_laptop = acpi_driver_data(device);
struct input_dev *input = fujitsu_hotkey->input; struct input_dev *input = fujitsu_laptop->input;
#if IS_ENABLED(CONFIG_LEDS_CLASS) #if IS_ENABLED(CONFIG_LEDS_CLASS)
if (fujitsu_hotkey->logolamp_registered) if (fujitsu_laptop->logolamp_registered)
led_classdev_unregister(&logolamp_led); led_classdev_unregister(&logolamp_led);
if (fujitsu_hotkey->kblamps_registered) if (fujitsu_laptop->kblamps_registered)
led_classdev_unregister(&kblamps_led); led_classdev_unregister(&kblamps_led);
if (fujitsu_hotkey->radio_led_registered) if (fujitsu_laptop->radio_led_registered)
led_classdev_unregister(&radio_led); led_classdev_unregister(&radio_led);
if (fujitsu_hotkey->eco_led_registered) if (fujitsu_laptop->eco_led_registered)
led_classdev_unregister(&eco_led); led_classdev_unregister(&eco_led);
#endif #endif
input_unregister_device(input); input_unregister_device(input);
kfifo_free(&fujitsu_hotkey->fifo); kfifo_free(&fujitsu_laptop->fifo);
fujitsu_hotkey->acpi_handle = NULL; fujitsu_laptop->acpi_handle = NULL;
return 0; return 0;
} }
static void acpi_fujitsu_hotkey_press(int keycode) static void acpi_fujitsu_laptop_press(int keycode)
{ {
struct input_dev *input = fujitsu_hotkey->input; struct input_dev *input = fujitsu_laptop->input;
int status; int status;
status = kfifo_in_locked(&fujitsu_hotkey->fifo, status = kfifo_in_locked(&fujitsu_laptop->fifo,
(unsigned char *)&keycode, sizeof(keycode), (unsigned char *)&keycode, sizeof(keycode),
&fujitsu_hotkey->fifo_lock); &fujitsu_laptop->fifo_lock);
if (status != sizeof(keycode)) { if (status != sizeof(keycode)) {
vdbg_printk(FUJLAPTOP_DBG_WARN, vdbg_printk(FUJLAPTOP_DBG_WARN,
"Could not push keycode [0x%x]\n", keycode); "Could not push keycode [0x%x]\n", keycode);
...@@ -1054,16 +1055,16 @@ static void acpi_fujitsu_hotkey_press(int keycode) ...@@ -1054,16 +1055,16 @@ static void acpi_fujitsu_hotkey_press(int keycode)
"Push keycode into ringbuffer [%d]\n", keycode); "Push keycode into ringbuffer [%d]\n", keycode);
} }
static void acpi_fujitsu_hotkey_release(void) static void acpi_fujitsu_laptop_release(void)
{ {
struct input_dev *input = fujitsu_hotkey->input; struct input_dev *input = fujitsu_laptop->input;
int keycode, status; int keycode, status;
while (true) { while (true) {
status = kfifo_out_locked(&fujitsu_hotkey->fifo, status = kfifo_out_locked(&fujitsu_laptop->fifo,
(unsigned char *)&keycode, (unsigned char *)&keycode,
sizeof(keycode), sizeof(keycode),
&fujitsu_hotkey->fifo_lock); &fujitsu_laptop->fifo_lock);
if (status != sizeof(keycode)) if (status != sizeof(keycode))
return; return;
input_report_key(input, keycode, 0); input_report_key(input, keycode, 0);
...@@ -1073,14 +1074,14 @@ static void acpi_fujitsu_hotkey_release(void) ...@@ -1073,14 +1074,14 @@ static void acpi_fujitsu_hotkey_release(void)
} }
} }
static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
{ {
struct input_dev *input; struct input_dev *input;
int keycode; int keycode;
unsigned int irb = 1; unsigned int irb = 1;
int i; int i;
input = fujitsu_hotkey->input; input = fujitsu_laptop->input;
if (event != ACPI_FUJITSU_NOTIFY_CODE1) { if (event != ACPI_FUJITSU_NOTIFY_CODE1) {
keycode = KEY_UNKNOWN; keycode = KEY_UNKNOWN;
...@@ -1093,9 +1094,9 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) ...@@ -1093,9 +1094,9 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
return; return;
} }
if (fujitsu_hotkey->rfkill_supported) if (fujitsu_laptop->flags_supported)
fujitsu_hotkey->rfkill_state = fujitsu_laptop->flags_state =
call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0);
i = 0; i = 0;
while ((irb = while ((irb =
...@@ -1103,19 +1104,19 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) ...@@ -1103,19 +1104,19 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
&& (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
switch (irb & 0x4ff) { switch (irb & 0x4ff) {
case KEY1_CODE: case KEY1_CODE:
keycode = fujitsu->keycode1; keycode = fujitsu_bl->keycode1;
break; break;
case KEY2_CODE: case KEY2_CODE:
keycode = fujitsu->keycode2; keycode = fujitsu_bl->keycode2;
break; break;
case KEY3_CODE: case KEY3_CODE:
keycode = fujitsu->keycode3; keycode = fujitsu_bl->keycode3;
break; break;
case KEY4_CODE: case KEY4_CODE:
keycode = fujitsu->keycode4; keycode = fujitsu_bl->keycode4;
break; break;
case KEY5_CODE: case KEY5_CODE:
keycode = fujitsu->keycode5; keycode = fujitsu_bl->keycode5;
break; break;
case 0: case 0:
keycode = 0; keycode = 0;
...@@ -1128,17 +1129,17 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) ...@@ -1128,17 +1129,17 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
} }
if (keycode > 0) if (keycode > 0)
acpi_fujitsu_hotkey_press(keycode); acpi_fujitsu_laptop_press(keycode);
else if (keycode == 0) else if (keycode == 0)
acpi_fujitsu_hotkey_release(); acpi_fujitsu_laptop_release();
} }
/* On some models (first seen on the Skylake-based Lifebook /* On some models (first seen on the Skylake-based Lifebook
* E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is
* handled in software; its state is queried using FUNC_RFKILL * handled in software; its state is queried using FUNC_FLAGS
*/ */
if ((fujitsu_hotkey->rfkill_supported & BIT(26)) && if ((fujitsu_laptop->flags_supported & BIT(26)) &&
(call_fext_func(FUNC_RFKILL, 0x1, 0x0, 0x0) & BIT(26))) { (call_fext_func(FUNC_FLAGS, 0x1, 0x0, 0x0) & BIT(26))) {
keycode = KEY_TOUCHPAD_TOGGLE; keycode = KEY_TOUCHPAD_TOGGLE;
input_report_key(input, keycode, 1); input_report_key(input, keycode, 1);
input_sync(input); input_sync(input);
...@@ -1150,83 +1151,81 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) ...@@ -1150,83 +1151,81 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
/* Initialization */ /* Initialization */
static const struct acpi_device_id fujitsu_device_ids[] = { static const struct acpi_device_id fujitsu_bl_device_ids[] = {
{ACPI_FUJITSU_HID, 0}, {ACPI_FUJITSU_BL_HID, 0},
{"", 0}, {"", 0},
}; };
static struct acpi_driver acpi_fujitsu_driver = { static struct acpi_driver acpi_fujitsu_bl_driver = {
.name = ACPI_FUJITSU_DRIVER_NAME, .name = ACPI_FUJITSU_BL_DRIVER_NAME,
.class = ACPI_FUJITSU_CLASS, .class = ACPI_FUJITSU_CLASS,
.ids = fujitsu_device_ids, .ids = fujitsu_bl_device_ids,
.ops = { .ops = {
.add = acpi_fujitsu_add, .add = acpi_fujitsu_bl_add,
.remove = acpi_fujitsu_remove, .remove = acpi_fujitsu_bl_remove,
.notify = acpi_fujitsu_notify, .notify = acpi_fujitsu_bl_notify,
}, },
}; };
static const struct acpi_device_id fujitsu_hotkey_device_ids[] = { static const struct acpi_device_id fujitsu_laptop_device_ids[] = {
{ACPI_FUJITSU_HOTKEY_HID, 0}, {ACPI_FUJITSU_LAPTOP_HID, 0},
{"", 0}, {"", 0},
}; };
static struct acpi_driver acpi_fujitsu_hotkey_driver = { static struct acpi_driver acpi_fujitsu_laptop_driver = {
.name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME, .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME,
.class = ACPI_FUJITSU_CLASS, .class = ACPI_FUJITSU_CLASS,
.ids = fujitsu_hotkey_device_ids, .ids = fujitsu_laptop_device_ids,
.ops = { .ops = {
.add = acpi_fujitsu_hotkey_add, .add = acpi_fujitsu_laptop_add,
.remove = acpi_fujitsu_hotkey_remove, .remove = acpi_fujitsu_laptop_remove,
.notify = acpi_fujitsu_hotkey_notify, .notify = acpi_fujitsu_laptop_notify,
}, },
}; };
static const struct acpi_device_id fujitsu_ids[] __used = { static const struct acpi_device_id fujitsu_ids[] __used = {
{ACPI_FUJITSU_HID, 0}, {ACPI_FUJITSU_BL_HID, 0},
{ACPI_FUJITSU_HOTKEY_HID, 0}, {ACPI_FUJITSU_LAPTOP_HID, 0},
{"", 0} {"", 0}
}; };
MODULE_DEVICE_TABLE(acpi, fujitsu_ids); MODULE_DEVICE_TABLE(acpi, fujitsu_ids);
static int __init fujitsu_init(void) static int __init fujitsu_init(void)
{ {
int ret, result, max_brightness; int ret, max_brightness;
if (acpi_disabled) if (acpi_disabled)
return -ENODEV; return -ENODEV;
fujitsu = kzalloc(sizeof(struct fujitsu_t), GFP_KERNEL); fujitsu_bl = kzalloc(sizeof(struct fujitsu_bl), GFP_KERNEL);
if (!fujitsu) if (!fujitsu_bl)
return -ENOMEM; return -ENOMEM;
fujitsu->keycode1 = KEY_PROG1; fujitsu_bl->keycode1 = KEY_PROG1;
fujitsu->keycode2 = KEY_PROG2; fujitsu_bl->keycode2 = KEY_PROG2;
fujitsu->keycode3 = KEY_PROG3; fujitsu_bl->keycode3 = KEY_PROG3;
fujitsu->keycode4 = KEY_PROG4; fujitsu_bl->keycode4 = KEY_PROG4;
fujitsu->keycode5 = KEY_RFKILL; fujitsu_bl->keycode5 = KEY_RFKILL;
dmi_check_system(fujitsu_dmi_table); dmi_check_system(fujitsu_dmi_table);
result = acpi_bus_register_driver(&acpi_fujitsu_driver); ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver);
if (result < 0) { if (ret)
ret = -ENODEV;
goto fail_acpi; goto fail_acpi;
}
/* Register platform stuff */ /* Register platform stuff */
fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); fujitsu_bl->pf_device = platform_device_alloc("fujitsu-laptop", -1);
if (!fujitsu->pf_device) { if (!fujitsu_bl->pf_device) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail_platform_driver; goto fail_platform_driver;
} }
ret = platform_device_add(fujitsu->pf_device); ret = platform_device_add(fujitsu_bl->pf_device);
if (ret) if (ret)
goto fail_platform_device1; goto fail_platform_device1;
ret = ret =
sysfs_create_group(&fujitsu->pf_device->dev.kobj, sysfs_create_group(&fujitsu_bl->pf_device->dev.kobj,
&fujitsupf_attribute_group); &fujitsu_pf_attribute_group);
if (ret) if (ret)
goto fail_platform_device2; goto fail_platform_device2;
...@@ -1236,90 +1235,88 @@ static int __init fujitsu_init(void) ...@@ -1236,90 +1235,88 @@ static int __init fujitsu_init(void)
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
max_brightness = fujitsu->max_brightness; max_brightness = fujitsu_bl->max_brightness;
props.type = BACKLIGHT_PLATFORM; props.type = BACKLIGHT_PLATFORM;
props.max_brightness = max_brightness - 1; props.max_brightness = max_brightness - 1;
fujitsu->bl_device = backlight_device_register("fujitsu-laptop", fujitsu_bl->bl_device = backlight_device_register("fujitsu-laptop",
NULL, NULL, NULL, NULL,
&fujitsubl_ops, &fujitsu_bl_ops,
&props); &props);
if (IS_ERR(fujitsu->bl_device)) { if (IS_ERR(fujitsu_bl->bl_device)) {
ret = PTR_ERR(fujitsu->bl_device); ret = PTR_ERR(fujitsu_bl->bl_device);
fujitsu->bl_device = NULL; fujitsu_bl->bl_device = NULL;
goto fail_sysfs_group; goto fail_sysfs_group;
} }
fujitsu->bl_device->props.brightness = fujitsu->brightness_level; fujitsu_bl->bl_device->props.brightness = fujitsu_bl->brightness_level;
} }
ret = platform_driver_register(&fujitsupf_driver); ret = platform_driver_register(&fujitsu_pf_driver);
if (ret) if (ret)
goto fail_backlight; goto fail_backlight;
/* Register hotkey driver */ /* Register laptop driver */
fujitsu_hotkey = kzalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL); fujitsu_laptop = kzalloc(sizeof(struct fujitsu_laptop), GFP_KERNEL);
if (!fujitsu_hotkey) { if (!fujitsu_laptop) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail_hotkey; goto fail_laptop;
} }
result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver); ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver);
if (result < 0) { if (ret)
ret = -ENODEV; goto fail_laptop1;
goto fail_hotkey1;
}
/* Sync backlight power status (needs FUJ02E3 device, hence deferred) */ /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3) if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
fujitsu->bl_device->props.power = FB_BLANK_POWERDOWN; fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN;
else else
fujitsu->bl_device->props.power = FB_BLANK_UNBLANK; fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK;
} }
pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n"); pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n");
return 0; return 0;
fail_hotkey1: fail_laptop1:
kfree(fujitsu_hotkey); kfree(fujitsu_laptop);
fail_hotkey: fail_laptop:
platform_driver_unregister(&fujitsupf_driver); platform_driver_unregister(&fujitsu_pf_driver);
fail_backlight: fail_backlight:
backlight_device_unregister(fujitsu->bl_device); backlight_device_unregister(fujitsu_bl->bl_device);
fail_sysfs_group: fail_sysfs_group:
sysfs_remove_group(&fujitsu->pf_device->dev.kobj, sysfs_remove_group(&fujitsu_bl->pf_device->dev.kobj,
&fujitsupf_attribute_group); &fujitsu_pf_attribute_group);
fail_platform_device2: fail_platform_device2:
platform_device_del(fujitsu->pf_device); platform_device_del(fujitsu_bl->pf_device);
fail_platform_device1: fail_platform_device1:
platform_device_put(fujitsu->pf_device); platform_device_put(fujitsu_bl->pf_device);
fail_platform_driver: fail_platform_driver:
acpi_bus_unregister_driver(&acpi_fujitsu_driver); acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
fail_acpi: fail_acpi:
kfree(fujitsu); kfree(fujitsu_bl);
return ret; return ret;
} }
static void __exit fujitsu_cleanup(void) static void __exit fujitsu_cleanup(void)
{ {
acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver); acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver);
kfree(fujitsu_hotkey); kfree(fujitsu_laptop);
platform_driver_unregister(&fujitsupf_driver); platform_driver_unregister(&fujitsu_pf_driver);
backlight_device_unregister(fujitsu->bl_device); backlight_device_unregister(fujitsu_bl->bl_device);
sysfs_remove_group(&fujitsu->pf_device->dev.kobj, sysfs_remove_group(&fujitsu_bl->pf_device->dev.kobj,
&fujitsupf_attribute_group); &fujitsu_pf_attribute_group);
platform_device_unregister(fujitsu->pf_device); platform_device_unregister(fujitsu_bl->pf_device);
acpi_bus_unregister_driver(&acpi_fujitsu_driver); acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver);
kfree(fujitsu); kfree(fujitsu_bl);
pr_info("driver unloaded\n"); pr_info("driver unloaded\n");
} }
...@@ -1341,7 +1338,3 @@ MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon"); ...@@ -1341,7 +1338,3 @@ MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
MODULE_DESCRIPTION("Fujitsu laptop extras support"); MODULE_DESCRIPTION("Fujitsu laptop extras support");
MODULE_VERSION(FUJITSU_DRIVER_VERSION); MODULE_VERSION(FUJITSU_DRIVER_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
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