platform/x86: asus-wmi: don't fail if platform_profile already registered
Luke D. Jones
maintainerPATCH v2 1/1 platform/x86: asus-wmi: don't fail if platform_profile already registered
On some newer laptops it appears that an AMD driver can register a platform_profile handler. If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system - this is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.
We can safely continue loading the driver instead of bombing out.
--- drivers/platform/x86/asus-wmi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +7 -2
@@ -3897,8 +3897,13 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.choices); err =platform_profile_register (&asus->platform_profile_handler); -if (err) +if (err == -EEXIST ) { +pr_warn ("A platform_profile handler is already registered, this may be a driver conflict.\n" ); +return 0 ; + }else if (err) { +pr_err ("Failed to register platform_profile: %d\n" , err);return err; + } asus->platform_profile_support = true;return 0 ;
@@ -4773,7 +4778,7 @@ static int asus_wmi_add(struct platform_device *pdev) goto fail_fan_boost_mode; err =platform_profile_setup (asus); -if (err) +if (err && err != -EEXIST ) goto fail_platform_profile_setup; err =asus_wmi_sysfs_init (asus->platform_device);
Signature · 1 line
2.45.2
Hi Luke,
Quoted 34 lines · Luke D. Jones
On some newer laptops it appears that an AMD driver can register a
platform_profilehandler. If this happens then theasus_wmidriver would error with-EEXISTwhen trying to register its own handler leaving the user with a possibly unusable system - this is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.We can safely continue loading the driver instead of bombing out.
Signed-off-by Luke D. Jones <[email protected]>--- drivers/platform/x86/asus-wmi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/platform/x86/asus-wmi.c +6
-1@@ -3897,8 +3897,13 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.choices); err =platform_profile_register (&asus->platform_profile_handler); -if (err) +if (err == -EEXIST ) { +pr_warn ("A platform_profile handler is already registered, this may be a driver conflict.\n" ); +return 0 ; + }else if (err) { +pr_err ("Failed to register platform_profile: %d\n" , err);return err; + } asus->platform_profile_support = true;return 0 ;
drivers/platform/x86/asus-wmi.c static int asus_wmi_add(struct platform_device *pdev) · line 4782
Quoted 6 lines
drivers/platform/x86/asus-wmi.c +1
-1@@ -4773,7 +4778,7 @@ static int asus_wmi_add(struct platform_device *pdev) goto fail_fan_boost_mode; err =platform_profile_setup (asus); -if (err) +if (err && err != -EEXIST ) goto fail_platform_profile_setup;
Since you already do "return 0" on EEXIST in platform_profile_setup() there is no need for this part of the patch.
Regards,
Hans
Quoted 2 lines
drivers/platform/x86/asus-wmi.c +0
-0err =asus_wmi_sysfs_init (asus->platform_device);