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>
This commit is contained in:
Родитель
d41789b266
Коммит
13c57e5b86
|
@ -192,7 +192,6 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
|
||||||
container_of(dev, struct platform_device, dev);
|
container_of(dev, struct platform_device, dev);
|
||||||
struct device_node *np = ssi_pdev->dev.of_node;
|
struct device_node *np = ssi_pdev->dev.of_node;
|
||||||
struct device_node *codec_np = NULL;
|
struct device_node *codec_np = NULL;
|
||||||
struct platform_device *sound_device = NULL;
|
|
||||||
struct mpc8610_hpcd_data *machine_data;
|
struct mpc8610_hpcd_data *machine_data;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
const char *sprop;
|
const char *sprop;
|
||||||
|
@ -341,34 +340,22 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
|
||||||
machine_data->card.probe = mpc8610_hpcd_machine_probe;
|
machine_data->card.probe = mpc8610_hpcd_machine_probe;
|
||||||
machine_data->card.remove = mpc8610_hpcd_machine_remove;
|
machine_data->card.remove = mpc8610_hpcd_machine_remove;
|
||||||
machine_data->card.name = pdev->name; /* The platform driver name */
|
machine_data->card.name = pdev->name; /* The platform driver name */
|
||||||
|
machine_data->card.owner = THIS_MODULE;
|
||||||
|
machine_data->card.dev = &pdev->dev;
|
||||||
machine_data->card.num_links = 2;
|
machine_data->card.num_links = 2;
|
||||||
machine_data->card.dai_link = machine_data->dai;
|
machine_data->card.dai_link = machine_data->dai;
|
||||||
|
|
||||||
/* Allocate a new audio platform device structure */
|
/* Register with ASoC */
|
||||||
sound_device = platform_device_alloc("soc-audio", -1);
|
ret = snd_soc_register_card(&machine_data->card);
|
||||||
if (!sound_device) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "platform device alloc failed\n");
|
dev_err(&pdev->dev, "could not register card\n");
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Associate the card data with the sound device */
|
|
||||||
platform_set_drvdata(sound_device, &machine_data->card);
|
|
||||||
|
|
||||||
/* Register with ASoC */
|
|
||||||
ret = platform_device_add(sound_device);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev, "platform device add failed\n");
|
|
||||||
goto error_sound;
|
|
||||||
}
|
|
||||||
dev_set_drvdata(&pdev->dev, sound_device);
|
|
||||||
|
|
||||||
of_node_put(codec_np);
|
of_node_put(codec_np);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_sound:
|
|
||||||
platform_device_put(sound_device);
|
|
||||||
error:
|
error:
|
||||||
kfree(machine_data);
|
kfree(machine_data);
|
||||||
error_alloc:
|
error_alloc:
|
||||||
|
@ -383,17 +370,12 @@ error_alloc:
|
||||||
*/
|
*/
|
||||||
static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev)
|
static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct platform_device *sound_device = dev_get_drvdata(&pdev->dev);
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||||
struct snd_soc_card *card = platform_get_drvdata(sound_device);
|
|
||||||
struct mpc8610_hpcd_data *machine_data =
|
struct mpc8610_hpcd_data *machine_data =
|
||||||
container_of(card, struct mpc8610_hpcd_data, card);
|
container_of(card, struct mpc8610_hpcd_data, card);
|
||||||
|
|
||||||
platform_device_unregister(sound_device);
|
snd_soc_unregister_card(card);
|
||||||
|
|
||||||
kfree(machine_data);
|
kfree(machine_data);
|
||||||
sound_device->dev.platform_data = NULL;
|
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, NULL);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,6 @@ static int p1022_ds_probe(struct platform_device *pdev)
|
||||||
container_of(dev, struct platform_device, dev);
|
container_of(dev, struct platform_device, dev);
|
||||||
struct device_node *np = ssi_pdev->dev.of_node;
|
struct device_node *np = ssi_pdev->dev.of_node;
|
||||||
struct device_node *codec_np = NULL;
|
struct device_node *codec_np = NULL;
|
||||||
struct platform_device *sound_device = NULL;
|
|
||||||
struct machine_data *mdata;
|
struct machine_data *mdata;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
const char *sprop;
|
const char *sprop;
|
||||||
|
@ -349,36 +348,23 @@ static int p1022_ds_probe(struct platform_device *pdev)
|
||||||
mdata->card.probe = p1022_ds_machine_probe;
|
mdata->card.probe = p1022_ds_machine_probe;
|
||||||
mdata->card.remove = p1022_ds_machine_remove;
|
mdata->card.remove = p1022_ds_machine_remove;
|
||||||
mdata->card.name = pdev->name; /* The platform driver name */
|
mdata->card.name = pdev->name; /* The platform driver name */
|
||||||
|
mdata->card.owner = THIS_MODULE;
|
||||||
|
mdata->card.dev = &pdev->dev;
|
||||||
mdata->card.num_links = 2;
|
mdata->card.num_links = 2;
|
||||||
mdata->card.dai_link = mdata->dai;
|
mdata->card.dai_link = mdata->dai;
|
||||||
|
|
||||||
/* Allocate a new audio platform device structure */
|
|
||||||
sound_device = platform_device_alloc("soc-audio", -1);
|
|
||||||
if (!sound_device) {
|
|
||||||
dev_err(&pdev->dev, "platform device alloc failed\n");
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Associate the card data with the sound device */
|
|
||||||
platform_set_drvdata(sound_device, &mdata->card);
|
|
||||||
|
|
||||||
/* Register with ASoC */
|
/* Register with ASoC */
|
||||||
ret = platform_device_add(sound_device);
|
ret = snd_soc_register_card(&mdata->card);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "platform device add failed\n");
|
dev_err(&pdev->dev, "could not register card\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
dev_set_drvdata(&pdev->dev, sound_device);
|
|
||||||
|
|
||||||
of_node_put(codec_np);
|
of_node_put(codec_np);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (sound_device)
|
|
||||||
platform_device_put(sound_device);
|
|
||||||
|
|
||||||
kfree(mdata);
|
kfree(mdata);
|
||||||
error_put:
|
error_put:
|
||||||
of_node_put(codec_np);
|
of_node_put(codec_np);
|
||||||
|
@ -392,17 +378,12 @@ error_put:
|
||||||
*/
|
*/
|
||||||
static int __devexit p1022_ds_remove(struct platform_device *pdev)
|
static int __devexit p1022_ds_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct platform_device *sound_device = dev_get_drvdata(&pdev->dev);
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||||
struct snd_soc_card *card = platform_get_drvdata(sound_device);
|
|
||||||
struct machine_data *mdata =
|
struct machine_data *mdata =
|
||||||
container_of(card, struct machine_data, card);
|
container_of(card, struct machine_data, card);
|
||||||
|
|
||||||
platform_device_unregister(sound_device);
|
snd_soc_unregister_card(card);
|
||||||
|
|
||||||
kfree(mdata);
|
kfree(mdata);
|
||||||
sound_device->dev.platform_data = NULL;
|
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, NULL);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче