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] [day] [month] [year] [list]
Message-ID: <ZjUIW3wMtib9KIKv@smile.fi.intel.com>
Date: Fri, 3 May 2024 18:52:59 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Shenghao Ding <shenghao-ding@...com>
Cc: broonie@...nel.org, lgirdwood@...il.com, perex@...ex.cz,
	pierre-louis.bossart@...ux.intel.com, 13916275206@....com,
	alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
	liam.r.girdwood@...el.com, bard.liao@...el.com,
	yung-chuan.liao@...ux.intel.com, kevin-lu@...com,
	cameron.berkenpas@...il.com, tiwai@...e.de, baojun.xu@...com,
	soyer@....hu, Baojun.Xu@....com
Subject: Re: [PATCH v3] ALSA: ASoc/tas2781: Fix wrong loading calibrated data
 sequence

On Fri, May 03, 2024 at 07:24:49AM +0800, Shenghao Ding wrote:
> Calibrated data will be set to default after loading DSP config params,
> which will cause speaker protection work abnormally. Reload calibrated
> data after loading DSP config params.

..

> +static void tasdev_load_calibrated_data(struct tasdevice_priv *priv, int i)
> +{

> +	struct tasdevice_fw *cal_fmw = priv->tasdevice[i].cali_data_fmw;
> +
> +	if (cal_fmw) {

Better variant is

	struct tasdevice_calibration *cal;
	struct tasdevice_fw *cal_fmw;

	cal_fmw = priv->tasdevice[i].cali_data_fmw;
	if (!cal_fmw)
		return;

> +		struct tasdevice_calibration *cal = cal_fmw->calibrations;
> +
> +		if (cal)
> +			load_calib_data(priv, &cal->dev_data);
> +	}

In the similar way

	cal = cal_fmw->calibrations;
	if (!cal)
		return;

	load_calib_data(priv, &cal->dev_data);

> +}

The result is much easier to read and understand and maintain, as it makes
harder to squeeze the code between initialization and use and breaking things.

..

> +			if (tas_priv->tasdevice[i].is_loaderr == false
> +				&& tas_priv->tasdevice[i].is_loading == true)
>  				tas_priv->tasdevice[i].cur_prog = prm_no;

While at it, make it better (fix the indentation and move operator to
the previous line):

			if (tas_priv->tasdevice[i].is_loaderr == false &&
			    tas_priv->tasdevice[i].is_loading == true)
				tas_priv->tasdevice[i].cur_prog = prm_no;

..

>  			if (tas_priv->tasdevice[i].is_loaderr == true) {
>  				status |= 1 << (i + 4);

Side note: Use BIT()

>  				continue;

..

> +			if (tas_priv->tasdevice[i].is_loaderr == false
> +				&& tas_priv->tasdevice[i].is_loading == true) {

As per above.

> +				tasdev_load_calibrated_data(tas_priv, i);
>  				tas_priv->tasdevice[i].cur_conf = cfg_no;
> +			}

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ