diff mbox series

[3/3] ASoC: wm_adsp: Remove pointless string comparison

Message ID 20210626155941.12251-3-ckeepax@opensource.cirrus.com (mailing list archive)
State Accepted
Commit 2ba907894f9e69b68e5934b57afb744482a72984
Headers show
Series [1/3] ASoC: wm_adsp: Correct wm_coeff_tlv_get handling | expand

Commit Message

Charles Keepax June 26, 2021, 3:59 p.m. UTC
The control fw_name is always directly assigned from the wm_adsp_fw_text
array, so it isn't necessary to compare the actual strings just the
pointer values.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Mark Brown June 28, 2021, 4:58 p.m. UTC | #1
On Sat, Jun 26, 2021 at 04:59:41PM +0100, Charles Keepax wrote:

> The control fw_name is always directly assigned from the wm_adsp_fw_text
> array, so it isn't necessary to compare the actual strings just the
> pointer values.

This feels like it's asking for trouble in the future...
Charles Keepax July 13, 2021, 12:33 p.m. UTC | #2
On Mon, Jun 28, 2021 at 05:58:37PM +0100, Mark Brown wrote:
> On Sat, Jun 26, 2021 at 04:59:41PM +0100, Charles Keepax wrote:
> 
> > The control fw_name is always directly assigned from the wm_adsp_fw_text
> > array, so it isn't necessary to compare the actual strings just the
> > pointer values.
> 
> This feels like it's asking for trouble in the future...

Thanks for applying anyway, apologies for my slow reply been off work.
We already have the same optimisation in other places so at least this
way its all broken in the same way if we hit an issue in the
future :-)

Thanks,
Charles
diff mbox series

Patch

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 549d98241daec..b395df1eb72d8 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -2030,10 +2030,9 @@  static struct wm_coeff_ctl *wm_adsp_get_ctl(struct wm_adsp *dsp,
 		if (!pos->subname)
 			continue;
 		if (strncmp(pos->subname, name, pos->subname_len) == 0 &&
-		    strncmp(pos->fw_name, fw_txt,
-			    SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0 &&
-				pos->alg_region.alg == alg &&
-				pos->alg_region.type == type) {
+		    pos->fw_name == fw_txt &&
+		    pos->alg_region.alg == alg &&
+		    pos->alg_region.type == type) {
 			rslt = pos;
 			break;
 		}