ASoC: SOF: Make creation of machine device from SOF core optional
[linux-2.6-microblaze.git] / sound / soc / sof / core.c
index 9832322..e258f6a 100644 (file)
@@ -92,47 +92,9 @@ out:
 }
 EXPORT_SYMBOL(snd_sof_get_status);
 
-/*
- * SOF Driver enumeration.
- */
-static int sof_machine_check(struct snd_sof_dev *sdev)
-{
-       struct snd_sof_pdata *plat_data = sdev->pdata;
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)
-       struct snd_soc_acpi_mach *machine;
-       int ret;
-#endif
-
-       if (plat_data->machine)
-               return 0;
-
-#if !IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)
-       dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
-       return -ENODEV;
-#else
-       /* fallback to nocodec mode */
-       dev_warn(sdev->dev, "No ASoC machine driver found - using nocodec\n");
-       machine = devm_kzalloc(sdev->dev, sizeof(*machine), GFP_KERNEL);
-       if (!machine)
-               return -ENOMEM;
-
-       ret = sof_nocodec_setup(sdev->dev, plat_data, machine,
-                               plat_data->desc, plat_data->desc->ops);
-       if (ret < 0)
-               return ret;
-
-       plat_data->machine = machine;
-
-       return 0;
-#endif
-}
-
 static int sof_probe_continue(struct snd_sof_dev *sdev)
 {
        struct snd_sof_pdata *plat_data = sdev->pdata;
-       const char *drv_name;
-       const void *mach;
-       int size;
        int ret;
 
        /* probe the DSP hardware */
@@ -218,22 +180,9 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
                goto fw_run_err;
        }
 
-       drv_name = plat_data->machine->drv_name;
-       mach = (const void *)plat_data->machine;
-       size = sizeof(*plat_data->machine);
-
-       /* register machine driver, pass machine info as pdata */
-       plat_data->pdev_mach =
-               platform_device_register_data(sdev->dev, drv_name,
-                                             PLATFORM_DEVID_NONE, mach, size);
-
-       if (IS_ERR(plat_data->pdev_mach)) {
-               ret = PTR_ERR(plat_data->pdev_mach);
+       ret = snd_sof_machine_register(sdev, plat_data);
+       if (ret < 0)
                goto fw_run_err;
-       }
-
-       dev_dbg(sdev->dev, "created machine %s\n",
-               dev_name(&plat_data->pdev_mach->dev));
 
        /*
         * Some platforms in SOF, ex: BYT, may not have their platform PM
@@ -363,9 +312,7 @@ int snd_sof_device_remove(struct device *dev)
         * will remove the component driver and unload the topology
         * before freeing the snd_card.
         */
-       if (!IS_ERR_OR_NULL(pdata->pdev_mach))
-               platform_device_unregister(pdata->pdev_mach);
-
+       snd_sof_machine_unregister(sdev, pdata);
        /*
         * Unregistering the machine driver results in unloading the topology.
         * Some widgets, ex: scheduler, attempt to power down the core they are