All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: linux-sound@vger.kernel.org
Subject: [bug report] ASoC: SDCA: Create DAPM widgets and routes from DisCo
Date: Tue, 27 May 2025 13:04:26 +0300	[thread overview]
Message-ID: <aDWOKjGYd4Qye3Co@stanley.mountain> (raw)

Hello Charles Keepax,

Commit 2c8b3a8e6aa8 ("ASoC: SDCA: Create DAPM widgets and routes from
DisCo") from May 16, 2025 (linux-next), leads to the following Smatch
static checker warning:

sound/soc/sdca/sdca_asoc.c:405 entity_pde_event() error: uninitialized symbol 'from'.
sound/soc/sdca/sdca_asoc.c:405 entity_pde_event() error: uninitialized symbol 'to'.
sound/soc/sdca/sdca_asoc.c:417 entity_pde_event() error: uninitialized symbol 'poll_us'.

sound/soc/sdca/sdca_asoc.c
    377 static int entity_pde_event(struct snd_soc_dapm_widget *widget,
    378                             struct snd_kcontrol *kctl, int event)
    379 {
    380         struct snd_soc_component *component = widget->dapm->component;
    381         struct sdca_entity *entity = widget->priv;
    382         static const int polls = 100;
    383         unsigned int reg, val;
    384         int from, to, i;
    385         int poll_us;
    386         int ret;
    387 
    388         if (!component)
    389                 return -EIO;
    390 
    391         switch (event) {
    392         case SND_SOC_DAPM_POST_PMD:
    393                 from = widget->on_val;
    394                 to = widget->off_val;
    395                 break;
    396         case SND_SOC_DAPM_POST_PMU:
    397                 from = widget->off_val;
    398                 to = widget->on_val;
    399                 break;

Smatch does a fairly naive analysis of the callers and thinks that
event could be 1-2,4,8,16,32,64,128.

    400         }
    401 
    402         for (i = 0; i < entity->pde.num_max_delay; i++) {
    403                 struct sdca_pde_delay *delay = &entity->pde.max_delay[i];
    404 
--> 405                 if (delay->from_ps == from && delay->to_ps == to) {
                                              ^^^^                    ^^^
Potentially uninitialized.

    406                         poll_us = delay->us / polls;
    407                         break;
    408                 }
    409         }
    410 
    411         reg = SDW_SDCA_CTL(SDW_SDCA_CTL_FUNC(widget->reg),
    412                            SDW_SDCA_CTL_ENT(widget->reg),
    413                            SDCA_CTL_PDE_ACTUAL_PS, 0);
    414 
    415         for (i = 0; i < polls; i++) {
    416                 if (i)
    417                         fsleep(poll_us);
    418 
    419                 ret = regmap_read(component->regmap, reg, &val);
    420                 if (ret)
    421                         return ret;
    422                 else if (val == to)
    423                         return 0;
    424         }
    425 
    426         dev_err(component->dev, "%s: power transition failed: %x\n",
    427                 entity->label, val);
    428         return -ETIMEDOUT;
    429 }

regards,
dan carpenter

             reply	other threads:[~2025-05-27 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27 10:04 Dan Carpenter [this message]
2025-05-27 14:43 ` [bug report] ASoC: SDCA: Create DAPM widgets and routes from DisCo Charles Keepax

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=aDWOKjGYd4Qye3Co@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linux-sound@vger.kernel.org \
    /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.