From: Stephen Warren Date: Fri, 28 Jan 2011 21:26:36 +0000 (-0700) Subject: ASoC: Tegra: Harmony: Don't use soc-audio platform device X-Git-Tag: MMI-PSA29.97-13-9~16612^2~1226^2~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=72de2b1a9a5b869c1eaea098dd2a75e6bbbf0488;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git ASoC: Tegra: Harmony: Don't use soc-audio platform device Previously, snd-soc-tegra-harmony internally instantiated a platform device object whenever the module was loaded. Instead, switch to a more typical model where arch/arm/mach-tegra defines a platform device, and snd-soc-tegra-harmony acts as a driver for such a platform device. Define a new struct tegra_harmony to store driver data in the future. Signed-off-by: Stephen Warren Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- diff --git a/sound/soc/tegra/harmony.c b/sound/soc/tegra/harmony.c index b160b7113f45..2d6a15c6bdfe 100644 --- a/sound/soc/tegra/harmony.c +++ b/sound/soc/tegra/harmony.c @@ -2,7 +2,7 @@ * harmony.c - Harmony machine ASoC driver * * Author: Stephen Warren - * Copyright (C) 2010 - NVIDIA, Inc. + * Copyright (C) 2010-2011 - NVIDIA, Inc. * * Based on code copyright/by: * @@ -29,7 +29,11 @@ */ #include + #include +#include +#include + #include #include #include @@ -40,9 +44,11 @@ #include "tegra_pcm.h" #include "tegra_asoc_utils.h" -#define PREFIX "ASoC Harmony: " +#define DRV_NAME "tegra-snd-harmony" +#define PREFIX DRV_NAME ": " -static struct platform_device *harmony_snd_device; +struct tegra_harmony { +}; static int harmony_asoc_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -154,56 +160,88 @@ static struct snd_soc_card snd_soc_harmony = { .num_links = 1, }; -static int __init harmony_soc_modinit(void) +static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev) { + struct snd_soc_card *card = &snd_soc_harmony; + struct tegra_harmony *harmony; int ret; if (!machine_is_harmony()) { - pr_err(PREFIX "Not running on Tegra Harmony!\n"); + dev_err(&pdev->dev, "Not running on Tegra Harmony!\n"); return -ENODEV; } - ret = tegra_asoc_utils_init(); - if (ret) { - return ret; + harmony = kzalloc(sizeof(struct tegra_harmony), GFP_KERNEL); + if (!harmony) { + dev_err(&pdev->dev, "Can't allocate tegra_harmony\n"); + return -ENOMEM; } - /* - * Create and register platform device - */ - harmony_snd_device = platform_device_alloc("soc-audio", -1); - if (harmony_snd_device == NULL) { - pr_err(PREFIX "platform_device_alloc failed\n"); - ret = -ENOMEM; - goto err_clock_utils; - } + ret = tegra_asoc_utils_init(); + if (ret) + goto err_free_harmony; - platform_set_drvdata(harmony_snd_device, &snd_soc_harmony); + card->dev = &pdev->dev; + platform_set_drvdata(pdev, card); + snd_soc_card_set_drvdata(card, harmony); - ret = platform_device_add(harmony_snd_device); + ret = snd_soc_register_card(card); if (ret) { - pr_err(PREFIX "platform_device_add failed (%d)\n", + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_device_put; + goto err_clear_drvdata; } return 0; -err_device_put: - platform_device_put(harmony_snd_device); -err_clock_utils: +err_clear_drvdata: + snd_soc_card_set_drvdata(card, NULL); + platform_set_drvdata(pdev, NULL); + card->dev = NULL; tegra_asoc_utils_fini(); +err_free_harmony: + kfree(harmony); return ret; } -module_init(harmony_soc_modinit); -static void __exit harmony_soc_modexit(void) +static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev) { - platform_device_unregister(harmony_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct tegra_harmony *harmony = snd_soc_card_get_drvdata(card); + + snd_soc_unregister_card(card); + + snd_soc_card_set_drvdata(card, NULL); + platform_set_drvdata(pdev, NULL); + card->dev = NULL; tegra_asoc_utils_fini(); + + kfree(harmony); + + return 0; +} + +static struct platform_driver tegra_snd_harmony_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = tegra_snd_harmony_probe, + .remove = __devexit_p(tegra_snd_harmony_remove), +}; + +static int __init snd_tegra_harmony_init(void) +{ + return platform_driver_register(&tegra_snd_harmony_driver); +} +module_init(snd_tegra_harmony_init); + +static void __exit snd_tegra_harmony_exit(void) +{ + platform_driver_unregister(&tegra_snd_harmony_driver); } -module_exit(harmony_soc_modexit); +module_exit(snd_tegra_harmony_exit); MODULE_AUTHOR("Stephen Warren "); MODULE_DESCRIPTION("Harmony machine ASoC driver");