Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Mukunda,Vijendar" <vijendar.mukunda@amd.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-sound@vger.kernel.org
Subject: Re: [bug report] ASoC: amd: acp: refactor SoundWire machine driver code
Date: Sat, 28 Sep 2024 11:34:50 +0530	[thread overview]
Message-ID: <a201e871-375e-43eb-960d-5c048956c2ff@amd.com> (raw)
In-Reply-To: <f7a1ddf3-b089-40ef-9518-a8cfd986b8fc@stanley.mountain>

On 27/09/24 16:09, Dan Carpenter wrote:
> Hello Vijendar Mukunda,
>
> Commit 6d8348ddc56e ("ASoC: amd: acp: refactor SoundWire machine
> driver code") from Sep 13, 2024 (linux-next), leads to the following
> Smatch static checker warning:
>
> 	sound/soc/amd/acp/acp-sdw-sof-mach.c:365 sof_card_dai_links_create()
> 	warn: inconsistent indenting
>
> sound/soc/amd/acp/acp-sdw-sof-mach.c
>     307 static int sof_card_dai_links_create(struct snd_soc_card *card)
>     308 {
>     309         struct device *dev = card->dev;
>     310         struct snd_soc_acpi_mach *mach = dev_get_platdata(card->dev);
>     311         int sdw_be_num = 0, dmic_num = 0;
>     312         struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
>     313         struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
>     314         struct snd_soc_codec_conf *codec_conf;
>     315         struct asoc_sdw_endpoint *sof_ends;
>     316         struct asoc_sdw_dailink *sof_dais;
>
> Just declare these as:
>
> 	struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
> 	struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
>
> Then you can delete all the gotos.
Will fix it.
>     317         struct snd_soc_dai_link *dai_links;
>     318         int num_devs = 0;
>     319         int num_ends = 0;
>     320         int num_links;
>     321         int be_id = 0;
>     322         int ret;
>     323 
>     324         ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
>     325         if (ret < 0) {
>     326                 dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
>     327                 return ret;
>     328         }
>     329 
>     330         /* One per DAI link, worst case is a DAI link for every endpoint */
>     331         sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL);
>     332         if (!sof_dais)
>     333                 return -ENOMEM;
>     334 
>     335         /* One per endpoint, ie. each DAI on each codec/amp */
>     336         sof_ends = kcalloc(num_ends, sizeof(*sof_ends), GFP_KERNEL);
>     337         if (!sof_ends) {
>     338                 ret = -ENOMEM;
>     339                 goto err_dai;
>     340         }
>     341 
>     342         ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
>     343         if (ret < 0)
>     344                 goto err_end;
>     345 
>     346         sdw_be_num = ret;
>     347 
>     348         /* enable dmic */
>     349         if (sof_sdw_quirk & ASOC_SDW_ACP_DMIC || mach_params->dmic_num)
>     350                 dmic_num = 1;
>     351 
>     352         dev_dbg(dev, "sdw %d, dmic %d", sdw_be_num, dmic_num);
>     353 
>     354         codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
>     355         if (!codec_conf) {
>     356                 ret = -ENOMEM;
>     357                 goto err_end;
>     358         }
>     359 
>     360         /* allocate BE dailinks */
>     361         num_links = sdw_be_num + dmic_num;
>     362         dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL);
>     363         if (!dai_links) {
>     364                 ret = -ENOMEM;
> --> 365         goto err_end;
>
> Missing tab.
Will fix it
>
>     366         }
>     367 
>     368         card->codec_conf = codec_conf;
>     369         card->num_configs = num_devs;
>     370         card->dai_link = dai_links;
>     371         card->num_links = num_links;
>     372 
>     373         /* SDW */
>     374         if (sdw_be_num) {
>     375                 ret = create_sdw_dailinks(card, &dai_links, &be_id,
>     376                                           sof_dais, &codec_conf);
>     377                 if (ret)
>     378                         goto err_end;
>     379         }
>     380 
>     381         /* dmic */
>     382         if (dmic_num > 0) {
>     383                 if (ctx->ignore_internal_dmic) {
>     384                         dev_warn(dev, "Ignoring ACP DMIC\n");
>     385                 } else {
>     386                         ret = create_dmic_dailinks(card, &dai_links, &be_id);
>     387                         if (ret)
>     388                                 goto err_end;
>     389                 }
>     390         }
>     391 
>     392         WARN_ON(codec_conf != card->codec_conf + card->num_configs);
>     393         WARN_ON(dai_links != card->dai_link + card->num_links);
>     394 
>     395 err_end:
>     396         kfree(sof_ends);
>     397 err_dai:
>     398         kfree(sof_dais);
>     399 
>     400         return ret;
>     401 }
>
> regards,
> dan carpenter


  reply	other threads:[~2024-09-28  6:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 10:39 [bug report] ASoC: amd: acp: refactor SoundWire machine driver code Dan Carpenter
2024-09-28  6:04 ` Mukunda,Vijendar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-27 10:35 Dan Carpenter
2024-10-03  6:28 ` Mukunda,Vijendar
2024-10-03  6:38   ` Mukunda,Vijendar

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=a201e871-375e-43eb-960d-5c048956c2ff@amd.com \
    --to=vijendar.mukunda@amd.com \
    --cc=dan.carpenter@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox