ARM: pxa: spitz: register spitz-audio device
Subsystems (5)
PATCH 1/2 ARM: pxa: spitz: register spitz-audio device
Register spitz-audio device to be used by ASoC driver.
--- arch/arm/mach-pxa/spitz.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/mach-pxa/spitz.c +18 -0
@@ -924,6 +924,23 @@ static inline void spitz_i2c_init(void) {}#endif /****************************************************************************** +* Audio devices +******************************************************************************/ +#if defined(CONFIG_SND_PXA2XX_SOC_SPITZ ) || defined(SND_PXA2XX_SOC_SPITZ_MODULE ) +static struct platform_device spitz_audio_device = { + .name ="spitz-audio" , + .id =-1 , +}; + +static inline void spitz_audio_init (void ) +{ +platform_device_register (&spitz_audio_device); +} +#else +static inline void spitz_audio_init (void ) {} +#endif + +/****************************************************************************** * Machine init ******************************************************************************/ static void spitz_poweroff (void )
@@ -970,6 +987,7 @@ static void __init spitz_init(void)spitz_nor_init ();spitz_nand_init ();spitz_i2c_init (); +spitz_audio_init (); }static void __init spitz_fixup (struct tag *tags,char **cmdline)
Signature · 1 line
2.1.1
PATCH 2/2 ASoC: pxa: Convert poodle to use snd_soc_register_card()
Use snd_soc_register_card() instead of creating a "soc-audio" platform device.
--- sound/soc/pxa/spitz.c | 52 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-)
sound/soc/pxa/spitz.c +28 -24
@@ -305,19 +305,15 @@ static struct snd_soc_card snd_soc_spitz = { .num_dapm_routes = ARRAY_SIZE(spitz_audio_map), }; -static struct platform_device *spitz_snd_device; - -static int __init spitz_init (void ) +static int spitz_probe (struct platform_device *pdev) { +struct snd_soc_card *card = &snd_soc_spitz;int ret; -if (!(machine_is_spitz () ||machine_is_borzoi () ||machine_is_akita ())) -return -ENODEV ; - -if (machine_is_borzoi () ||machine_is_spitz ()) - spitz_mic_gpio =SPITZ_GPIO_MIC_BIAS ; -else +if (machine_is_akita ()) spitz_mic_gpio =AKITA_GPIO_MIC_BIAS ; +else + spitz_mic_gpio =SPITZ_GPIO_MIC_BIAS ; ret =gpio_request (spitz_mic_gpio,"MIC GPIO" );if (ret)
@@ -327,37 +323,45 @@ static int __init spitz_init(void)if (ret) goto err2; - spitz_snd_device =platform_device_alloc ("soc-audio" ,-1 ); -if (!spitz_snd_device) { - ret = -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); goto err2; } -platform_set_drvdata (spitz_snd_device, &snd_soc_spitz); - - ret =platform_device_add (spitz_snd_device); -if (ret) - goto err3; -return 0 ; -err3: -platform_device_put (spitz_snd_device); err2:gpio_free (spitz_mic_gpio); err1:return ret; } -static void __exit spitz_exit(void) +static int spitz_remove (struct platform_device *pdev) { -platform_device_unregister (spitz_snd_device); +struct snd_soc_card *card =platform_get_drvdata (pdev); + +snd_soc_unregister_card (card);gpio_free (spitz_mic_gpio); +return 0 ; } -module_init (spitz_init); -module_exit (spitz_exit); +static struct platform_driver spitz_driver = { + .driver = { + .name ="spitz-audio" , + .owner =THIS_MODULE , + .pm = &snd_soc_pm_ops, + }, + .probe = spitz_probe, + .remove = spitz_remove, +}; + +module_platform_driver (spitz_driver);MODULE_AUTHOR ("Richard Purdie" );MODULE_DESCRIPTION ("ALSA SoC Spitz" );MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:spitz-audio" );
Signature · 1 line
2.1.1
Robert Jarzmik
maintainerDmitry Eremin-Solenikov <[email protected]> writes:
Hi Dmitry,
Quoted 20 lines
Register spitz-audio device to be used by ASoC driver.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- arch/arm/mach-pxa/spitz.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)arch/arm/mach-pxa/spitz.c +5
-0@@ -924,6 +924,23 @@ static inline void spitz_i2c_init(void) {}#endif /****************************************************************************** +* Audio devices +******************************************************************************/ +#if defined(CONFIG_SND_PXA2XX_SOC_SPITZ ) || defined(SND_PXA2XX_SOC_SPITZ_MODULE ) +static struct platform_device spitz_audio_device = { + .name = "spitz-audio",
arch/arm/mach-pxa/spitz.c static inline void spitz_i2c_init(void) {} · line 941
Quoted 10 lines
arch/arm/mach-pxa/spitz.c +10
-0+ .id = -1, +}; + +static inline void spitz_audio_init (void ) +{ +platform_device_register (&spitz_audio_device); +} +#else +static inline void spitz_audio_init (void ) {} +#endif
Couldn't you eliminate the "#if defined" line , and "#else ... #endif" ?
I mean that spitz_audio_init() would always register the spitz_audio_device, regardless of the config. The config would build or not build the sound soc platform driver. Would that be alright for all your usecases ?
Cheers.
Signature · 1 line
Robert
Hello,
2014-10-21 21:12 GMT+04:00 Robert Jarzmik <[email protected]>:
Quoted 37 lines
Dmitry Eremin-Solenikov <[email protected]> writes:
Hi Dmitry,
Quoted 20 lines
Register spitz-audio device to be used by ASoC driver.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- arch/arm/mach-pxa/spitz.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)arch/arm/mach-pxa/spitz.c +5
-0@@ -924,6 +924,23 @@ static inline void spitz_i2c_init(void) {}#endif /****************************************************************************** +* Audio devices +******************************************************************************/ +#if defined(CONFIG_SND_PXA2XX_SOC_SPITZ ) || defined(SND_PXA2XX_SOC_SPITZ_MODULE ) +static struct platform_device spitz_audio_device = { + .name = "spitz-audio",arch/arm/mach-pxa/spitz.c static inline void spitz_i2c_init(void) {} · line 941
Quoted 10 lines
arch/arm/mach-pxa/spitz.c +10
-0+ .id = -1, +}; + +static inline void spitz_audio_init (void ) +{ +platform_device_register (&spitz_audio_device); +} +#else +static inline void spitz_audio_init (void ) {} +#endif Couldn't you eliminate the "#if defined" line , and "#else ... #endif" ?
Quoted 3 lines
I mean that
spitz_audio_init()would always register thespitz_audio_device, regardless of the config. The config would build or not build the sound soc platform driver. Would that be alright for all your usecases ?
Yes, of course. I just tried to mimic the style of the rest of the file.
I will resubmit the patch shortly.
Signature · 2 lines
With best wishes Dmitry