ACPI and driver patches for 2.6.31-rc1
Len Brown
reviewera couple that should have made the merge window...
Len Brown
reviewerPATCH 1/8 eeepc-laptop: Register as a pci-hotplug device
From: Corentin Chary <[email protected]>
The eee contains a logically (but not physically) hotpluggable PCIe slot. Currently this is handled by adding or removing the PCI device in response to rfkill events, but if a user has forced pciehp to bind to it (with the force=1 argument) then both drivers will try to handle the event and hilarity (in the form of oopses) will ensue. This can be avoided by having eee-laptop register the slot as a hotplug slot. Only one of pciehp and eee-laptop will successfully register this, avoiding the problem.
--- drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/eeepc-laptop.c | 87 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 0 deletions(-)
drivers/platform/x86/Kconfig +2 -0
@@ -357,6 +357,8 @@ config EEEPC_LAPTOP depends on RFKILL || RFKILL = n select BACKLIGHT_CLASS_DEVICE select HWMON + select HOTPLUG + select HOTPLUG_PCI if PCI ---help--- This driver supports the Fn-Fx keys on Eee PC laptops.
drivers/platform/x86/eeepc-laptop.c +87 -0
131 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Re: [PATCH 1/8] eeepc-laptop: Register as a pci-hotplug device
Quoted 10 lines · Len Brown
From: Corentin Chary <[email protected]>
The eee contains a logically (but not physically) hotpluggable PCIe slot. Currently this is handled by adding or removing the PCI device in response to rfkill events, but if a user has forced pciehp to bind to it (with the force=1 argument) then both drivers will try to handle the event and hilarity (in the form of oopses) will ensue. This can be avoided by having eee-laptop register the slot as a hotplug slot. Only one of pciehp and eee-laptop will successfully register this, avoiding the problem.
Quoted 6 lines
Signed-off-by Matthew Garrett <[email protected]>Signed-off-by Corentin Chary <[email protected]>Tested-by Darren Salt <[email protected]>Signed-off-by Len Brown <[email protected]>Signed-off-by Randy Dunlap <[email protected]>Signed-off-by Len Brown <[email protected]>
Actually this only solves half the problem.
drivers/platform/x86/eeepc-laptop.c static int eeepc_hotk_add(struct acpi_device *device) · line 887
Quoted 11 lines
drivers/platform/x86/eeepc-laptop.c +10
-0+ result =eeepc_setup_pci_hotplug (); +/* +* If we get -EBUSY then something else is handling the PCI hotplug - +* don't fail in this case +*/ +if (result == -EBUSY ) +return 0 ; +else if (result) + goto pci_fail; +return 0 ;
It works fine if eeepc-laptop is loaded first, preventing pciehp from messing with the hardware. But it doesn't stop eeepc-laptop from messing with the hardware if pciehp is loaded first. In that case, eeepc-laptop fails to register as a PCI hotplug device, but it still messes with the hardware.
I have tested this - if I do
modprobe -r eeepc-laptop
modprobe pciehp pciehp_force=1
modprobe eeepc-laptop
and press the wireless-toggle key a couple of times, I get a lovely set of oopses and a non-responsive system.
Thanks
Alan
PATCH 1/1 eeepc-laptop: don't touch the pci slot if it was claimed by a different driver
The whole point of registering as a PCI hotplug driver was to prevent conflict with pciehp. At the moment it happens to work because eeepc-laptop is loaded first, but it doesn't work the other way round. If pciehp is loaded first then we fail to claim the slot - we need to respect this and not handle hotplug events.
---
IMO this is not an urgent patch - it's not a regression from 2.6.30. Given the number of other changes, I'd be happier if it could be held back for 2.6.32.
drivers/platform/x86/eeepc-laptop.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/platform/x86/eeepc-laptop.c +8 -5
@@ -664,15 +664,20 @@ static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,static void eeepc_hotplug_work (struct work_struct *work) {struct pci_dev *dev; -struct pci_bus *bus =pci_find_bus (0 ,1 ); -bool blocked; +struct pci_bus *bus; +bool blocked =eeepc_wlan_rfkill_blocked (); + +rfkill_set_sw_state (ehotk->wlan_rfkill, blocked); +if (ehotk->hotplug_slot ==NULL ) +return ; + + bus =pci_find_bus (0 ,1 );if (!bus) {pr_warning ("Unable to find PCI bus 1?\n" );return ; } - blocked =eeepc_wlan_rfkill_blocked ();if (!blocked) { dev =pci_get_slot (bus,0 );if (dev) {
@@ -693,8 +698,6 @@ static void eeepc_hotplug_work(struct work_struct *work)pci_dev_put (dev); } } - -rfkill_set_sw_state (ehotk->wlan_rfkill, blocked); }static void eeepc_rfkill_notify (acpi_handle handle,u32 event,void *data)
Signature · 1 line
1.6.3.2
Re: [PATCH] eeepc-laptop: don't touch the pci slot if it was claimed by a different driver
Quoted 7 lines · Alan Jenkins
The whole point of registering as a PCI hotplug driver was to prevent conflict with pciehp. At the moment it happens to work because eeepc-laptop is loaded first, but it doesn't work the other way round. If pciehp is loaded first then we fail to claim the slot - we need to respect this and not handle hotplug events.
Signed-off-by Alan Jenkins <[email protected]>
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH] eeepc-laptop: don't touch the pci slot if it was claimed by a different driver
Quoted 7 lines · Matthew Garrett
Quoted 6 lines · Alan Jenkins
The whole point of registering as a PCI hotplug driver was to prevent conflict with pciehp. At the moment it happens to work because eeepc-laptop is loaded first, but it doesn't work the other way round. If pciehp is loaded first then we fail to claim the slot - we need to respect this and not handle hotplug events.
Quoted 6 lines
Quoted 1 line
Signed-off-by Alan Jenkins <[email protected]>Acked-by Matthew Garrett <[email protected]>IMO this is not an urgent patch - it's not a regression from 2.6.30. Given the number of other changes, I'd be happier if it could be held back for 2.6.32.
Merged into ACPI4Asus, while waiting 2.6.32.
Thanks
Signature · 6 lines
Corentin Chary http://xf.iksaif.net - http://uffs.org -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Len Brown
reviewerPATCH 2/8 eeepc-laptop.c: use pr_fmt and pr_<level>
In reply to Len BrownFrom: Joe Perches <[email protected]>
Convert the unusual printk(EEEPC_<level> uses to the more standard pr_fmt and pr_<level>(.
--- drivers/platform/x86/eeepc-laptop.c | 55 ++++++++++++++--------------------- 1 files changed, 22 insertions(+), 33 deletions(-)
drivers/platform/x86/eeepc-laptop.c +22 -33
@@ -16,6 +16,8 @@* GNU General Public License for more details. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h>
@@ -41,11 +43,6 @@#define EEEPC_HOTK_DEVICE_NAME "Hotkey"#define EEEPC_HOTK_HID "ASUS010" -#define EEEPC_LOG EEEPC_HOTK_FILE ": " -#define EEEPC_ERR KERN_ERR EEEPC_LOG -#define EEEPC_WARNING KERN_WARNING EEEPC_LOG -#define EEEPC_NOTICE KERN_NOTICE EEEPC_LOG -#define EEEPC_INFO KERN_INFO EEEPC_LOG/* * Definitions for Asus EeePC
@@ -285,7 +282,7 @@ static int set_acpi(int cm, int value)if (method ==NULL )return -ENODEV ;if (write_acpi_int (ehotk->handle, method, value,NULL )) -printk (EEEPC_WARNING "Error writing %s\n" , method); +pr_warning ("Error writing %s\n" , method); }return 0 ; }
@@ -298,7 +295,7 @@ static int get_acpi(int cm)if (method ==NULL )return -ENODEV ;if (read_acpi_int (ehotk->handle, method, &value)) -printk (EEEPC_WARNING "Error reading %s\n" , method); +pr_warning ("Error reading %s\n" , method); }return value; }
@@ -562,26 +559,23 @@ static int eeepc_hotk_check(void)if (ehotk->device->status.present) {if (write_acpi_int (ehotk->handle,"INIT" , ehotk->init_flag, &buffer)) { -printk (EEEPC_ERR "Hotkey initialization failed\n" ); +pr_err ("Hotkey initialization failed\n" );return -ENODEV ; }else { -printk (EEEPC_NOTICE "Hotkey init flags 0x%x\n" , - ehotk->init_flag); +pr_notice ("Hotkey init flags 0x%x\n" , ehotk->init_flag); }/* get control methods supported */ if (read_acpi_int (ehotk->handle,"CMSG" , &ehotk->cm_supported)) { -printk (EEEPC_ERR -"Get control methods supported failed\n" ); +pr_err ("Get control methods supported failed\n" );return -ENODEV ; }else { -printk (EEEPC_INFO -"Get control methods supported: 0x%x\n" , - ehotk->cm_supported); +pr_info ("Get control methods supported: 0x%x\n" , + ehotk->cm_supported); } ehotk->inputdev =input_allocate_device ();if (!ehotk->inputdev) { -printk (EEEPC_INFO "Unable to allocate input device\n" ); +pr_info ("Unable to allocate input device\n" );return 0 ; } ehotk->inputdev->name ="Asus EeePC extra buttons" ;
@@ -600,12 +594,12 @@ static int eeepc_hotk_check(void) } result =input_register_device (ehotk->inputdev);if (result) { -printk (EEEPC_INFO "Unable to register input device\n" ); +pr_info ("Unable to register input device\n" );input_free_device (ehotk->inputdev);return 0 ; } }else { -printk (EEEPC_ERR "Hotkey device not present, aborting\n" ); +pr_err ("Hotkey device not present, aborting\n" );return -EINVAL ; }return 0 ;
@@ -643,7 +637,7 @@ static void eeepc_rfkill_hotplug(void)bool blocked;if (!bus) { -printk (EEEPC_WARNING "Unable to find PCI bus 1?\n" ); +pr_warning ("Unable to find PCI bus 1?\n" );return ; }
@@ -659,7 +653,7 @@ static void eeepc_rfkill_hotplug(void)if (dev) {pci_bus_assign_resources (bus);if (pci_bus_add_device (dev)) -printk (EEEPC_ERR "Unable to hotplug wifi\n" ); +pr_err ("Unable to hotplug wifi\n" ); } }else { dev =pci_get_slot (bus,0 );
@@ -742,8 +736,7 @@ static int eeepc_register_rfkill_notifier(char *node) eeepc_rfkill_notify, NULL);if (ACPI_FAILURE (status)) -printk (EEEPC_WARNING -"Failed to register notify on %s\n" , node); +pr_warning ("Failed to register notify on %s\n" , node); }else return -ENODEV ;
@@ -762,8 +755,7 @@ static void eeepc_unregister_rfkill_notifier(char *node)ACPI_SYSTEM_NOTIFY , eeepc_rfkill_notify);if (ACPI_FAILURE (status)) -printk (EEEPC_ERR -"Error removing rfkill notify handler %s\n" , +pr_err ("Error removing rfkill notify handler %s\n" , node); } }
@@ -780,7 +772,7 @@ static int eeepc_setup_pci_hotplug(void)struct pci_bus *bus =pci_find_bus (0 ,1 );if (!bus) { -printk (EEEPC_ERR "Unable to find wifi PCI bus\n" ); +pr_err ("Unable to find wifi PCI bus\n" );return -ENODEV ; }
@@ -801,7 +793,7 @@ static int eeepc_setup_pci_hotplug(void) ret =pci_hp_register (ehotk->hotplug_slot, bus,0 ,"eeepc-wifi" );if (ret) { -printk (EEEPC_ERR "Unable to register hotplug slot - %d\n" , ret); +pr_err ("Unable to register hotplug slot - %d\n" , ret); goto error_register; }
@@ -822,7 +814,7 @@ static int eeepc_hotk_add(struct acpi_device *device)if (!device)return -EINVAL ; - printk(EEEPC_NOTICE EEEPC_HOTK_NAME "\n"); +pr_notice (EEEPC_HOTK_NAME "\n" ); ehotk =kzalloc (sizeof (struct eeepc_hotk ),GFP_KERNEL );if (!ehotk)return -ENOMEM ;
@@ -1105,8 +1097,7 @@ static int eeepc_backlight_init(struct device *dev) bd =backlight_device_register (EEEPC_HOTK_FILE , dev,NULL , &eeepcbl_ops);if (IS_ERR (bd)) { -printk (EEEPC_ERR -"Could not register eeepc backlight device\n" ); +pr_err ("Could not register eeepc backlight device\n" ); eeepc_backlight_device =NULL ;return PTR_ERR (bd); }
@@ -1125,8 +1116,7 @@ static int eeepc_hwmon_init(struct device *dev) hwmon =hwmon_device_register (dev);if (IS_ERR (hwmon)) { -printk (EEEPC_ERR -"Could not register eeepc hwmon device\n" ); +pr_err ("Could not register eeepc hwmon device\n" ); eeepc_hwmon_device =NULL ;return PTR_ERR (hwmon); }
@@ -1159,8 +1149,7 @@ static int __init eeepc_laptop_init(void)if (result) goto fail_backlight; }else -printk (EEEPC_INFO "Backlight controlled by ACPI video " -"driver\n" ); +pr_info ("Backlight controlled by ACPI video driver\n" ); result =eeepc_hwmon_init (dev);if (result)
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 3/8 eeepc-laptop: rfkill refactoring
In reply to Len BrownFrom: Corentin Chary <[email protected]>
Refactor rfkill code, because we'll add another
rfkill for wwan3g later.
--- drivers/platform/x86/eeepc-laptop.c | 160 ++++++++++++++++++----------------- 1 files changed, 84 insertions(+), 76 deletions(-)
drivers/platform/x86/eeepc-laptop.c +84 -76
@@ -139,8 +139,8 @@ struct eeepc_hotk {u16 event_count[128 ];/* count for each event */ struct input_dev *inputdev;u16 *keycode_map; -struct rfkill *eeepc_wlan_rfkill; -struct rfkill *eeepc_bluetooth_rfkill; +struct rfkill *wlan_rfkill; +struct rfkill *bluetooth_rfkill;struct hotplug_slot *hotplug_slot; };
@@ -663,7 +663,7 @@ static void eeepc_rfkill_hotplug(void) } } -rfkill_set_sw_state (ehotk->eeepc_wlan_rfkill, blocked); +rfkill_set_sw_state (ehotk->wlan_rfkill, blocked); }static void eeepc_rfkill_notify (acpi_handle handle,u32 event,void *data)
@@ -828,66 +828,8 @@ static int eeepc_hotk_add(struct acpi_device *device)if (result) goto ehotk_fail; -eeepc_register_rfkill_notifier ("\\_SB.PCI0.P0P6" ); -eeepc_register_rfkill_notifier ("\\_SB.PCI0.P0P7" ); - -if (get_acpi (CM_ASL_WLAN ) !=-1 ) { - ehotk->eeepc_wlan_rfkill =rfkill_alloc ("eeepc-wlan" , - &device->dev, -RFKILL_TYPE_WLAN , - &eeepc_rfkill_ops, - (void *)CM_ASL_WLAN ); - -if (!ehotk->eeepc_wlan_rfkill) - goto wlan_fail; - -rfkill_init_sw_state (ehotk->eeepc_wlan_rfkill, -get_acpi (CM_ASL_WLAN ) !=1 ); - result =rfkill_register (ehotk->eeepc_wlan_rfkill); -if (result) - goto wlan_fail; - } - -if (get_acpi (CM_ASL_BLUETOOTH ) !=-1 ) { - ehotk->eeepc_bluetooth_rfkill = -rfkill_alloc ("eeepc-bluetooth" , - &device->dev, -RFKILL_TYPE_BLUETOOTH , - &eeepc_rfkill_ops, - (void *)CM_ASL_BLUETOOTH ); - -if (!ehotk->eeepc_bluetooth_rfkill) - goto bluetooth_fail; - -rfkill_init_sw_state (ehotk->eeepc_bluetooth_rfkill, -get_acpi (CM_ASL_BLUETOOTH ) !=1 ); - result =rfkill_register (ehotk->eeepc_bluetooth_rfkill); -if (result) - goto bluetooth_fail; - } - - result =eeepc_setup_pci_hotplug (); -/* -* If we get -EBUSY then something else is handling the PCI hotplug - -* don't fail in this case -*/ -if (result == -EBUSY ) -return 0 ; -else if (result) - goto pci_fail; -return 0 ; - pci_fail: -if (ehotk->eeepc_bluetooth_rfkill) -rfkill_unregister (ehotk->eeepc_bluetooth_rfkill); - bluetooth_fail: -rfkill_destroy (ehotk->eeepc_bluetooth_rfkill); -rfkill_unregister (ehotk->eeepc_wlan_rfkill); - wlan_fail: -rfkill_destroy (ehotk->eeepc_wlan_rfkill); -eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P6" ); -eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P7" ); ehotk_fail:kfree (ehotk); ehotk =NULL ;
@@ -900,18 +842,13 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)if (!device || !acpi_driver_data (device))return -EINVAL ; -eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P6" ); -eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P7" ); -if (ehotk->hotplug_slot) -pci_hp_deregister (ehotk->hotplug_slot); -kfree (ehotk);return 0 ; }static int eeepc_hotk_resume (struct acpi_device *device) { -if (ehotk->eeepc_wlan_rfkill) { +if (ehotk->wlan_rfkill) {bool wlan;/* Workaround - it seems that _PTS disables the wireless
@@ -923,14 +860,13 @@ static int eeepc_hotk_resume(struct acpi_device *device) wlan =get_acpi (CM_ASL_WLAN );set_acpi (CM_ASL_WLAN , wlan); -rfkill_set_sw_state (ehotk->eeepc_wlan_rfkill, - wlan !=1 ); +rfkill_set_sw_state (ehotk->wlan_rfkill, wlan !=1 );eeepc_rfkill_hotplug (); } -if (ehotk->eeepc_bluetooth_rfkill) -rfkill_set_sw_state (ehotk->eeepc_bluetooth_rfkill, +if (ehotk->bluetooth_rfkill) +rfkill_set_sw_state (ehotk->bluetooth_rfkill,get_acpi (CM_ASL_BLUETOOTH ) !=1 );return 0 ;
@@ -1052,10 +988,14 @@ static void eeepc_backlight_exit(void)static void eeepc_rfkill_exit (void ) { -if (ehotk->eeepc_wlan_rfkill) -rfkill_unregister (ehotk->eeepc_wlan_rfkill); -if (ehotk->eeepc_bluetooth_rfkill) -rfkill_unregister (ehotk->eeepc_bluetooth_rfkill); +eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P6" ); +eeepc_unregister_rfkill_notifier ("\\_SB.PCI0.P0P7" ); +if (ehotk->wlan_rfkill) +rfkill_unregister (ehotk->wlan_rfkill); +if (ehotk->bluetooth_rfkill) +rfkill_unregister (ehotk->bluetooth_rfkill); +if (ehotk->hotplug_slot) +pci_hp_deregister (ehotk->hotplug_slot); }static void eeepc_input_exit (void )
@@ -1090,6 +1030,67 @@ static void __exit eeepc_laptop_exit(void)platform_driver_unregister (&platform_driver); } +static int eeepc_new_rfkill (struct rfkill **rfkill, +const char *name,struct device *dev, +enum rfkill_type type,int cm) +{ +int result; + +if (get_acpi (cm) ==-1 ) +return -ENODEV ; + + *rfkill =rfkill_alloc (name, dev, type, + &eeepc_rfkill_ops, (void *)(unsigned long )cm); + +if (!*rfkill) +return -EINVAL ; + +rfkill_init_sw_state (*rfkill,get_acpi (cm) !=1 ); + result =rfkill_register (*rfkill); +if (result) { +rfkill_destroy (*rfkill); + *rfkill =NULL ; +return result; + } +return 0 ; +} + + +static int eeepc_rfkill_init (struct device *dev) +{ +int result =0 ; + +eeepc_register_rfkill_notifier ("\\_SB.PCI0.P0P6" ); +eeepc_register_rfkill_notifier ("\\_SB.PCI0.P0P7" ); + + result =eeepc_new_rfkill (&ehotk->wlan_rfkill, +"eeepc-wlan" , dev, +RFKILL_TYPE_WLAN ,CM_ASL_WLAN ); + +if (result && result != -ENODEV ) + goto exit; + + result =eeepc_new_rfkill (&ehotk->bluetooth_rfkill, +"eeepc-bluetooth" , dev, +RFKILL_TYPE_BLUETOOTH ,CM_ASL_BLUETOOTH ); + +if (result && result != -ENODEV ) + goto exit; + + result =eeepc_setup_pci_hotplug (); +/* +* If we get -EBUSY then something else is handling the PCI hotplug - +* don't fail in this case +*/ +if (result == -EBUSY ) + result =0 ; + +exit: +if (result && result != -ENODEV ) +eeepc_rfkill_exit (); +return result; +} +static int eeepc_backlight_init (struct device *dev) {struct backlight_device *bd;
@@ -1173,7 +1174,15 @@ static int __init eeepc_laptop_init(void) &platform_attribute_group);if (result) goto fail_sysfs; + + result =eeepc_rfkill_init (dev); +if (result) + goto fail_rfkill; +return 0 ; +fail_rfkill: +sysfs_remove_group (&platform_device->dev.kobj, + &platform_attribute_group); fail_sysfs:platform_device_del (platform_device); fail_platform_device2:
@@ -1186,7 +1195,6 @@ fail_hwmon:eeepc_backlight_exit (); fail_backlight:eeepc_input_exit (); -eeepc_rfkill_exit ();return result; }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 4/8 eeepc-laptop: right parent device
In reply to Len BrownFrom: Corentin Chary <[email protected]>
--- drivers/platform/x86/eeepc-laptop.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-)
drivers/platform/x86/eeepc-laptop.c +18 -16
@@ -1143,18 +1143,6 @@ static int __init eeepc_laptop_init(void)acpi_bus_unregister_driver (&eeepc_hotk_driver);return -ENODEV ; } - dev =acpi_get_physical_device (ehotk->device->handle); - -if (!acpi_video_backlight_support ()) { - result =eeepc_backlight_init (dev); -if (result) - goto fail_backlight; - }else -pr_info ("Backlight controlled by ACPI video driver\n" ); - - result =eeepc_hwmon_init (dev); -if (result) - goto fail_hwmon;eeepc_enable_camera ();
@@ -1175,12 +1163,30 @@ static int __init eeepc_laptop_init(void)if (result) goto fail_sysfs; + dev = &platform_device->dev; + +if (!acpi_video_backlight_support ()) { + result =eeepc_backlight_init (dev); +if (result) + goto fail_backlight; + }else +pr_info ("Backlight controlled by ACPI video " +"driver\n" ); + + result =eeepc_hwmon_init (dev); +if (result) + goto fail_hwmon; + result =eeepc_rfkill_init (dev);if (result) goto fail_rfkill;return 0 ; fail_rfkill: +eeepc_hwmon_exit (); +fail_hwmon: +eeepc_backlight_exit (); +fail_backlight:sysfs_remove_group (&platform_device->dev.kobj, &platform_attribute_group); fail_sysfs:
@@ -1190,10 +1196,6 @@ fail_platform_device2: fail_platform_device1:platform_driver_unregister (&platform_driver); fail_platform_driver: -eeepc_hwmon_exit (); -fail_hwmon: -eeepc_backlight_exit (); -fail_backlight:eeepc_input_exit ();return result; }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 5/8 eeepc-laptop: makes get_acpi() returns -ENODEV
In reply to Len BrownFrom: Corentin Chary <[email protected]>
If there is there is no getter defined, get_acpi() will return -ENODEV.
--- drivers/platform/x86/eeepc-laptop.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/platform/x86/eeepc-laptop.c +12 -5
@@ -289,7 +289,7 @@ static int set_acpi(int cm, int value)static int get_acpi (int cm) { -int value =-1 ; +int value = -ENODEV ;if ((ehotk->cm_supported & (0x1 << cm))) {const char *method = cm_getv[cm];if (method ==NULL )
@@ -367,13 +367,19 @@ static ssize_t store_sys_acpi(int cm, const char *buf, size_t count) rv =parse_arg (buf, count, &value);if (rv >0 ) -set_acpi (cm, value); + value =set_acpi (cm, value); +if (value <0 ) +return value;return rv; }static ssize_t show_sys_acpi (int cm,char *buf) { -return sprintf (buf,"%d\n" ,get_acpi (cm)); +int value =get_acpi (cm); + +if (value <0 ) +return value; +return sprintf (buf,"%d\n" , value); }#define EEEPC_CREATE_DEVICE_ATTR (_name, _cm) \
@@ -1036,8 +1042,9 @@ static int eeepc_new_rfkill(struct rfkill **rfkill, {int result; -if (get_acpi (cm) ==-1 ) -return -ENODEV ; + result =get_acpi (cm); +if (result <0 ) +return result; *rfkill =rfkill_alloc (name, dev, type, &eeepc_rfkill_ops, (void *)(unsigned long )cm);
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 6/8 eeepc-laptop: get the right value for CMSG
In reply to Len BrownFrom: Corentin Chary <[email protected]>
CMSG is an ACPI method used to find features available on an Eee PC. But some features are never repported, even if present.
If the getter of a feature is present, this patch will set the corresponding bit in cmsg.
--- drivers/platform/x86/eeepc-laptop.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
drivers/platform/x86/eeepc-laptop.c +23 -0
@@ -553,6 +553,28 @@ static int eeepc_setkeycode(struct input_dev *dev, int scancode, int keycode)return -EINVAL ; } +static void cmsg_quirk (int cm,const char *name) +{ +int dummy; + +/* Some BIOSes do not report cm although it is avaliable. +Check if cm_getv[cm] works and, if yes, assume cm should be set. */ +if (!(ehotk->cm_supported & (1 << cm)) + && !read_acpi_int (ehotk->handle, cm_getv[cm], &dummy)) { +pr_info ("%s (%x) not reported by BIOS," +" enabling anyway\n" , name,1 << cm); + ehotk->cm_supported |=1 << cm; + } +} + +static void cmsg_quirks (void ) +{ +cmsg_quirk (CM_ASL_LID ,"LID" ); +cmsg_quirk (CM_ASL_TYPE ,"TYPE" ); +cmsg_quirk (CM_ASL_PANELPOWER ,"PANELPOWER" ); +cmsg_quirk (CM_ASL_TPD ,"TPD" ); +} +static int eeepc_hotk_check (void ) {const struct key_entry *key;
@@ -576,6 +598,7 @@ static int eeepc_hotk_check(void)pr_err ("Get control methods supported failed\n" );return -ENODEV ; }else { +cmsg_quirks ();pr_info ("Get control methods supported: 0x%x\n" , ehotk->cm_supported); }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 7/8 eeepc-laptop: add rfkill support for the 3G modem in Eee PC 901 Go
In reply to Len BrownFrom: Corentin Chary <[email protected]>
--- drivers/platform/x86/eeepc-laptop.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/platform/x86/eeepc-laptop.c +10 -0
@@ -141,6 +141,7 @@ struct eeepc_hotk {u16 *keycode_map;struct rfkill *wlan_rfkill;struct rfkill *bluetooth_rfkill; +struct rfkill *wwan3g_rfkill;struct hotplug_slot *hotplug_slot; };
@@ -1023,6 +1024,8 @@ static void eeepc_rfkill_exit(void)rfkill_unregister (ehotk->wlan_rfkill);if (ehotk->bluetooth_rfkill)rfkill_unregister (ehotk->bluetooth_rfkill); +if (ehotk->wwan3g_rfkill) +rfkill_unregister (ehotk->wwan3g_rfkill);if (ehotk->hotplug_slot)pci_hp_deregister (ehotk->hotplug_slot); }
@@ -1107,6 +1110,13 @@ static int eeepc_rfkill_init(struct device *dev)if (result && result != -ENODEV ) goto exit; + result =eeepc_new_rfkill (&ehotk->wwan3g_rfkill, +"eeepc-wwan3g" , dev, +RFKILL_TYPE_WWAN ,CM_ASL_3G ); + +if (result && result != -ENODEV ) + goto exit; + result =eeepc_setup_pci_hotplug ();/* * If we get -EBUSY then something else is handling the PCI hotplug -
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 8/8 ACPI: video: prevent NULL deref in acpi_get_pci_dev()
In reply to Len BrownFrom: Troy Moure <[email protected]>
ref: http://thread.gmane.org/gmane.linux.kernel/857228/focus=857468
When the ACPI video driver initializes, it does a namespace walk looking for for supported devices. When we find an appropriate handle, we walk up the ACPI tree looking for a PCI root bus, and then walk back down the PCI bus, assuming that every device inbetween is a P2P bridge.
This assumption is not correct, and is reported broken on at least:
Dell Latitude E6400 ThinkPad X61 Dell XPS M1330
Add a NULL deref check to prevent boot panics.
--- drivers/acpi/pci_root.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/pci_root.c +1 -1
@@ -395,7 +395,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle) fn = adr &0xffff ; pdev =pci_get_slot (pbus,PCI_DEVFN (dev, fn)); -if (hnd == handle) +if (!pdev || hnd == handle)break ; pbus = pdev->subordinate;
Signature · 1 line
1.6.0.6