[PATCH v3] ASoC: omap: convert per-board modules to platform drivers

2011-09-09 Thread Mans Rullgard
This converts the per-board modules to platform drivers for a
device created by in main platform setup.  These drivers call
snd_soc_register_card() directly instead of going via a soc-audio
device and the corresponding driver in soc-core.

Signed-off-by: Mans Rullgard mans.rullg...@linaro.org
---
This version uses a table to assign the device name in omap_init_audio().
It is certainly less ugly than the previous patch.

Again, tested only on Beagle.
---
 arch/arm/mach-omap2/devices.c |   34 +++
 sound/soc/omap/am3517evm.c|   55 +++---
 sound/soc/omap/igep0020.c |   52 +++--
 sound/soc/omap/n810.c |   73 ++---
 sound/soc/omap/omap3beagle.c  |   55 +++---
 sound/soc/omap/omap3evm.c |   56 ---
 sound/soc/omap/omap3pandora.c |   70 ---
 sound/soc/omap/overo.c|   56 +++
 sound/soc/omap/rx51.c |   55 +--
 sound/soc/omap/sdp3430.c  |   65 ++--
 sound/soc/omap/sdp4430.c  |   60 +
 sound/soc/omap/zoom2.c|   68 +-
 12 files changed, 458 insertions(+), 241 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5b8ca68..cfec01b 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -299,6 +299,10 @@ static struct platform_device omap_pcm = {
.id = -1,
 };
 
+static struct platform_device omap_soc_audio = {
+   .id = -1,
+};
+
 /*
  * OMAP2420 has 2 McBSP ports
  * OMAP2430 has 5 McBSP ports
@@ -311,8 +315,30 @@ OMAP_MCBSP_PLATFORM_DEVICE(3);
 OMAP_MCBSP_PLATFORM_DEVICE(4);
 OMAP_MCBSP_PLATFORM_DEVICE(5);
 
+static struct {
+   int machine;
+   const char *name;
+} soc_device_names[] = {
+   { MACH_TYPE_OMAP3517EVM,am3517evm-soc-audio   },
+   { MACH_TYPE_IGEP0020,   igep2-soc-audio   },
+   { MACH_TYPE_NOKIA_N810, n8x1-soc-audio},
+   { MACH_TYPE_NOKIA_N810_WIMAX,   n8x1-soc-audio},
+   { MACH_TYPE_OMAP3_BEAGLE,   omap3beagle-soc-audio },
+   { MACH_TYPE_DEVKIT8000, omap3beagle-soc-audio },
+   { MACH_TYPE_OMAP3EVM,   omap3evm-soc-audio},
+   { MACH_TYPE_OMAP3_PANDORA,  pandora-soc-audio },
+   { MACH_TYPE_OVERO,  overo-soc-audio,  },
+   { MACH_TYPE_CM_T35, overo-soc-audio,  },
+   { MACH_TYPE_NOKIA_RX51, rx51-soc-audio,   },
+   { MACH_TYPE_OMAP_3430SDP,   sdp3430-soc-audio,},
+   { MACH_TYPE_OMAP_4430SDP,   sdp4430-soc-audio,},
+   { MACH_TYPE_OMAP_ZOOM2, zoom2-soc-audio,  },
+};
+
 static void omap_init_audio(void)
 {
+   int i;
+
platform_device_register(omap_mcbsp1);
platform_device_register(omap_mcbsp2);
if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
@@ -323,6 +349,14 @@ static void omap_init_audio(void)
platform_device_register(omap_mcbsp5);
 
platform_device_register(omap_pcm);
+
+   for (i = 0; i  ARRAY_SIZE(soc_device_names); i++) {
+   if (machine_arch_type == soc_device_names[i].machine) {
+   omap_soc_audio.name = soc_device_names[i].name;
+   platform_device_register(omap_soc_audio);
+   break;
+   }
+   }
 }
 
 #else
diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c
index 73dde4a..75c8766 100644
--- a/sound/soc/omap/am3517evm.c
+++ b/sound/soc/omap/am3517evm.c
@@ -151,45 +151,60 @@ static struct snd_soc_card snd_soc_am3517evm = {
.num_links = 1,
 };
 
-static struct platform_device *am3517evm_snd_device;
-
-static int __init am3517evm_soc_init(void)
+static int __devinit am3517evm_soc_probe(struct platform_device *pdev)
 {
+   struct snd_soc_card *card = snd_soc_am3517evm;
int ret;
 
-   if (!machine_is_omap3517evm())
-   return -ENODEV;
pr_info(OMAP3517 / AM3517 EVM SoC init\n);
 
-   am3517evm_snd_device = platform_device_alloc(soc-audio, -1);
-   if (!am3517evm_snd_device) {
-   printk(KERN_ERR Platform device allocation failed\n);
-   return -ENOMEM;
+   card-dev = pdev-dev;
+
+   ret = snd_soc_register_card(card);
+   if (ret) {
+   dev_err(pdev-dev, snd_soc_register_card() failed: %d\n,
+   ret);
+   return ret;
}
 
-   platform_set_drvdata(am3517evm_snd_device, snd_soc_am3517evm);
+   return 0;
+}
 
-   ret = platform_device_add(am3517evm_snd_device);
-   if (ret)
-   goto err1;
+static int __devexit am3517evm_soc_remove(struct platform_device *pdev)
+{
+   struct 

Re: [PATCH v3] ASoC: omap: convert per-board modules to platform drivers

2011-09-09 Thread Mark Brown
On Fri, Sep 09, 2011 at 12:38:51PM +0100, Mans Rullgard wrote:
 This converts the per-board modules to platform drivers for a
 device created by in main platform setup.  These drivers call
 snd_soc_register_card() directly instead of going via a soc-audio
 device and the corresponding driver in soc-core.
 
 Signed-off-by: Mans Rullgard mans.rullg...@linaro.org

Acked-by: Mark Brown broo...@opensource.wolfsonmicro.com
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] ASoC: omap: convert per-board modules to platform drivers

2011-09-09 Thread Russell King - ARM Linux
On Fri, Sep 09, 2011 at 12:38:51PM +0100, Mans Rullgard wrote:
 This converts the per-board modules to platform drivers for a
 device created by in main platform setup.  These drivers call
 snd_soc_register_card() directly instead of going via a soc-audio
 device and the corresponding driver in soc-core.
 
 Signed-off-by: Mans Rullgard mans.rullg...@linaro.org
 ---
 This version uses a table to assign the device name in omap_init_audio().
 It is certainly less ugly than the previous patch.
 
 Again, tested only on Beagle.
 ---
  arch/arm/mach-omap2/devices.c |   34 +++
  sound/soc/omap/am3517evm.c|   55 +++---
  sound/soc/omap/igep0020.c |   52 +++--
  sound/soc/omap/n810.c |   73 
 ++---
  sound/soc/omap/omap3beagle.c  |   55 +++---
  sound/soc/omap/omap3evm.c |   56 ---
  sound/soc/omap/omap3pandora.c |   70 ---
  sound/soc/omap/overo.c|   56 +++
  sound/soc/omap/rx51.c |   55 +--
  sound/soc/omap/sdp3430.c  |   65 ++--
  sound/soc/omap/sdp4430.c  |   60 +
  sound/soc/omap/zoom2.c|   68 +-
  12 files changed, 458 insertions(+), 241 deletions(-)

I don't think this is an improvement.  Just look at the diffstat - it almost
doubles the number of lines of code.

One thing here which is utterly silly is:

 +static struct {
 + int machine;
 + const char *name;
 +} soc_device_names[] = {
 + { MACH_TYPE_OMAP3517EVM,am3517evm-soc-audio   },
 + { MACH_TYPE_IGEP0020,   igep2-soc-audio   },
 + { MACH_TYPE_NOKIA_N810, n8x1-soc-audio},
 + { MACH_TYPE_NOKIA_N810_WIMAX,   n8x1-soc-audio},
 + { MACH_TYPE_OMAP3_BEAGLE,   omap3beagle-soc-audio },
 + { MACH_TYPE_DEVKIT8000, omap3beagle-soc-audio },
 + { MACH_TYPE_OMAP3EVM,   omap3evm-soc-audio},
 + { MACH_TYPE_OMAP3_PANDORA,  pandora-soc-audio },
 + { MACH_TYPE_OVERO,  overo-soc-audio,  },
 + { MACH_TYPE_CM_T35, overo-soc-audio,  },
 + { MACH_TYPE_NOKIA_RX51, rx51-soc-audio,   },
 + { MACH_TYPE_OMAP_3430SDP,   sdp3430-soc-audio,},
 + { MACH_TYPE_OMAP_4430SDP,   sdp4430-soc-audio,},
 + { MACH_TYPE_OMAP_ZOOM2, zoom2-soc-audio,  },
 +};

So you're using the machine ID to select the name of the device.
(That's not really DT compatible.)

 +static int __init am3517evm_soc_init(void)
 +{
 + if (!machine_is_omap3517evm())
 + return -ENODEV;

But then you conditionalize the registration of the drivers on the
platform as well.  Why?  It's pointless.  If you don't have the core
code register the struct device for this platform then this driver
won't be bound to a device, and therefore the probe function won't be
called.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html