From: Sachin Mokashi Date: Mon, 27 Apr 2026 14:46:19 +0000 (-0400) Subject: ASoC: Intel: cht_bsw_rt5672: Simplify probe() with local 'dev' pointer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cda1cf0526f1544e67283c019c3654c831cefc6c;p=thirdparty%2Flinux.git ASoC: Intel: cht_bsw_rt5672: Simplify probe() with local 'dev' pointer In snd_cht_mc_probe(), &pdev->dev is dereferenced repeatedly throughout the function. Introduce a local dev pointer early in the function and use it consistently in place of all open-coded &pdev->dev references. It reduces repetition, improves readability, and aligns with the common kernel driver pattern of caching the device pointer at function entry. Signed-off-by: Sachin Mokashi Reviewed-by: Cezary Rojewski Link: https://patch.msgid.link/20260427144619.1739971-1-sachin.mokashi@intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c index fd4cefd298d21..8e5670e590ed7 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5672.c +++ b/sound/soc/intel/boards/cht_bsw_rt5672.c @@ -454,12 +454,13 @@ static int snd_cht_mc_probe(struct platform_device *pdev) struct cht_mc_private *drv; struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; const char *platform_name; + struct device *dev = &pdev->dev; struct acpi_device *adev; bool sof_parent; int dai_index = 0; int i; - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); + drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; @@ -481,7 +482,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) "i2c-%s", acpi_dev_name(adev)); cht_dailink[dai_index].codecs->name = drv->codec_name; } else { - dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + dev_err(dev, "Error cannot find '%s' dev\n", mach->id); return -ENOENT; } @@ -494,7 +495,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) } /* override platform name, if required */ - snd_soc_card_cht.dev = &pdev->dev; + snd_soc_card_cht.dev = dev; platform_name = mach->mach_params.platform; ret_val = snd_soc_fixup_dai_links_platform_name(&snd_soc_card_cht, @@ -504,16 +505,16 @@ static int snd_cht_mc_probe(struct platform_device *pdev) snd_soc_card_cht.components = rt5670_components(); - drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); + drv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); if (IS_ERR(drv->mclk)) { - dev_err(&pdev->dev, + dev_err(dev, "Failed to get MCLK from pmc_plt_clk_3: %ld\n", PTR_ERR(drv->mclk)); return PTR_ERR(drv->mclk); } snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); - sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); + sof_parent = snd_soc_acpi_sof_parent(dev); /* set card and driver name */ if (sof_parent) { @@ -529,9 +530,9 @@ static int snd_cht_mc_probe(struct platform_device *pdev) pdev->dev.driver->pm = &snd_soc_pm_ops; /* register the soc card */ - ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); + ret_val = devm_snd_soc_register_card(dev, &snd_soc_card_cht); if (ret_val) { - dev_err(&pdev->dev, + dev_err(dev, "snd_soc_register_card failed %d\n", ret_val); return ret_val; }