Commit 91432e97 authored by Ian Molton's avatar Ian Molton Committed by Mark Brown
Browse files

ASoC: fixes to caching implementations



This patch takes fixes a number of bugs in the caching code used by
several ASoC codec drivers. Mostly off-by-one fixes.

Signed-off-by: default avatarIan Molton <ian@mnementh.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 28796eaf
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ static int ac97_soc_probe(struct platform_device *pdev)
	snd_soc_free_pcms(socdev);

err:
	kfree(socdev->codec->reg_cache);
	kfree(socdev->codec);
	socdev->codec = NULL;
	return ret;
@@ -138,7 +137,6 @@ static int ac97_soc_remove(struct platform_device *pdev)
		return 0;

	snd_soc_free_pcms(socdev);
	kfree(socdev->codec->reg_cache);
	kfree(socdev->codec);

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec,
	default:
		reg = reg >> 1;

		if (reg >= (ARRAY_SIZE(ad1980_reg)))
		if (reg >= ARRAY_SIZE(ad1980_reg))
			return -EINVAL;

		return cache[reg];
@@ -123,7 +123,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,

	soc_ac97_ops.write(codec->ac97, reg, val);
	reg = reg >> 1;
	if (reg < (ARRAY_SIZE(ad1980_reg)))
	if (reg < ARRAY_SIZE(ad1980_reg))
		cache[reg] = val;

	return 0;
+3 −0
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec,
{
	u8 *cache = codec->reg_cache;

	if (reg >= TWL4030_CACHEREGNUM)
		return -EIO;

	return cache[reg];
}

+2 −2
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ static inline unsigned int wm8580_read_reg_cache(struct snd_soc_codec *codec,
	unsigned int reg)
{
	u16 *cache = codec->reg_cache;
	BUG_ON(reg > ARRAY_SIZE(wm8580_reg));
	BUG_ON(reg >= ARRAY_SIZE(wm8580_reg));
	return cache[reg];
}

@@ -223,7 +223,7 @@ static int wm8580_write(struct snd_soc_codec *codec, unsigned int reg,
{
	u8 data[2];

	BUG_ON(reg > ARRAY_SIZE(wm8580_reg));
	BUG_ON(reg >= ARRAY_SIZE(wm8580_reg));

	/* Registers are 9 bits wide */
	value &= 0x1ff;
+2 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static inline unsigned int wm8728_read_reg_cache(struct snd_soc_codec *codec,
	unsigned int reg)
{
	u16 *cache = codec->reg_cache;
	BUG_ON(reg > ARRAY_SIZE(wm8728_reg_defaults));
	BUG_ON(reg >= ARRAY_SIZE(wm8728_reg_defaults));
	return cache[reg];
}

@@ -55,7 +55,7 @@ static inline void wm8728_write_reg_cache(struct snd_soc_codec *codec,
	u16 reg, unsigned int value)
{
	u16 *cache = codec->reg_cache;
	BUG_ON(reg > ARRAY_SIZE(wm8728_reg_defaults));
	BUG_ON(reg >= ARRAY_SIZE(wm8728_reg_defaults));
	cache[reg] = value;
}

Loading