lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZzsFZnWeEAbIjgbN@smile.fi.intel.com>
Date: Mon, 18 Nov 2024 11:14:14 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Baojun Xu <baojun.xu@...com>
Cc: tiwai@...e.de, robh+dt@...nel.org, lgirdwood@...il.com, perex@...ex.cz,
	pierre-louis.bossart@...ux.intel.com, shenghao-ding@...com,
	navada@...com, 13916275206@....com, v-hampiholi@...com, v-po@...com,
	linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
	liam.r.girdwood@...el.com, yung-chuan.liao@...ux.intel.com,
	broonie@...nel.org, antheas.dk@...il.com, philm@...jaro.org
Subject: Re: [PATCH v5] ALSA: hda/tas2781: Add speaker id check for ASUS
 projects

On Sat, Nov 16, 2024 at 03:50:06PM +0800, Baojun Xu wrote:
> Add speaker id check by gpio in ACPI for ASUS projects.
> In other vendors, speaker id was checked by BIOS, and was applied in
> last bit of subsys id, so we can load corresponding firmware binary file
> for its speaker by subsys id.
> But in ASUS project, the firmware binary name will be appended an extra
> number to tell the speakers from different vendors. And this single digit
> come from gpio level of speaker id in BIOS.

...

> +	// Speaker id was needed for ASUS projects.
> +	if (!strncmp(sub, TAS2781_ASUS_ID, strlen(TAS2781_ASUS_ID))) {

Better approach is

	ret = sscanf(sub, "%04x%04x", &vid, &did);
	if (ret == 2 && vid == ASUS_ID) {
		... // matched to ASUS_ID
	} else {
		... // no match
	}

Alternatively it can be

	u32 subid;

	ret = kstrtou32(sub, 16, &subid);
	if (ret || upper_16_bits(subid) != ASUS_ID) {
		... // no match (as in previous 'else')
	} else {
		... // matched to ASUS_ID
	}

With it it will be clearer to see what's going on here.

With the above you can get rid of the custom constant and
use PCI_VENDOR_ID_ASUSTEK directly.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ