public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Shenghao Ding <shenghao-ding@ti.com>
Cc: tiwai@suse.de, robh+dt@kernel.org, lgirdwood@gmail.com,
	perex@perex.cz, pierre-louis.bossart@linux.intel.com,
	kevin-lu@ti.com, 13916275206@139.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	liam.r.girdwood@intel.com, mengdong.lin@intel.com,
	baojun.xu@ti.com, thomas.gfeller@q-drop.com, peeyush@ti.com,
	navada@ti.com, broonie@kernel.org, gentuser@gmail.com
Subject: Re: [PATCH v1] ALSA: hda/tas2781: Support ACPI_ID both TXNW2781 and TIAS2781
Date: Mon, 11 Sep 2023 13:23:29 +0300	[thread overview]
Message-ID: <ZP7qoamIicmnbsB0@smile.fi.intel.com> (raw)
In-Reply-To: <20230910072704.1359-1-shenghao-ding@ti.com>

On Sun, Sep 10, 2023 at 03:27:03PM +0800, Shenghao Ding wrote:
> Support ACPI_ID both TXNW2781 and TIAS2781, TXNW2781 is the only one legal
> ACPI ID, TIAS2781 is the widely-used ACPI ID named by our customers, so
> far it is not registered. We have discussed this with them, they requested
> TIAS2781 must be supported for the laptops already released to market,
> their new laptops will switch to TXNW2781.

...

> +/* TIAS2781 is the unofficial ACPI id, but widely used in current devices.
> + * TXNW2781 is the official ACPI id, and will be used in the new devices.
> + * Check TIAS2781 or TXNW2781
> + */

/*
 * This style is only for networking.
 * please use one as in this example.
 */

...

> +	const char c[][10] = { "TXNW2781", "TIAS2781" };

Can you put this to the ACPI device ID table, it will be easier to use it with
some other acpi_*() APIs?
That table might need a comment why it has no MODULE_DEVICE_TABLE() with it.

...

> +	int n = strlen(bus), i;

>  
> -	if (strncmp(d, p->bus, n))
> +	if (strncmp(d, bus, n))
>  		return 0;

It means you need to use str_has_prefix().

...

> +	for (i = 0; i < ARRAY_SIZE(c); i++) {
> +		/* the rest must be exact matching */
> +		snprintf(tmp, sizeof(tmp), "-%s:00", c[i]);
> +
> +		if (!strcmp(d + n, tmp))
> +			return 1;
> +	}

This can be done differently.
You are comparing the instance of the device to the actual id, right?
We have ACPI match APIs for that. Have you tried to look at them?

...

> +/* TIAS2781 is the unofficial ACPI id, but widely used in current devices.
> + * TXNW2781 is the official ACPI id, and will be used in the new devices.
> + */
> +static const struct acpi_device_id tas2781_acpi_hda_match[] = {
> +	{"TIAS2781", 0 },
> +	{"TXNW2781", 1 },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(acpi, tas2781_acpi_hda_match);

So, besides the style of the comment, why do you have two different data
structures for the same? Can you find a common place and deduplicate it?

...

> -MODULE_DEVICE_TABLE(acpi, tas2781_acpi_hda_match);

Ah, I see now, it's used for probing. Please, don't move it. The hid is
available via device pointer.

...

This patch requires much more work, and esp. be redesigned to use proper
ACPI APIs.

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2023-09-11 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-10  7:27 [PATCH v1] ALSA: hda/tas2781: Support ACPI_ID both TXNW2781 and TIAS2781 Shenghao Ding
2023-09-10  7:52 ` Biju Das
2023-09-11 10:23 ` Andy Shevchenko [this message]
2023-09-12 16:11 ` kernel test robot

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=ZP7qoamIicmnbsB0@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=13916275206@139.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=gentuser@gmail.com \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mengdong.lin@intel.com \
    --cc=navada@ti.com \
    --cc=peeyush@ti.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=shenghao-ding@ti.com \
    --cc=thomas.gfeller@q-drop.com \
    --cc=tiwai@suse.de \
    /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