Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: max98373-sdw: use first_hw_init flag on resume

The intent of the status check on resume was to verify if a SoundWire
peripheral reported ATTACHED before waiting for the initialization to
complete. This is required to avoid timeouts that will happen with
'ghost' devices that are exposed in the platform firmware but are not
populated in hardware.

Unfortunately we used 'hw_init' instead of 'first_hw_init'. Due to
another error, the resume operation never timed out, but the volume
settings were not properly restored.

This patch renames the status flag to 'first_hw_init' for consistency
with other drivers.

BugLink: https://github.com/thesofproject/linux/issues/2637
Fixes: 56a5b7910e96 ('ASoC: codecs: max98373: add SoundWire support')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Link: https://lore.kernel.org/r/20210607222239.582139-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
bf881170 468a272c

+7 -7
+6 -6
sound/soc/codecs/max98373-sdw.c
··· 270 270 struct max98373_priv *max98373 = dev_get_drvdata(dev); 271 271 unsigned long time; 272 272 273 - if (!max98373->hw_init) 273 + if (!max98373->first_hw_init) 274 274 return 0; 275 275 276 276 if (!slave->unattach_request) ··· 361 361 struct device *dev = &slave->dev; 362 362 struct max98373_priv *max98373 = dev_get_drvdata(dev); 363 363 364 - if (max98373->pm_init_once) { 364 + if (max98373->first_hw_init) { 365 365 regcache_cache_only(max98373->regmap, false); 366 366 regcache_cache_bypass(max98373->regmap, true); 367 367 } ··· 369 369 /* 370 370 * PM runtime is only enabled when a Slave reports as Attached 371 371 */ 372 - if (!max98373->pm_init_once) { 372 + if (!max98373->first_hw_init) { 373 373 /* set autosuspend parameters */ 374 374 pm_runtime_set_autosuspend_delay(dev, 3000); 375 375 pm_runtime_use_autosuspend(dev); ··· 461 461 regmap_write(max98373->regmap, MAX98373_R20B5_BDE_EN, 1); 462 462 regmap_write(max98373->regmap, MAX98373_R20E2_LIMITER_EN, 1); 463 463 464 - if (max98373->pm_init_once) { 464 + if (max98373->first_hw_init) { 465 465 regcache_cache_bypass(max98373->regmap, false); 466 466 regcache_mark_dirty(max98373->regmap); 467 467 } 468 468 469 - max98373->pm_init_once = true; 469 + max98373->first_hw_init = true; 470 470 max98373->hw_init = true; 471 471 472 472 pm_runtime_mark_last_busy(dev); ··· 796 796 max98373_slot_config(dev, max98373); 797 797 798 798 max98373->hw_init = false; 799 - max98373->pm_init_once = false; 799 + max98373->first_hw_init = false; 800 800 801 801 /* codec registration */ 802 802 ret = devm_snd_soc_register_component(dev, &soc_codec_dev_max98373_sdw,
+1 -1
sound/soc/codecs/max98373.h
··· 226 226 /* variables to support soundwire */ 227 227 struct sdw_slave *slave; 228 228 bool hw_init; 229 - bool pm_init_once; 229 + bool first_hw_init; 230 230 int slot; 231 231 unsigned int rx_mask; 232 232 };