All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: bui duc phuc <phucduc.bui@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: [bug report] ASoC: codecs: pcm6240: Use guard() for mutex locks
Date: Mon, 14 Sep 2026 13:08:09 +0300	[thread overview]
Message-ID: <aqfHiX3pE-0BiCt9@stanley.mountain> (raw)

Hello bui duc phuc,

Commit f3da3b7f6ed2 ("ASoC: codecs: pcm6240: Use guard() for mutex
locks") from Jul 21, 2026 (linux-next), leads to the following Smatch
static checker warning:

	sound/soc/codecs/pcm6240.c:623 pcmdev_get_volsw()
	warn: missing error code? 'ret'

sound/soc/codecs/pcm6240.c
    594 static int pcmdev_get_volsw(struct snd_kcontrol *kcontrol,
    595         struct snd_ctl_elem_value *ucontrol, int vol_ctrl_type)
    596 {
    597         struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
    598         struct pcmdevice_priv *pcm_dev =
    599                 snd_soc_component_get_drvdata(component);
    600         struct pcmdevice_mixer_control *mc =
    601                 (struct pcmdevice_mixer_control *)kcontrol->private_value;
    602         int max = mc->max, ret;
    603         unsigned int mask = BIT(fls(max)) - 1;
    604         unsigned int dev_no = mc->dev_no;
    605         unsigned int shift = mc->shift;
    606         unsigned int reg = mc->reg;
    607         unsigned int val;
    608 
    609         guard(mutex)(&pcm_dev->codec_lock);
    610 
    611         if (pcm_dev->chip_id == PCM1690) {
    612                 ret = pcmdev_dev_read(pcm_dev, dev_no, PCM1690_REG_MODE_CTRL,
    613                         &val);
    614                 if (ret) {
    615                         dev_err(pcm_dev->dev, "%s: read mode err=%d\n",
    616                                 __func__, ret);
    617                         return ret;
    618                 }
    619                 val &= PCM1690_REG_MODE_CTRL_DAMS_MSK;
    620                 /* Set to wide-range mode, before using vol ctrl. */
    621                 if (!val && vol_ctrl_type == PCMDEV_PCM1690_VOL_CTRL) {
    622                         ucontrol->value.integer.value[0] = -25500;
--> 623                         return ret;

This was intentional, but it would be better to "return 0;" here.

    624                 }
    625                 /* Set to fine mode, before using fine vol ctrl. */
    626                 if (val && vol_ctrl_type == PCMDEV_PCM1690_FINE_VOL_CTRL) {
    627                         ucontrol->value.integer.value[0] = -12750;
    628                         return ret;

Same here.

    629                 }
    630         }
    631 
    632         ret = pcmdev_dev_read(pcm_dev, dev_no, reg, &val);
    633         if (ret) {
    634                 dev_err(pcm_dev->dev, "%s: read err=%d\n",
    635                         __func__, ret);
    636                 return ret;
    637         }
    638 
    639         val = (val >> shift) & mask;
    640         val = (val > max) ? max : val;
    641         val = mc->invert ? max - val : val;
    642         ucontrol->value.integer.value[0] = val;
    643 
    644         return ret;

And here.

    645 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

             reply	other threads:[~2026-09-14 10:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 10:08 Dan Carpenter [this message]
2026-09-15 11:08 ` [bug report] ASoC: codecs: pcm6240: Use guard() for mutex locks Bui Duc Phuc

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=aqfHiX3pE-0BiCt9@stanley.mountain \
    --to=error27@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=phucduc.bui@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.