Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30ad751a authored by Laxminath Kasam's avatar Laxminath Kasam Committed by Meng Wang
Browse files

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: default avatarLaxminath Kasam <lkasam@codeaurora.org>
Signed-off-by: default avatarMeng Wang <mwang@codeaurora.org>
parent da56c67b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
/* 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)
+15 −2
Original line number Diff line number Diff line
/* 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 @@ static int msm_sdw_probe(struct platform_device *pdev)
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;
+10 −5
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-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
@@ -4396,7 +4396,7 @@ static int msm_anlg_cdc_init_supplies(struct sdm660_cdc_priv *sdm660_cdc,
	return ret;

err_supplies:
	kfree(sdm660_cdc->supplies);
	devm_kfree(sdm660_cdc->dev, sdm660_cdc->supplies);
err:
	return ret;
}
@@ -4442,9 +4442,6 @@ static void msm_anlg_cdc_disable_supplies(struct sdm660_cdc_priv *sdm660_cdc,
				pdata->regulator[i].max_uv);
		regulator_set_load(sdm660_cdc->supplies[i].consumer, 0);
	}
	regulator_bulk_free(sdm660_cdc->num_of_supplies,
			    sdm660_cdc->supplies);
	kfree(sdm660_cdc->supplies);
}

static const struct of_device_id sdm660_codec_of_match[] = {
@@ -4531,6 +4528,7 @@ static void msm_anlg_add_child_devices(struct work_struct *work)
				__func__);
			pdata->dig_ctrl_data = dig_ctrl_data;
		}
		pdata->pdev_child_devices[pdata->child_count++] = pdev;
	}

	return;
@@ -4639,9 +4637,16 @@ static int msm_anlg_cdc_remove(struct platform_device *pdev)
{
	struct sdm660_cdc_priv *sdm660_cdc = dev_get_drvdata(&pdev->dev);
	struct sdm660_cdc_pdata *pdata = sdm660_cdc->dev->platform_data;
	int count;

	for (count = 0; count < sdm660_cdc->child_count &&
				count < ANLG_CDC_CHILD_DEVICES_MAX; count++)
		platform_device_unregister(
				sdm660_cdc->pdev_child_devices[count]);
	snd_soc_unregister_codec(&pdev->dev);
	msm_anlg_cdc_disable_supplies(sdm660_cdc, pdata);
	wcd9xxx_spmi_irq_exit();
	devm_kfree(&pdev->dev, sdm660_cdc);
	return 0;
}

+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-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
@@ -21,6 +21,7 @@

#define MICBIAS_EXT_BYP_CAP 0x00
#define MICBIAS_NO_EXT_BYP_CAP 0x01
#define ANLG_CDC_CHILD_DEVICES_MAX 1

#define MSM89XX_NUM_IRQ_REGS	2
#define MAX_REGULATOR		7
@@ -215,6 +216,9 @@ struct sdm660_cdc_priv {
	/* Entry for version info */
	struct snd_info_entry *entry;
	struct snd_info_entry *version_entry;
	struct platform_device *pdev_child_devices
		[ANLG_CDC_CHILD_DEVICES_MAX];
	int child_count;
};

struct sdm660_cdc_pdata {
+6 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-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
@@ -409,5 +409,10 @@ int wcd9xxx_spmi_irq_init(void)
	return 0;
}

void wcd9xxx_spmi_irq_exit(void)
{
	pm_qos_remove_request(&map.pm_qos_req);
	mutex_destroy(&map.pm_lock);
}
MODULE_DESCRIPTION("MSM8x16 SPMI IRQ driver");
MODULE_LICENSE("GPL v2");
Loading