[alsa-devel] [PATCH v2] ASoC: omap: convert per-board modules to platform drivers
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.rullgard@linaro.org --- Platform device names fixed. N8x0 changed to get clocks before registering card. --- arch/arm/mach-omap2/board-3430sdp.c | 6 ++ arch/arm/mach-omap2/board-4430sdp.c | 6 ++ arch/arm/mach-omap2/board-am3517evm.c | 7 +++ arch/arm/mach-omap2/board-devkit8000.c | 6 ++ arch/arm/mach-omap2/board-igep0020.c | 6 ++ arch/arm/mach-omap2/board-n8x0.c | 6 ++ arch/arm/mach-omap2/board-omap3beagle.c | 6 ++ arch/arm/mach-omap2/board-omap3evm.c | 7 +++ arch/arm/mach-omap2/board-omap3pandora.c | 6 ++ arch/arm/mach-omap2/board-overo.c | 17 ++++++ arch/arm/mach-omap2/board-rx51.c | 6 ++ arch/arm/mach-omap2/board-zoom-peripherals.c | 6 ++ 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 ++++++++++++++++-------- 23 files changed, 509 insertions(+), 241 deletions(-)
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c index 5dac974..4c6a845 100644 --- a/arch/arm/mach-omap2/board-3430sdp.c +++ b/arch/arm/mach-omap2/board-3430sdp.c @@ -470,6 +470,11 @@ static struct twl4030_codec_data sdp3430_codec = { .audio = &sdp3430_audio, };
+static struct platform_device sdp3430_soc_audio = { + .name = "sdp3430-soc-audio", + .id = -1, +}; + static struct twl4030_platform_data sdp3430_twldata = { .irq_base = TWL4030_IRQ_BASE, .irq_end = TWL4030_IRQ_END, @@ -796,6 +801,7 @@ static void __init omap_3430sdp_init(void) sdp3430_display_init(); enable_board_wakeup_source(); usbhs_init(&usbhs_bdata); + platform_device_register(&sdp3430_soc_audio); }
MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board") diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index 63de2d3..d73d7e7 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c @@ -276,11 +276,17 @@ static struct platform_device sdp4430_lcd_device = { .id = -1, };
+static struct platform_device sdp4430_soc_audio = { + .name = "sdp4430-soc-audio", + .id = -1, +}; + static struct platform_device *sdp4430_devices[] __initdata = { &sdp4430_lcd_device, &sdp4430_gpio_keys_device, &sdp4430_leds_gpio, &sdp4430_leds_pwm, + &sdp4430_soc_audio, };
static struct omap_lcd_config sdp4430_lcd_config __initdata = { diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c index 63af417..5d632f6 100644 --- a/arch/arm/mach-omap2/board-am3517evm.c +++ b/arch/arm/mach-omap2/board-am3517evm.c @@ -457,6 +457,11 @@ static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata) platform_device_register(&am3517_hecc_device); }
+static struct platform_device am3517_evm_soc_audio = { + .name = "am3517evm-soc-audio", + .id = -1, +}; + static struct omap_board_config_kernel am3517_evm_config[] __initdata = { };
@@ -487,6 +492,8 @@ static void __init am3517_evm_init(void)
/* MUSB */ am3517_evm_musb_init(); + + platform_device_register(&am3517_evm_soc_audio); }
MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c index 34956ec..070d4f6 100644 --- a/arch/arm/mach-omap2/board-devkit8000.c +++ b/arch/arm/mach-omap2/board-devkit8000.c @@ -477,6 +477,11 @@ static struct platform_device omap_dm9000_dev = { }, };
+static struct platform_device soc_audio = { + .name = "omap3beagle-soc-audio", + .id = -1, +}; + static void __init omap_dm9000_init(void) { unsigned char *eth_addr = omap_dm9000_platdata.dev_addr; @@ -505,6 +510,7 @@ static struct platform_device *devkit8000_devices[] __initdata = { &leds_gpio, &keys_gpio, &omap_dm9000_dev, + &soc_audio, };
static const struct usbhs_omap_board_data usbhs_bdata __initconst = { diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index 4bcbee3..9bfc8cb 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -508,8 +508,14 @@ static void __init igep2_display_init(void) pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n"); }
+static struct platform_device igep_soc_audio = { + .name = "igep2-soc-audio", + .id = -1, +}; + static struct platform_device *igep_devices[] __initdata = { &igep_vwlan_device, + &igep_soc_audio, };
static void __init igep_init_early(void) diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c index 8d74318..a477e6c 100644 --- a/arch/arm/mach-omap2/board-n8x0.c +++ b/arch/arm/mach-omap2/board-n8x0.c @@ -616,6 +616,11 @@ static struct i2c_board_info n810_i2c_board_info_2[] __initdata = { }, };
+static struct platform_device n8x0_soc_audio = { + .name = "n8x0-soc-audio", + .id = -1, +}; + static void __init n8x0_map_io(void) { omap2_set_globals_242x(); @@ -692,6 +697,7 @@ static void __init n8x0_init_machine(void) gpmc_onenand_init(board_onenand_data); n8x0_mmc_init(); n8x0_usb_init(); + platform_device_register(&n8x0_soc_audio); }
MACHINE_START(NOKIA_N800, "Nokia N800") diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 4f23c15..b9b5231 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -503,6 +503,11 @@ static struct platform_device keys_gpio = { }, };
+static struct platform_device soc_audio = { + .name = "omap3beagle-soc-audio", + .id = -1, +}; + static void __init omap3_beagle_init_early(void) { omap2_init_common_infrastructure(); @@ -521,6 +526,7 @@ static void __init omap3_beagle_init_irq(void) static struct platform_device *omap3_beagle_devices[] __initdata = { &leds_gpio, &keys_gpio, + &soc_audio, };
static const struct usbhs_omap_board_data usbhs_bdata __initconst = { diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index b4d4346..4cd7d2e 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c @@ -678,6 +678,11 @@ static struct gpio omap3_evm_ehci_gpios[] __initdata = { { OMAP3_EVM_EHCI_SELECT, GPIOF_OUT_INIT_LOW, "select EHCI port" }, };
+static struct platform_device omap3evm_soc_audio = { + .name = "omap3evm-soc-audio", + .id = -1, +}; + static void __init omap3_evm_init(void) { omap3_evm_get_revision(); @@ -732,6 +737,8 @@ static void __init omap3_evm_init(void) pr_err("error setting wl12xx data\n"); platform_device_register(&omap3evm_wlan_regulator); #endif + + platform_device_register(&omap3evm_soc_audio); }
MACHINE_START(OMAP3EVM, "OMAP3 EVM") diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c index 23f71d4..56a22fc 100644 --- a/arch/arm/mach-omap2/board-omap3pandora.c +++ b/arch/arm/mach-omap2/board-omap3pandora.c @@ -593,10 +593,16 @@ fail: printk(KERN_ERR "wl1251 board initialisation failed\n"); }
+static struct platform_device pandora_soc_audio = { + .name = "omap3pandora-soc-audio", + .id = -1, +}; + static struct platform_device *omap3pandora_devices[] __initdata = { &pandora_leds_gpio, &pandora_keys_gpio, &pandora_vwlan_device, + &pandora_soc_audio, };
static const struct usbhs_omap_board_data usbhs_bdata __initconst = { diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c index b32b492..f9379eb 100644 --- a/arch/arm/mach-omap2/board-overo.c +++ b/arch/arm/mach-omap2/board-overo.c @@ -410,6 +410,22 @@ static void __init overo_init_keys(void) static inline void __init overo_init_keys(void) { return; } #endif
+#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE) + +static struct platform_device soc_audio = { + .name = "overo-soc-audio", + .id = -1, +}; + +static void overo_init_audio(void) +{ + platform_device_register(&soc_audio); +} + +#else +static inline void overo_init_audio(void) {} +#endif + static int overo_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) { @@ -573,6 +589,7 @@ static void __init overo_init(void) overo_display_init(); overo_init_led(); overo_init_keys(); + overo_init_audio();
/* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c index fec4cac..bb3537a 100644 --- a/arch/arm/mach-omap2/board-rx51.c +++ b/arch/arm/mach-omap2/board-rx51.c @@ -58,6 +58,11 @@ static struct platform_device leds_gpio = { }, };
+static struct platform_device soc_audio = { + .name = "rx51-soc-audio", + .id = -1, +}; + /* * cpuidle C-states definition override from the default values. * The 'exit_latency' field is the sum of sleep and wake-up latencies. @@ -140,6 +145,7 @@ static void __init rx51_init(void) omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
platform_device_register(&leds_gpio); + platform_device_register(&soc_audio); }
static void __init rx51_map_io(void) diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c index 118c6f5..037a9cc 100644 --- a/arch/arm/mach-omap2/board-zoom-peripherals.c +++ b/arch/arm/mach-omap2/board-zoom-peripherals.c @@ -286,6 +286,11 @@ static int zoom_twl_gpio_setup(struct device *dev, return ret; }
+static struct platform_device zoom_soc_audio = { + .name = "zoom2-soc-audio", + .id = -1, +}; + /* EXTMUTE callback function */ static void zoom2_set_hs_extmute(int mute) { @@ -378,4 +383,5 @@ void __init zoom_peripherals_init(void) usb_musb_init(NULL); enable_board_wakeup_source(); omap_serial_init(); + platform_device_register(&zoom_soc_audio); } 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 snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card);
return 0; +}
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(am3517evm_snd_device); +static struct platform_driver am3517evm_driver = { + .driver = { + .name = "am3517evm-soc-audio", + .owner = THIS_MODULE, + },
- return ret; + .probe = am3517evm_soc_probe, + .remove = __devexit_p(am3517evm_soc_remove), +}; + +static int __init am3517evm_soc_init(void) +{ + if (!machine_is_omap3517evm()) + return -ENODEV; + + return platform_driver_register(&am3517evm_driver); } +module_init(am3517evm_soc_init);
static void __exit am3517evm_soc_exit(void) { - platform_device_unregister(am3517evm_snd_device); + platform_driver_unregister(&am3517evm_driver); } - -module_init(am3517evm_soc_init); module_exit(am3517evm_soc_exit);
MODULE_AUTHOR("Anuj Aggarwal anuj.aggarwal@ti.com"); MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM"); MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:am3517evm-soc-audio"); diff --git a/sound/soc/omap/igep0020.c b/sound/soc/omap/igep0020.c index 0ae3470..1d6b756 100644 --- a/sound/soc/omap/igep0020.c +++ b/sound/soc/omap/igep0020.c @@ -94,44 +94,60 @@ static struct snd_soc_card snd_soc_card_igep2 = { .num_links = 1, };
-static struct platform_device *igep2_snd_device; - -static int __init igep2_soc_init(void) +static int __devinit igep2_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_card_igep2; int ret;
- if (!machine_is_igep0020()) - return -ENODEV; printk(KERN_INFO "IGEP v2 SoC init\n");
- igep2_snd_device = platform_device_alloc("soc-audio", -1); - if (!igep2_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(igep2_snd_device, &snd_soc_card_igep2); + return 0; +} + +static int __devexit igep2_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev);
- ret = platform_device_add(igep2_snd_device); - if (ret) - goto err1; + snd_soc_unregister_card(card);
return 0; +} + +static struct platform_driver igep2_driver = { + .driver = { + .name = "igep2-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = igep2_soc_probe, + .remove = __devexit_p(igep2_soc_remove), +};
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(igep2_snd_device); +static int __init igep2_soc_init(void) +{ + if (!machine_is_igep0020()) + return -ENODEV;
- return ret; + return platform_driver_register(&igep2_driver); } module_init(igep2_soc_init);
static void __exit igep2_soc_exit(void) { - platform_device_unregister(igep2_snd_device); + platform_driver_unregister(&igep2_driver); } module_exit(igep2_soc_exit);
MODULE_AUTHOR("Enric Balletbo i Serra eballetbo@iseebcn.com"); MODULE_DESCRIPTION("ALSA SoC IGEP v2"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:igep2-soc-audio"); diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 83d213b..2904499 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -323,38 +323,25 @@ static struct snd_soc_card snd_soc_n810 = { .num_links = 1, };
-static struct platform_device *n810_snd_device; - -static int __init n810_soc_init(void) +static int __devinit n810_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_n810; + struct device *dev = &pdev->dev; int err; - struct device *dev; - - if (!(machine_is_nokia_n810() || machine_is_nokia_n810_wimax())) - return -ENODEV;
- n810_snd_device = platform_device_alloc("soc-audio", -1); - if (!n810_snd_device) - return -ENOMEM; - - platform_set_drvdata(n810_snd_device, &snd_soc_n810); - err = platform_device_add(n810_snd_device); - if (err) - goto err1; - - dev = &n810_snd_device->dev; + card->dev = dev;
sys_clkout2_src = clk_get(dev, "sys_clkout2_src"); if (IS_ERR(sys_clkout2_src)) { dev_err(dev, "Could not get sys_clkout2_src clock\n"); err = PTR_ERR(sys_clkout2_src); - goto err2; + return err; } sys_clkout2 = clk_get(dev, "sys_clkout2"); if (IS_ERR(sys_clkout2)) { dev_err(dev, "Could not get sys_clkout2\n"); err = PTR_ERR(sys_clkout2); - goto err3; + goto err1; } /* * Configure 12 MHz output on SYS_CLKOUT2. Therefore we must use @@ -364,7 +351,7 @@ static int __init n810_soc_init(void) if (IS_ERR(func96m_clk)) { dev_err(dev, "Could not get func 96M clock\n"); err = PTR_ERR(func96m_clk); - goto err4; + goto err2; } clk_set_parent(sys_clkout2_src, func96m_clk); clk_set_rate(sys_clkout2, 12000000); @@ -375,33 +362,65 @@ static int __init n810_soc_init(void) gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);
+ err = snd_soc_register_card(card); + if (err) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + err); + goto err3; + } + return 0; -err4: - clk_put(sys_clkout2); err3: - clk_put(sys_clkout2_src); + clk_put(func96m_clk); err2: - platform_device_del(n810_snd_device); + clk_put(sys_clkout2); err1: - platform_device_put(n810_snd_device); + clk_put(sys_clkout2_src);
return err; }
-static void __exit n810_soc_exit(void) +static int __devexit n810_soc_remove(struct platform_device *pdev) { + struct snd_soc_card *card = platform_get_drvdata(pdev); + gpio_free(N810_SPEAKER_AMP_GPIO); gpio_free(N810_HEADSET_AMP_GPIO); clk_put(sys_clkout2_src); clk_put(sys_clkout2); clk_put(func96m_clk);
- platform_device_unregister(n810_snd_device); + snd_soc_unregister_card(card); + + return 0; }
+static struct platform_driver n810_driver = { + .driver = { + .name = "n8x0-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = n810_soc_probe, + .remove = __devexit_p(n810_soc_remove), +}; + +static int __init n810_soc_init(void) +{ + if (!(machine_is_nokia_n810() || machine_is_nokia_n810_wimax())) + return -ENODEV; + + return platform_driver_register(&n810_driver); +} module_init(n810_soc_init); + +static void __exit n810_soc_exit(void) +{ + platform_driver_unregister(&n810_driver); +} module_exit(n810_soc_exit);
MODULE_AUTHOR("Jarkko Nikula jhnikula@gmail.com"); MODULE_DESCRIPTION("ALSA SoC Nokia N810"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:n8x0-soc-audio"); diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c index 40db813..85db9c3 100644 --- a/sound/soc/omap/omap3beagle.c +++ b/sound/soc/omap/omap3beagle.c @@ -105,45 +105,60 @@ static struct snd_soc_card snd_soc_omap3beagle = { .num_links = 1, };
-static struct platform_device *omap3beagle_snd_device; - -static int __init omap3beagle_soc_init(void) +static int __devinit omap3beagle_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_omap3beagle; int ret;
- if (!(machine_is_omap3_beagle() || machine_is_devkit8000())) - return -ENODEV; pr_info("OMAP3 Beagle/Devkit8000 SoC init\n");
- omap3beagle_snd_device = platform_device_alloc("soc-audio", -1); - if (!omap3beagle_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(omap3beagle_snd_device, &snd_soc_omap3beagle); + return 0; +}
- ret = platform_device_add(omap3beagle_snd_device); - if (ret) - goto err1; +static int __devexit omap3beagle_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card);
return 0; +}
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(omap3beagle_snd_device); +static struct platform_driver omap3beagle_driver = { + .driver = { + .name = "omap3beagle-soc-audio", + .owner = THIS_MODULE, + },
- return ret; + .probe = omap3beagle_soc_probe, + .remove = __devexit_p(omap3beagle_soc_remove), +}; + +static int __init omap3beagle_soc_init(void) +{ + if (!(machine_is_omap3_beagle() || machine_is_devkit8000())) + return -ENODEV; + + return platform_driver_register(&omap3beagle_driver); } +module_init(omap3beagle_soc_init);
static void __exit omap3beagle_soc_exit(void) { - platform_device_unregister(omap3beagle_snd_device); + platform_driver_unregister(&omap3beagle_driver); } - -module_init(omap3beagle_soc_init); module_exit(omap3beagle_soc_exit);
MODULE_AUTHOR("Steve Sakoman steve@sakoman.com"); MODULE_DESCRIPTION("ALSA SoC OMAP3 Beagle"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:omap3beagle-soc-audio"); diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c index 0daa044..55c9aa3 100644 --- a/sound/soc/omap/omap3evm.c +++ b/sound/soc/omap/omap3evm.c @@ -92,44 +92,60 @@ static struct snd_soc_card snd_soc_omap3evm = { .num_links = 1, };
-static struct platform_device *omap3evm_snd_device; - -static int __init omap3evm_soc_init(void) +static int __devinit omap3evm_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_omap3evm; int ret;
- if (!machine_is_omap3evm()) - return -ENODEV; pr_info("OMAP3 EVM SoC init\n");
- omap3evm_snd_device = platform_device_alloc("soc-audio", -1); - if (!omap3evm_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(omap3evm_snd_device, &snd_soc_omap3evm); - ret = platform_device_add(omap3evm_snd_device); - if (ret) - goto err1; + return 0; +} + +static int __devexit omap3evm_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card);
return 0; +} + +static struct platform_driver omap3evm_driver = { + .driver = { + .name = "omap3evm-soc-audio", + .owner = THIS_MODULE, + },
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(omap3evm_snd_device); + .probe = omap3evm_soc_probe, + .remove = __devexit_p(omap3evm_soc_remove), +};
- return ret; +static int __init omap3evm_soc_init(void) +{ + if (!machine_is_omap3evm()) + return -ENODEV; + + return platform_driver_register(&omap3evm_driver); } +module_init(omap3evm_soc_init);
static void __exit omap3evm_soc_exit(void) { - platform_device_unregister(omap3evm_snd_device); + platform_driver_unregister(&omap3evm_driver); } - -module_init(omap3evm_soc_init); module_exit(omap3evm_soc_exit);
MODULE_AUTHOR("Anuj Aggarwal anuj.aggarwal@ti.com"); MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM"); MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:omap3evm-soc-audio"); diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 8047c52..c523e5f 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -252,17 +252,15 @@ static struct snd_soc_card snd_soc_card_omap3pandora = { .num_links = ARRAY_SIZE(omap3pandora_dai), };
-static struct platform_device *omap3pandora_snd_device; - -static int __init omap3pandora_soc_init(void) +static int __devinit omap3pandora_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_card_omap3pandora; int ret;
- if (!machine_is_omap3_pandora()) - return -ENODEV; - pr_info("OMAP3 Pandora SoC init\n");
+ card->dev = &pdev->dev; + ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power"); if (ret) { pr_err(PREFIX "Failed to get DAC power GPIO\n"); @@ -287,53 +285,71 @@ static int __init omap3pandora_soc_init(void) goto fail1; }
- omap3pandora_snd_device = platform_device_alloc("soc-audio", -1); - if (omap3pandora_snd_device == NULL) { - pr_err(PREFIX "Platform device allocation failed\n"); - ret = -ENOMEM; - goto fail1; - } - - platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora); - - ret = platform_device_add(omap3pandora_snd_device); + ret = snd_soc_register_card(card); if (ret) { - pr_err(PREFIX "Unable to add platform device\n"); - goto fail2; + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + goto fail1; }
- omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc"); + omap3pandora_dac_reg = regulator_get(card->dev, "vcc"); if (IS_ERR(omap3pandora_dac_reg)) { pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n", - dev_name(&omap3pandora_snd_device->dev), + dev_name(card->dev), PTR_ERR(omap3pandora_dac_reg)); ret = PTR_ERR(omap3pandora_dac_reg); - goto fail3; + goto fail2; }
return 0;
-fail3: - platform_device_del(omap3pandora_snd_device); fail2: - platform_device_put(omap3pandora_snd_device); + snd_soc_unregister_card(card); fail1: gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); fail0: gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); return ret; } -module_init(omap3pandora_soc_init);
-static void __exit omap3pandora_soc_exit(void) +static int __devexit omap3pandora_soc_remove(struct platform_device *pdev) { + struct snd_soc_card *card = platform_get_drvdata(pdev); + regulator_put(omap3pandora_dac_reg); - platform_device_unregister(omap3pandora_snd_device); + snd_soc_unregister_card(card); gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO); gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO); + + return 0; +} + +static struct platform_driver omap3pandora_driver = { + .driver = { + .name = "omap3pandora-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = omap3pandora_soc_probe, + .remove = __devexit_p(omap3pandora_soc_remove), +}; + +static int __init omap3pandora_soc_init(void) +{ + if (!machine_is_omap3_pandora()) + return -ENODEV; + + return platform_driver_register(&omap3pandora_driver); +} +module_init(omap3pandora_soc_init); + +static void __exit omap3pandora_soc_exit(void) +{ + platform_driver_unregister(&omap3pandora_driver); } module_exit(omap3pandora_soc_exit);
MODULE_AUTHOR("Grazvydas Ignotas notasas@gmail.com"); MODULE_DESCRIPTION("ALSA SoC OMAP3 Pandora"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:omap3pandora-soc-audio"); diff --git a/sound/soc/omap/overo.c b/sound/soc/omap/overo.c index bbcf380..a8337f6 100644 --- a/sound/soc/omap/overo.c +++ b/sound/soc/omap/overo.c @@ -94,46 +94,60 @@ static struct snd_soc_card snd_soc_card_overo = { .num_links = 1, };
-static struct platform_device *overo_snd_device; - -static int __init overo_soc_init(void) +static int __devinit overo_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_card_overo; int ret;
- if (!(machine_is_overo() || machine_is_cm_t35())) { - pr_debug("Incomatible machine!\n"); - return -ENODEV; - } - printk(KERN_INFO "overo SoC init\n"); + pr_info("overo SoC init\n"); + + card->dev = &pdev->dev;
- overo_snd_device = platform_device_alloc("soc-audio", -1); - if (!overo_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; + 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(overo_snd_device, &snd_soc_card_overo); + return 0; +}
- ret = platform_device_add(overo_snd_device); - if (ret) - goto err1; +static int __devexit overo_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card);
return 0; +} + +static struct platform_driver overo_driver = { + .driver = { + .name = "overo-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = overo_soc_probe, + .remove = __devexit_p(overo_soc_remove), +};
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(overo_snd_device); +static int __init overo_soc_init(void) +{ + if (!(machine_is_overo() || machine_is_cm_t35())) + return -ENODEV;
- return ret; + return platform_driver_register(&overo_driver); } module_init(overo_soc_init);
static void __exit overo_soc_exit(void) { - platform_device_unregister(overo_snd_device); + platform_driver_unregister(&overo_driver); } module_exit(overo_soc_exit);
MODULE_AUTHOR("Steve Sakoman steve@sakoman.com"); MODULE_DESCRIPTION("ALSA SoC overo"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:overo-soc-audio"); diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 0aae998..a14f4d4 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -408,14 +408,12 @@ static struct snd_soc_card rx51_sound_card = { .num_configs = ARRAY_SIZE(rx51_codec_conf), };
-static struct platform_device *rx51_snd_device; - -static int __init rx51_soc_init(void) +static int __devinit rx51_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &rx51_sound_card; int err;
- if (!machine_is_nokia_rx51()) - return -ENODEV; + card->dev = &pdev->dev;
err = gpio_request_one(RX51_TVOUT_SEL_GPIO, GPIOF_DIR_OUT | GPIOF_INIT_LOW, "tvout_sel"); @@ -426,21 +424,14 @@ static int __init rx51_soc_init(void) if (err) goto err_gpio_eci_sw;
- rx51_snd_device = platform_device_alloc("soc-audio", -1); - if (!rx51_snd_device) { - err = -ENOMEM; + err = snd_soc_register_card(card); + if (err) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + err); goto err1; }
- platform_set_drvdata(rx51_snd_device, &rx51_sound_card); - - err = platform_device_add(rx51_snd_device); - if (err) - goto err2; - return 0; -err2: - platform_device_put(rx51_snd_device); err1: gpio_free(RX51_ECI_SW_GPIO); err_gpio_eci_sw: @@ -450,19 +441,47 @@ err_gpio_tvout_sel: return err; }
-static void __exit rx51_soc_exit(void) +static int __devexit rx51_soc_remove(struct platform_device *pdev) { + struct snd_soc_card *card = platform_get_drvdata(pdev); + snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), rx51_av_jack_gpios);
- platform_device_unregister(rx51_snd_device); + snd_soc_unregister_card(card); + gpio_free(RX51_ECI_SW_GPIO); gpio_free(RX51_TVOUT_SEL_GPIO); + + return 0; }
+static struct platform_driver rx51_driver = { + .driver = { + .name = "rx51-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = rx51_soc_probe, + .remove = __devexit_p(rx51_soc_remove), +}; + +static int __init rx51_soc_init(void) +{ + if (!machine_is_nokia_rx51()) + return -ENODEV; + + return platform_driver_register(&rx51_driver); +} module_init(rx51_soc_init); + +static void __exit rx51_soc_exit(void) +{ + platform_driver_unregister(&rx51_driver); +} module_exit(rx51_soc_exit);
MODULE_AUTHOR("Nokia Corporation"); MODULE_DESCRIPTION("ALSA SoC Nokia RX-51"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:rx51-soc-audio"); diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 3f72d17..73e317e 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -289,24 +289,15 @@ static struct snd_soc_card snd_soc_sdp3430 = { .num_links = ARRAY_SIZE(sdp3430_dai), };
-static struct platform_device *sdp3430_snd_device; - -static int __init sdp3430_soc_init(void) +static int __devinit sdp3430_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_sdp3430; int ret; u8 pin_mux;
- if (!machine_is_omap_3430sdp()) - return -ENODEV; - printk(KERN_INFO "SDP3430 SoC init\n"); + pr_info("SDP3430 SoC init\n");
- sdp3430_snd_device = platform_device_alloc("soc-audio", -1); - if (!sdp3430_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(sdp3430_snd_device, &snd_soc_sdp3430); + card->dev = &pdev->dev;
/* Set TWL4030 GPIO6 as EXTMUTE signal */ twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux, @@ -316,30 +307,54 @@ static int __init sdp3430_soc_init(void) twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux, TWL4030_INTBR_PMBR1);
- ret = platform_device_add(sdp3430_snd_device); - if (ret) - goto err1; + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + return ret; + }
return 0; +}
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(sdp3430_snd_device); +static int __devexit sdp3430_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev);
- return ret; + snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); + + snd_soc_unregister_card(card); + + return 0; +} + +static struct platform_driver sdp3430_driver = { + .driver = { + .name = "sdp3430-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = sdp3430_soc_probe, + .remove = __devexit_p(sdp3430_soc_remove), +}; + +static int __init sdp3430_soc_init(void) +{ + if (!machine_is_omap_3430sdp()) + return -ENODEV; + + return platform_driver_register(&sdp3430_driver); } module_init(sdp3430_soc_init);
static void __exit sdp3430_soc_exit(void) { - snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), - hs_jack_gpios); - - platform_device_unregister(sdp3430_snd_device); + platform_driver_unregister(&sdp3430_driver); } module_exit(sdp3430_soc_exit);
MODULE_AUTHOR("Misael Lopez Cruz x0052729@ti.com"); MODULE_DESCRIPTION("ALSA SoC SDP3430"); MODULE_LICENSE("GPL"); - +MODULE_ALIAS("platform:sdp3430-soc-audio"); diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c index 189e039..9dfa9fd 100644 --- a/sound/soc/omap/sdp4430.c +++ b/sound/soc/omap/sdp4430.c @@ -215,47 +215,63 @@ static struct snd_soc_card snd_soc_sdp4430 = { .num_links = 1, };
-static struct platform_device *sdp4430_snd_device; - -static int __init sdp4430_soc_init(void) +static int __devinit sdp4430_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_sdp4430; int ret;
- if (!machine_is_omap_4430sdp()) - return -ENODEV; - printk(KERN_INFO "SDP4430 SoC init\n"); + pr_info("SDP4430 SoC init\n");
- sdp4430_snd_device = platform_device_alloc("soc-audio", -1); - if (!sdp4430_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); + card->dev = &pdev->dev;
- ret = platform_device_add(sdp4430_snd_device); - if (ret) - goto err; + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + return ret; + }
/* Codec starts in HP mode */ twl6040_power_mode = 1;
return 0; +}
-err: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(sdp4430_snd_device); - return ret; +static int __devexit sdp4430_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; +} + +static struct platform_driver sdp4430_driver = { + .driver = { + .name = "sdp4430-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = sdp4430_soc_probe, + .remove = __devexit_p(sdp4430_soc_remove), +}; + +static int __init sdp4430_soc_init(void) +{ + if (!machine_is_omap_4430sdp()) + return -ENODEV; + + return platform_driver_register(&sdp4430_driver); } module_init(sdp4430_soc_init);
static void __exit sdp4430_soc_exit(void) { - platform_device_unregister(sdp4430_snd_device); + platform_driver_unregister(&sdp4430_driver); } module_exit(sdp4430_soc_exit);
MODULE_AUTHOR("Misael Lopez Cruz x0052729@ti.com"); MODULE_DESCRIPTION("ALSA SoC SDP4430"); MODULE_LICENSE("GPL"); - +MODULE_ALIAS("platform:sdp4430-soc-audio"); diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c index 0170994..15691e0 100644 --- a/sound/soc/omap/zoom2.c +++ b/sound/soc/omap/zoom2.c @@ -239,26 +239,14 @@ static struct snd_soc_card snd_soc_zoom2 = { .num_links = ARRAY_SIZE(zoom2_dai), };
-static struct platform_device *zoom2_snd_device; - -static int __init zoom2_soc_init(void) +static int __devinit zoom2_soc_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_zoom2; int ret;
- if (!machine_is_omap_zoom2()) - return -ENODEV; - printk(KERN_INFO "Zoom2 SoC init\n"); + pr_info("Zoom2 SoC init\n");
- zoom2_snd_device = platform_device_alloc("soc-audio", -1); - if (!zoom2_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(zoom2_snd_device, &snd_soc_zoom2); - ret = platform_device_add(zoom2_snd_device); - if (ret) - goto err1; + card->dev = &pdev->dev;
BUG_ON(gpio_request(ZOOM2_HEADSET_MUX_GPIO, "hs_mux") < 0); gpio_direction_output(ZOOM2_HEADSET_MUX_GPIO, 0); @@ -266,26 +254,60 @@ static int __init zoom2_soc_init(void) BUG_ON(gpio_request(ZOOM2_HEADSET_EXTMUTE_GPIO, "ext_mute") < 0); gpio_direction_output(ZOOM2_HEADSET_EXTMUTE_GPIO, 0);
+ ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + goto err; + } + return 0;
-err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(zoom2_snd_device); +err: + gpio_free(ZOOM2_HEADSET_MUX_GPIO); + gpio_free(ZOOM2_HEADSET_EXTMUTE_GPIO);
return ret; } -module_init(zoom2_soc_init);
-static void __exit zoom2_soc_exit(void) +static int __devexit zoom2_soc_remove(struct platform_device *pdev) { + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + gpio_free(ZOOM2_HEADSET_MUX_GPIO); gpio_free(ZOOM2_HEADSET_EXTMUTE_GPIO);
- platform_device_unregister(zoom2_snd_device); + return 0; +} + +static struct platform_driver zoom2_driver = { + .driver = { + .name = "zoom2-soc-audio", + .owner = THIS_MODULE, + }, + + .probe = zoom2_soc_probe, + .remove = __devexit_p(zoom2_soc_remove), +}; + +static int __init zoom2_soc_init(void) +{ + if (!machine_is_omap_zoom2()) + return -ENODEV; + + return platform_driver_register(&zoom2_driver); +} +module_init(zoom2_soc_init); + +static void __exit zoom2_soc_exit(void) +{ + platform_driver_unregister(&zoom2_driver); } module_exit(zoom2_soc_exit);
MODULE_AUTHOR("Misael Lopez Cruz x0052729@ti.com"); MODULE_DESCRIPTION("ALSA SoC Zoom2"); MODULE_LICENSE("GPL"); - +MODULE_ALIAS("platform:zoom2-soc-audio");
On Thu, Sep 8, 2011 at 11:04 PM, Mans Rullgard mans.rullgard@linaro.org 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.rullgard@linaro.org
Platform device names fixed. N8x0 changed to get clocks before registering card.
arch/arm/mach-omap2/board-3430sdp.c | 6 ++ arch/arm/mach-omap2/board-4430sdp.c | 6 ++ arch/arm/mach-omap2/board-am3517evm.c | 7 +++ arch/arm/mach-omap2/board-devkit8000.c | 6 ++ arch/arm/mach-omap2/board-igep0020.c | 6 ++ arch/arm/mach-omap2/board-n8x0.c | 6 ++ arch/arm/mach-omap2/board-omap3beagle.c | 6 ++ arch/arm/mach-omap2/board-omap3evm.c | 7 +++ arch/arm/mach-omap2/board-omap3pandora.c | 6 ++ arch/arm/mach-omap2/board-overo.c | 17 ++++++ arch/arm/mach-omap2/board-rx51.c | 6 ++ arch/arm/mach-omap2/board-zoom-peripherals.c | 6 ++
Can't we do by having omap_init_audio() in arch/arm/mach-omap2/devices.c generate a platform device of name depending upon machine_is_* ?
On Thu, Sep 08, 2011 at 11:47:16PM +0530, Jassi Brar wrote:
Can't we do by having omap_init_audio() in arch/arm/mach-omap2/devices.c generate a platform device of name depending upon machine_is_* ?
That's not a bad idea. If we were going to do that it shouldn't be OMAP specific, any platform could use it. Though we'd need a way to override it to provide platform data on systems that needs it.
On 8 September 2011 19:17, Jassi Brar jassisinghbrar@gmail.com wrote:
On Thu, Sep 8, 2011 at 11:04 PM, Mans Rullgard mans.rullgard@linaro.org 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.rullgard@linaro.org
Platform device names fixed. N8x0 changed to get clocks before registering card.
arch/arm/mach-omap2/board-3430sdp.c | 6 ++ arch/arm/mach-omap2/board-4430sdp.c | 6 ++ arch/arm/mach-omap2/board-am3517evm.c | 7 +++ arch/arm/mach-omap2/board-devkit8000.c | 6 ++ arch/arm/mach-omap2/board-igep0020.c | 6 ++ arch/arm/mach-omap2/board-n8x0.c | 6 ++ arch/arm/mach-omap2/board-omap3beagle.c | 6 ++ arch/arm/mach-omap2/board-omap3evm.c | 7 +++ arch/arm/mach-omap2/board-omap3pandora.c | 6 ++ arch/arm/mach-omap2/board-overo.c | 17 ++++++ arch/arm/mach-omap2/board-rx51.c | 6 ++ arch/arm/mach-omap2/board-zoom-peripherals.c | 6 ++
Can't we do by having omap_init_audio() in arch/arm/mach-omap2/devices.c generate a platform device of name depending upon machine_is_* ?
I had the same thought, but I couldn't find a suitable string anywhere. Are you suggesting an if(machine_is_foo()) cascade in omap_init_audio()?
I'll be the first to agree this patch is not particularly pretty.
On Thursday 08 September 2011 20:05:48 Mans Rullgard wrote:
Can't we do by having omap_init_audio() in arch/arm/mach-omap2/devices.c generate a platform device of name depending upon machine_is_* ?
I had the same thought, but I couldn't find a suitable string anywhere. Are you suggesting an if(machine_is_foo()) cascade in omap_init_audio()?
I'll be the first to agree this patch is not particularly pretty.
My general feeling is that practically every time someone writes machine_is_*(), they are doing it wrong. There are of course exceptions, but I would strongly recommend to have the initialization calling up from the board file into more general functions instead of having all boards calling the same function which then goes to board specific code again.
Arnd
On Thu, 2011-09-08 at 22:28 +0200, Arnd Bergmann wrote:
On Thursday 08 September 2011 20:05:48 Mans Rullgard wrote:
I had the same thought, but I couldn't find a suitable string anywhere. Are you suggesting an if(machine_is_foo()) cascade in omap_init_audio()?
I'll be the first to agree this patch is not particularly pretty.
My general feeling is that practically every time someone writes machine_is_*(), they are doing it wrong. There are of course exceptions, but I would strongly recommend to have the initialization calling up from the board file into more general functions instead of having all boards calling the same function which then goes to board specific code again.
I have to agree, that seems tasteless. I'd expect something like triggering registration of devices based off walking down a table of machine IDs or something. One other issue to consider here is that we don't want to discourage people from sharing machine drivers while we can so it can't be completely automatic, it
Perhaps some sort of generic machine type based mechanism for instantiating drivers a bit like what's done with DMI might be useful, video will have a similar issue I guess.
On Thu, Sep 08, 2011 at 03:29:11PM -0700, Mark Brown wrote:
On Thu, 2011-09-08 at 22:28 +0200, Arnd Bergmann wrote:
On Thursday 08 September 2011 20:05:48 Mans Rullgard wrote:
I had the same thought, but I couldn't find a suitable string anywhere. Are you suggesting an if(machine_is_foo()) cascade in omap_init_audio()?
I'll be the first to agree this patch is not particularly pretty.
My general feeling is that practically every time someone writes machine_is_*(), they are doing it wrong. There are of course exceptions, but I would strongly recommend to have the initialization calling up from the board file into more general functions instead of having all boards calling the same function which then goes to board specific code again.
I have to agree, that seems tasteless. I'd expect something like triggering registration of devices based off walking down a table of machine IDs or something. One other issue to consider here is that we don't want to discourage people from sharing machine drivers while we can so it can't be completely automatic, it
This problem has been solved (before DT) for _ages_ through the use of platform devices in the platform support files, registered by the .init_machine callback.
Where it went wrong is when ASOC and PCMCIA became rather complicated that you could no longer just pass a platform data structure, but instead needed some complex platform specific code - which started the demand to have mini platform specific chunks of code in drivers/pcmcia/ and sound/.
With DT of course, all devices get instantiated from the device tree, so there should not be any more platform specific chunks of code in these locations (ha, it couldn't be solved with platform data so I suspect it will continue to persist, forever unsolved.)
On Thu, Sep 08, 2011 at 11:37:20PM +0100, Russell King - ARM Linux wrote:
With DT of course, all devices get instantiated from the device tree, so there should not be any more platform specific chunks of code in these locations (ha, it couldn't be solved with platform data so I suspect it will continue to persist, forever unsolved.)
That's not the case at all for audio, the PCB schematic for the audio subsystem on a device like a smartphone is a sufficiently interesting piece of hardware to be a device with a driver in its own right. The ASoC machine drivers aren't about instantiating devices, they are about controlling the interrelationships between the various devices in the audio subsystem.
What will happen for device tree is that there will be a device in the device tree for the ASoC board.
On Thu, Sep 08, 2011 at 03:47:31PM -0700, Mark Brown wrote:
On Thu, Sep 08, 2011 at 11:37:20PM +0100, Russell King - ARM Linux wrote:
With DT of course, all devices get instantiated from the device tree, so there should not be any more platform specific chunks of code in these locations (ha, it couldn't be solved with platform data so I suspect it will continue to persist, forever unsolved.)
That's not the case at all for audio, the PCB schematic for the audio subsystem on a device like a smartphone is a sufficiently interesting piece of hardware to be a device with a driver in its own right. The ASoC machine drivers aren't about instantiating devices, they are about controlling the interrelationships between the various devices in the audio subsystem.
What will happen for device tree is that there will be a device in the device tree for the ASoC board.
Sounds like you just solved the machine_is_xxx() problem in ASoC land too there. If you're _already_ going for separate devices to describe the ASoC stuff on the board, then there's no reason that couldn't have already been done to eliminate the machine_is_xxx() usage in ASoC - rather than complaining about machine_is_xxx() not being a very good solution.
As I said, the problem was solved years ago, and all the component parts have been there also for years.
On Fri, Sep 09, 2011 at 12:01:02AM +0100, Russell King - ARM Linux wrote:
On Thu, Sep 08, 2011 at 03:47:31PM -0700, Mark Brown wrote:
What will happen for device tree is that there will be a device in the device tree for the ASoC board.
Sounds like you just solved the machine_is_xxx() problem in ASoC land too there. If you're _already_ going for separate devices to describe the ASoC stuff on the board, then there's no reason that couldn't have already been done to eliminate the machine_is_xxx() usage in ASoC - rather than complaining about machine_is_xxx() not being a very good solution.
The problem is that someone has to manually go and add the device to every board that needs one and people find that tedious and slightly inelegant (especially for device tree where not everyone is entirely happy that it's a good idea to have the node for the board when we already have the top level machine information saying what board we're running on). Jassi's suggestion was that we should have some magic to automatically generate defaults for the relevant device registrations to sidestep these issues.
On Thu, Sep 08, 2011 at 04:59:04PM -0700, Mark Brown wrote:
On Fri, Sep 09, 2011 at 12:01:02AM +0100, Russell King - ARM Linux wrote:
On Thu, Sep 08, 2011 at 03:47:31PM -0700, Mark Brown wrote:
What will happen for device tree is that there will be a device in the device tree for the ASoC board.
Sounds like you just solved the machine_is_xxx() problem in ASoC land too there. If you're _already_ going for separate devices to describe the ASoC stuff on the board, then there's no reason that couldn't have already been done to eliminate the machine_is_xxx() usage in ASoC - rather than complaining about machine_is_xxx() not being a very good solution.
The problem is that someone has to manually go and add the device to every board that needs one and people find that tedious and slightly inelegant
Sheesh. So now you're arguing against your statement above? Please stop wasting my time.
On Fri, Sep 09, 2011 at 10:41:56AM +0100, Russell King - ARM Linux wrote:
On Thu, Sep 08, 2011 at 04:59:04PM -0700, Mark Brown wrote:
The problem is that someone has to manually go and add the device to every board that needs one and people find that tedious and slightly inelegant
Sheesh. So now you're arguing against your statement above? Please stop wasting my time.
There's two things going on here - what we are doing and what people would like to be able to do. What we are doing is explicitly adding devices, what people would like to do is infer the devices from the board type. Personally I'm totally happy with explicitly adding an audio device, but not everyone is and I do understand where they're coming from.
On Fri, Sep 09, 2011 at 09:11:52AM -0700, Mark Brown wrote:
On Fri, Sep 09, 2011 at 10:41:56AM +0100, Russell King - ARM Linux wrote:
On Thu, Sep 08, 2011 at 04:59:04PM -0700, Mark Brown wrote:
The problem is that someone has to manually go and add the device to every board that needs one and people find that tedious and slightly inelegant
Sheesh. So now you're arguing against your statement above? Please stop wasting my time.
There's two things going on here - what we are doing and what people would like to be able to do. What we are doing is explicitly adding devices, what people would like to do is infer the devices from the board type. Personally I'm totally happy with explicitly adding an audio device, but not everyone is and I do understand where they're coming from.
Well, with DT, there won't be any 'board type' anymore. There won't be any 'machine_is_xxx()' to sort it out anymore. Using DT, all that will be history - it's all got to be sorted out by either devices or device properties.
So, given that, I don't see the logic of having two methods - it might as well be dealt with by devices and [platform data for non-DT | DT properties], and which then means we have everything working the same way irrespective of what the backing data for the platform actually is.
Therefore, as we are heading for DT, I'd definitely say that having machine_is_xxx() outside of arch/arm is a bug, no less and no more.
On Fri, Sep 09, 2011 at 08:01:35PM +0100, Russell King - ARM Linux wrote:
Well, with DT, there won't be any 'board type' anymore. There won't be any 'machine_is_xxx()' to sort it out anymore. Using DT, all that will be history - it's all got to be sorted out by either devices or device properties.
There is a board type - there's a root compatible property for the board which fulfils this purpose - so the situation with and without device tree is essentially the same.
On Fri, Sep 09, 2011 at 12:30:11PM -0700, Mark Brown wrote:
On Fri, Sep 09, 2011 at 08:01:35PM +0100, Russell King - ARM Linux wrote:
Well, with DT, there won't be any 'board type' anymore. There won't be any 'machine_is_xxx()' to sort it out anymore. Using DT, all that will be history - it's all got to be sorted out by either devices or device properties.
There is a board type - there's a root compatible property for the board which fulfils this purpose - so the situation with and without device tree is essentially the same.
So instead of a table of machine id numbers and soc device strings, you're going to have a table of board 'compatible' strings and soc device strings, and you're going to have to manually create the struct device with that name.
That's just twisted and utterly insane - adding more code for precisely zero benefit what so ever. Think about it - the device tree is *already* creating platform devices for entries in the device tree file. What's the point of having this special ASoC code look up the platform compatible property in a table of strings to find a different string to manually create a device with. Why not just _add_ the bloody device to the DT file in the first place? That's partly what DT is there for - to create platform specific struct devices.
On Friday 09 September 2011, Russell King - ARM Linux wrote:
That's just twisted and utterly insane - adding more code for precisely zero benefit what so ever. Think about it - the device tree is already creating platform devices for entries in the device tree file. What's the point of having this special ASoC code look up the platform compatible property in a table of strings to find a different string to manually create a device with. Why not just add the bloody device to the DT file in the first place? That's partly what DT is there for - to create platform specific struct devices.
Exactly. No driver or (worse) user program should ever need to look at the top-level compatible property. When you want information about a localized part of the system (e.g. the ASoC components), you should look up the information for that component.
Arnd
On Sat, Sep 10, 2011 at 10:37:15PM +0200, Arnd Bergmann wrote:
On Friday 09 September 2011, Russell King - ARM Linux wrote:
That's just twisted and utterly insane - adding more code for precisely zero benefit what so ever. Think about it - the device tree is already creating platform devices for entries in the device tree file. What's
Exactly. No driver or (worse) user program should ever need to look at the top-level compatible property. When you want information about a localized part of the system (e.g. the ASoC components), you should look up the information for that component.
Right, and this is the state of the art right now. I can see why people find this inelegant and want to come up with a way of automatically generating all these different devices to describe boards especially with the non-device tree systems, though, so if people want to work on that stuff I don't see a problem with it.
participants (5)
-
Arnd Bergmann
-
Jassi Brar
-
Mans Rullgard
-
Mark Brown
-
Russell King - ARM Linux