ASoC: fsl: Let imx-audio-rpmsg register platform device for card

Let imx-audio-rpmsg register platform device for card. So that card
register and unregister can be controlled by rpmsg driver's register
and unregister.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Link: https://msgid.link/r/20240311111349.723256-4-chancel.liu@nxp.com
Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Chancel Liu 2024-03-11 20:13:47 +09:00 committed by Mark Brown
parent dacc745974
commit c73524768e
2 changed files with 16 additions and 12 deletions

View File

@ -240,17 +240,6 @@ static int fsl_rpmsg_probe(struct platform_device *pdev)
if (ret)
goto err_pm_disable;
rpmsg->card_pdev = platform_device_register_data(&pdev->dev,
"imx-audio-rpmsg",
PLATFORM_DEVID_AUTO,
NULL,
0);
if (IS_ERR(rpmsg->card_pdev)) {
dev_err(&pdev->dev, "failed to register rpmsg card\n");
ret = PTR_ERR(rpmsg->card_pdev);
goto err_pm_disable;
}
return 0;
err_pm_disable:

View File

@ -12,6 +12,7 @@
*/
struct imx_audio_rpmsg {
struct platform_device *rpmsg_pdev;
struct platform_device *card_pdev;
};
static int imx_audio_rpmsg_cb(struct rpmsg_device *rpdev, void *data, int len,
@ -95,6 +96,16 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
ret = PTR_ERR(data->rpmsg_pdev);
}
data->card_pdev = platform_device_register_data(&rpdev->dev,
"imx-audio-rpmsg",
PLATFORM_DEVID_AUTO,
rpdev->id.name,
strlen(rpdev->id.name) + 1);
if (IS_ERR(data->card_pdev)) {
dev_err(&rpdev->dev, "failed to register rpmsg card.\n");
ret = PTR_ERR(data->card_pdev);
}
return ret;
}
@ -105,6 +116,9 @@ static void imx_audio_rpmsg_remove(struct rpmsg_device *rpdev)
if (data->rpmsg_pdev)
platform_device_unregister(data->rpmsg_pdev);
if (data->card_pdev)
platform_device_unregister(data->card_pdev);
dev_info(&rpdev->dev, "audio rpmsg driver is removed\n");
}
@ -113,6 +127,7 @@ static struct rpmsg_device_id imx_audio_rpmsg_id_table[] = {
{ .name = "rpmsg-micfil-channel" },
{ },
};
MODULE_DEVICE_TABLE(rpmsg, imx_audio_rpmsg_id_table);
static struct rpmsg_driver imx_audio_rpmsg_driver = {
.drv.name = "imx_audio_rpmsg",
@ -126,5 +141,5 @@ module_rpmsg_driver(imx_audio_rpmsg_driver);
MODULE_DESCRIPTION("Freescale SoC Audio RPMSG interface");
MODULE_AUTHOR("Shengjiu Wang <shengjiu.wang@nxp.com>");
MODULE_ALIAS("platform:imx_audio_rpmsg");
MODULE_ALIAS("rpmsg:imx_audio_rpmsg");
MODULE_LICENSE("GPL v2");