@@ -246,8 +246,17 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
if (plat_data->sof_probe_complete)
plat_data->sof_probe_complete(sdev->dev);
+ /* If registering certain clients fails, unregister the previously registered clients. */
+ ret = snd_sof_register_clients(sdev);
+ if (ret < 0) {
+ dev_err(sdev->dev, "error: failed to register clients %d\n", ret);
+ goto client_reg_err;
+ }
+
return 0;
+client_reg_err:
+ snd_sof_unregister_clients(sdev);
fw_trace_err:
snd_sof_free_trace(sdev);
fw_run_err:
@@ -356,6 +365,7 @@ int snd_sof_device_remove(struct device *dev)
dev_warn(dev, "error: %d failed to prepare DSP for device removal",
ret);
+ snd_sof_unregister_clients(sdev);
snd_sof_fw_unload(sdev);
snd_sof_ipc_free(sdev);
snd_sof_free_debug(sdev);
@@ -470,6 +470,20 @@ snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach,
sof_ops(sdev)->set_mach_params(mach, dev);
}
+static inline int snd_sof_register_clients(struct snd_sof_dev *sdev)
+{
+ if (sof_ops(sdev) && sof_ops(sdev)->register_clients)
+ return sof_ops(sdev)->register_clients(sdev);
+
+ return 0;
+}
+
+static inline void snd_sof_unregister_clients(struct snd_sof_dev *sdev)
+{
+ if (sof_ops(sdev) && sof_ops(sdev)->unregister_clients)
+ return sof_ops(sdev)->unregister_clients(sdev);
+}
+
static inline const struct snd_sof_dsp_ops
*sof_get_ops(const struct sof_dev_desc *d,
const struct sof_ops_table mach_ops[], int asize)
@@ -249,6 +249,10 @@ struct snd_sof_dsp_ops {
void (*set_mach_params)(const struct snd_soc_acpi_mach *mach,
struct device *dev); /* optional */
+ /* client ops */
+ int (*register_clients)(struct snd_sof_dev *sdev); /* optional */
+ void (*unregister_clients)(struct snd_sof_dev *sdev); /* optional */
+
/* DAI ops */
struct snd_soc_dai_driver *drv;
int num_drv;