platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Barnabás Pőcze" <pobrn@protonmail.com>
To: Kelly Anderson <kelly@xilka.com>
Cc: ike.pan@canonical.com, hdegoede@redhat.com,
	mgross@linux.intel.com, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Mark Pearson <markpearson@lenovo.com>
Subject: Re: [PATCH] add platform support for Ideapad 5 Pro 16ACH6-82L5
Date: Sun, 19 Sep 2021 00:35:59 +0000	[thread overview]
Message-ID: <3Soz67mh7ym93lrTM_rsCqDig9DuBcTXQH5aSd5e25ydtipCsnR5RA53p07q0f1AnPZOS18BqklcSxPEQnmtCoStolX6n4vLOAqkPcg-rgE=@protonmail.com> (raw)
In-Reply-To: <5753131.lOV4Wx5bFT@comer.internal>

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:
> 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 | 37 ++++++++++++++++++++++++---
>  1 file changed, 34 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index e7a1299e3776..92b8f7dc79f5 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -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`.


> +{
> +	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;
> +		}

Have you checked if you can use `dmi_check_system()`?


> +	}
> +
> +	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);

The platform device is already available via `priv->platform_device`.


>  	if (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

      reply	other threads:[~2021-09-19  0:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18 22:59 [PATCH] add platform support for Ideapad 5 Pro 16ACH6-82L5 Kelly Anderson
2021-09-19  0:35 ` Barnabás Pőcze [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='3Soz67mh7ym93lrTM_rsCqDig9DuBcTXQH5aSd5e25ydtipCsnR5RA53p07q0f1AnPZOS18BqklcSxPEQnmtCoStolX6n4vLOAqkPcg-rgE=@protonmail.com' \
    --to=pobrn@protonmail.com \
    --cc=hdegoede@redhat.com \
    --cc=ike.pan@canonical.com \
    --cc=kelly@xilka.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markpearson@lenovo.com \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).