Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2c812e2 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Add indirection for CODEC private data



One of the features of the multi CODEC work is that it embeds a struct
device in the CODEC to provide diagnostics via a sysfs class rather than
via the device tree, at which point it's much better to use the struct
device private data rather than having two places to store it. Provide
an accessor function to allow this change to be made more easily, and
update all the CODEC drivers are updated.

To ensure use of the accessor the private data structure member is
renamed, meaning that if code developed with older an older core that
still uses private_data is merged it will fail to build.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 890c6812
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -414,7 +414,7 @@ struct snd_soc_codec {
	struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
	unsigned int active;
	unsigned int pcm_devs;
	void *private_data;
	void *drvdata;

	/* codec IO */
	void *control_data; /* codec control (i2c/3wire) data */
@@ -597,6 +597,17 @@ static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
	return codec->write(codec, reg, val);
}

static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
					     void *data)
{
	codec->drvdata = data;
}

static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
{
	return codec->drvdata;
}

#include <sound/soc-dai.h>

#endif
+1 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ static int ad1836_register(struct ad1836_priv *ad1836)
	mutex_init(&codec->mutex);
	INIT_LIST_HEAD(&codec->dapm_widgets);
	INIT_LIST_HEAD(&codec->dapm_paths);
	codec->private_data = ad1836;
	snd_soc_codec_set_drvdata(codec, ad1836);
	codec->reg_cache = ad1836->reg_cache;
	codec->reg_cache_size = AD1836_NUM_REGS;
	codec->name = "AD1836";
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ static int ad193x_bus_probe(struct device *dev, void *ctrl_data, int bus_type)
	mutex_init(&codec->mutex);
	codec->control_data = ctrl_data;
	codec->dev = dev;
	codec->private_data = ad193x;
	snd_soc_codec_set_drvdata(codec, ad193x);
	codec->reg_cache = ad193x->reg_cache;
	codec->reg_cache_size = AD193X_NUM_REGS;
	codec->name = "AD193X";
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ static int ak4104_spi_probe(struct spi_device *spi)
	codec->owner = THIS_MODULE;
	codec->dai = &ak4104_dai;
	codec->num_dai = 1;
	codec->private_data = ak4104;
	snd_soc_codec_set_drvdata(codec, ak4104);
	codec->control_data = spi;
	codec->reg_cache = ak4104->reg_cache;
	codec->reg_cache_size = AK4104_NUM_REGS;
+5 −5
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai,
	int clk_id, unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct ak4535_priv *ak4535 = codec->private_data;
	struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);

	ak4535->sysclk = freq;
	return 0;
@@ -314,7 +314,7 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream,
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_device *socdev = rtd->socdev;
	struct snd_soc_codec *codec = socdev->card->codec;
	struct ak4535_priv *ak4535 = codec->private_data;
	struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec);
	u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5);
	int rate = params_rate(params), fs = 256;

@@ -599,7 +599,7 @@ static int ak4535_probe(struct platform_device *pdev)
		return -ENOMEM;
	}

	codec->private_data = ak4535;
	snd_soc_codec_set_drvdata(codec, ak4535);
	socdev->card->codec = codec;
	mutex_init(&codec->mutex);
	INIT_LIST_HEAD(&codec->dapm_widgets);
@@ -616,7 +616,7 @@ static int ak4535_probe(struct platform_device *pdev)
#endif

	if (ret != 0) {
		kfree(codec->private_data);
		kfree(snd_soc_codec_get_drvdata(codec));
		kfree(codec);
	}
	return ret;
@@ -638,7 +638,7 @@ static int ak4535_remove(struct platform_device *pdev)
		i2c_unregister_device(codec->control_data);
	i2c_del_driver(&ak4535_i2c_driver);
#endif
	kfree(codec->private_data);
	kfree(snd_soc_codec_get_drvdata(codec));
	kfree(codec);

	return 0;
Loading