public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] add platform support for Ideapad 5 Pro 16ACH6-82L5
@ 2021-09-26  4:39 Kelly Anderson
  2021-09-28 15:06 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Kelly Anderson @ 2021-09-26  4:39 UTC (permalink / raw)
  To: ike.pan, hdegoede, pobrn, mgross
  Cc: platform-driver-x86, linux-kernel, markpearson, kelly

V2 - Addressed issues brought up by Barnabás Pőcze.

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.

Signed-off-by: Kelly Anderson <kelly@xilka.com>

 drivers/platform/x86/ideapad-laptop.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index e7a1299e3776..fc54f6ab614f 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -868,6 +868,18 @@ static void dytc_profile_refresh(struct ideapad_private *priv)
 	}
 }
 
+static const struct dmi_system_id ideapad_dytc_v4_whitelist_table[] = {
+	{
+		/* Ideapad 5 Pro 16ACH6 */
+		.ident = "LENOVO 82L5",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "82L5")
+		}
+	},
+	{}
+};
+
 static int ideapad_dytc_profile_init(struct ideapad_private *priv)
 {
 	int err, dytc_version;
@@ -882,12 +894,20 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
 		return err;
 
 	/* Check DYTC is enabled and supports mode setting */
-	if (!test_bit(DYTC_QUERY_ENABLE_BIT, &output))
+	if (!test_bit(DYTC_QUERY_ENABLE_BIT, &output)) {
+		dev_info(&priv->platform_device->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 < 5) {
+		if ( dytc_version < 4 || ! dmi_check_system(ideapad_dytc_v4_whitelist_table) ) {
+			dev_info(&priv->platform_device->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)
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] add platform support for Ideapad 5 Pro 16ACH6-82L5
  2021-09-26  4:39 [PATCH v2] add platform support for Ideapad 5 Pro 16ACH6-82L5 Kelly Anderson
@ 2021-09-28 15:06 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-09-28 15:06 UTC (permalink / raw)
  To: Kelly Anderson, ike.pan, pobrn, mgross
  Cc: platform-driver-x86, linux-kernel, markpearson

Hi,

On 9/26/21 6:39 AM, Kelly Anderson wrote:
> V2 - Addressed issues brought up by Barnabás Pőcze.
> 
> 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.
> 
> Signed-off-by: Kelly Anderson <kelly@xilka.com>
> 
>  drivers/platform/x86/ideapad-laptop.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index e7a1299e3776..fc54f6ab614f 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -868,6 +868,18 @@ static void dytc_profile_refresh(struct ideapad_private *priv)
>  	}
>  }
>  
> +static const struct dmi_system_id ideapad_dytc_v4_whitelist_table[] = {

Documentation/process/coding-style.rst chapter 4 "Naming" says:

"""
For symbol names and documentation, avoid introducing new usage of
'master / slave' (or 'slave' independent of 'master') and 'blacklist /
whitelist'.

Recommended replacements for 'master / slave' are:
    '{primary,main} / {secondary,replica,subordinate}'
    '{initiator,requester} / {target,responder}'
    '{controller,host} / {device,worker,proxy}'
    'leader / follower'
    'director / performer'

Recommended replacements for 'blacklist/whitelist' are:
    'denylist / allowlist'
    'blocklist / passlist'
"""

So I've done a s/whitelist/allow/ on your patch.


> +	{
> +		/* Ideapad 5 Pro 16ACH6 */
> +		.ident = "LENOVO 82L5",
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "82L5")
> +		}
> +	},
> +	{}
> +};
> +
>  static int ideapad_dytc_profile_init(struct ideapad_private *priv)
>  {
>  	int err, dytc_version;
> @@ -882,12 +894,20 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
>  		return err;
>  
>  	/* Check DYTC is enabled and supports mode setting */
> -	if (!test_bit(DYTC_QUERY_ENABLE_BIT, &output))
> +	if (!test_bit(DYTC_QUERY_ENABLE_BIT, &output)) {
> +		dev_info(&priv->platform_device->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 < 5) {
> +		if ( dytc_version < 4 || ! dmi_check_system(ideapad_dytc_v4_whitelist_table) ) {

There is a bunch of extra spaces here which go against the codingstyle, I've fixed this up
while applying this to my tree:

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans





> +			dev_info(&priv->platform_device->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)
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-28 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-26  4:39 [PATCH v2] add platform support for Ideapad 5 Pro 16ACH6-82L5 Kelly Anderson
2021-09-28 15:06 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox