Skip to content

Commit cda1cf0

Browse files
mokashisachinbroonie
authored andcommitted
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 <sachin.mokashi@intel.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20260427144619.1739971-1-sachin.mokashi@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f4d0086 commit cda1cf0

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

sound/soc/intel/boards/cht_bsw_rt5672.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,13 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
454454
struct cht_mc_private *drv;
455455
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
456456
const char *platform_name;
457+
struct device *dev = &pdev->dev;
457458
struct acpi_device *adev;
458459
bool sof_parent;
459460
int dai_index = 0;
460461
int i;
461462

462-
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
463+
drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
463464
if (!drv)
464465
return -ENOMEM;
465466

@@ -481,7 +482,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
481482
"i2c-%s", acpi_dev_name(adev));
482483
cht_dailink[dai_index].codecs->name = drv->codec_name;
483484
} else {
484-
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
485+
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
485486
return -ENOENT;
486487
}
487488

@@ -494,7 +495,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
494495
}
495496

496497
/* override platform name, if required */
497-
snd_soc_card_cht.dev = &pdev->dev;
498+
snd_soc_card_cht.dev = dev;
498499
platform_name = mach->mach_params.platform;
499500

500501
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)
504505

505506
snd_soc_card_cht.components = rt5670_components();
506507

507-
drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
508+
drv->mclk = devm_clk_get(dev, "pmc_plt_clk_3");
508509
if (IS_ERR(drv->mclk)) {
509-
dev_err(&pdev->dev,
510+
dev_err(dev,
510511
"Failed to get MCLK from pmc_plt_clk_3: %ld\n",
511512
PTR_ERR(drv->mclk));
512513
return PTR_ERR(drv->mclk);
513514
}
514515
snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
515516

516-
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
517+
sof_parent = snd_soc_acpi_sof_parent(dev);
517518

518519
/* set card and driver name */
519520
if (sof_parent) {
@@ -529,9 +530,9 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
529530
pdev->dev.driver->pm = &snd_soc_pm_ops;
530531

531532
/* register the soc card */
532-
ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
533+
ret_val = devm_snd_soc_register_card(dev, &snd_soc_card_cht);
533534
if (ret_val) {
534-
dev_err(&pdev->dev,
535+
dev_err(dev,
535536
"snd_soc_register_card failed %d\n", ret_val);
536537
return ret_val;
537538
}

0 commit comments

Comments
 (0)