aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2012-09-14 17:14:34 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-18 22:32:44 -0400
commit13c57e5b868b4f023f6436d8c6a079eaffd7f3a8 (patch)
tree22120beedac85988c1c7abe794f7ddd8b635bb6c
parentd41789b2660e5b18b8401bf83ebcd502916c2cb5 (diff)
ASoC: fsl: use snd_soc_register_card to register the card
Use snd_soc_register_card() instead of platform_device_alloc("soc-audio") to register the sound card from the machine drivers. The use of platform_device_alloc is deprecated. Although several other drivers still use platform_device_alloc(), the Freescale drivers were not using it to pass driver data. Instead of fixing the driver data usage, it's better to replace the deprecated code. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/fsl/mpc8610_hpcd.c32
-rw-r--r--sound/soc/fsl/p1022_ds.c31
2 files changed, 13 insertions, 50 deletions
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index 60bcba1bc30e..9ff9318c52b9 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -192,7 +192,6 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
192 container_of(dev, struct platform_device, dev); 192 container_of(dev, struct platform_device, dev);
193 struct device_node *np = ssi_pdev->dev.of_node; 193 struct device_node *np = ssi_pdev->dev.of_node;
194 struct device_node *codec_np = NULL; 194 struct device_node *codec_np = NULL;
195 struct platform_device *sound_device = NULL;
196 struct mpc8610_hpcd_data *machine_data; 195 struct mpc8610_hpcd_data *machine_data;
197 int ret = -ENODEV; 196 int ret = -ENODEV;
198 const char *sprop; 197 const char *sprop;
@@ -341,34 +340,22 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
341 machine_data->card.probe = mpc8610_hpcd_machine_probe; 340 machine_data->card.probe = mpc8610_hpcd_machine_probe;
342 machine_data->card.remove = mpc8610_hpcd_machine_remove; 341 machine_data->card.remove = mpc8610_hpcd_machine_remove;
343 machine_data->card.name = pdev->name; /* The platform driver name */ 342 machine_data->card.name = pdev->name; /* The platform driver name */
343 machine_data->card.owner = THIS_MODULE;
344 machine_data->card.dev = &pdev->dev;
344 machine_data->card.num_links = 2; 345 machine_data->card.num_links = 2;
345 machine_data->card.dai_link = machine_data->dai; 346 machine_data->card.dai_link = machine_data->dai;
346 347
347 /* Allocate a new audio platform device structure */
348 sound_device = platform_device_alloc("soc-audio", -1);
349 if (!sound_device) {
350 dev_err(&pdev->dev, "platform device alloc failed\n");
351 ret = -ENOMEM;
352 goto error;
353 }
354
355 /* Associate the card data with the sound device */
356 platform_set_drvdata(sound_device, &machine_data->card);
357
358 /* Register with ASoC */ 348 /* Register with ASoC */
359 ret = platform_device_add(sound_device); 349 ret = snd_soc_register_card(&machine_data->card);
360 if (ret) { 350 if (ret) {
361 dev_err(&pdev->dev, "platform device add failed\n"); 351 dev_err(&pdev->dev, "could not register card\n");
362 goto error_sound; 352 goto error;
363 } 353 }
364 dev_set_drvdata(&pdev->dev, sound_device);
365 354
366 of_node_put(codec_np); 355 of_node_put(codec_np);
367 356
368 return 0; 357 return 0;
369 358
370error_sound:
371 platform_device_put(sound_device);
372error: 359error:
373 kfree(machine_data); 360 kfree(machine_data);
374error_alloc: 361error_alloc:
@@ -383,17 +370,12 @@ error_alloc:
383 */ 370 */
384static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev) 371static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev)
385{ 372{
386 struct platform_device *sound_device = dev_get_drvdata(&pdev->dev); 373 struct snd_soc_card *card = platform_get_drvdata(pdev);
387 struct snd_soc_card *card = platform_get_drvdata(sound_device);
388 struct mpc8610_hpcd_data *machine_data = 374 struct mpc8610_hpcd_data *machine_data =
389 container_of(card, struct mpc8610_hpcd_data, card); 375 container_of(card, struct mpc8610_hpcd_data, card);
390 376
391 platform_device_unregister(sound_device); 377 snd_soc_unregister_card(card);
392
393 kfree(machine_data); 378 kfree(machine_data);
394 sound_device->dev.platform_data = NULL;
395
396 dev_set_drvdata(&pdev->dev, NULL);
397 379
398 return 0; 380 return 0;
399} 381}
diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c
index 50adf4032bcc..144d49603637 100644
--- a/sound/soc/fsl/p1022_ds.c
+++ b/sound/soc/fsl/p1022_ds.c
@@ -202,7 +202,6 @@ static int p1022_ds_probe(struct platform_device *pdev)
202 container_of(dev, struct platform_device, dev); 202 container_of(dev, struct platform_device, dev);
203 struct device_node *np = ssi_pdev->dev.of_node; 203 struct device_node *np = ssi_pdev->dev.of_node;
204 struct device_node *codec_np = NULL; 204 struct device_node *codec_np = NULL;
205 struct platform_device *sound_device = NULL;
206 struct machine_data *mdata; 205 struct machine_data *mdata;
207 int ret = -ENODEV; 206 int ret = -ENODEV;
208 const char *sprop; 207 const char *sprop;
@@ -349,36 +348,23 @@ static int p1022_ds_probe(struct platform_device *pdev)
349 mdata->card.probe = p1022_ds_machine_probe; 348 mdata->card.probe = p1022_ds_machine_probe;
350 mdata->card.remove = p1022_ds_machine_remove; 349 mdata->card.remove = p1022_ds_machine_remove;
351 mdata->card.name = pdev->name; /* The platform driver name */ 350 mdata->card.name = pdev->name; /* The platform driver name */
351 mdata->card.owner = THIS_MODULE;
352 mdata->card.dev = &pdev->dev;
352 mdata->card.num_links = 2; 353 mdata->card.num_links = 2;
353 mdata->card.dai_link = mdata->dai; 354 mdata->card.dai_link = mdata->dai;
354 355
355 /* Allocate a new audio platform device structure */
356 sound_device = platform_device_alloc("soc-audio", -1);
357 if (!sound_device) {
358 dev_err(&pdev->dev, "platform device alloc failed\n");
359 ret = -ENOMEM;
360 goto error;
361 }
362
363 /* Associate the card data with the sound device */
364 platform_set_drvdata(sound_device, &mdata->card);
365
366 /* Register with ASoC */ 356 /* Register with ASoC */
367 ret = platform_device_add(sound_device); 357 ret = snd_soc_register_card(&mdata->card);
368 if (ret) { 358 if (ret) {
369 dev_err(&pdev->dev, "platform device add failed\n"); 359 dev_err(&pdev->dev, "could not register card\n");
370 goto error; 360 goto error;
371 } 361 }
372 dev_set_drvdata(&pdev->dev, sound_device);
373 362
374 of_node_put(codec_np); 363 of_node_put(codec_np);
375 364
376 return 0; 365 return 0;
377 366
378error: 367error:
379 if (sound_device)
380 platform_device_put(sound_device);
381
382 kfree(mdata); 368 kfree(mdata);
383error_put: 369error_put:
384 of_node_put(codec_np); 370 of_node_put(codec_np);
@@ -392,17 +378,12 @@ error_put:
392 */ 378 */
393static int __devexit p1022_ds_remove(struct platform_device *pdev) 379static int __devexit p1022_ds_remove(struct platform_device *pdev)
394{ 380{
395 struct platform_device *sound_device = dev_get_drvdata(&pdev->dev); 381 struct snd_soc_card *card = platform_get_drvdata(pdev);
396 struct snd_soc_card *card = platform_get_drvdata(sound_device);
397 struct machine_data *mdata = 382 struct machine_data *mdata =
398 container_of(card, struct machine_data, card); 383 container_of(card, struct machine_data, card);
399 384
400 platform_device_unregister(sound_device); 385 snd_soc_unregister_card(card);
401
402 kfree(mdata); 386 kfree(mdata);
403 sound_device->dev.platform_data = NULL;
404
405 dev_set_drvdata(&pdev->dev, NULL);
406 387
407 return 0; 388 return 0;
408} 389}