add platform support for Ideapad 5 Pro 16ACH6-82L5
PATCH 1/1 add platform support for Ideapad 5 Pro 16ACH6-82L5
Adding support specifically for Ideapad 5 Pro 16ACH6-82L5 by adding a whitelist function that can validate notebooks for which dytc_version is less than 5, and seem to work fine at dytc_version 4. This code has been tested to work properly on the specified system.
drivers/platform/x86/ideapad-laptop.c | 37 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
drivers/platform/x86/ideapad-laptop.c +34 -3
@@ -868,7 +868,28 @@ static void dytc_profile_refresh(struct ideapad_private *priv) } } -static int ideapad_dytc_profile_init (struct ideapad_private *priv) +static int ideapad_dytc_v4_whitelist (struct platform_device *pdev) +{ +const char *vendor =dmi_get_system_info (DMI_SYS_VENDOR ); +const char *product =dmi_get_system_info (DMI_PRODUCT_NAME ); + +if ( product ) { +if ( vendor ) { +dev_info (&pdev->dev,"DYTC Vendor: %s\n" , vendor); + } + +dev_info (&pdev->dev,"DYTC Product: %s\n" , product); + +if ( !strncmp (product,"82L5" ,4 ) )/* IdeaPad 5 Pro 16ACH6 */ { +return 1 ; + } + } + +return 0 ; +} + +static int ideapad_dytc_profile_init (struct platform_device *pdev, +struct ideapad_private *priv) {int err, dytc_version;unsigned long output;
@@ -883,11 +904,21 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)/* Check DYTC is enabled and supports mode setting */ if (!test_bit (DYTC_QUERY_ENABLE_BIT , &output)) + { +dev_info (&pdev->dev,"DYTC_QUERY_ENABLE_BIT returned false\n" );return -ENODEV ; + } dytc_version = (output >>DYTC_QUERY_REV_BIT ) &0xF ; +if (dytc_version <5 ) -return -ENODEV ; + { +if ( dytc_version <4 || !ideapad_dytc_v4_whitelist (pdev) ) + { +dev_info (&pdev->dev,"DYTC_VERSION is less than 4 or is not whitelisted: %d\n" , dytc_version); +return -ENODEV ; + } + } priv->dytc =kzalloc (sizeof (*priv->dytc),GFP_KERNEL );if (!priv->dytc)
@@ -1595,7 +1626,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)ideapad_sync_rfk_state (priv);ideapad_sync_touchpad_state (priv); - err =ideapad_dytc_profile_init (priv); + err =ideapad_dytc_profile_init (pdev, priv);if (err) {if (err != -ENODEV )dev_warn (&pdev->dev,"Could not set up DYTC interface: %d\n" , err);
Signature · 1 line
2.33.0
Hi
+CC Mark Pearson - because he added to code originally to the thinkpad_acpi driver with the DYTC version limitation.
Please also check the coding style guide [1].
2021. szeptember 19., vasárnap 0:59 keltezéssel, Kelly Anderson írta:
Quoted 15 lines
Adding support specifically for Ideapad 5 Pro 16ACH6-82L5 by adding a whitelist function that can validate notebooks for which
dytc_versionis less than 5, and seem to work fine atdytc_version4. This code has been tested to work properly on the specified system.Signed-off-by Kelly Anderson <[email protected]>drivers/platform/x86/ideapad-laptop.c | 37 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)drivers/platform/x86/ideapad-laptop.c +0
-0
drivers/platform/x86/ideapad-laptop.c static void dytc_profile_refresh(struct ideapad_private *priv) · line 871
Quoted 5 lines
drivers/platform/x86/ideapad-laptop.c +1
-1@@ -868,7 +868,28 @@ static void dytc_profile_refresh(struct ideapad_private *priv) } } -static int ideapad_dytc_profile_init (struct ideapad_private *priv) +static int ideapad_dytc_v4_whitelist (struct platform_device *pdev)
Please use bool.
Quoted 4 lines
drivers/platform/x86/ideapad-laptop.c +4
-0+{ +const char *vendor =dmi_get_system_info (DMI_SYS_VENDOR ); +const char *product =dmi_get_system_info (DMI_PRODUCT_NAME ); +
drivers/platform/x86/ideapad-laptop.c static void dytc_profile_refresh(struct ideapad_private *priv) · line 885
Quoted 10 lines
drivers/platform/x86/ideapad-laptop.c +10
-0+if ( product ) { +if ( vendor ) { +dev_info (&pdev->dev,"DYTC Vendor: %s\n" , vendor); + } + +dev_info (&pdev->dev,"DYTC Product: %s\n" , product); + +if ( !strncmp (product,"82L5" ,4 ) )/* IdeaPad 5 Pro 16ACH6 */ { +return 1 ; + }
Have you checked if you can use dmi_check_system()?
Quoted 34 lines
drivers/platform/x86/ideapad-laptop.c +18
-1+ } + +return 0 ; +} + +static int ideapad_dytc_profile_init (struct platform_device *pdev, +struct ideapad_private *priv) {int err, dytc_version;unsigned long output;@@ -883,11 +904,21 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)/* Check DYTC is enabled and supports mode setting */ if (!test_bit (DYTC_QUERY_ENABLE_BIT , &output)) + { +dev_info (&pdev->dev,"DYTC_QUERY_ENABLE_BIT returned false\n" );return -ENODEV ; + } dytc_version = (output >>DYTC_QUERY_REV_BIT ) &0xF ; +if (dytc_version <5 ) -return -ENODEV ; + { +if ( dytc_version <4 || !ideapad_dytc_v4_whitelist (pdev) ) + { +dev_info (&pdev->dev,"DYTC_VERSION is less than 4 or is not whitelisted: %d\n" , dytc_version); +return -ENODEV ; + } + } priv->dytc =kzalloc (sizeof (*priv->dytc),GFP_KERNEL );if (!priv->dytc)
drivers/platform/x86/ideapad-laptop.c static int ideapad_acpi_add(struct platform_device *pdev) · line 1629
Quoted 5 lines
drivers/platform/x86/ideapad-laptop.c +1
-1@@ -1595,7 +1626,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)ideapad_sync_rfk_state (priv);ideapad_sync_touchpad_state (priv); - err =ideapad_dytc_profile_init (priv); + err =ideapad_dytc_profile_init (pdev, priv);
The platform device is already available via priv->platform_device.
Quoted 5 lines
drivers/platform/x86/ideapad-laptop.c +0
-1if (err) {if (err != -ENODEV )dev_warn (&pdev->dev,"Could not set up DYTC interface: %d\n" , err); --2.33.0
[1]: https://www.kernel.org/doc/html/latest/process/coding-style.html
Regards,
Barnabás Pőcze