From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Shenghao Ding <shenghao-ding@ti.com>
Cc: broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz,
pierre-louis.bossart@linux.intel.com, 13916275206@139.com,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
liam.r.girdwood@intel.com, bard.liao@intel.com,
yung-chuan.liao@linux.intel.com, kevin-lu@ti.com,
cameron.berkenpas@gmail.com, tiwai@suse.de, baojun.xu@ti.com,
soyer@irl.hu, Baojun.Xu@fpt.com
Subject: Re: [PATCH v3] ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence
Date: Fri, 3 May 2024 18:52:59 +0300 [thread overview]
Message-ID: <ZjUIW3wMtib9KIKv@smile.fi.intel.com> (raw)
In-Reply-To: <20240502232450.484-1-shenghao-ding@ti.com>
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
prev parent reply other threads:[~2024-05-03 15:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-02 23:24 [PATCH v3] ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence Shenghao Ding
2024-05-03 7:42 ` Takashi Iwai
2024-05-03 15:52 ` Andy Shevchenko [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=ZjUIW3wMtib9KIKv@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=13916275206@139.com \
--cc=Baojun.Xu@fpt.com \
--cc=alsa-devel@alsa-project.org \
--cc=baojun.xu@ti.com \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=cameron.berkenpas@gmail.com \
--cc=kevin-lu@ti.com \
--cc=lgirdwood@gmail.com \
--cc=liam.r.girdwood@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=shenghao-ding@ti.com \
--cc=soyer@irl.hu \
--cc=tiwai@suse.de \
--cc=yung-chuan.liao@linux.intel.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).