* [PATCH] ad193x: move codec register/unregister to bus probe/remove
@ 2010-03-29 3:16 Barry Song
[not found] ` <1269832560-6845-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Barry Song @ 2010-03-29 3:16 UTC (permalink / raw)
To: lrg, broonie; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
The way i've factored out the bus probe and removal functions so
that there's no code in the individual I2C and SPI functions means
that the register() and unregister() functions could just be squashed
into the bus_probe() and bus_remove() functions.
Signed-off-by: Barry Song <21cnbao@gmail.com>
---
sound/soc/codecs/ad193x.c | 102 +++++++++++++++++++-------------------------
1 files changed, 44 insertions(+), 58 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index d034464..e6fe8ac 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -34,8 +34,6 @@ static const u8 ad193x_reg[AD193X_NUM_REGS] = {
static struct snd_soc_codec *ad193x_codec;
struct snd_soc_codec_device soc_codec_dev_ad193x;
-static int ad193x_register(struct ad193x_priv *ad193x, int bus_type);
-static void ad193x_unregister(struct ad193x_priv *ad193x);
/*
* AD193X volume/mute/de-emphasis etc. controls
@@ -289,69 +287,23 @@ static int ad193x_bus_probe(struct device *dev, void *ctrl_data, int bus_type)
{
struct snd_soc_codec *codec;
struct ad193x_priv *ad193x;
+ int ret;
+
+ if (ad193x_codec) {
+ dev_err(dev, "Another ad193x is registered\n");
+ return -EINVAL;
+ }
ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL);
if (ad193x == NULL)
return -ENOMEM;
- codec = &ad193x->codec;
- codec->control_data = ctrl_data;
- codec->dev = dev;
-
dev_set_drvdata(dev, ad193x);
- return ad193x_register(ad193x, bus_type);
-}
-
-static int ad193x_bus_remove(struct device *dev)
-{
- struct ad193x_priv *ad193x = dev_get_drvdata(dev);
-
- ad193x_unregister(ad193x);
- return 0;
-}
-
-static struct snd_soc_dai_ops ad193x_dai_ops = {
- .hw_params = ad193x_hw_params,
- .digital_mute = ad193x_mute,
- .set_tdm_slot = ad193x_set_tdm_slot,
- .set_fmt = ad193x_set_dai_fmt,
-};
-
-/* codec DAI instance */
-struct snd_soc_dai ad193x_dai = {
- .name = "AD193X",
- .playback = {
- .stream_name = "Playback",
- .channels_min = 2,
- .channels_max = 8,
- .rates = SNDRV_PCM_RATE_48000,
- .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
- },
- .capture = {
- .stream_name = "Capture",
- .channels_min = 2,
- .channels_max = 4,
- .rates = SNDRV_PCM_RATE_48000,
- .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
- },
- .ops = &ad193x_dai_ops,
-};
-EXPORT_SYMBOL_GPL(ad193x_dai);
-
-static int ad193x_register(struct ad193x_priv *ad193x, int bus_type)
-{
- int ret;
- struct snd_soc_codec *codec = &ad193x->codec;
-
- if (ad193x_codec) {
- dev_err(codec->dev, "Another ad193x is registered\n");
- return -EINVAL;
- }
-
+ codec = &ad193x->codec;
mutex_init(&codec->mutex);
+ codec->control_data = ctrl_data;
+ codec->dev = dev;
codec->private_data = ad193x;
codec->reg_cache = ad193x->reg_cache;
codec->reg_cache_size = AD193X_NUM_REGS;
@@ -412,14 +364,48 @@ static int ad193x_register(struct ad193x_priv *ad193x, int bus_type)
return 0;
}
-static void ad193x_unregister(struct ad193x_priv *ad193x)
+static int ad193x_bus_remove(struct device *dev)
{
+ struct ad193x_priv *ad193x = dev_get_drvdata(dev);
+
snd_soc_unregister_dai(&ad193x_dai);
snd_soc_unregister_codec(&ad193x->codec);
kfree(ad193x);
ad193x_codec = NULL;
+
+ return 0;
}
+static struct snd_soc_dai_ops ad193x_dai_ops = {
+ .hw_params = ad193x_hw_params,
+ .digital_mute = ad193x_mute,
+ .set_tdm_slot = ad193x_set_tdm_slot,
+ .set_fmt = ad193x_set_dai_fmt,
+};
+
+/* codec DAI instance */
+struct snd_soc_dai ad193x_dai = {
+ .name = "AD193X",
+ .playback = {
+ .stream_name = "Playback",
+ .channels_min = 2,
+ .channels_max = 8,
+ .rates = SNDRV_PCM_RATE_48000,
+ .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
+ SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
+ },
+ .capture = {
+ .stream_name = "Capture",
+ .channels_min = 2,
+ .channels_max = 4,
+ .rates = SNDRV_PCM_RATE_48000,
+ .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
+ SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
+ },
+ .ops = &ad193x_dai_ops,
+};
+EXPORT_SYMBOL_GPL(ad193x_dai);
+
static int ad193x_probe(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
--
1.5.6.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [alsa-devel] [PATCH] ad193x: move codec register/unregister to bus probe/remove
[not found] ` <1269832560-6845-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-03-29 13:40 ` Liam Girdwood
2010-03-29 20:03 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Liam Girdwood @ 2010-03-29 13:40 UTC (permalink / raw)
To: Barry Song
Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E
On Mon, 2010-03-29 at 11:16 +0800, Barry Song wrote:
> The way i've factored out the bus probe and removal functions so
> that there's no code in the individual I2C and SPI functions means
> that the register() and unregister() functions could just be squashed
> into the bus_probe() and bus_remove() functions.
>
> Signed-off-by: Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
Acked-by: Liam Girdwood <lrg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>
Btw, the multi-codec branch does very similar refactoring and removes
the need for the extra register/unregister too.
Liam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ad193x: move codec register/unregister to bus probe/remove
2010-03-29 13:40 ` [alsa-devel] " Liam Girdwood
@ 2010-03-29 20:03 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-03-29 20:03 UTC (permalink / raw)
To: Liam Girdwood; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
On Mon, Mar 29, 2010 at 02:40:01PM +0100, Liam Girdwood wrote:
> On Mon, 2010-03-29 at 11:16 +0800, Barry Song wrote:
> > The way i've factored out the bus probe and removal functions so
> > that there's no code in the individual I2C and SPI functions means
> > that the register() and unregister() functions could just be squashed
> > into the bus_probe() and bus_remove() functions.
> >
> > Signed-off-by: Barry Song <21cnbao@gmail.com>
> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-29 20:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-29 3:16 [PATCH] ad193x: move codec register/unregister to bus probe/remove Barry Song
[not found] ` <1269832560-6845-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-03-29 13:40 ` [alsa-devel] " Liam Girdwood
2010-03-29 20:03 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).