summaryrefslogtreecommitdiff
path: root/asoc/codecs/msm_sdw
diff options
context:
space:
mode:
authorLaxminath Kasam <lkasam@codeaurora.org>2017-11-28 12:40:22 +0530
committerMeng Wang <mwang@codeaurora.org>2018-03-01 16:02:06 +0800
commit30ad751aacb9f348e895d2fe110660d5bc440d0b (patch)
tree2a8d7b0ace994696875a4e08e2cf2062f01525e5 /asoc/codecs/msm_sdw
parentda56c67bc43cbf42d1004d9e1499fbe9a28f3dd2 (diff)
downloadmsm-extra-30ad751aacb9f348e895d2fe110660d5bc440d0b.tar.gz
ASoC: rmmod fixes for audio drivers
For remove module(rmmod), update drivers to cleanup resources and allow insert module again without any issue. Change-Id: Iddc6e5e11d986359afd3100bf3c5eab70cb1c1eb Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org> Signed-off-by: Meng Wang <mwang@codeaurora.org>
Diffstat (limited to 'asoc/codecs/msm_sdw')
-rw-r--r--asoc/codecs/msm_sdw/msm_sdw.h6
-rw-r--r--asoc/codecs/msm_sdw/msm_sdw_cdc.c17
2 files changed, 20 insertions, 3 deletions
diff --git a/asoc/codecs/msm_sdw/msm_sdw.h b/asoc/codecs/msm_sdw/msm_sdw.h
index d4ac4333..3c7a07dc 100644
--- a/asoc/codecs/msm_sdw/msm_sdw.h
+++ b/asoc/codecs/msm_sdw/msm_sdw.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -17,6 +17,7 @@
#include "msm_sdw_registers.h"
#define MSM_SDW_MAX_REGISTER 0x400
+#define MSM_SDW_CHILD_DEVICES_MAX 1
extern const struct regmap_config msm_sdw_regmap_config;
extern const u8 msm_sdw_page_map[MSM_SDW_MAX_REGISTER];
@@ -154,6 +155,9 @@ struct msm_sdw_priv {
/* Entry for version info */
struct snd_info_entry *entry;
struct snd_info_entry *version_entry;
+ struct platform_device *pdev_child_devices
+ [MSM_SDW_CHILD_DEVICES_MAX];
+ int child_count;
};
#if IS_ENABLED(CONFIG_SND_SOC_MSM_SDW)
diff --git a/asoc/codecs/msm_sdw/msm_sdw_cdc.c b/asoc/codecs/msm_sdw/msm_sdw_cdc.c
index 7a5ba8f0..3e4921d1 100644
--- a/asoc/codecs/msm_sdw/msm_sdw_cdc.c
+++ b/asoc/codecs/msm_sdw/msm_sdw_cdc.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1251,7 +1251,13 @@ static int msm_sdw_swrm_write(void *handle, int reg, int val)
static int msm_sdw_swrm_clock(void *handle, bool enable)
{
- struct msm_sdw_priv *msm_sdw = (struct msm_sdw_priv *) handle;
+ struct msm_sdw_priv *msm_sdw;
+
+ if (!handle) {
+ pr_err("%s: NULL handle\n", __func__);
+ return -EINVAL;
+ }
+ msm_sdw = (struct msm_sdw_priv *)handle;
mutex_lock(&msm_sdw->sdw_clk_lock);
@@ -1934,6 +1940,7 @@ static void msm_sdw_add_child_devices(struct work_struct *work)
msm_sdw->nr = ctrl_num;
msm_sdw->sdw_ctrl_data = sdw_ctrl_data;
}
+ msm_sdw->pdev_child_devices[msm_sdw->child_count++] = pdev;
}
return;
@@ -2050,15 +2057,21 @@ err_sdw_cdc:
static int msm_sdw_remove(struct platform_device *pdev)
{
struct msm_sdw_priv *msm_sdw;
+ int count;
msm_sdw = dev_get_drvdata(&pdev->dev);
+ for (count = 0; count < msm_sdw->child_count &&
+ count < MSM_SDW_CHILD_DEVICES_MAX; count++)
+ platform_device_unregister(msm_sdw->pdev_child_devices[count]);
+
mutex_destroy(&msm_sdw->io_lock);
mutex_destroy(&msm_sdw->sdw_read_lock);
mutex_destroy(&msm_sdw->sdw_write_lock);
mutex_destroy(&msm_sdw->sdw_clk_lock);
mutex_destroy(&msm_sdw->codec_mutex);
mutex_destroy(&msm_sdw->cdc_int_mclk1_mutex);
+
devm_kfree(&pdev->dev, msm_sdw);
snd_soc_unregister_codec(&pdev->dev);
return 0;