mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ASoC: Intel: bytcht_es8316: Fix invalid quirk input mapping
[ Upstream commit b20eb0e8de383116f1e1470d74da2a3c83c4e345 ]
When an invalid value is passed via quirk option, currently
bytcht_es8316 driver just ignores and leaves as is, which may lead to
unepxected results like OOB access.
This patch adds the sanity check and corrects the input mapping to the
certain default value if an invalid value is passed.
Fixes: 249d2fc9e5 ("ASoC: Intel: bytcht_es8316: Set card long_name based on quirks")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <20250902171826.27329-2-tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cf71834a0c
commit
d75a561ba1
@@ -46,7 +46,8 @@ enum {
|
||||
BYT_CHT_ES8316_INTMIC_IN2_MAP,
|
||||
};
|
||||
|
||||
#define BYT_CHT_ES8316_MAP(quirk) ((quirk) & GENMASK(3, 0))
|
||||
#define BYT_CHT_ES8316_MAP_MASK GENMASK(3, 0)
|
||||
#define BYT_CHT_ES8316_MAP(quirk) ((quirk) & BYT_CHT_ES8316_MAP_MASK)
|
||||
#define BYT_CHT_ES8316_SSP0 BIT(16)
|
||||
#define BYT_CHT_ES8316_MONO_SPEAKER BIT(17)
|
||||
#define BYT_CHT_ES8316_JD_INVERTED BIT(18)
|
||||
@@ -59,10 +60,23 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");
|
||||
|
||||
static void log_quirks(struct device *dev)
|
||||
{
|
||||
if (BYT_CHT_ES8316_MAP(quirk) == BYT_CHT_ES8316_INTMIC_IN1_MAP)
|
||||
int map;
|
||||
|
||||
map = BYT_CHT_ES8316_MAP(quirk);
|
||||
switch (map) {
|
||||
case BYT_CHT_ES8316_INTMIC_IN1_MAP:
|
||||
dev_info(dev, "quirk IN1_MAP enabled");
|
||||
if (BYT_CHT_ES8316_MAP(quirk) == BYT_CHT_ES8316_INTMIC_IN2_MAP)
|
||||
break;
|
||||
case BYT_CHT_ES8316_INTMIC_IN2_MAP:
|
||||
dev_info(dev, "quirk IN2_MAP enabled");
|
||||
break;
|
||||
default:
|
||||
dev_warn_once(dev, "quirk sets invalid input map: 0x%x, default to INTMIC_IN1_MAP\n", map);
|
||||
quirk &= ~BYT_CHT_ES8316_MAP_MASK;
|
||||
quirk |= BYT_CHT_ES8316_INTMIC_IN1_MAP;
|
||||
break;
|
||||
}
|
||||
|
||||
if (quirk & BYT_CHT_ES8316_SSP0)
|
||||
dev_info(dev, "quirk SSP0 enabled");
|
||||
if (quirk & BYT_CHT_ES8316_MONO_SPEAKER)
|
||||
|
||||
Reference in New Issue
Block a user