Browse Source

asoc: codecs: Replace dev_err/info with ratelimit prints

replace all dev(pr)_err/info logs
that could potentially flood kernel logs with
ratelimit functions dev_err_ratelimited and
dev_info_ratelimited

Change-Id: I32dc6002dead1a07622978c4de63d541c01982fd
Signed-off-by: Shazmaan Ali <[email protected]>
Shazmaan Ali 3 years ago
parent
commit
a20e11e0c3

+ 51 - 45
asoc/codecs/lpass-cdc/lpass-cdc-rx-macro.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -916,20 +917,20 @@ static bool lpass_cdc_rx_macro_get_data(struct snd_soc_component *component,
 	*rx_dev = lpass_cdc_get_device_ptr(component->dev, RX_MACRO);
 
 	if (!(*rx_dev)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: null device for macro!\n", func_name);
 		return false;
 	}
 
 	*rx_priv = dev_get_drvdata((*rx_dev));
 	if (!(*rx_priv)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: priv is null for macro!\n", func_name);
 		return false;
 	}
 
 	if (!(*rx_priv)->component) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: rx_priv component is not initialized!\n", func_name);
 		return false;
 	}
@@ -1014,7 +1015,7 @@ static int lpass_cdc_rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai
 		int_1_mix1_inp = port;
 		if ((int_1_mix1_inp < LPASS_CDC_RX_MACRO_RX0) ||
 			(int_1_mix1_inp > LPASS_CDC_RX_MACRO_PORTS_MAX)) {
-			pr_err("%s: Invalid RX port, Dai ID is %d\n",
+			pr_err_ratelimited("%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
 		}
@@ -1077,7 +1078,7 @@ static int lpass_cdc_rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai,
 		int_2_inp = port;
 		if ((int_2_inp < LPASS_CDC_RX_MACRO_RX0) ||
 			(int_2_inp > LPASS_CDC_RX_MACRO_PORTS_MAX)) {
-			pr_err("%s: Invalid RX port, Dai ID is %d\n",
+			pr_err_ratelimited("%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
 		}
@@ -1179,7 +1180,7 @@ static int lpass_cdc_rx_macro_hw_params(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_STREAM_PLAYBACK:
 		ret = lpass_cdc_rx_macro_set_interpolator_rate(dai, params_rate(params));
 		if (ret) {
-			pr_err("%s: cannot set sample rate: %u\n",
+			pr_err_ratelimited("%s: cannot set sample rate: %u\n",
 				__func__, params_rate(params));
 			return ret;
 		}
@@ -1272,7 +1273,7 @@ static int lpass_cdc_rx_macro_get_channel_map(struct snd_soc_dai *dai,
 		*tx_num = cnt;
 		break;
 	default:
-		dev_err(rx_dev, "%s: Invalid AIF\n", __func__);
+		dev_err_ratelimited(rx_dev, "%s: Invalid AIF\n", __func__);
 		break;
 	}
 	return 0;
@@ -1340,7 +1341,7 @@ static int lpass_cdc_rx_macro_mclk_enable(
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(rx_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1354,7 +1355,7 @@ static int lpass_cdc_rx_macro_mclk_enable(
 				rx_priv->clk_id = RX_CORE_CLK;
 			ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
 			if (ret < 0) {
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx request core vote failed\n",
 					__func__);
 				goto exit;
@@ -1365,7 +1366,7 @@ static int lpass_cdc_rx_macro_mclk_enable(
 							   true);
 			lpass_cdc_rx_macro_core_vote(rx_priv, false);
 			if (ret < 0) {
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx request clock enable failed\n",
 					__func__);
 				goto exit;
@@ -1392,7 +1393,7 @@ static int lpass_cdc_rx_macro_mclk_enable(
 		rx_priv->rx_mclk_users++;
 	} else {
 		if (rx_priv->rx_mclk_users <= 0) {
-			dev_err(rx_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(rx_priv->dev, "%s: clock already disabled\n",
 				__func__);
 			rx_priv->rx_mclk_users = 0;
 			goto exit;
@@ -1415,7 +1416,7 @@ static int lpass_cdc_rx_macro_mclk_enable(
 			   false);
 			ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
 			if (ret < 0) {
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx request core vote failed\n",
 					__func__);
 			}
@@ -1467,7 +1468,7 @@ static int lpass_cdc_rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
 			ret = lpass_cdc_rx_macro_mclk_enable(rx_priv, 0, true);
 		break;
 	default:
-		dev_err(rx_priv->dev,
+		dev_err_ratelimited(rx_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -1535,7 +1536,7 @@ static int lpass_cdc_rx_macro_event_handler(struct snd_soc_component *component,
 	case LPASS_CDC_MACRO_EVT_PRE_SSR_UP:
 		ret = lpass_cdc_rx_macro_core_vote(rx_priv, true);
 		if (ret < 0) {
-			dev_err(rx_priv->dev,
+			dev_err_ratelimited(rx_priv->dev,
 				"%s: rx request core vote failed\n",
 				__func__);
 			break;
@@ -1756,7 +1757,7 @@ static int lpass_cdc_rx_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
 		return -EINVAL;
 
 	if (w->shift >= INTERP_MAX) {
-		dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid Interpolator value %d for name %s\n",
 			__func__, w->shift, w->name);
 		return -EINVAL;
 	}
@@ -1844,7 +1845,7 @@ static int lpass_cdc_rx_macro_enable_main_path(struct snd_soc_dapm_widget *w,
 	dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name);
 
 	if (w->shift >= INTERP_MAX) {
-		dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid Interpolator value %d for name %s\n",
 			__func__, w->shift, w->name);
 		return -EINVAL;
 	}
@@ -2273,11 +2274,11 @@ static int lpass_cdc_rx_macro_mux_put(struct snd_kcontrol *kcontrol,
 	aif_rst = rx_priv->rx_port_value[widget->shift];
 	if (!rx_port_value) {
 		if (aif_rst == 0) {
-			dev_err(rx_dev, "%s:AIF reset already\n", __func__);
+			dev_err_ratelimited(rx_dev, "%s:AIF reset already\n", __func__);
 			return 0;
 		}
 		if (aif_rst > RX_MACRO_AIF4_PB) {
-			dev_err(rx_dev, "%s: Invalid AIF reset\n", __func__);
+			dev_err_ratelimited(rx_dev, "%s: Invalid AIF reset\n", __func__);
 			return 0;
 		}
 	}
@@ -2303,7 +2304,7 @@ static int lpass_cdc_rx_macro_mux_put(struct snd_kcontrol *kcontrol,
 		rx_priv->active_ch_cnt[rx_port_value]++;
 		break;
 	default:
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s:Invalid AIF_ID for LPASS_CDC_RX_MACRO MUX %d\n",
 			__func__, rx_port_value);
 		goto err;
@@ -2652,7 +2653,7 @@ static int lpass_cdc_rx_macro_enable_vbat(struct snd_soc_dapm_widget *w,
 			LPASS_CDC_RX_BCL_VBAT_PATH_CTL, 0x10, 0x00);
 		break;
 	default:
-		dev_err(rx_dev, "%s: Invalid event %d\n", __func__, event);
+		dev_err_ratelimited(rx_dev, "%s: Invalid event %d\n", __func__, event);
 		break;
 	}
 	return 0;
@@ -2749,7 +2750,7 @@ static int lpass_cdc_rx_macro_enable_interp_clk(struct snd_soc_component *compon
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2884,7 +2885,7 @@ static void lpass_cdc_rx_macro_restore_iir_coeff(struct lpass_cdc_rx_macro_priv
 	struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
 
 	if (regmap == NULL) {
-		dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(rx_priv->dev, "%s: regmap is NULL\n", __func__);
 		return;
 	}
 
@@ -3200,7 +3201,7 @@ static int lpass_cdc_rx_macro_fir_filter_enable_get(struct snd_kcontrol *kcontro
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3221,7 +3222,7 @@ static int lpass_cdc_rx_macro_fir_filter_enable_put(struct snd_kcontrol *kcontro
 	int ret = 0;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3321,7 +3322,7 @@ static int lpass_cdc_rx_macro_fir_audio_mixer_get(struct snd_kcontrol *kcontrol,
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3329,12 +3330,14 @@ static int lpass_cdc_rx_macro_fir_audio_mixer_get(struct snd_kcontrol *kcontrol,
 		return -EINVAL;
 
 	if (path_idx >= FIR_PATH_MAX) {
-		dev_err(rx_priv->dev, "%s: path_idx:%d is invalid\n", __func__, path_idx);
+		dev_err_ratelimited(rx_priv->dev, "%s: path_idx:%d is invalid\n",
+			__func__, path_idx);
 		return -EINVAL;
 	}
 
 	if (grp_idx >= GRP_MAX) {
-		dev_err(rx_priv->dev, "%s: grp_idx:%d is invalid\n", __func__, grp_idx);
+		dev_err_ratelimited(rx_priv->dev, "%s: grp_idx:%d is invalid\n",
+			__func__, grp_idx);
 		return -EINVAL;
 	}
 
@@ -3377,7 +3380,7 @@ static int set_fir_filter_coeff(struct snd_soc_component *component,
 		fir_ctl_addr = LPASS_CDC_RX_RX1_RX_FIR_CTL;
 		break;
 	default:
-		dev_err(rx_priv->dev,
+		dev_err_ratelimited(rx_priv->dev,
 			"%s: inavlid FIR ID: %d\n", __func__, path_idx);
 		ret = -EINVAL;
 		goto exit;
@@ -3425,7 +3428,7 @@ static int set_fir_filter_coeff(struct snd_soc_component *component,
 
 		num_coeff_grp = rx_priv->num_fir_coeff[path_idx][grp_idx];
 		if (num_coeff_grp > max_coeff_num) {
-			dev_err(rx_priv->dev,
+			dev_err_ratelimited(rx_priv->dev,
 				"%s: inavlid number of RX_FIR coefficients:%d"
 				" in path:%d, group:%d\n",
 				__func__, num_coeff_grp, path_idx, grp_idx);
@@ -3544,7 +3547,7 @@ static int lpass_cdc_rx_macro_fir_audio_mixer_put(struct snd_kcontrol *kcontrol,
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3552,12 +3555,14 @@ static int lpass_cdc_rx_macro_fir_audio_mixer_put(struct snd_kcontrol *kcontrol,
 		return -EINVAL;
 
 	if (path_idx >= FIR_PATH_MAX) {
-		dev_err(rx_priv->dev,"%s: path_idx:%d is invalid\n", __func__, path_idx);
+		dev_err_ratelimited(rx_priv->dev, "%s: path_idx:%d is invalid\n",
+			__func__, path_idx);
 		return -EINVAL;
 	}
 
 	if (grp_idx >= GRP_MAX) {
-		dev_err(rx_priv->dev,"%s: grp_idx:%d is invalid\n", __func__, grp_idx);
+		dev_err_ratelimited(rx_priv->dev, "%s: grp_idx:%d is invalid\n",
+			__func__, grp_idx);
 		return -EINVAL;
 	}
 
@@ -3581,7 +3586,7 @@ static int lpass_cdc_rx_macro_fir_audio_mixer_put(struct snd_kcontrol *kcontrol,
 		__func__, path_idx, grp_idx, num_coeff_grp);
 
 	if (num_coeff_grp > LPASS_CDC_RX_MACRO_FIR_COEFF_MAX) {
-		dev_err(rx_priv->dev,
+		dev_err_ratelimited(rx_priv->dev,
 			"%s: inavlid number of RX_FIR coefficients:%d in path:%d, group:%d\n",
 				 __func__, num_coeff_grp, path_idx, grp_idx);
 		rx_priv->num_fir_coeff[path_idx][grp_idx] = 0;
@@ -3623,7 +3628,7 @@ static int lpass_cdc_rx_macro_fir_coeff_num_get(struct snd_kcontrol *kcontrol,
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3631,7 +3636,8 @@ static int lpass_cdc_rx_macro_fir_coeff_num_get(struct snd_kcontrol *kcontrol,
 		return -EINVAL;
 
 	if (path_idx >= FIR_PATH_MAX) {
-		dev_err(rx_priv->dev,"%s: path_idx:%d is invalid\n", __func__, path_idx);
+		dev_err_ratelimited(rx_priv->dev, "%s: path_idx:%d is invalid\n",
+			__func__, path_idx);
 		return -EINVAL;
 	}
 
@@ -3654,7 +3660,7 @@ static int lpass_cdc_rx_macro_fir_coeff_num_put(struct snd_kcontrol *kcontrol,
 	unsigned int grp_idx, stored_total_num;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3662,7 +3668,7 @@ static int lpass_cdc_rx_macro_fir_coeff_num_put(struct snd_kcontrol *kcontrol,
 		return -EINVAL;
 
 	if (fir_total_coeff_num > LPASS_CDC_RX_MACRO_FIR_COEFF_MAX * GRP_MAX) {
-		dev_err(rx_priv->dev,
+		dev_err_ratelimited(rx_priv->dev,
 			"%s: inavlid total number of RX_FIR coefficients:%d"
 			" in path:%d\n",
 			__func__, fir_total_coeff_num, path_idx);
@@ -3846,7 +3852,7 @@ static int lpass_cdc_rx_macro_enable_echo(struct snd_soc_dapm_widget *w,
 		ec_tx = (val & 0x0f) - 1;
 
 	if (ec_tx < 0 || (ec_tx >= LPASS_CDC_RX_MACRO_EC_MUX_MAX)) {
-		dev_err(rx_dev, "%s: EC mix control not set correctly\n",
+		dev_err_ratelimited(rx_dev, "%s: EC mix control not set correctly\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -4340,7 +4346,7 @@ static int lpass_cdc_rx_macro_core_vote(void *handle, bool enable)
 	struct lpass_cdc_rx_macro_priv *rx_priv = (struct lpass_cdc_rx_macro_priv *) handle;
 
 	if (rx_priv == NULL) {
-		pr_err("%s: rx priv data is NULL\n", __func__);
+		pr_err_ratelimited("%s: rx priv data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (enable) {
@@ -4363,7 +4369,7 @@ static int rx_swrm_clock(void *handle, bool enable)
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(rx_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -4379,7 +4385,7 @@ static int rx_swrm_clock(void *handle, bool enable)
 			ret = msm_cdc_pinctrl_select_active_state(
 						rx_priv->rx_swr_gpio_p);
 			if (ret < 0) {
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx swr pinctrl enable failed\n",
 					__func__);
 				pm_runtime_mark_last_busy(rx_priv->dev);
@@ -4390,7 +4396,7 @@ static int rx_swrm_clock(void *handle, bool enable)
 			if (ret < 0) {
 				msm_cdc_pinctrl_select_sleep_state(
 						rx_priv->rx_swr_gpio_p);
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx request clock enable failed\n",
 					__func__);
 				pm_runtime_mark_last_busy(rx_priv->dev);
@@ -4415,7 +4421,7 @@ static int rx_swrm_clock(void *handle, bool enable)
 		rx_priv->swr_clk_users++;
 	} else {
 		if (rx_priv->swr_clk_users <= 0) {
-			dev_err(rx_priv->dev,
+			dev_err_ratelimited(rx_priv->dev,
 				"%s: rx swrm clock users already reset\n",
 				__func__);
 			rx_priv->swr_clk_users = 0;
@@ -4430,7 +4436,7 @@ static int rx_swrm_clock(void *handle, bool enable)
 			ret = msm_cdc_pinctrl_select_sleep_state(
 						rx_priv->rx_swr_gpio_p);
 			if (ret < 0) {
-				dev_err(rx_priv->dev,
+				dev_err_ratelimited(rx_priv->dev,
 					"%s: rx swr pinctrl disable failed\n",
 					__func__);
 				goto exit;
@@ -4460,7 +4466,7 @@ int lpass_cdc_rx_set_fir_capability(struct snd_soc_component *component, bool ca
 	struct lpass_cdc_rx_macro_priv *rx_priv = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 

+ 14 - 13
asoc/codecs/lpass-cdc/lpass-cdc-tx-macro.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -155,20 +156,20 @@ static bool lpass_cdc_tx_macro_get_data(struct snd_soc_component *component,
 {
 	*tx_dev = lpass_cdc_get_device_ptr(component->dev, TX_MACRO);
 	if (!(*tx_dev)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: null device for macro!\n", func_name);
 		return false;
 	}
 
 	*tx_priv = dev_get_drvdata((*tx_dev));
 	if (!(*tx_priv)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: priv is null for macro!\n", func_name);
 		return false;
 	}
 
 	if (!(*tx_priv)->component) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: tx_priv->component not initialized!\n", func_name);
 		return false;
 	}
@@ -184,7 +185,7 @@ static int lpass_cdc_tx_macro_mclk_enable(
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(tx_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -220,7 +221,7 @@ static int lpass_cdc_tx_macro_mclk_enable(
 		tx_priv->tx_mclk_users++;
 	} else {
 		if (tx_priv->tx_mclk_users <= 0) {
-			dev_err(tx_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(tx_priv->dev, "%s: clock already disabled\n",
 				__func__);
 			tx_priv->tx_mclk_users = 0;
 			goto exit;
@@ -285,7 +286,7 @@ static int lpass_cdc_tx_macro_mclk_event(struct snd_soc_dapm_widget *w,
 			ret = lpass_cdc_tx_macro_mclk_enable(tx_priv, 0);
 		break;
 	default:
-		dev_err(tx_priv->dev,
+		dev_err_ratelimited(tx_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -505,7 +506,7 @@ static int lpass_cdc_tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
 		mic_sel_reg = LPASS_CDC_TX7_TX_PATH_CFG0;
 		break;
 	default:
-		dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
+		dev_err_ratelimited(component->dev, "%s: e->reg: 0x%x not expected\n",
 			__func__, e->reg);
 		return -EINVAL;
 	}
@@ -612,21 +613,21 @@ static inline int lpass_cdc_tx_macro_path_get(const char *wname,
 
 	path_name = strsep(&widget_name, " ");
 	if (!path_name) {
-		pr_err("%s: Invalid widget name = %s\n",
+		pr_err_ratelimited("%s: Invalid widget name = %s\n",
 			__func__, widget_name);
 		ret = -EINVAL;
 		goto err;
 	}
 	path_num_char = strpbrk(path_name, "01234567");
 	if (!path_num_char) {
-		pr_err("%s: tx path index not found\n",
+		pr_err_ratelimited("%s: tx path index not found\n",
 			__func__);
 		ret = -EINVAL;
 		goto err;
 	}
 	ret = kstrtouint(path_num_char, 10, path_num);
 	if (ret < 0)
-		pr_err("%s: Invalid tx path = %s\n",
+		pr_err_ratelimited("%s: Invalid tx path = %s\n",
 			__func__, w_name);
 
 err:
@@ -1112,7 +1113,7 @@ static int lpass_cdc_tx_macro_hw_params(struct snd_pcm_substream *substream,
 		tx_fs_rate = 7;
 		break;
 	default:
-		dev_err(component->dev, "%s: Invalid TX sample rate: %d\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid TX sample rate: %d\n",
 			__func__, params_rate(params));
 		return -EINVAL;
 	}
@@ -1126,7 +1127,7 @@ static int lpass_cdc_tx_macro_hw_params(struct snd_pcm_substream *substream,
 			snd_soc_component_update_bits(component, tx_fs_reg,
 						0x0F, tx_fs_rate);
 		} else {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: ERROR: Invalid decimator: %d\n",
 				__func__, decimator);
 			return -EINVAL;
@@ -1154,7 +1155,7 @@ static int lpass_cdc_tx_macro_get_channel_map(struct snd_soc_dai *dai,
 		*tx_num = tx_priv->active_ch_cnt[dai->id];
 		break;
 	default:
-		dev_err(tx_dev, "%s: Invalid AIF\n", __func__);
+		dev_err_ratelimited(tx_dev, "%s: Invalid AIF\n", __func__);
 		break;
 	}
 	return 0;

+ 8 - 7
asoc/codecs/lpass-cdc/lpass-cdc-utils.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/kernel.h>
@@ -51,15 +52,15 @@ static int regmap_bus_read(void *context, const void *reg, size_t reg_size,
 	int ret = -EINVAL;
 
 	if (!priv) {
-		dev_err(dev, "%s: priv is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is NULL\n", __func__);
 		return ret;
 	}
 	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: reg or val is NULL\n", __func__);
 		return ret;
 	}
 	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
+		dev_err_ratelimited(dev, "%s: register size %zd bytes, not supported\n",
 			__func__, reg_size);
 		return ret;
 	}
@@ -101,15 +102,15 @@ static int regmap_bus_gather_write(void *context,
 	int ret = -EINVAL;
 
 	if (!priv) {
-		dev_err(dev, "%s: priv is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is NULL\n", __func__);
 		return ret;
 	}
 	if (!reg || !val) {
-		dev_err(dev, "%s: reg or val is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: reg or val is NULL\n", __func__);
 		return ret;
 	}
 	if (reg_size != REG_BYTES) {
-		dev_err(dev, "%s: register size %zd bytes, not supported\n",
+		dev_err_ratelimited(dev, "%s: register size %zd bytes, not supported\n",
 			__func__, reg_size);
 		return ret;
 	}
@@ -146,7 +147,7 @@ static int regmap_bus_write(void *context, const void *data, size_t count)
 		return -EINVAL;
 
 	if (count < REG_BYTES) {
-		dev_err(dev, "%s: count %zd bytes < %d, not supported\n",
+		dev_err_ratelimited(dev, "%s: count %zd bytes < %d, not supported\n",
 			__func__, count, REG_BYTES);
 		return -EINVAL;
 	}

+ 31 - 30
asoc/codecs/lpass-cdc/lpass-cdc-va-macro.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -185,13 +186,13 @@ static bool lpass_cdc_va_macro_get_data(struct snd_soc_component *component,
 {
 	*va_dev = lpass_cdc_get_device_ptr(component->dev, VA_MACRO);
 	if (!(*va_dev)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: null device for macro!\n", func_name);
 		return false;
 	}
 	*va_priv = dev_get_drvdata((*va_dev));
 	if (!(*va_priv) || !(*va_priv)->component) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: priv is null for macro!\n", func_name);
 		return false;
 	}
@@ -223,7 +224,7 @@ static int lpass_cdc_va_macro_mclk_enable(
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(va_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -234,7 +235,7 @@ static int lpass_cdc_va_macro_mclk_enable(
 	if (mclk_enable) {
 		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
 		if (ret < 0) {
-			dev_err(va_priv->dev,
+			dev_err_ratelimited(va_priv->dev,
 				"%s: va request core vote failed\n",
 				__func__);
 			goto exit;
@@ -245,7 +246,7 @@ static int lpass_cdc_va_macro_mclk_enable(
 						   true);
 		lpass_cdc_va_macro_core_vote(va_priv, false);
 		if (ret < 0) {
-			dev_err(va_priv->dev,
+			dev_err_ratelimited(va_priv->dev,
 				"%s: va request clock en failed\n",
 				__func__);
 			goto exit;
@@ -261,7 +262,7 @@ static int lpass_cdc_va_macro_mclk_enable(
 		va_priv->va_mclk_users++;
 	} else {
 		if (va_priv->va_mclk_users <= 0) {
-			dev_err(va_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(va_priv->dev, "%s: clock already disabled\n",
 			__func__);
 			va_priv->va_mclk_users = 0;
 			goto exit;
@@ -271,7 +272,7 @@ static int lpass_cdc_va_macro_mclk_enable(
 					  false);
 		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
 		if (ret < 0) {
-			dev_err(va_priv->dev,
+			dev_err_ratelimited(va_priv->dev,
 				"%s: va request core vote failed\n",
 				__func__);
 		}
@@ -315,7 +316,7 @@ static int lpass_cdc_va_macro_event_handler(struct snd_soc_component *component,
 			retry_cnt--;
 		}
 		if (retry_cnt == 0)
-			dev_err(va_dev,
+			dev_err_ratelimited(va_dev,
 				"%s: va_mclk_users non-zero, SSR fail!!\n",
 				__func__);
 		break;
@@ -323,7 +324,7 @@ static int lpass_cdc_va_macro_event_handler(struct snd_soc_component *component,
 		/* enable&disable VA_CORE_CLK to reset GFMUX reg */
 		ret = lpass_cdc_va_macro_core_vote(va_priv, true);
 		if (ret < 0) {
-			dev_err(va_priv->dev,
+			dev_err_ratelimited(va_priv->dev,
 				"%s: va request core vote failed\n",
 				__func__);
 			break;
@@ -442,7 +443,7 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 				va_priv->tx_clk_status)  {
 			ret = lpass_cdc_va_macro_core_vote(va_priv, true);
 			if (ret < 0) {
-				dev_err(va_priv->dev,
+				dev_err_ratelimited(va_priv->dev,
 					"%s: va request core vote failed\n",
 					__func__);
 				break;
@@ -482,7 +483,7 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 					TX_CORE_CLK,
 					true);
 			if (ret) {
-				dev_err(component->dev,
+				dev_err_ratelimited(component->dev,
 					"%s: request clock TX_CLK enable failed\n",
 					__func__);
 				if (va_priv->dev_up)
@@ -490,7 +491,7 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 			}
 			ret = lpass_cdc_va_macro_core_vote(va_priv, true);
 			if (ret < 0) {
-				dev_err(va_priv->dev,
+				dev_err_ratelimited(va_priv->dev,
 					"%s: va request core vote failed\n",
 					__func__);
 				if (va_priv->dev_up)
@@ -502,7 +503,7 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 					false);
 			lpass_cdc_va_macro_core_vote(va_priv, false);
 			if (ret) {
-				dev_err(component->dev,
+				dev_err_ratelimited(component->dev,
 					"%s: request clock VA_CLK disable failed\n",
 					__func__);
 				if (va_priv->dev_up)
@@ -516,7 +517,7 @@ static int lpass_cdc_va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
 		}
 		break;
 	default:
-		dev_err(va_priv->dev,
+		dev_err_ratelimited(va_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -594,7 +595,7 @@ static int lpass_cdc_va_macro_mclk_event(struct snd_soc_dapm_widget *w,
 		}
 		break;
 	default:
-		dev_err(va_priv->dev,
+		dev_err_ratelimited(va_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -737,7 +738,7 @@ static int lpass_cdc_va_macro_core_vote(void *handle, bool enable)
 					(struct lpass_cdc_va_macro_priv *) handle;
 
 	if (va_priv == NULL) {
-		pr_err("%s: va priv data is NULL\n", __func__);
+		pr_err_ratelimited("%s: va priv data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	trace_printk("%s, enter: enable %d\n", __func__, enable);
@@ -764,7 +765,7 @@ static int lpass_cdc_va_macro_swrm_clock(void *handle, bool enable)
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(va_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1001,7 +1002,7 @@ static int lpass_cdc_va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
 		mic_sel_reg = LPASS_CDC_VA_TX3_TX_PATH_CFG0;
 		break;
 	default:
-		dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
+		dev_err_ratelimited(component->dev, "%s: e->reg: 0x%x not expected\n",
 			__func__, e->reg);
 		return -EINVAL;
 	}
@@ -1377,7 +1378,7 @@ static int lpass_cdc_va_macro_enable_tx(struct snd_soc_dapm_widget *w,
 			va_priv->dapm_tx_clk_status++;
 		break;
 	default:
-		dev_err(va_priv->dev,
+		dev_err_ratelimited(va_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 		break;
@@ -1400,7 +1401,7 @@ static int lpass_cdc_va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
 		return -EINVAL;
 
 	if (!va_priv->micb_supply) {
-		dev_err(va_dev,
+		dev_err_ratelimited(va_dev,
 			"%s:regulator not provided in dtsi\n", __func__);
 		return -EINVAL;
 	}
@@ -1412,20 +1413,20 @@ static int lpass_cdc_va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
 				      va_priv->micb_voltage,
 				      va_priv->micb_voltage);
 		if (ret) {
-			dev_err(va_dev, "%s: Setting voltage failed, err = %d\n",
+			dev_err_ratelimited(va_dev, "%s: Setting voltage failed, err = %d\n",
 				__func__, ret);
 			return ret;
 		}
 		ret = regulator_set_load(va_priv->micb_supply,
 					 va_priv->micb_current);
 		if (ret) {
-			dev_err(va_dev, "%s: Setting current failed, err = %d\n",
+			dev_err_ratelimited(va_dev, "%s: Setting current failed, err = %d\n",
 				__func__, ret);
 			return ret;
 		}
 		ret = regulator_enable(va_priv->micb_supply);
 		if (ret) {
-			dev_err(va_dev, "%s: regulator enable failed, err = %d\n",
+			dev_err_ratelimited(va_dev, "%s: regulator enable failed, err = %d\n",
 				__func__, ret);
 			return ret;
 		}
@@ -1441,7 +1442,7 @@ static int lpass_cdc_va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
 		}
 		ret = regulator_disable(va_priv->micb_supply);
 		if (ret) {
-			dev_err(va_dev, "%s: regulator disable failed, err = %d\n",
+			dev_err_ratelimited(va_dev, "%s: regulator disable failed, err = %d\n",
 				__func__, ret);
 			return ret;
 		}
@@ -1470,21 +1471,21 @@ static inline int lpass_cdc_va_macro_path_get(const char *wname,
 
 	path_name = strsep(&widget_name, " ");
 	if (!path_name) {
-		pr_err("%s: Invalid widget name = %s\n",
+		pr_err_ratelimited("%s: Invalid widget name = %s\n",
 			__func__, widget_name);
 		ret = -EINVAL;
 		goto err;
 	}
 	path_num_char = strpbrk(path_name, "01234567");
 	if (!path_num_char) {
-		pr_err("%s: va path index not found\n",
+		pr_err_ratelimited("%s: va path index not found\n",
 			__func__);
 		ret = -EINVAL;
 		goto err;
 	}
 	ret = kstrtouint(path_num_char, 10, path_num);
 	if (ret < 0)
-		pr_err("%s: Invalid tx path = %s\n",
+		pr_err_ratelimited("%s: Invalid tx path = %s\n",
 			__func__, w_name);
 
 err:
@@ -1585,7 +1586,7 @@ static int lpass_cdc_va_macro_hw_params(struct snd_pcm_substream *substream,
 		tx_fs_rate = 7;
 		break;
 	default:
-		dev_err(va_dev, "%s: Invalid TX sample rate: %d\n",
+		dev_err_ratelimited(va_dev, "%s: Invalid TX sample rate: %d\n",
 			__func__, params_rate(params));
 		return -EINVAL;
 	}
@@ -1599,7 +1600,7 @@ static int lpass_cdc_va_macro_hw_params(struct snd_pcm_substream *substream,
 			snd_soc_component_update_bits(component, tx_fs_reg,
 						0x0F, tx_fs_rate);
 		} else {
-			dev_err(va_dev,
+			dev_err_ratelimited(va_dev,
 				"%s: ERROR: Invalid decimator: %d\n",
 				__func__, decimator);
 			return -EINVAL;
@@ -1628,7 +1629,7 @@ static int lpass_cdc_va_macro_get_channel_map(struct snd_soc_dai *dai,
 		*tx_num = va_priv->active_ch_cnt[dai->id];
 		break;
 	default:
-		dev_err(va_dev, "%s: Invalid AIF\n", __func__);
+		dev_err_ratelimited(va_dev, "%s: Invalid AIF\n", __func__);
 		break;
 	}
 	return 0;

+ 29 - 29
asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c

@@ -516,13 +516,13 @@ static bool lpass_cdc_wsa_macro_get_data(struct snd_soc_component *component,
 	*wsa_dev = lpass_cdc_get_device_ptr(component->dev,
 							WSA_MACRO);
 	if (!(*wsa_dev)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: null device for macro!\n", func_name);
 		return false;
 	}
 	*wsa_priv = dev_get_drvdata((*wsa_dev));
 	if (!(*wsa_priv) || !(*wsa_priv)->component) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: priv is null for macro!\n", func_name);
 		return false;
 	}
@@ -575,7 +575,7 @@ static int lpass_cdc_wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *da
 		int_1_mix1_inp = port;
 		if ((int_1_mix1_inp < LPASS_CDC_WSA_MACRO_RX0) ||
 			(int_1_mix1_inp > LPASS_CDC_WSA_MACRO_RX_MIX1)) {
-			dev_err(wsa_dev,
+			dev_err_ratelimited(wsa_dev,
 				"%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
@@ -647,7 +647,7 @@ static int lpass_cdc_wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai
 		int_2_inp = port;
 		if ((int_2_inp < LPASS_CDC_WSA_MACRO_RX0) ||
 			(int_2_inp > LPASS_CDC_WSA_MACRO_RX_MIX1)) {
-			dev_err(wsa_dev,
+			dev_err_ratelimited(wsa_dev,
 				"%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
@@ -744,7 +744,7 @@ static int lpass_cdc_wsa_macro_hw_params(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_STREAM_PLAYBACK:
 		ret = lpass_cdc_wsa_macro_set_interpolator_rate(dai, params_rate(params));
 		if (ret) {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: cannot set sample rate: %u\n",
 				__func__, params_rate(params));
 			return ret;
@@ -760,7 +760,7 @@ static int lpass_cdc_wsa_macro_hw_params(struct snd_pcm_substream *substream,
 			wsa_priv->bit_width[dai->id] = 32;
 			break;
 		default:
-			dev_err(component->dev, "%s: Invalid format 0x%x\n",
+			dev_err_ratelimited(component->dev, "%s: Invalid format 0x%x\n",
 				__func__, params_width(params));
 			return -EINVAL;
 		}
@@ -776,7 +776,7 @@ static int lpass_cdc_wsa_macro_hw_params(struct snd_pcm_substream *substream,
 			wsa_priv->bit_width[dai->id] = 24;
 			break;
 		default:
-			dev_err(component->dev, "%s: Invalid format 0x%x\n",
+			dev_err_ratelimited(component->dev, "%s: Invalid format 0x%x\n",
 				__func__, params_width(params));
 			return -EINVAL;
 			}
@@ -835,7 +835,7 @@ static int lpass_cdc_wsa_macro_get_channel_map(struct snd_soc_dai *dai,
 		*tx_num = cnt;
 		break;
 	default:
-		dev_err(wsa_dev, "%s: Invalid AIF\n", __func__);
+		dev_err_ratelimited(wsa_dev, "%s: Invalid AIF\n", __func__);
 		break;
 	}
 	return 0;
@@ -901,7 +901,7 @@ static int lpass_cdc_wsa_macro_mclk_enable(
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -940,7 +940,7 @@ static int lpass_cdc_wsa_macro_mclk_enable(
 		wsa_priv->wsa_mclk_users++;
 	} else {
 		if (wsa_priv->wsa_mclk_users <= 0) {
-			dev_err(wsa_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(wsa_priv->dev, "%s: clock already disabled\n",
 			__func__);
 			wsa_priv->wsa_mclk_users = 0;
 			goto exit;
@@ -995,7 +995,7 @@ static int lpass_cdc_wsa_macro_mclk_event(struct snd_soc_dapm_widget *w,
 		}
 		break;
 	default:
-		dev_err(wsa_priv->dev,
+		dev_err_ratelimited(wsa_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -1272,7 +1272,7 @@ static int lpass_cdc_wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
 	} else if (!(strcmp(w->name, "WSA_RX1 MIX INP"))) {
 		gain_reg = LPASS_CDC_WSA_RX1_RX_VOL_MIX_CTL;
 	} else {
-		dev_err(component->dev, "%s: No gain register avail for %s\n",
+		dev_err_ratelimited(component->dev, "%s: No gain register avail for %s\n",
 			__func__, w->name);
 		return 0;
 	}
@@ -1740,7 +1740,7 @@ static int lpass_cdc_wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w
 	} else if (!(strcmp(w->name, "WSA_RX INT1 INTERP"))) {
 		reg = LPASS_CDC_WSA_RX1_RX_PATH_CTL;
 	} else {
-		dev_err(component->dev, "%s: Interpolator reg not found\n",
+		dev_err_ratelimited(component->dev, "%s: Interpolator reg not found\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -1826,7 +1826,7 @@ static int lpass_cdc_wsa_macro_spk_boost_event(struct snd_soc_dapm_widget *w,
 		reg = LPASS_CDC_WSA_RX1_RX_PATH_CTL;
 		reg_mix = LPASS_CDC_WSA_RX1_RX_PATH_MIX_CTL;
 	} else {
-		dev_err(component->dev, "%s: unknown widget: %s\n",
+		dev_err_ratelimited(component->dev, "%s: unknown widget: %s\n",
 			__func__, w->name);
 		return -EINVAL;
 	}
@@ -1991,7 +1991,7 @@ static int lpass_cdc_wsa_macro_enable_vbat(struct snd_soc_dapm_widget *w,
 			LPASS_CDC_WSA_VBAT_BCL_VBAT_PATH_CTL, 0x10, 0x00);
 		break;
 	default:
-		dev_err(wsa_dev, "%s: Invalid event %d\n", __func__, event);
+		dev_err_ratelimited(wsa_dev, "%s: Invalid event %d\n", __func__, event);
 		break;
 	}
 	return 0;
@@ -2020,7 +2020,7 @@ static int lpass_cdc_wsa_macro_enable_echo(struct snd_soc_dapm_widget *w,
 		ec_tx = ((val & 0x38) >> 0x3) - 1;
 
 	if (ec_tx < 0 || ec_tx >= (LPASS_CDC_WSA_MACRO_RX1 + 1)) {
-		dev_err(wsa_dev, "%s: EC mix control not set correctly\n",
+		dev_err_ratelimited(wsa_dev, "%s: EC mix control not set correctly\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -2136,7 +2136,7 @@ static int lpass_cdc_wsa_macro_set_rx_mute_status(struct snd_kcontrol *kcontrol,
 				0x10, value << 4);
 		break;
 	default:
-		pr_err("%s: invalid argument rx_shift = %d\n", __func__,
+		pr_err_ratelimited("%s: invalid argument rx_shift = %d\n", __func__,
 			wsa_rx_shift);
 		ret = -EINVAL;
 	}
@@ -2166,7 +2166,7 @@ static int lpass_cdc_wsa_macro_set_digital_volume(struct snd_kcontrol *kcontrol,
 		return -EINVAL;
 
 	if (!wsa_priv) {
-		pr_err("%s: priv is null for macro!\n",
+		pr_err_ratelimited("%s: priv is null for macro!\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -2186,7 +2186,7 @@ static int lpass_cdc_wsa_macro_set_digital_volume(struct snd_kcontrol *kcontrol,
 		gain = (u8)(wsa_priv->rx1_origin_gain -
 				wsa_priv->thermal_cur_state);
 	} else {
-		dev_err(wsa_priv->dev,
+		dev_err_ratelimited(wsa_priv->dev,
 			"%s: Incorrect RX Path selected\n", __func__);
 		return -EINVAL;
 	}
@@ -2400,11 +2400,11 @@ static int lpass_cdc_wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 	aif_rst = wsa_priv->rx_port_value[widget->shift];
 	if (!rx_port_value) {
 		if (aif_rst == 0) {
-			dev_err(wsa_dev, "%s: AIF reset already\n", __func__);
+			dev_err_ratelimited(wsa_dev, "%s: AIF reset already\n", __func__);
 			return 0;
 		}
 		if (aif_rst >= LPASS_CDC_WSA_MACRO_RX_MAX) {
-			dev_err(wsa_dev, "%s: Invalid AIF reset\n", __func__);
+			dev_err_ratelimited(wsa_dev, "%s: Invalid AIF reset\n", __func__);
 			return 0;
 		}
 	}
@@ -2431,7 +2431,7 @@ static int lpass_cdc_wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 		wsa_priv->active_ch_cnt[rx_port_value]++;
 		break;
 	default:
-		dev_err(wsa_dev,
+		dev_err_ratelimited(wsa_dev,
 			"%s: Invalid AIF_ID for WSA RX MUX %d\n",
 			__func__, rx_port_value);
 		return -EINVAL;
@@ -3178,7 +3178,7 @@ static int lpass_cdc_wsa_macro_core_vote(void *handle, bool enable)
 	struct lpass_cdc_wsa_macro_priv *wsa_priv = (struct lpass_cdc_wsa_macro_priv *) handle;
 
 	if (wsa_priv == NULL) {
-		pr_err("%s: wsa priv data is NULL\n", __func__);
+		pr_err_ratelimited("%s: wsa priv data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (enable) {
@@ -3202,7 +3202,7 @@ static int wsa_swrm_clock(void *handle, bool enable)
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3258,7 +3258,7 @@ static int wsa_swrm_clock(void *handle, bool enable)
 		pm_runtime_put_autosuspend(wsa_priv->dev);
 	} else {
 		if (wsa_priv->swr_clk_users <= 0) {
-			dev_err(wsa_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(wsa_priv->dev, "%s: clock already disabled\n",
 			__func__);
 			wsa_priv->swr_clk_users = 0;
 			goto exit;
@@ -3296,7 +3296,7 @@ static int lpass_cdc_wsa_macro_get_max_state(
 {
 	struct lpass_cdc_wsa_macro_priv *wsa_priv = cdev->devdata;
 	if (!wsa_priv) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 	*state = wsa_priv->thermal_max_state;
@@ -3311,7 +3311,7 @@ static int lpass_cdc_wsa_macro_get_cur_state(
 	struct lpass_cdc_wsa_macro_priv *wsa_priv = cdev->devdata;
 
 	if (!wsa_priv) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 	*state = wsa_priv->thermal_cur_state;
@@ -3327,14 +3327,14 @@ static int lpass_cdc_wsa_macro_set_cur_state(
 	struct lpass_cdc_wsa_macro_priv *wsa_priv = cdev->devdata;
 
 	if (!wsa_priv || !wsa_priv->dev) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	if (state <= wsa_priv->thermal_max_state) {
 		wsa_priv->thermal_cur_state = state;
 	} else {
-		dev_err(wsa_priv->dev,
+		dev_err_ratelimited(wsa_priv->dev,
 			"%s: incorrect requested state:%d\n",
 			__func__, state);
 		return -EINVAL;

+ 30 - 29
asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -496,13 +497,13 @@ static bool lpass_cdc_wsa2_macro_get_data(struct snd_soc_component *component,
 	*wsa2_dev = lpass_cdc_get_device_ptr(component->dev,
 							WSA2_MACRO);
 	if (!(*wsa2_dev)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: null device for macro!\n", func_name);
 		return false;
 	}
 	*wsa2_priv = dev_get_drvdata((*wsa2_dev));
 	if (!(*wsa2_priv) || !(*wsa2_priv)->component) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: priv is null for macro!\n", func_name);
 		return false;
 	}
@@ -555,7 +556,7 @@ static int lpass_cdc_wsa2_macro_set_prim_interpolator_rate(struct snd_soc_dai *d
 		int_1_mix1_inp = port;
 		if ((int_1_mix1_inp < LPASS_CDC_WSA2_MACRO_RX0) ||
 			(int_1_mix1_inp > LPASS_CDC_WSA2_MACRO_RX_MIX1)) {
-			dev_err(wsa2_dev,
+			dev_err_ratelimited(wsa2_dev,
 				"%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
@@ -627,7 +628,7 @@ static int lpass_cdc_wsa2_macro_set_mix_interpolator_rate(struct snd_soc_dai *da
 		int_2_inp = port;
 		if ((int_2_inp < LPASS_CDC_WSA2_MACRO_RX0) ||
 			(int_2_inp > LPASS_CDC_WSA2_MACRO_RX_MIX1)) {
-			dev_err(wsa2_dev,
+			dev_err_ratelimited(wsa2_dev,
 				"%s: Invalid RX port, Dai ID is %d\n",
 				__func__, dai->id);
 			return -EINVAL;
@@ -724,7 +725,7 @@ static int lpass_cdc_wsa2_macro_hw_params(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_STREAM_PLAYBACK:
 		ret = lpass_cdc_wsa2_macro_set_interpolator_rate(dai, params_rate(params));
 		if (ret) {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: cannot set sample rate: %u\n",
 				__func__, params_rate(params));
 			return ret;
@@ -790,7 +791,7 @@ static int lpass_cdc_wsa2_macro_get_channel_map(struct snd_soc_dai *dai,
 		*tx_num = cnt;
 		break;
 	default:
-		dev_err(wsa2_dev, "%s: Invalid AIF\n", __func__);
+		dev_err_ratelimited(wsa2_dev, "%s: Invalid AIF\n", __func__);
 		break;
 	}
 	return 0;
@@ -856,7 +857,7 @@ static int lpass_cdc_wsa2_macro_mclk_enable(
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(wsa2_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(wsa2_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -895,7 +896,7 @@ static int lpass_cdc_wsa2_macro_mclk_enable(
 		wsa2_priv->wsa2_mclk_users++;
 	} else {
 		if (wsa2_priv->wsa2_mclk_users <= 0) {
-			dev_err(wsa2_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(wsa2_priv->dev, "%s: clock already disabled\n",
 			__func__);
 			wsa2_priv->wsa2_mclk_users = 0;
 			goto exit;
@@ -950,7 +951,7 @@ static int lpass_cdc_wsa2_macro_mclk_event(struct snd_soc_dapm_widget *w,
 		}
 		break;
 	default:
-		dev_err(wsa2_priv->dev,
+		dev_err_ratelimited(wsa2_priv->dev,
 			"%s: invalid DAPM event %d\n", __func__, event);
 		ret = -EINVAL;
 	}
@@ -1227,7 +1228,7 @@ static int lpass_cdc_wsa2_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
 	} else if (!(strcmp(w->name, "WSA2_RX1 MIX INP"))) {
 		gain_reg = LPASS_CDC_WSA2_RX1_RX_VOL_MIX_CTL;
 	} else {
-		dev_err(component->dev, "%s: No gain register avail for %s\n",
+		dev_err_ratelimited(component->dev, "%s: No gain register avail for %s\n",
 			__func__, w->name);
 		return 0;
 	}
@@ -1547,7 +1548,7 @@ static int lpass_cdc_wsa2_macro_enable_interpolator(struct snd_soc_dapm_widget *
 	} else if (!(strcmp(w->name, "WSA2_RX INT1 INTERP"))) {
 		reg = LPASS_CDC_WSA2_RX1_RX_PATH_CTL;
 	} else {
-		dev_err(component->dev, "%s: Interpolator reg not found\n",
+		dev_err_ratelimited(component->dev, "%s: Interpolator reg not found\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -1627,7 +1628,7 @@ static int lpass_cdc_wsa2_macro_spk_boost_event(struct snd_soc_dapm_widget *w,
 		reg = LPASS_CDC_WSA2_RX1_RX_PATH_CTL;
 		reg_mix = LPASS_CDC_WSA2_RX1_RX_PATH_MIX_CTL;
 	} else {
-		dev_err(component->dev, "%s: unknown widget: %s\n",
+		dev_err_ratelimited(component->dev, "%s: unknown widget: %s\n",
 			__func__, w->name);
 		return -EINVAL;
 	}
@@ -1792,7 +1793,7 @@ static int lpass_cdc_wsa2_macro_enable_vbat(struct snd_soc_dapm_widget *w,
 			LPASS_CDC_WSA2_VBAT_BCL_VBAT_PATH_CTL, 0x10, 0x00);
 		break;
 	default:
-		dev_err(wsa2_dev, "%s: Invalid event %d\n", __func__, event);
+		dev_err_ratelimited(wsa2_dev, "%s: Invalid event %d\n", __func__, event);
 		break;
 	}
 	return 0;
@@ -1821,7 +1822,7 @@ static int lpass_cdc_wsa2_macro_enable_echo(struct snd_soc_dapm_widget *w,
 		ec_tx = ((val & 0x38) >> 0x3) - 1;
 
 	if (ec_tx < 0 || ec_tx >= (LPASS_CDC_WSA2_MACRO_RX1 + 1)) {
-		dev_err(wsa2_dev, "%s: EC mix control not set correctly\n",
+		dev_err_ratelimited(wsa2_dev, "%s: EC mix control not set correctly\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -1937,7 +1938,7 @@ static int lpass_cdc_wsa2_macro_set_rx_mute_status(struct snd_kcontrol *kcontrol
 				0x10, value << 4);
 		break;
 	default:
-		pr_err("%s: invalid argument rx_shift = %d\n", __func__,
+		pr_err_ratelimited("%s: invalid argument rx_shift = %d\n", __func__,
 			wsa2_rx_shift);
 		ret = -EINVAL;
 	}
@@ -1967,7 +1968,7 @@ static int lpass_cdc_wsa2_macro_set_digital_volume(struct snd_kcontrol *kcontrol
 		return -EINVAL;
 
 	if (!wsa2_priv) {
-		pr_err("%s: priv is null for macro!\n",
+		pr_err_ratelimited("%s: priv is null for macro!\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -1987,7 +1988,7 @@ static int lpass_cdc_wsa2_macro_set_digital_volume(struct snd_kcontrol *kcontrol
 		gain = (u8)(wsa2_priv->rx1_origin_gain -
 				wsa2_priv->thermal_cur_state);
 	} else {
-		dev_err(wsa2_priv->dev,
+		dev_err_ratelimited(wsa2_priv->dev,
 			"%s: Incorrect RX Path selected\n", __func__);
 		return -EINVAL;
 	}
@@ -2168,11 +2169,11 @@ static int lpass_cdc_wsa2_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 	aif_rst = wsa2_priv->rx_port_value[widget->shift];
 	if (!rx_port_value) {
 		if (aif_rst == 0) {
-			dev_err(wsa2_dev, "%s: AIF reset already\n", __func__);
+			dev_err_ratelimited(wsa2_dev, "%s: AIF reset already\n", __func__);
 			return 0;
 		}
 		if (aif_rst >= LPASS_CDC_WSA2_MACRO_RX_MAX) {
-			dev_err(wsa2_dev, "%s: Invalid AIF reset\n", __func__);
+			dev_err_ratelimited(wsa2_dev, "%s: Invalid AIF reset\n", __func__);
 			return 0;
 		}
 	}
@@ -2199,7 +2200,7 @@ static int lpass_cdc_wsa2_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 		wsa2_priv->active_ch_cnt[rx_port_value]++;
 		break;
 	default:
-		dev_err(wsa2_dev,
+		dev_err_ratelimited(wsa2_dev,
 			"%s: Invalid AIF_ID for WSA2 RX MUX %d\n",
 			__func__, rx_port_value);
 		return -EINVAL;
@@ -2754,7 +2755,7 @@ static int lpass_cdc_wsa2_macro_core_vote(void *handle, bool enable)
 	struct lpass_cdc_wsa2_macro_priv *wsa2_priv = (struct lpass_cdc_wsa2_macro_priv *) handle;
 
 	if (wsa2_priv == NULL) {
-		pr_err("%s: wsa2 priv data is NULL\n", __func__);
+		pr_err_ratelimited("%s: wsa2 priv data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (enable) {
@@ -2777,7 +2778,7 @@ static int wsa2_swrm_clock(void *handle, bool enable)
 	int ret = 0;
 
 	if (regmap == NULL) {
-		dev_err(wsa2_priv->dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(wsa2_priv->dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2833,7 +2834,7 @@ static int wsa2_swrm_clock(void *handle, bool enable)
 		pm_runtime_put_autosuspend(wsa2_priv->dev);
 	} else {
 		if (wsa2_priv->swr_clk_users <= 0) {
-			dev_err(wsa2_priv->dev, "%s: clock already disabled\n",
+			dev_err_ratelimited(wsa2_priv->dev, "%s: clock already disabled\n",
 			__func__);
 			wsa2_priv->swr_clk_users = 0;
 			goto exit;
@@ -2871,7 +2872,7 @@ static int lpass_cdc_wsa2_macro_get_max_state(
 {
 	struct lpass_cdc_wsa2_macro_priv *wsa2_priv = cdev->devdata;
 	if (!wsa2_priv) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 	*state = wsa2_priv->thermal_max_state;
@@ -2886,7 +2887,7 @@ static int lpass_cdc_wsa2_macro_get_cur_state(
 	struct lpass_cdc_wsa2_macro_priv *wsa2_priv = cdev->devdata;
 
 	if (!wsa2_priv) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 	*state = wsa2_priv->thermal_cur_state;
@@ -2902,14 +2903,14 @@ static int lpass_cdc_wsa2_macro_set_cur_state(
 	struct lpass_cdc_wsa2_macro_priv *wsa2_priv = cdev->devdata;
 
 	if (!wsa2_priv || !wsa2_priv->dev) {
-		pr_err("%s: cdev->devdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: cdev->devdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	if (state <= wsa2_priv->thermal_max_state) {
 		wsa2_priv->thermal_cur_state = state;
 	} else {
-		dev_err(wsa2_priv->dev,
+		dev_err_ratelimited(wsa2_priv->dev,
 			"%s: incorrect requested state:%d\n",
 			__func__, state);
 		return -EINVAL;
@@ -3119,12 +3120,12 @@ static void lpass_cdc_wsa2_macro_cooling_adjust_gain(struct work_struct *work)
 	wsa2_priv = container_of(work, struct lpass_cdc_wsa2_macro_priv,
 			     lpass_cdc_wsa2_macro_cooling_work);
 	if (!wsa2_priv) {
-		pr_err("%s: priv is null for macro!\n",
+		pr_err_ratelimited("%s: priv is null for macro!\n",
 			__func__);
 		return;
 	}
 	if (!wsa2_priv->dev || !wsa2_priv->dev->of_node) {
-		dev_err(wsa2_priv->dev,
+		dev_err_ratelimited(wsa2_priv->dev,
 			"%s: DT node for wsa2_priv does not exist\n", __func__);
 		return;
 	}

+ 34 - 33
asoc/codecs/lpass-cdc/lpass-cdc.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/of_platform.h>
@@ -55,7 +56,7 @@ int lpass_cdc_set_port_map(struct snd_soc_component *component,
 		return -EINVAL;
 
 	if (!lpass_cdc_is_valid_codec_dev(priv->dev)) {
-		dev_err(priv->dev, "%s: invalid codec\n", __func__);
+		dev_err_ratelimited(priv->dev, "%s: invalid codec\n", __func__);
 		return -EINVAL;
 	}
 	map = (struct swr_mstr_port_map *)data;
@@ -164,7 +165,7 @@ static int lpass_cdc_update_wcd_event(void *handle, u16 event, u32 data)
 	struct lpass_cdc_priv *priv = (struct lpass_cdc_priv *)handle;
 
 	if (!priv) {
-		pr_err("%s:Invalid lpass_cdc priv handle\n", __func__);
+		pr_err_ratelimited("%s:Invalid lpass_cdc priv handle\n", __func__);
 		return -EINVAL;
 	}
 
@@ -219,7 +220,7 @@ static int lpass_cdc_update_wcd_event(void *handle, u16 event, u32 data)
 				LPASS_CDC_MACRO_EVT_HPHR_HD2_ENABLE, data);
 		break;
 	default:
-		dev_err(priv->dev, "%s: Invalid event %d trigger from wcd\n",
+		dev_err_ratelimited(priv->dev, "%s: Invalid event %d trigger from wcd\n",
 			__func__, event);
 		return -EINVAL;
 	}
@@ -233,7 +234,7 @@ static int lpass_cdc_register_notifier(void *handle,
 	struct lpass_cdc_priv *priv = (struct lpass_cdc_priv *)handle;
 
 	if (!priv) {
-		pr_err("%s: lpass_cdc priv is null\n", __func__);
+		pr_err_ratelimited("%s: lpass_cdc priv is null\n", __func__);
 		return -EINVAL;
 	}
 	if (enable)
@@ -323,17 +324,17 @@ struct device *lpass_cdc_get_device_ptr(struct device *dev, u16 macro_id)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is null\n", __func__);
+		pr_err_ratelimited("%s: dev is null\n", __func__);
 		return NULL;
 	}
 
 	if (!lpass_cdc_is_valid_codec_dev(dev)) {
-		pr_err("%s: invalid codec\n", __func__);
+		pr_err_ratelimited("%s: invalid codec\n", __func__);
 		return NULL;
 	}
 	priv = dev_get_drvdata(dev);
 	if (!priv || (macro_id >= MAX_MACRO)) {
-		dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null or invalid macro\n", __func__);
 		return NULL;
 	}
 
@@ -353,17 +354,17 @@ struct device *lpass_cdc_get_rsc_clk_device_ptr(struct device *dev)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is null\n", __func__);
+		pr_err_ratelimited("%s: dev is null\n", __func__);
 		return NULL;
 	}
 
 	if (!lpass_cdc_is_valid_codec_dev(dev)) {
-		pr_err("%s: invalid codec\n", __func__);
+		pr_err_ratelimited("%s: invalid codec\n", __func__);
 		return NULL;
 	}
 	priv = dev_get_drvdata(dev);
 	if (!priv) {
-		dev_err(dev, "%s: priv is null\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null\n", __func__);
 		return NULL;
 	}
 
@@ -413,17 +414,17 @@ int lpass_cdc_register_res_clk(struct device *dev, rsc_clk_cb_t rsc_clk_cb)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev || !rsc_clk_cb) {
-		pr_err("%s: dev or rsc_clk_cb is null\n", __func__);
+		pr_err_ratelimited("%s: dev or rsc_clk_cb is null\n", __func__);
 		return -EINVAL;
 	}
 	if (!lpass_cdc_is_valid_child_dev(dev)) {
-		dev_err(dev, "%s: child device :%pK not added yet\n",
+		dev_err_ratelimited(dev, "%s: child device :%pK not added yet\n",
 			__func__, dev);
 		return -EINVAL;
 	}
 	priv = dev_get_drvdata(dev->parent);
 	if (!priv) {
-		dev_err(dev, "%s: priv is null\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -444,17 +445,17 @@ void lpass_cdc_unregister_res_clk(struct device *dev)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return;
 	}
 	if (!lpass_cdc_is_valid_child_dev(dev)) {
-		dev_err(dev, "%s: child device :%pK not added\n",
+		dev_err_ratelimited(dev, "%s: child device :%pK not added\n",
 			__func__, dev);
 		return;
 	}
 	priv = dev_get_drvdata(dev->parent);
 	if (!priv) {
-		dev_err(dev, "%s: priv is null\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null\n", __func__);
 		return;
 	}
 
@@ -523,7 +524,7 @@ int lpass_cdc_dmic_clk_enable(struct snd_soc_component *component,
 		freq_change_mask = 0x08;
 		break;
 	default:
-		dev_err(component->dev, "%s: Invalid DMIC Selection\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -591,17 +592,17 @@ bool lpass_cdc_is_va_macro_registered(struct device *dev)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is null\n", __func__);
+		pr_err_ratelimited("%s: dev is null\n", __func__);
 		return false;
 	}
 	if (!lpass_cdc_is_valid_child_dev(dev)) {
-		dev_err(dev, "%s: child device calling is not added yet\n",
+		dev_err_ratelimited(dev, "%s: child device calling is not added yet\n",
 			__func__);
 		return false;
 	}
 	priv = dev_get_drvdata(dev->parent);
 	if (!priv) {
-		dev_err(dev, "%s: priv is null\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null\n", __func__);
 		return false;
 	}
 	return priv->macros_supported[VA_MACRO];
@@ -703,17 +704,17 @@ void lpass_cdc_unregister_macro(struct device *dev, u16 macro_id)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is null\n", __func__);
+		pr_err_ratelimited("%s: dev is null\n", __func__);
 		return;
 	}
 	if (!lpass_cdc_is_valid_child_dev(dev)) {
-		dev_err(dev, "%s: macro:%d not in valid registered macro-list\n",
+		dev_err_ratelimited(dev, "%s: macro:%d not in valid registered macro-list\n",
 			__func__, macro_id);
 		return;
 	}
 	priv = dev_get_drvdata(dev->parent);
 	if (!priv || (macro_id >= MAX_MACRO)) {
-		dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null or invalid macro\n", __func__);
 		return;
 	}
 
@@ -744,17 +745,17 @@ void lpass_cdc_wsa_pa_on(struct device *dev, bool adie_lb)
 	struct lpass_cdc_priv *priv;
 
 	if (!dev) {
-		pr_err("%s: dev is null\n", __func__);
+		pr_err_ratelimited("%s: dev is null\n", __func__);
 		return;
 	}
 	if (!lpass_cdc_is_valid_child_dev(dev)) {
-		dev_err(dev, "%s: not a valid child dev\n",
+		dev_err_ratelimited(dev, "%s: not a valid child dev\n",
 			__func__);
 		return;
 	}
 	priv = dev_get_drvdata(dev->parent);
 	if (!priv) {
-		dev_err(dev, "%s: priv is null\n", __func__);
+		dev_err_ratelimited(dev, "%s: priv is null\n", __func__);
 		return;
 	}
 	if (adie_lb)
@@ -800,7 +801,7 @@ static ssize_t lpass_cdc_version_read(struct snd_info_entry *entry,
 
 	priv = (struct lpass_cdc_priv *) entry->private_data;
 	if (!priv) {
-		pr_err("%s: lpass_cdc priv is null\n", __func__);
+		pr_err_ratelimited("%s: lpass_cdc priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -974,7 +975,7 @@ int lpass_cdc_info_create_codec_entry(struct snd_info_entry *codec_root,
 						   "version",
 						   priv->entry);
 	if (!version_entry) {
-		dev_err(component->dev, "%s: failed to create lpass_cdc version entry\n",
+		dev_err_ratelimited(component->dev, "%s: failed to create lpass_cdc version entry\n",
 			__func__);
 		snd_info_free_entry(priv->entry);
 		return -ENOMEM;
@@ -1017,7 +1018,7 @@ int lpass_cdc_register_wake_irq(struct snd_soc_component *component,
 		return -EINVAL;
 
 	if (!lpass_cdc_is_valid_codec_dev(priv->dev)) {
-		dev_err(component->dev, "%s: invalid codec\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: invalid codec\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1051,7 +1052,7 @@ int lpass_cdc_tx_mclk_enable(struct snd_soc_component *component,
 		return -EINVAL;
 
 	if (!lpass_cdc_is_valid_codec_dev(priv->dev)) {
-		dev_err(component->dev, "%s: invalid codec\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: invalid codec\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1086,7 +1087,7 @@ int lpass_cdc_register_event_listener(struct snd_soc_component *component,
 		return -EINVAL;
 
 	if (!lpass_cdc_is_valid_codec_dev(priv->dev)) {
-		dev_err(component->dev, "%s: invalid codec\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: invalid codec\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1384,7 +1385,7 @@ int lpass_cdc_runtime_resume(struct device *dev)
 	if (priv->core_hw_vote_count == 0) {
 		ret = digital_cdc_rsc_mgr_hw_vote_enable(priv->lpass_core_hw_vote);
 		if (ret < 0) {
-			dev_err(dev, "%s:lpass core hw enable failed\n",
+			dev_err_ratelimited(dev, "%s:lpass core hw enable failed\n",
 				__func__);
 			goto audio_vote;
 		}
@@ -1402,7 +1403,7 @@ audio_vote:
 	if (priv->core_audio_vote_count == 0) {
 		ret = digital_cdc_rsc_mgr_hw_vote_enable(priv->lpass_audio_hw_vote);
 		if (ret < 0) {
-			dev_err(dev, "%s:lpass audio hw enable failed\n",
+			dev_err_ratelimited(dev, "%s:lpass audio hw enable failed\n",
 				__func__);
 			goto done;
 		}

+ 6 - 6
asoc/codecs/msm-cdc-pinctrl.c

@@ -40,19 +40,19 @@ static struct msm_cdc_pinctrl_info *msm_cdc_pinctrl_get_gpiodata(
 	struct msm_cdc_pinctrl_info *gpio_data;
 
 	if (!np) {
-		pr_err("%s: device node is null\n", __func__);
+		pr_err_ratelimited("%s: device node is null\n", __func__);
 		return NULL;
 	}
 
 	pdev = of_find_device_by_node(np);
 	if (!pdev) {
-		pr_err("%s: platform device not found!\n", __func__);
+		pr_err_ratelimited("%s: platform device not found!\n", __func__);
 		return NULL;
 	}
 
 	gpio_data = dev_get_drvdata(&pdev->dev);
 	if (!gpio_data)
-		dev_err(&pdev->dev, "%s: cannot find cdc gpio info\n",
+		dev_err_ratelimited(&pdev->dev, "%s: cannot find cdc gpio info\n",
 			__func__);
 
 	return gpio_data;
@@ -95,7 +95,7 @@ int msm_cdc_pinctrl_select_sleep_state(struct device_node *np)
 		return -EINVAL;
 
 	if (!gpio_data->pinctrl_sleep) {
-		pr_err("%s: pinctrl sleep state is null\n", __func__);
+		pr_err_ratelimited("%s: pinctrl sleep state is null\n", __func__);
 		return -EINVAL;
 	}
 	gpio_data->state = false;
@@ -120,7 +120,7 @@ int msm_cdc_pinctrl_select_alt_active_state(struct device_node *np)
 		return -EINVAL;
 
 	if (!gpio_data->pinctrl_alt_active) {
-		pr_err("%s: pinctrl alt_active state is null\n", __func__);
+		pr_err_ratelimited("%s: pinctrl alt_active state is null\n", __func__);
 		return -EINVAL;
 	}
 	gpio_data->state = true;
@@ -145,7 +145,7 @@ int msm_cdc_pinctrl_select_active_state(struct device_node *np)
 		return -EINVAL;
 
 	if (!gpio_data->pinctrl_active) {
-		pr_err("%s: pinctrl active state is null\n", __func__);
+		pr_err_ratelimited("%s: pinctrl active state is null\n", __func__);
 		return -EINVAL;
 	}
 	gpio_data->state = true;

+ 21 - 20
asoc/codecs/msm-cdc-supply.c

@@ -119,12 +119,12 @@ static int msm_cdc_check_supply_param(struct device *dev,
 				      int num_supplies)
 {
 	if (!dev) {
-		pr_err("%s: device is NULL\n", __func__);
+		pr_err_ratelimited("%s: device is NULL\n", __func__);
 		return -ENODEV;
 	}
 
 	if (!cdc_vreg || (num_supplies <= 0)) {
-		dev_err(dev, "%s: supply check failed: vreg: %pK, num_supplies: %d\n",
+		dev_err_ratelimited(dev, "%s: supply check failed: vreg: %pK, num_supplies: %d\n",
 			__func__, cdc_vreg, num_supplies);
 		return -EINVAL;
 	}
@@ -154,7 +154,7 @@ bool msm_cdc_is_ondemand_supply(struct device *dev,
 	int ret, i;
 
 	if ((!supply_name) || (!supplies)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
+		pr_err_ratelimited("%s: either dev or supplies or cdc_vreg is NULL\n",
 				__func__);
 		return rc;
 	}
@@ -195,7 +195,7 @@ int msm_cdc_set_supply_min_voltage(struct device *dev,
 	int rc = 0, i;
 
 	if ((!supply_name) || (!supplies)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
+		pr_err_ratelimited("%s: either dev or supplies or cdc_vreg is NULL\n",
 				__func__);
 		return -EINVAL;
 	}
@@ -240,7 +240,7 @@ int msm_cdc_disable_ondemand_supply(struct device *dev,
 	int rc, i;
 
 	if ((!supply_name) || (!supplies)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
+		pr_err_ratelimited("%s: either dev or supplies or cdc_vreg is NULL\n",
 				__func__);
 		return -EINVAL;
 	}
@@ -254,13 +254,14 @@ int msm_cdc_disable_ondemand_supply(struct device *dev,
 			!strcmp(cdc_vreg[i].name, supply_name)) {
 			rc = regulator_disable(supplies[i].consumer);
 			if (rc)
-				dev_err(dev, "%s: failed to disable supply %s, err:%d\n",
+				dev_err_ratelimited(dev,
+					"%s: failed to disable supply %s, err:%d\n",
 					__func__, supplies[i].supply, rc);
 			break;
 		}
 	}
 	if (i == num_supplies) {
-		dev_err(dev, "%s: not able to find supply %s\n",
+		dev_err_ratelimited(dev, "%s: not able to find supply %s\n",
 			__func__, supply_name);
 		rc = -EINVAL;
 	}
@@ -290,7 +291,7 @@ int msm_cdc_enable_ondemand_supply(struct device *dev,
 	int rc, i;
 
 	if ((!supply_name) || (!supplies)) {
-		pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
+		pr_err_ratelimited("%s: either dev or supplies or cdc_vreg is NULL\n",
 				__func__);
 		return -EINVAL;
 	}
@@ -304,13 +305,13 @@ int msm_cdc_enable_ondemand_supply(struct device *dev,
 			!strcmp(cdc_vreg[i].name, supply_name)) {
 			rc = regulator_enable(supplies[i].consumer);
 			if (rc)
-				dev_err(dev, "%s: failed to enable supply %s, rc: %d\n",
+				dev_err_ratelimited(dev, "%s: failed to enable supply %s, rc: %d\n",
 					__func__, supplies[i].supply, rc);
 			break;
 		}
 	}
 	if (i == num_supplies) {
-		dev_err(dev, "%s: not able to find supply %s\n",
+		dev_err_ratelimited(dev, "%s: not able to find supply %s\n",
 			__func__, supply_name);
 		rc = -EINVAL;
 	}
@@ -341,7 +342,7 @@ int msm_cdc_set_supplies_lpm_mode(struct device *dev,
 	int rc = 0, i;
 
 	if (!supplies) {
-		pr_err("%s: supplies is NULL\n",
+		pr_err_ratelimited("%s: supplies is NULL\n",
 				__func__);
 		return -EINVAL;
 	}
@@ -356,7 +357,7 @@ int msm_cdc_set_supplies_lpm_mode(struct device *dev,
 				supplies[i].consumer,
 				flag ? 0 : cdc_vreg[i].optimum_uA);
 			if (rc)
-				dev_err(dev,
+				dev_err_ratelimited(dev,
 					"%s: failed to set supply %s to %s, err:%d\n",
 					__func__, supplies[i].supply,
 					flag ? "LPM" : "NOM",
@@ -646,13 +647,13 @@ int msm_cdc_get_power_supplies(struct device *dev,
 	int rc;
 
 	if (!dev) {
-		pr_err("%s: device pointer is NULL\n", __func__);
+		pr_err_ratelimited("%s: device pointer is NULL\n", __func__);
 		return -EINVAL;
 	}
 	static_sup_cnt = of_property_count_strings(dev->of_node,
 						   static_prop_name);
 	if (static_sup_cnt < 0) {
-		dev_err(dev, "%s: Failed to get static supplies(%d)\n",
+		dev_err_ratelimited(dev, "%s: Failed to get static supplies(%d)\n",
 			__func__, static_sup_cnt);
 		rc = static_sup_cnt;
 		goto err_supply_cnt;
@@ -668,7 +669,7 @@ int msm_cdc_get_power_supplies(struct device *dev,
 
 	num_supplies = static_sup_cnt + ond_sup_cnt + cp_sup_cnt;
 	if (num_supplies <= 0) {
-		dev_err(dev, "%s: supply count is 0 or negative\n", __func__);
+		dev_err_ratelimited(dev, "%s: supply count is 0 or negative\n", __func__);
 		rc = -EINVAL;
 		goto err_supply_cnt;
 	}
@@ -684,7 +685,7 @@ int msm_cdc_get_power_supplies(struct device *dev,
 	rc = msm_cdc_parse_supplies(dev, cdc_reg, static_prop_name,
 				    static_sup_cnt, false);
 	if (rc) {
-		dev_err(dev, "%s: failed to parse static supplies(%d)\n",
+		dev_err_ratelimited(dev, "%s: failed to parse static supplies(%d)\n",
 				__func__, rc);
 		goto err_sup;
 	}
@@ -693,7 +694,7 @@ int msm_cdc_get_power_supplies(struct device *dev,
 				    ond_prop_name, ond_sup_cnt,
 				    true);
 	if (rc) {
-		dev_err(dev, "%s: failed to parse demand supplies(%d)\n",
+		dev_err_ratelimited(dev, "%s: failed to parse demand supplies(%d)\n",
 				__func__, rc);
 		goto err_sup;
 	}
@@ -702,7 +703,7 @@ int msm_cdc_get_power_supplies(struct device *dev,
 				    &cdc_reg[static_sup_cnt + ond_sup_cnt],
 				    cp_prop_name, cp_sup_cnt, true);
 	if (rc) {
-		dev_err(dev, "%s: failed to parse cp supplies(%d)\n",
+		dev_err_ratelimited(dev, "%s: failed to parse cp supplies(%d)\n",
 				__func__, rc);
 		goto err_sup;
 	}
@@ -764,7 +765,7 @@ int msm_cdc_enable_wcd_supply(struct cdc_wcd_supply *cdc_supply, bool enable)
 	int rc;
 
 	if (!component) {
-		pr_err("%s: Component memory is NULL\n", __func__);
+		pr_err_ratelimited("%s: Component memory is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -780,7 +781,7 @@ int msm_cdc_enable_wcd_supply(struct cdc_wcd_supply *cdc_supply, bool enable)
 	if (!rc)
 		snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
 	else
-		dev_err(component->dev, "%s: micbias %s force %s pin failed\n",
+		dev_err_ratelimited(component->dev, "%s: micbias %s force %s pin failed\n",
 			__func__, cdc_supply->name, (enable ? "enable" : "disable"));
 
 	return rc;

+ 30 - 28
asoc/codecs/msm_hdmi_codec_rx.c

@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -88,7 +89,7 @@ static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev, "%s: codec_data is NULL\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: codec_data is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -139,7 +140,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev, "%s: codec_data is NULL\n",
+		dev_err_ratelimited(component->dev, "%s: codec_data is NULL\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -156,7 +157,8 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
 	rc = msm_ext_disp_select_audio_codec(codec_data->ext_disp_core_pdev,
 						 &codec_info);
 	if (!codec_data->ext_disp_ops.get_audio_edid_blk || rc) {
-		dev_err(component->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n",
+		dev_err_ratelimited(component->dev,
+			"%s: codec_data or get_audio_edid_blk() is NULL\n",
 			__func__);
 		mutex_unlock(&codec_data->dp_ops_lock);
 		return -EINVAL;
@@ -168,7 +170,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol,
 		if (sizeof(ucontrol->value.bytes.data) <
 			  (edid_blk.audio_data_blk_size +
 			   edid_blk.spk_alloc_data_blk_size)) {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: Not enough memory to copy EDID data\n",
 				__func__);
 			return -ENOMEM;
@@ -205,7 +207,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev, "%s: codec_data is NULL\n",
+		dev_err_ratelimited(component->dev, "%s: codec_data is NULL\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -233,7 +235,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
 	cable_state = codec_data->ext_disp_ops.cable_status(
 				codec_data->ext_disp_core_pdev, 1);
 	if (cable_state < 0) {
-		dev_err(component->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
+		dev_err_ratelimited(component->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n",
 			__func__, cable_state);
 		rc = cable_state;
 		goto cable_err;
@@ -241,7 +243,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
 
 	codec_data->cable_status[dai_id] = cable_state;
 	if (cable_state == EXT_DISPLAY_CABLE_DISCONNECT) {
-		dev_err(component->dev, "%s: Display cable disconnected\n",
+		dev_err_ratelimited(component->dev, "%s: Display cable disconnected\n",
 			__func__);
 		ucontrol->value.integer.value[0] = 0;
 		rc = 0;
@@ -263,14 +265,14 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol,
 			break;
 		default:
 			rc = -EINVAL;
-			dev_err(component->dev, "%s: Invalid disp_type:%d\n",
+			dev_err_ratelimited(component->dev, "%s: Invalid disp_type:%d\n",
 			       __func__, disp_type);
 			goto done;
 		}
 		dev_dbg(component->dev, "%s: Display type: %d\n",
 			__func__, disp_type);
 	} else {
-		dev_err(component->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
+		dev_err_ratelimited(component->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n",
 			__func__, disp_type);
 		rc = disp_type;
 	}
@@ -296,7 +298,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: codec_data is NULL\n",
 			__func__);
 		return -EINVAL;
@@ -315,7 +317,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
 						 &codec_info);
 
 	if (!codec_data->ext_disp_ops.acknowledge || rc) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: codec_data ops acknowledge() is NULL\n",
 			__func__);
 		rc = -EINVAL;
@@ -334,7 +336,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
 		break;
 	default:
 		rc = -EINVAL;
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: invalid value %d for mixer ctl\n",
 			__func__, ucontrol->value.enumerated.item[0]);
 		goto err;
@@ -346,7 +348,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol,
 			 codec_data->ext_disp_core_pdev, ack_state);
 	mutex_unlock(&codec_data->dp_ops_lock);
 	if (rc < 0) {
-		dev_err(component->dev, "%s: error from acknowledge(), err:%d\n",
+		dev_err_ratelimited(component->dev, "%s: error from acknowledge(), err:%d\n",
 			__func__, rc);
 	}
 	return rc;
@@ -367,7 +369,7 @@ static int msm_ext_disp_audio_device_get(struct snd_kcontrol *kcontrol,
 				kcontrol->private_value)->shift;
 
 	if (dai_id < 0 || dai_id > DP_DAI2) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: invalid dai id: %d\n", __func__, dai_id);
 		rc = -EINVAL;
 		goto done;
@@ -375,7 +377,7 @@ static int msm_ext_disp_audio_device_get(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: codec_data or ops acknowledge() is NULL\n",
 			__func__);
 		rc = -EINVAL;
@@ -399,7 +401,7 @@ static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol,
 				kcontrol->private_value)->shift;
 
 	if (dai_id < 0 || dai_id > DP_DAI2) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: invalid dai id: %d\n", __func__, dai_id);
 		rc = -EINVAL;
 		goto done;
@@ -407,7 +409,7 @@ static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol,
 
 	codec_data = snd_soc_component_get_drvdata(component);
 	if (!codec_data) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: codec_data or ops acknowledge() is NULL\n",
 			__func__);
 		rc = -EINVAL;
@@ -418,7 +420,7 @@ static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol,
 		(ucontrol->value.integer.value[1] > (DP_STREAM_MAX - 1)) ||
 		(ucontrol->value.integer.value[0] < 0) ||
 		(ucontrol->value.integer.value[1] < 0)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: DP audio control index invalid\n",
 			__func__);
 		rc = -EINVAL;
@@ -516,7 +518,7 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
 	int type;
 
 	if (!codec_data) {
-		dev_err(dai->dev, "%s() codec_data is null\n",
+		dev_err_ratelimited(dai->dev, "%s() codec_data is null\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -535,7 +537,7 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
 						 &codec_info);
 
 	if (!codec_data->ext_disp_ops.cable_status || rc) {
-		dev_err(dai->dev, "%s() cable_status is null\n",
+		dev_err_ratelimited(dai->dev, "%s() cable_status is null\n",
 			__func__);
 		mutex_unlock(&codec_data->dp_ops_lock);
 		return -EINVAL;
@@ -546,12 +548,12 @@ static int msm_ext_disp_audio_codec_rx_dai_startup(
 		codec_data->ext_disp_core_pdev, 1);
 	mutex_unlock(&codec_data->dp_ops_lock);
 	if (codec_data->cable_status[dai->id] < 0) {
-		dev_err(dai->dev,
+		dev_err_ratelimited(dai->dev,
 			"%s() ext disp core is not ready (ret val = %d)\n",
 			__func__, codec_data->cable_status[dai->id]);
 		ret = codec_data->cable_status[dai->id];
 	} else if (!codec_data->cable_status[dai->id]) {
-		dev_err(dai->dev,
+		dev_err_ratelimited(dai->dev,
 			"%s() ext disp cable is not connected (ret val = %d)\n",
 			__func__, codec_data->cable_status[dai->id]);
 		ret = -ENODEV;
@@ -577,7 +579,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
 			dev_get_drvdata(dai->component->dev);
 
 	if (!codec_data) {
-		dev_err(dai->dev, "%s() codec_data is null\n",
+		dev_err_ratelimited(dai->dev, "%s() codec_data is null\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -596,7 +598,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
 						 &codec_info);
 
 	if (!codec_data->ext_disp_ops.audio_info_setup || rc) {
-		dev_err(dai->dev, "%s: audio_info_setup is null\n",
+		dev_err_ratelimited(dai->dev, "%s: audio_info_setup is null\n",
 			__func__);
 		mutex_unlock(&codec_data->dp_ops_lock);
 		return -EINVAL;
@@ -645,7 +647,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params(
 		audio_setup_params.sample_present = 0xf;
 		break;
 	default:
-		dev_err(dai->dev, "invalid Channels = %u\n", num_channels);
+		dev_err_ratelimited(dai->dev, "invalid Channels = %u\n", num_channels);
 		return -EINVAL;
 	}
 
@@ -691,7 +693,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
 	int type;
 
 	if (!codec_data) {
-		dev_err(dai->dev, "%s() codec_data is null\n",
+		dev_err_ratelimited(dai->dev, "%s() codec_data is null\n",
 			__func__);
 		return;
 	}
@@ -711,7 +713,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
 
 	if (!codec_data->ext_disp_ops.teardown_done ||
 	    !codec_data->ext_disp_ops.cable_status || rc) {
-		dev_err(dai->dev, "%s: teardown_done or cable_status is null\n",
+		dev_err_ratelimited(dai->dev, "%s: teardown_done or cable_status is null\n",
 			__func__);
 		mutex_unlock(&codec_data->dp_ops_lock);
 		return;
@@ -720,7 +722,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown(
 	rc = codec_data->ext_disp_ops.cable_status(
 			codec_data->ext_disp_core_pdev, 0);
 	if (rc < 0) {
-		dev_err(dai->dev,
+		dev_err_ratelimited(dai->dev,
 			"%s: ext disp core had problems releasing audio flag\n",
 			__func__);
 	}

+ 13 - 12
asoc/codecs/swr-dmic.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -138,13 +139,13 @@ static int swr_dmic_tx_master_port_get(struct snd_kcontrol *kcontrol,
 	unsigned int slave_port_idx = SWR_DMIC_MAX_PORTS;
 
 	if (NULL == component) {
-		pr_err("%s: swr dmic component is NULL\n", __func__);
+		pr_err_ratelimited("%s: swr dmic component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	swr_dmic = snd_soc_component_get_drvdata(component);
 	if (NULL == swr_dmic) {
-		pr_err("%s: swr_dmic_priv is NULL\n", __func__);
+		pr_err_ratelimited("%s: swr_dmic_priv is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -156,7 +157,7 @@ static int swr_dmic_tx_master_port_get(struct snd_kcontrol *kcontrol,
 	}
 
 	if (slave_port_idx >= SWR_DMIC_MAX_PORTS) {
-		pr_err("%s: invalid slave port id\n", __func__);
+		pr_err_ratelimited("%s: invalid slave port id\n", __func__);
 		return -EINVAL;
 	}
 
@@ -181,13 +182,13 @@ static int swr_dmic_tx_master_port_put(struct snd_kcontrol *kcontrol,
 	unsigned int idx = 0;
 
 	if (NULL == component) {
-		pr_err("%s: swr dmic component is NULL\n", __func__);
+		pr_err_ratelimited("%s: swr dmic component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	swr_dmic = snd_soc_component_get_drvdata(component);
 	if (NULL == swr_dmic) {
-		pr_err("%s: swr_dmic_priv is NULL\n", __func__);
+		pr_err_ratelimited("%s: swr_dmic_priv is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -199,7 +200,7 @@ static int swr_dmic_tx_master_port_put(struct snd_kcontrol *kcontrol,
 	}
 
 	if (slave_port_idx >= SWR_DMIC_MAX_PORTS) {
-		pr_err("%s: invalid slave port id\n", __func__);
+		pr_err_ratelimited("%s: invalid slave port id\n", __func__);
 		return -EINVAL;
 	}
 
@@ -262,7 +263,7 @@ static int dmic_swr_ctrl(struct snd_soc_dapm_widget *w,
 
 	if (port_id >= SWR_DMIC_MAX_PORTS)
 	{
-		dev_err(component->dev, "%s: invalid port id: %d\n",
+		dev_err_ratelimited(component->dev, "%s: invalid port id: %d\n",
 			__func__, port_id);
 		return -EINVAL;
 	}
@@ -518,7 +519,7 @@ static int enable_wcd_codec_supply(struct swr_dmic_priv *swr_dmic, bool enable)
 	struct snd_soc_component *component = swr_dmic->supply_component;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 	dev_dbg(component->dev, "%s: supply %d micbias: %d enable: %d\n",
@@ -785,7 +786,7 @@ static int swr_dmic_up(struct swr_device *pdev)
 
 	swr_dmic = swr_get_dev_data(pdev);
 	if (!swr_dmic) {
-		dev_err(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
+		dev_err_ratelimited(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -803,7 +804,7 @@ static int swr_dmic_down(struct swr_device *pdev)
 
 	swr_dmic = swr_get_dev_data(pdev);
 	if (!swr_dmic) {
-		dev_err(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
+		dev_err_ratelimited(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -831,7 +832,7 @@ static int swr_dmic_reset(struct swr_device *pdev)
 
 	swr_dmic = swr_get_dev_data(pdev);
 	if (!swr_dmic) {
-		dev_err(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
+		dev_err_ratelimited(&pdev->dev, "%s: swr_dmic is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -857,7 +858,7 @@ static int swr_dmic_resume(struct device *dev)
 	struct swr_dmic_priv *swr_dmic = swr_get_dev_data(to_swr_device(dev));
 
 	if (!swr_dmic) {
-		dev_err(dev, "%s: swr_dmic private data is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: swr_dmic private data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	dev_dbg(dev, "%s: system resume\n", __func__);

+ 17 - 16
asoc/codecs/swr-haptics.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/device.h>
@@ -145,14 +146,14 @@ static int swr_hap_enable_hpwr_vreg(struct swr_haptics_dev *swr_hap)
 	rc = regulator_set_voltage(swr_hap->hpwr_vreg,
 			swr_hap->hpwr_voltage_mv * 1000, INT_MAX);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: Set hpwr voltage failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: Set hpwr voltage failed, rc=%d\n",
 				__func__, rc);
 		return rc;
 	}
 
 	rc = regulator_enable(swr_hap->hpwr_vreg);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: Enable hpwr failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: Enable hpwr failed, rc=%d\n",
 				__func__, rc);
 		regulator_set_voltage(swr_hap->hpwr_vreg, 0, INT_MAX);
 		return rc;
@@ -172,14 +173,14 @@ static int swr_hap_disable_hpwr_vreg(struct swr_haptics_dev *swr_hap)
 
 	rc = regulator_disable(swr_hap->hpwr_vreg);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: Disable hpwr failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: Disable hpwr failed, rc=%d\n",
 				__func__, rc);
 		return rc;
 	}
 
 	rc = regulator_set_voltage(swr_hap->hpwr_vreg, 0, INT_MAX);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: Set hpwr voltage failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: Set hpwr voltage failed, rc=%d\n",
 				__func__, rc);
 		return rc;
 	}
@@ -198,7 +199,7 @@ static int swr_haptics_slave_enable(struct swr_haptics_dev *swr_hap)
 
 	rc = regulator_enable(swr_hap->slave_vdd);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: enable swr-slave-vdd failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: enable swr-slave-vdd failed, rc=%d\n",
 				__func__, rc);
 		return rc;
 	}
@@ -217,7 +218,7 @@ static int swr_haptics_slave_disable(struct swr_haptics_dev *swr_hap)
 
 	rc = regulator_disable(swr_hap->slave_vdd);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "%s: disable swr-slave-vdd failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "%s: disable swr-slave-vdd failed, rc=%d\n",
 				__func__, rc);
 		return rc;
 	}
@@ -288,7 +289,7 @@ static int hap_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 
 		rc = regmap_write(swr_hap->regmap, SWR_VMAX_REG, swr_hap->vmax);
 		if (rc) {
-			dev_err(swr_hap->dev, "%s: SWR_VMAX update failed, rc=%d\n",
+			dev_err_ratelimited(swr_hap->dev, "%s: SWR_VMAX update failed, rc=%d\n",
 				__func__, rc);
 			return rc;
 		}
@@ -302,7 +303,7 @@ static int hap_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 	case SND_SOC_DAPM_POST_PMU:
 		rc = swr_hap_enable_hpwr_vreg(swr_hap);
 		if (rc < 0) {
-			dev_err(swr_hap->dev, "%s: Enable hpwr_vreg failed, rc=%d\n",
+			dev_err_ratelimited(swr_hap->dev, "%s: Enable hpwr_vreg failed, rc=%d\n",
 					__func__, rc);
 			return rc;
 		}
@@ -313,7 +314,7 @@ static int hap_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 		val = SWR_PLAY_BIT | SWR_PLAY_SRC_VAL_SWR;
 		rc = regmap_write(swr_hap->regmap, SWR_PLAY_REG, val);
 		if (rc) {
-			dev_err(swr_hap->dev, "%s: Enable SWR_PLAY failed, rc=%d\n",
+			dev_err_ratelimited(swr_hap->dev, "%s: Enable SWR_PLAY failed, rc=%d\n",
 					__func__, rc);
 			swr_slvdev_datapath_control(swr_hap->swr_slave,
 					swr_hap->swr_slave->dev_num, false);
@@ -326,14 +327,14 @@ static int hap_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 		val = 0;
 		rc = regmap_write(swr_hap->regmap, SWR_PLAY_REG, val);
 		if (rc) {
-			dev_err(swr_hap->dev, "%s: Enable SWR_PLAY failed, rc=%d\n",
+			dev_err_ratelimited(swr_hap->dev, "%s: Enable SWR_PLAY failed, rc=%d\n",
 					__func__, rc);
 			return rc;
 		}
 
 		rc = swr_hap_disable_hpwr_vreg(swr_hap);
 		if (rc < 0) {
-			dev_err(swr_hap->dev, "%s: Disable hpwr_vreg failed, rc=%d\n",
+			dev_err_ratelimited(swr_hap->dev, "%s: Disable hpwr_vreg failed, rc=%d\n",
 					__func__, rc);
 			return rc;
 		}
@@ -622,7 +623,7 @@ static int swr_haptics_device_up(struct swr_device *sdev)
 
 	swr_hap = swr_get_dev_data(sdev);
 	if (!swr_hap) {
-		dev_err(&sdev->dev, "%s: no data for swr_hap\n", __func__);
+		dev_err_ratelimited(&sdev->dev, "%s: no data for swr_hap\n", __func__);
 		return -ENODEV;
 	}
 
@@ -639,14 +640,14 @@ static int swr_haptics_device_down(struct swr_device *sdev)
 	int rc;
 
 	if (!swr_hap) {
-		dev_err(&sdev->dev, "%s: no data for swr_hap\n", __func__);
+		dev_err_ratelimited(&sdev->dev, "%s: no data for swr_hap\n", __func__);
 		return -ENODEV;
 	}
 
 	/* Disable HAP_PWR regulator */
 	rc = swr_hap_disable_hpwr_vreg(swr_hap);
 	if (rc < 0) {
-		dev_err(swr_hap->dev, "Disable hpwr_vreg failed, rc=%d\n",
+		dev_err_ratelimited(swr_hap->dev, "Disable hpwr_vreg failed, rc=%d\n",
 				rc);
 		return rc;
 	}
@@ -662,7 +663,7 @@ static int swr_haptics_suspend(struct device *dev)
 
 	swr_hap = swr_get_dev_data(to_swr_device(dev));
 	if (!swr_hap) {
-		dev_err(dev, "%s: no data for swr_hap\n", __func__);
+		dev_err_ratelimited(dev, "%s: no data for swr_hap\n", __func__);
 		return -ENODEV;
 	}
 	trace_printk("%s: suspended\n", __func__);
@@ -677,7 +678,7 @@ static int swr_haptics_resume(struct device *dev)
 
 	swr_hap = swr_get_dev_data(to_swr_device(dev));
 	if (!swr_hap) {
-		dev_err(dev, "%s: no data for swr_hap\n", __func__);
+		dev_err_ratelimited(dev, "%s: no data for swr_hap\n", __func__);
 		return -ENODEV;
 	}
 	trace_printk("%s: resumed\n", __func__);

+ 13 - 12
asoc/codecs/wcd-dsp-utils.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/device.h>
@@ -15,28 +16,28 @@ static bool wdsp_is_valid_elf_hdr(const struct elf32_hdr *ehdr,
 				  size_t fw_size)
 {
 	if (fw_size < sizeof(*ehdr)) {
-		pr_err("%s: Firmware too small\n", __func__);
+		pr_err_ratelimited("%s: Firmware too small\n", __func__);
 		goto elf_check_fail;
 	}
 
 	if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
-		pr_err("%s: Not an ELF file\n", __func__);
+		pr_err_ratelimited("%s: Not an ELF file\n", __func__);
 		goto elf_check_fail;
 	}
 
 	if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
-		pr_err("%s: Not an executable image\n", __func__);
+		pr_err_ratelimited("%s: Not an executable image\n", __func__);
 		goto elf_check_fail;
 	}
 
 	if (ehdr->e_phnum == 0) {
-		pr_err("%s: no segments to load\n", __func__);
+		pr_err_ratelimited("%s: no segments to load\n", __func__);
 		goto elf_check_fail;
 	}
 
 	if (sizeof(struct elf32_phdr) * ehdr->e_phnum +
 	    sizeof(struct elf32_hdr) > fw_size) {
-		pr_err("%s: Too small MDT file\n", __func__);
+		pr_err_ratelimited("%s: Too small MDT file\n", __func__);
 		goto elf_check_fail;
 	}
 
@@ -69,13 +70,13 @@ static int wdsp_add_segment_to_list(struct device *dev,
 		 "%s.b%02d", img_fname, phdr_idx);
 	ret = request_firmware(&seg->split_fw, seg->split_fname, dev);
 	if (ret < 0) {
-		dev_err(dev, "%s: firmware %s not found\n",
+		dev_err_ratelimited(dev, "%s: firmware %s not found\n",
 			__func__, seg->split_fname);
 		goto bad_seg;
 	}
 
 	if (phdr->p_filesz != seg->split_fw->size) {
-		dev_err(dev,
+		dev_err_ratelimited(dev,
 			"%s: %s size mismatch, phdr_size: 0x%x fw_size: 0x%zx",
 			__func__, seg->split_fname, phdr->p_filesz,
 			seg->split_fw->size);
@@ -144,20 +145,20 @@ int wdsp_get_segment_list(struct device *dev,
 
 	if (!dev) {
 		ret = -EINVAL;
-		pr_err("%s: Invalid device handle\n", __func__);
+		pr_err_ratelimited("%s: Invalid device handle\n", __func__);
 		goto done;
 	}
 
 	if (!img_fname || !seg_list || !entry_point) {
 		ret = -EINVAL;
-		dev_err(dev, "%s: Invalid input params\n",
+		dev_err_ratelimited(dev, "%s: Invalid input params\n",
 			__func__);
 		goto done;
 	}
 
 	if (segment_type != WDSP_ELF_FLAG_RE &&
 	    segment_type != WDSP_ELF_FLAG_WRITE) {
-		dev_err(dev, "%s: Invalid request for segment_type %d\n",
+		dev_err_ratelimited(dev, "%s: Invalid request for segment_type %d\n",
 			__func__, segment_type);
 		ret = -EINVAL;
 		goto done;
@@ -166,7 +167,7 @@ int wdsp_get_segment_list(struct device *dev,
 	snprintf(mdt_name, sizeof(mdt_name), "%s.mdt", img_fname);
 	ret = request_firmware(&fw, mdt_name, dev);
 	if (ret < 0) {
-		dev_err(dev, "%s: firmware %s not found\n",
+		dev_err_ratelimited(dev, "%s: firmware %s not found\n",
 			__func__, mdt_name);
 		goto done;
 	}
@@ -174,7 +175,7 @@ int wdsp_get_segment_list(struct device *dev,
 	ehdr = (struct elf32_hdr *) fw->data;
 	*entry_point = ehdr->e_entry;
 	if (!wdsp_is_valid_elf_hdr(ehdr, fw->size)) {
-		dev_err(dev, "%s: fw mdt %s is invalid\n",
+		dev_err_ratelimited(dev, "%s: fw mdt %s is invalid\n",
 			__func__, mdt_name);
 		ret = -EINVAL;
 		goto bad_elf;

+ 15 - 14
asoc/codecs/wcd938x/wcd938x-mbhc.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 #include <linux/module.h>
 #include <linux/init.h>
@@ -223,7 +224,7 @@ static void wcd938x_mbhc_program_btn_thr(struct snd_soc_component *component,
 	int vth;
 
 	if (num_btn > WCD_MBHC_DEF_BUTTONS) {
-		dev_err(component->dev, "%s: invalid number of buttons: %d\n",
+		dev_err_ratelimited(component->dev, "%s: invalid number of buttons: %d\n",
 			__func__, num_btn);
 		return;
 	}
@@ -336,12 +337,12 @@ static struct firmware_cal *wcd938x_get_hwdep_fw_cal(struct wcd_mbhc *mbhc,
 	wcd938x_mbhc = container_of(mbhc, struct wcd938x_mbhc, wcd_mbhc);
 
 	if (!component) {
-		pr_err("%s: NULL component pointer\n", __func__);
+		pr_err_ratelimited("%s: NULL component pointer\n", __func__);
 		return NULL;
 	}
 	hwdep_cal = wcdcal_get_fw_cal(wcd938x_mbhc->fw_data, type);
 	if (!hwdep_cal)
-		dev_err(component->dev, "%s: cal not sent by %d\n",
+		dev_err_ratelimited(component->dev, "%s: cal not sent by %d\n",
 			__func__, type);
 
 	return hwdep_cal;
@@ -848,7 +849,7 @@ static int wcd938x_get_hph_type(struct snd_kcontrol *kcontrol,
 	struct wcd_mbhc *mbhc;
 
 	if (!wcd938x_mbhc) {
-		dev_err(component->dev, "%s: mbhc not initialized!\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: mbhc not initialized!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -871,7 +872,7 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol,
 	struct wcd938x_mbhc *wcd938x_mbhc = wcd938x_soc_get_mbhc(component);
 
 	if (!wcd938x_mbhc) {
-		dev_err(component->dev, "%s: mbhc not initialized!\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: mbhc not initialized!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -908,11 +909,11 @@ int wcd938x_mbhc_get_impedance(struct wcd938x_mbhc *wcd938x_mbhc,
 			     uint32_t *zl, uint32_t *zr)
 {
 	if (!wcd938x_mbhc) {
-		pr_err("%s: mbhc not initialized!\n", __func__);
+		pr_err_ratelimited("%s: mbhc not initialized!\n", __func__);
 		return -EINVAL;
 	}
 	if (!zl || !zr) {
-		pr_err("%s: zl or zr null!\n", __func__);
+		pr_err_ratelimited("%s: zl or zr null!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -933,19 +934,19 @@ int wcd938x_mbhc_hs_detect(struct snd_soc_component *component,
 	struct wcd938x_mbhc *wcd938x_mbhc = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	wcd938x = snd_soc_component_get_drvdata(component);
 	if (!wcd938x) {
-		pr_err("%s: wcd938x is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	wcd938x_mbhc = wcd938x->mbhc;
 	if (!wcd938x_mbhc) {
-		dev_err(component->dev, "%s: mbhc not initialized!\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: mbhc not initialized!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -963,19 +964,19 @@ void wcd938x_mbhc_hs_detect_exit(struct snd_soc_component *component)
 	struct wcd938x_mbhc *wcd938x_mbhc = NULL;
 
 	if (!component) {
-		pr_err("%s: component is NULL\n", __func__);
+		pr_err_ratelimited("%s: component is NULL\n", __func__);
 		return;
 	}
 
 	wcd938x = snd_soc_component_get_drvdata(component);
 	if (!wcd938x) {
-		pr_err("%s: wcd938x is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x is NULL\n", __func__);
 		return;
 	}
 
 	wcd938x_mbhc = wcd938x->mbhc;
 	if (!wcd938x_mbhc) {
-		dev_err(component->dev, "%s: mbhc not initialized!\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: mbhc not initialized!\n", __func__);
 		return;
 	}
 	wcd_mbhc_stop(&wcd938x_mbhc->wcd_mbhc);
@@ -998,7 +999,7 @@ void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc,
 
 	wcd_mbhc = &mbhc->wcd_mbhc;
 	if (!wcd_mbhc) {
-		dev_err(component->dev, "%s: wcd_mbhc is NULL\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: wcd_mbhc is NULL\n", __func__);
 		return;
 	}
 

+ 6 - 5
asoc/codecs/wcd938x/wcd938x-slave.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -119,7 +120,7 @@ static ssize_t wcd938x_swrslave_reg_show(struct swr_device *pdev,
 		if (((total + len) >= count - 1) || (len < 0))
 			break;
 		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
+			pr_err_ratelimited("%s: fail to copy reg dump\n", __func__);
 			total = -EFAULT;
 			goto copy_err;
 		}
@@ -216,7 +217,7 @@ static ssize_t codec_debug_peek_write(struct file *file,
 	if (rc == 0)
 		rc = cnt;
 	else
-		pr_err("%s: rc = %d\n", __func__, rc);
+		pr_err_ratelimited("%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -252,7 +253,7 @@ static ssize_t codec_debug_write(struct file *file,
 	if (rc == 0)
 		rc = cnt;
 	else
-		pr_err("%s: rc = %d\n", __func__, rc);
+		pr_err_ratelimited("%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -283,7 +284,7 @@ static int wcd938x_slave_bind(struct device *dev,
 	int retry = SWR_MAX_RETRY;
 
 	if (!pdev) {
-		pr_err("%s: invalid swr device handle\n", __func__);
+		pr_err_ratelimited("%s: invalid swr device handle\n", __func__);
 		return -EINVAL;
 	}
 
@@ -313,7 +314,7 @@ static void wcd938x_slave_unbind(struct device *dev,
 
 	wcd938x_slave = swr_get_dev_data(pdev);
 	if (!wcd938x_slave) {
-		dev_err(&pdev->dev, "%s: wcd938x_slave is NULL\n", __func__);
+		dev_err_ratelimited(&pdev->dev, "%s: wcd938x_slave is NULL\n", __func__);
 		return;
 	}
 }

+ 53 - 52
asoc/codecs/wcd938x/wcd938x.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -317,7 +318,7 @@ static int wcd938x_set_port_params(struct snd_soc_component *component,
 		num_ports = wcd938x->num_tx_ports;
 		break;
 	default:
-		dev_err(component->dev, "%s Invalid path selected %u\n",
+		dev_err_ratelimited(component->dev, "%s Invalid path selected %u\n",
 					__func__, path);
 		return -EINVAL;
 	}
@@ -330,7 +331,7 @@ static int wcd938x_set_port_params(struct snd_soc_component *component,
 	}
 found:
 	if (i > num_ports || j == MAX_CH_PER_PORT) {
-		dev_err(component->dev, "%s Failed to find slave port for type %u\n",
+		dev_err_ratelimited(component->dev, "%s Failed to find slave port for type %u\n",
 						__func__, slv_prt_type);
 		return -EINVAL;
 	}
@@ -615,13 +616,13 @@ struct wcd938x_mbhc *wcd938x_soc_get_mbhc(struct snd_soc_component *component)
 	struct wcd938x_priv *wcd938x;
 
 	if (!component) {
-		pr_err("%s: Invalid params, NULL component\n", __func__);
+		pr_err_ratelimited("%s: Invalid params, NULL component\n", __func__);
 		return NULL;
 	}
 	wcd938x = snd_soc_component_get_drvdata(component);
 
 	if (!wcd938x) {
-		pr_err("%s: wcd938x is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x is NULL\n", __func__);
 		return NULL;
 	}
 
@@ -1457,7 +1458,7 @@ static int wcd938x_codec_enable_dmic(struct snd_soc_dapm_widget *w,
 		dmic_ctl_shift = 0x03;
 		break;
 	default:
-		dev_err(component->dev, "%s: Invalid DMIC Selection\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
 			__func__);
 		return -EINVAL;
 	};
@@ -1514,7 +1515,7 @@ int wcd938x_get_micb_vout_ctl_val(u32 micb_mv)
 {
 	/* min micbias voltage is 1V and maximum is 2.85V */
 	if (micb_mv < 1000 || micb_mv > 2850) {
-		pr_err("%s: unsupported micbias voltage\n", __func__);
+		pr_err_ratelimited("%s: unsupported micbias voltage\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1729,7 +1730,7 @@ static int wcd938x_get_adc_mode(int val)
 		break;
 	default:
 		ret = -EINVAL;
-		pr_err("%s: invalid ADC mode value %d\n", __func__, val);
+		pr_err_ratelimited("%s: invalid ADC mode value %d\n", __func__, val);
 		break;
 	}
 	return ret;
@@ -1759,7 +1760,7 @@ int wcd938x_tx_channel_config(struct snd_soc_component *component,
 		mask = 0x20;
 		break;
 	default:
-		pr_err("%s: Invalid channel num %d\n", __func__, channel);
+		pr_err_ratelimited("%s: Invalid channel num %d\n", __func__, channel);
 		ret = -EINVAL;
 		break;
 	}
@@ -1885,7 +1886,7 @@ static int wcd938x_enable_req(struct snd_soc_dapm_widget *w,
 		ret = wcd938x_tx_channel_config(component, w->shift, 1);
 		mode = wcd938x_get_adc_mode(wcd938x->tx_mode[w->shift]);
 		if (mode < 0) {
-			dev_info(component->dev,
+			dev_info_ratelimited(component->dev,
 				 "%s: invalid mode, setting to normal mode\n",
 				 __func__);
 			mode = ADC_MODE_VAL_NORMAL;
@@ -1981,14 +1982,14 @@ int wcd938x_micbias_control(struct snd_soc_component *component,
 	int ret = 0;
 
 	if ((micb_index < 0) || (micb_index > WCD938X_MAX_MICBIAS - 1)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: Invalid micbias index, micb_ind:%d\n",
 			__func__, micb_index);
 		return -EINVAL;
 	}
 
 	if (NULL == wcd938x) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: wcd938x private data is NULL\n", __func__);
 		return -EINVAL;
 	}
@@ -2012,7 +2013,7 @@ int wcd938x_micbias_control(struct snd_soc_component *component,
 		micb_reg = WCD938X_ANA_MICB4;
 		break;
 	default:
-		dev_err(component->dev, "%s: Invalid micbias number: %d\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid micbias number: %d\n",
 			__func__, micb_num);
 		return -EINVAL;
 	};
@@ -2141,7 +2142,7 @@ static int wcd938x_get_logical_addr(struct swr_device *swr_dev)
 	} while (ret && --num_retry);
 
 	if (ret)
-		dev_err(&swr_dev->dev,
+		dev_err_ratelimited(&swr_dev->dev,
 			"%s get devnum %d for dev addr %llx failed\n",
 			__func__, devnum, swr_dev->addr);
 
@@ -2166,7 +2167,7 @@ int wcd938x_swr_dmic_register_notifier(struct snd_soc_component *component,
 {
 	struct wcd938x_priv *wcd938x_priv;
 	if(NULL == component) {
-		pr_err("%s: wcd938x component is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2254,7 +2255,7 @@ static int wcd938x_event_notify(struct notifier_block *block,
 		mbhc = &wcd938x->mbhc->wcd_mbhc;
 		ret = wcd938x_mbhc_post_ssr_init(wcd938x->mbhc, component);
 		if (ret) {
-			dev_err(component->dev, "%s: mbhc initialization failed\n",
+			dev_err_ratelimited(component->dev, "%s: mbhc initialization failed\n",
 				__func__);
 		} else {
 			wcd938x_mbhc_hs_detect(component, mbhc->mbhc_cfg);
@@ -2378,12 +2379,12 @@ static int wcd938x_wakeup(void *handle, bool enable)
 	int ret = 0;
 
 	if (!handle) {
-		pr_err("%s: NULL handle\n", __func__);
+		pr_err_ratelimited("%s: NULL handle\n", __func__);
 		return -EINVAL;
 	}
 	priv = (struct wcd938x_priv *)handle;
 	if (!priv->tx_swr_dev) {
-		pr_err("%s: tx swr dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: tx swr dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 	mutex_lock(&priv->wakeup_lock);
@@ -2428,7 +2429,7 @@ static int wcd938x_enable_micbias(struct wcd938x_priv *wcd938x,
 	u16 micb_reg;
 
 	if (NULL == wcd938x) {
-		pr_err("%s: wcd938x private data is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x private data is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2446,7 +2447,7 @@ static int wcd938x_enable_micbias(struct wcd938x_priv *wcd938x,
 		micb_reg = WCD938X_ANA_MICB4;
 		break;
 	default:
-		pr_err("%s: Invalid micbias number: %d\n", __func__, micb_num);
+		pr_err_ratelimited("%s: Invalid micbias number: %d\n", __func__, micb_num);
 		return -EINVAL;
 	};
 
@@ -2521,15 +2522,15 @@ int wcd938x_codec_force_enable_micbias_v2(struct snd_soc_component *component,
 	int micb_index = micb_num - 1;
 
 	if(NULL == component) {
-		pr_err("%s: wcd938x component is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x component is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if(event != SND_SOC_DAPM_PRE_PMU && event != SND_SOC_DAPM_POST_PMD) {
-		pr_err("%s: invalid event: %d\n", __func__, event);
+		pr_err_ratelimited("%s: invalid event: %d\n", __func__, event);
 		return -EINVAL;
 	}
 	if(micb_num < MIC_BIAS_1 || micb_num > MIC_BIAS_4) {
-		pr_err("%s: invalid mic bias num: %d\n", __func__, micb_num);
+		pr_err_ratelimited("%s: invalid mic bias num: %d\n", __func__, micb_num);
 		return -EINVAL;
 	}
 
@@ -2579,21 +2580,21 @@ static inline int wcd938x_tx_path_get(const char *wname,
 
 	path_name = strsep(&widget_name, " ");
 	if (!path_name) {
-		pr_err("%s: Invalid widget name = %s\n",
+		pr_err_ratelimited("%s: Invalid widget name = %s\n",
 			__func__, widget_name);
 		ret = -EINVAL;
 		goto err;
 	}
 	path_num_char = strpbrk(path_name, "0123");
 	if (!path_num_char) {
-		pr_err("%s: tx path index not found\n",
+		pr_err_ratelimited("%s: tx path index not found\n",
 			__func__);
 		ret = -EINVAL;
 		goto err;
 	}
 	ret = kstrtouint(path_num_char, 10, path_num);
 	if (ret < 0)
-		pr_err("%s: Invalid tx path = %s\n",
+		pr_err_ratelimited("%s: Invalid tx path = %s\n",
 			__func__, w_name);
 
 err:
@@ -2681,14 +2682,14 @@ static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
 
 	if (wcd938x->variant == WCD9380) {
 		if (mode_val == CLS_H_HIFI || mode_val == CLS_AB_HIFI) {
-			dev_info(component->dev,
+			dev_info_ratelimited(component->dev,
 				"%s:Invalid HPH Mode, default to CLS_H_ULP\n",
 				__func__);
 			mode_val = CLS_H_ULP;
 		}
 	}
 	if (mode_val == CLS_H_NORMAL) {
-		dev_info(component->dev,
+		dev_info_ratelimited(component->dev,
 			"%s:Invalid HPH Mode, default to class_AB\n",
 			__func__);
 		mode_val = CLS_H_ULP;
@@ -2754,7 +2755,7 @@ int wcd938x_codec_get_dev_num(struct snd_soc_component *component)
 
 	wcd938x = snd_soc_component_get_drvdata(component);
 	if (!wcd938x || !wcd938x->rx_swr_dev) {
-		pr_err("%s: wcd938x component is NULL\n", __func__);
+		pr_err_ratelimited("%s: wcd938x component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2813,7 +2814,7 @@ static int wcd938x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w,
 	pdata = dev_get_platdata(wcd938x->dev);
 
 	if (!pdata) {
-		dev_err(component->dev, "%s: pdata is NULL\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: pdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -2842,7 +2843,7 @@ static int wcd938x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w,
 						pdata->num_supplies,
 						"cdc-vdd-buck");
 		if (ret == -EINVAL) {
-			dev_err(component->dev, "%s: vdd buck is not enabled\n",
+			dev_err_ratelimited(component->dev, "%s: vdd buck is not enabled\n",
 				__func__);
 			return ret;
 		}
@@ -2927,7 +2928,7 @@ static void wcd938x_tx_get_slave_ch_type_idx(const char *wname, int *ch_idx)
 	else if (strnstr(wname, "DMIC7", sizeof("DMIC7")))
 		ch_type = DMIC7;
 	else
-		pr_err("%s: port name: %s is not listed\n", __func__, wname);
+		pr_err_ratelimited("%s: port name: %s is not listed\n", __func__, wname);
 
 	if (ch_type)
 		*ch_idx = wcd938x_slave_get_slave_ch_val(ch_type);
@@ -3759,7 +3760,7 @@ static ssize_t wcd938x_version_read(struct snd_info_entry *entry,
 
 	priv = (struct wcd938x_priv *) entry->private_data;
 	if (!priv) {
-		pr_err("%s: wcd938x priv is null\n", __func__);
+		pr_err_ratelimited("%s: wcd938x priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -3790,7 +3791,7 @@ static ssize_t wcd938x_variant_read(struct snd_info_entry *entry,
 
 	priv = (struct wcd938x_priv *) entry->private_data;
 	if (!priv) {
-		pr_err("%s: wcd938x priv is null\n", __func__);
+		pr_err_ratelimited("%s: wcd938x priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -4145,7 +4146,7 @@ static int wcd938x_reset(struct device *dev)
 		return -EINVAL;
 
 	if (!wcd938x->rst_np) {
-		dev_err(dev, "%s: reset gpio device node not specified\n",
+		dev_err_ratelimited(dev, "%s: reset gpio device node not specified\n",
 				__func__);
 		return -EINVAL;
 	}
@@ -4156,7 +4157,7 @@ static int wcd938x_reset(struct device *dev)
 
 	rc = msm_cdc_pinctrl_select_sleep_state(wcd938x->rst_np);
 	if (rc) {
-		dev_err(dev, "%s: wcd sleep state request fail!\n",
+		dev_err_ratelimited(dev, "%s: wcd sleep state request fail!\n",
 				__func__);
 		return rc;
 	}
@@ -4165,7 +4166,7 @@ static int wcd938x_reset(struct device *dev)
 
 	rc = msm_cdc_pinctrl_select_active_state(wcd938x->rst_np);
 	if (rc) {
-		dev_err(dev, "%s: wcd active state request fail!\n",
+		dev_err_ratelimited(dev, "%s: wcd active state request fail!\n",
 				__func__);
 		return rc;
 	}
@@ -4260,14 +4261,14 @@ static int wcd938x_reset_low(struct device *dev)
 		return -EINVAL;
 
 	if (!wcd938x->rst_np) {
-		dev_err(dev, "%s: reset gpio device node not specified\n",
+		dev_err_ratelimited(dev, "%s: reset gpio device node not specified\n",
 				__func__);
 		return -EINVAL;
 	}
 
 	rc = msm_cdc_pinctrl_select_sleep_state(wcd938x->rst_np);
 	if (rc) {
-		dev_err(dev, "%s: wcd sleep state request fail!\n",
+		dev_err_ratelimited(dev, "%s: wcd sleep state request fail!\n",
 				__func__);
 		return rc;
 	}
@@ -4290,7 +4291,7 @@ struct wcd938x_pdata *wcd938x_populate_dt_data(struct device *dev)
 			"qcom,wcd-rst-gpio-node", 0);
 
 	if (!pdata->rst_np) {
-		dev_err(dev, "%s: Looking up %s property in node %s failed\n",
+		dev_err_ratelimited(dev, "%s: Looking up %s property in node %s failed\n",
 				__func__, "qcom,wcd-rst-gpio-node",
 				dev->of_node->full_name);
 		return NULL;
@@ -4300,7 +4301,7 @@ struct wcd938x_pdata *wcd938x_populate_dt_data(struct device *dev)
 	msm_cdc_get_power_supplies(dev, &pdata->regulator,
 				   &pdata->num_supplies);
 	if (!pdata->regulator || (pdata->num_supplies <= 0)) {
-		dev_err(dev, "%s: no power supplies defined for codec\n",
+		dev_err_ratelimited(dev, "%s: no power supplies defined for codec\n",
 			__func__);
 		return NULL;
 	}
@@ -4359,14 +4360,14 @@ static int wcd938x_bind(struct device *dev)
 
 	ret = component_bind_all(dev, wcd938x);
 	if (ret) {
-		dev_err(dev, "%s: Slave bind failed, ret = %d\n",
+		dev_err_ratelimited(dev, "%s: Slave bind failed, ret = %d\n",
 			__func__, ret);
 		return ret;
 	}
 
 	wcd938x->rx_swr_dev = get_matching_swr_slave_device(pdata->rx_slave);
 	if (!wcd938x->rx_swr_dev) {
-		dev_err(dev, "%s: Could not find RX swr slave device\n",
+		dev_err_ratelimited(dev, "%s: Could not find RX swr slave device\n",
 			 __func__);
 		ret = -ENODEV;
 		goto err;
@@ -4374,7 +4375,7 @@ static int wcd938x_bind(struct device *dev)
 
 	wcd938x->tx_swr_dev = get_matching_swr_slave_device(pdata->tx_slave);
 	if (!wcd938x->tx_swr_dev) {
-		dev_err(dev, "%s: Could not find TX swr slave device\n",
+		dev_err_ratelimited(dev, "%s: Could not find TX swr slave device\n",
 			__func__);
 		ret = -ENODEV;
 		goto err;
@@ -4385,7 +4386,7 @@ static int wcd938x_bind(struct device *dev)
 	wcd938x->regmap = devm_regmap_init_swr(wcd938x->tx_swr_dev,
 					       &wcd938x_regmap_config);
 	if (!wcd938x->regmap) {
-		dev_err(dev, "%s: Regmap init failed\n",
+		dev_err_ratelimited(dev, "%s: Regmap init failed\n",
 				__func__);
 		goto err;
 	}
@@ -4403,7 +4404,7 @@ static int wcd938x_bind(struct device *dev)
 	ret = wcd_irq_init(&wcd938x->irq_info, &wcd938x->virq);
 
 	if (ret) {
-		dev_err(wcd938x->dev, "%s: IRQ init failed: %d\n",
+		dev_err_ratelimited(wcd938x->dev, "%s: IRQ init failed: %d\n",
 			__func__, ret);
 		goto err;
 	}
@@ -4411,7 +4412,7 @@ static int wcd938x_bind(struct device *dev)
 
 	ret = wcd938x_set_micbias_data(wcd938x, pdata);
 	if (ret < 0) {
-		dev_err(dev, "%s: bad micbias pdata\n", __func__);
+		dev_err_ratelimited(dev, "%s: bad micbias pdata\n", __func__);
 		goto err_irq;
 	}
 
@@ -4430,7 +4431,7 @@ static int wcd938x_bind(struct device *dev)
 	ret = snd_soc_register_component(dev, &soc_codec_dev_wcd938x,
 					wcd938x_dai, ARRAY_SIZE(wcd938x_dai));
 	if (ret) {
-		dev_err(dev, "%s: Codec registration failed\n",
+		dev_err_ratelimited(dev, "%s: Codec registration failed\n",
 				__func__);
 		goto err_irq;
 	}
@@ -4485,7 +4486,7 @@ static int wcd938x_add_slave_components(struct device *dev,
 
 	rx_node = of_parse_phandle(np, "qcom,rx-slave", 0);
 	if (!rx_node) {
-		dev_err(dev, "%s: Rx-slave node not defined\n", __func__);
+		dev_err_ratelimited(dev, "%s: Rx-slave node not defined\n", __func__);
 		return -ENODEV;
 	}
 	of_node_get(rx_node);
@@ -4496,7 +4497,7 @@ static int wcd938x_add_slave_components(struct device *dev,
 
 	tx_node = of_parse_phandle(np, "qcom,tx-slave", 0);
 	if (!tx_node) {
-		dev_err(dev, "%s: Tx-slave node not defined\n", __func__);
+		dev_err_ratelimited(dev, "%s: Tx-slave node not defined\n", __func__);
 			return -ENODEV;
 	}
 	of_node_get(tx_node);
@@ -4640,7 +4641,7 @@ static int wcd938x_suspend(struct device *dev)
 	pdata = dev_get_platdata(wcd938x->dev);
 
 	if (!pdata) {
-		dev_err(dev, "%s: pdata is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: pdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -4651,7 +4652,7 @@ static int wcd938x_suspend(struct device *dev)
 						pdata->num_supplies,
 						"cdc-vdd-buck");
 		if (ret == -EINVAL) {
-			dev_err(dev, "%s: vdd buck is not disabled\n",
+			dev_err_ratelimited(dev, "%s: vdd buck is not disabled\n",
 				__func__);
 			return 0;
 		}
@@ -4683,7 +4684,7 @@ static int wcd938x_resume(struct device *dev)
 	pdata = dev_get_platdata(wcd938x->dev);
 
 	if (!pdata) {
-		dev_err(dev, "%s: pdata is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: pdata is NULL\n", __func__);
 		return -EINVAL;
 	}
 

+ 10 - 9
asoc/codecs/wcd9xxx-common-v2.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2015-2018, 2020-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -744,7 +745,7 @@ static void wcd_clsh_state_lo(struct snd_soc_component *component,
 		is_enable ? "enable" : "disable");
 
 	if (mode != CLS_AB && mode != CLS_AB_HIFI) {
-		dev_err(component->dev, "%s: LO cannot be in this mode: %d\n",
+		dev_err_ratelimited(component->dev, "%s: LO cannot be in this mode: %d\n",
 			__func__, mode);
 		return;
 	}
@@ -1090,7 +1091,7 @@ static void wcd_clsh_state_hph_r(struct snd_soc_component *component,
 		is_enable ? "enable" : "disable");
 
 	if (mode == CLS_H_NORMAL) {
-		dev_err(component->dev, "%s: Normal mode not applicable for hph_r\n",
+		dev_err_ratelimited(component->dev, "%s: Normal mode not applicable for hph_r\n",
 			__func__);
 		return;
 	}
@@ -1151,7 +1152,7 @@ static void wcd_clsh_state_hph_l(struct snd_soc_component *component,
 		is_enable ? "enable" : "disable");
 
 	if (mode == CLS_H_NORMAL) {
-		dev_err(component->dev, "%s: Normal mode not applicable for hph_l\n",
+		dev_err_ratelimited(component->dev, "%s: Normal mode not applicable for hph_l\n",
 			__func__);
 		return;
 	}
@@ -1212,7 +1213,7 @@ static void wcd_clsh_state_ear(struct snd_soc_component *component,
 		is_enable ? "enable" : "disable");
 
 	if (mode != CLS_H_NORMAL) {
-		dev_err(component->dev, "%s: mode: %s cannot be used for EAR\n",
+		dev_err_ratelimited(component->dev, "%s: mode: %s cannot be used for EAR\n",
 			__func__, mode_to_str(mode));
 		return;
 	}
@@ -1245,7 +1246,7 @@ static void wcd_clsh_state_err(struct snd_soc_component *component,
 {
 	char msg[128];
 
-	dev_err(component->dev,
+	dev_err_ratelimited(component->dev,
 		"%s Wrong request for class H state machine requested to %s %s",
 		__func__, is_enable ? "enable" : "disable",
 		state_to_str(req_state, msg, sizeof(msg)));
@@ -1303,14 +1304,14 @@ void wcd_clsh_fsm(struct snd_soc_component *component,
 		new_state = old_state | req_state;
 
 		if (!wcd_clsh_is_state_valid(new_state)) {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: Class-H not a valid new state: %s\n",
 				__func__,
 				state_to_str(new_state, msg0, sizeof(msg0)));
 			return;
 		}
 		if (new_state == old_state) {
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: Class-H already in requested state: %s\n",
 				__func__,
 				state_to_str(new_state, msg0, sizeof(msg0)));
@@ -1330,7 +1331,7 @@ void wcd_clsh_fsm(struct snd_soc_component *component,
 		new_state = old_state & (~req_state);
 		if (new_state < NUM_CLSH_STATES_V2) {
 			if (!wcd_clsh_is_state_valid(old_state)) {
-				dev_err(component->dev,
+				dev_err_ratelimited(component->dev,
 					"%s:Invalid old state:%s\n",
 					__func__,
 					state_to_str(old_state, msg0,
@@ -1338,7 +1339,7 @@ void wcd_clsh_fsm(struct snd_soc_component *component,
 				return;
 			}
 			if (new_state == old_state) {
-				dev_err(component->dev,
+				dev_err_ratelimited(component->dev,
 					"%s: Class-H already in requested state: %s\n",
 					__func__,
 					state_to_str(new_state, msg0,

+ 16 - 16
asoc/codecs/wsa884x/wsa884x.c

@@ -315,14 +315,14 @@ static ssize_t swr_slave_reg_show(struct swr_device *pdev, char __user *ubuf,
 		len = snprintf(tmp_buf, sizeof(tmp_buf), "0x%.3x: 0x%.2x\n", i,
 			       (reg_val & 0xFF));
 		if (len < 0) {
-			pr_err("%s: fail to fill the buffer\n", __func__);
+			pr_err_ratelimited("%s: fail to fill the buffer\n", __func__);
 			total = -EFAULT;
 			goto copy_err;
 		}
 		if ((total + len) >= count - 1)
 			break;
 		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
+			pr_err_ratelimited("%s: fail to copy reg dump\n", __func__);
 			total = -EFAULT;
 			goto copy_err;
 		}
@@ -419,7 +419,7 @@ static ssize_t codec_debug_peek_write(struct file *file,
 	if (rc == 0)
 		rc = cnt;
 	else
-		pr_err("%s: rc = %d\n", __func__, rc);
+		pr_err_ratelimited("%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -455,7 +455,7 @@ static ssize_t codec_debug_write(struct file *file,
 	if (rc == 0)
 		rc = cnt;
 	else
-		pr_err("%s: rc = %d\n", __func__, rc);
+		pr_err_ratelimited("%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -884,7 +884,7 @@ static ssize_t wsa884x_codec_version_read(struct snd_info_entry *entry,
 
 	wsa884x = (struct wsa884x_priv *) entry->private_data;
 	if (!wsa884x) {
-		pr_err("%s: wsa884x priv is null\n", __func__);
+		pr_err_ratelimited("%s: wsa884x priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -916,7 +916,7 @@ static ssize_t wsa884x_variant_read(struct snd_info_entry *entry,
 
 	wsa884x = (struct wsa884x_priv *) entry->private_data;
 	if (!wsa884x) {
-		pr_err("%s: wsa884x priv is null\n", __func__);
+		pr_err_ratelimited("%s: wsa884x priv is null\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1056,7 +1056,7 @@ int wsa884x_codec_get_dev_num(struct snd_soc_component *component)
 
 	wsa884x = snd_soc_component_get_drvdata(component);
 	if (!wsa884x) {
-		pr_err("%s: wsa884x component is NULL\n", __func__);
+		pr_err_ratelimited("%s: wsa884x component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1076,7 +1076,7 @@ static int wsa884x_get_dev_num(struct snd_kcontrol *kcontrol,
 
 	wsa884x = snd_soc_component_get_drvdata(component);
 	if (!wsa884x) {
-		pr_err("%s: wsa884x component is NULL\n", __func__);
+		pr_err_ratelimited("%s: wsa884x component is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1349,7 +1349,7 @@ static int wsa884x_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 		break;
 	case SND_SOC_DAPM_POST_PMD:
 		if (swr_set_device_group(wsa884x->swr_slave, SWR_GROUP_NONE))
-			dev_err(component->dev,
+			dev_err_ratelimited(component->dev,
 				"%s: set num ch failed\n", __func__);
 
 		swr_slvdev_datapath_control(wsa884x->swr_slave,
@@ -1467,7 +1467,7 @@ int wsa884x_set_channel_map(struct snd_soc_component *component, u8 *port,
 
 	if (!port || !ch_mask || !ch_rate ||
 		(num_port > WSA884X_MAX_SWR_PORTS)) {
-		dev_err(component->dev,
+		dev_err_ratelimited(component->dev,
 			"%s: Invalid port=%pK, ch_mask=%pK, ch_rate=%pK\n",
 			__func__, port, ch_mask, ch_rate);
 		return -EINVAL;
@@ -1510,7 +1510,7 @@ static int32_t wsa884x_temp_reg_read(struct snd_soc_component *component,
 	struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component);
 
 	if (!wsa884x) {
-		dev_err(component->dev, "%s: wsa884x is NULL\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: wsa884x is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -1571,7 +1571,7 @@ static int wsa884x_get_temperature(struct snd_soc_component *component,
 	do {
 		ret = wsa884x_temp_reg_read(component, &reg);
 		if (ret) {
-			pr_err("%s: temp read failed: %d, current temp: %d\n",
+			pr_err_ratelimited("%s: temp read failed: %d, current temp: %d\n",
 				__func__, ret, wsa884x->curr_temp);
 			if (temp)
 				*temp = wsa884x->curr_temp;
@@ -1736,7 +1736,7 @@ static int wsa884x_gpio_ctrl(struct wsa884x_priv *wsa884x, bool enable)
 		ret = msm_cdc_pinctrl_select_sleep_state(
 						wsa884x->wsa_rst_np);
 	if (ret != 0)
-		dev_err(wsa884x->dev,
+		dev_err_ratelimited(wsa884x->dev,
 			"%s: Failed to turn state %d; ret=%d\n",
 			__func__, enable, ret);
 
@@ -1749,7 +1749,7 @@ static int wsa884x_swr_up(struct wsa884x_priv *wsa884x)
 
 	ret = wsa884x_gpio_ctrl(wsa884x, true);
 	if (ret)
-		dev_err(wsa884x->dev, "%s: Failed to enable gpio\n", __func__);
+		dev_err_ratelimited(wsa884x->dev, "%s: Failed to enable gpio\n", __func__);
 
 	return ret;
 }
@@ -1760,7 +1760,7 @@ static int wsa884x_swr_down(struct wsa884x_priv *wsa884x)
 
 	ret = wsa884x_gpio_ctrl(wsa884x, false);
 	if (ret)
-		dev_err(wsa884x->dev, "%s: Failed to disable gpio\n", __func__);
+		dev_err_ratelimited(wsa884x->dev, "%s: Failed to disable gpio\n", __func__);
 
 	return ret;
 }
@@ -2369,7 +2369,7 @@ static int wsa884x_swr_suspend(struct device *dev)
 	struct wsa884x_priv *wsa884x = swr_get_dev_data(to_swr_device(dev));
 
 	if (!wsa884x) {
-		dev_err(dev, "%s: wsa884x private data is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: wsa884x private data is NULL\n", __func__);
 		return -EINVAL;
 	}
 	dev_dbg(dev, "%s: system suspend\n", __func__);

+ 24 - 22
asoc/kalama.c

@@ -184,24 +184,24 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 	struct msm_asoc_mach_data *pdata = NULL;
 
 	if (!rtd) {
-		pr_err("%s: rtd is NULL\n", __func__);
+		pr_err_ratelimited("%s: rtd is NULL\n", __func__);
 		return;
 	}
 
 	pdata = snd_soc_card_get_drvdata(rtd->card);
 	if (!pdata) {
-		pr_err("%s: pdata is NULL\n", __func__);
+		pr_err_ratelimited("%s: pdata is NULL\n", __func__);
 		return;
 	}
 	if (!pdata->get_dev_num) {
-		pr_err("%s: get_dev_num is NULL\n", __func__);
+		pr_err_ratelimited("%s: get_dev_num is NULL\n", __func__);
 		return;
 	}
 
 	if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
 		!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
                 !pdata->upd_config.ear_pa_pkd_reg_addr) {
-		pr_err("%s: upd static configuration is not set\n", __func__);
+		pr_err_ratelimited("%s: upd static configuration is not set\n", __func__);
 		return;
 	}
 
@@ -215,14 +215,14 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 
 	component = snd_soc_rtdcom_lookup(rtd, cdc_name);
 	if (!component) {
-		pr_err("%s: %s component is NULL\n", __func__,
+		pr_err_ratelimited("%s: %s component is NULL\n", __func__,
 			cdc_name);
 		return;
 	}
 
 	dev_num = pdata->get_dev_num(component);
 	if (dev_num < 0 || dev_num > 6) {
-		pr_err("%s: invalid slave dev num : %d\n", __func__,
+		pr_err_ratelimited("%s: invalid slave dev num : %d\n", __func__,
 							dev_num);
 		return;
 	}
@@ -257,7 +257,7 @@ static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
 
 	ret = audio_prm_set_cdc_earpa_duty_cycling_req(&pdata->upd_config, 1);
 	if (ret < 0)
-		pr_err("%s: upd cdc duty cycling registration failed\n", __func__);
+		pr_err_ratelimited("%s: upd cdc duty cycling registration failed\n", __func__);
 }
 
 static struct snd_soc_ops msm_common_be_ops = {
@@ -279,13 +279,13 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
 
 	wname = strpbrk(w->name, "01234567");
 	if (!wname) {
-		dev_err(component->dev, "%s: widget not found\n", __func__);
+		dev_err_ratelimited(component->dev, "%s: widget not found\n", __func__);
 		return -EINVAL;
 	}
 
 	ret = kstrtouint(wname, 10, &dmic_idx);
 	if (ret < 0) {
-		dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid DMIC line on the codec\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -314,7 +314,7 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
 		dmic_gpio = pdata->dmic67_gpio_p;
 		break;
 	default:
-		dev_err(component->dev, "%s: Invalid DMIC Selection\n",
+		dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
 			__func__);
 		return -EINVAL;
 	}
@@ -329,7 +329,7 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
 			ret = msm_cdc_pinctrl_select_active_state(
 						dmic_gpio);
 			if (ret < 0) {
-				pr_err("%s: gpio set cannot be activated %sd",
+				pr_err_ratelimited("%s: gpio set cannot be activated %sd",
 					__func__, "dmic_gpio");
 				return ret;
 			}
@@ -342,14 +342,14 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
 			ret = msm_cdc_pinctrl_select_sleep_state(
 					dmic_gpio);
 			if (ret < 0) {
-				pr_err("%s: gpio set cannot be de-activated %sd",
+				pr_err_ratelimited("%s: gpio set cannot be de-activated %sd",
 					__func__, "dmic_gpio");
 				return ret;
 			}
 		}
 		break;
 	default:
-		pr_err("%s: invalid DAPM event %d\n", __func__, event);
+		pr_err_ratelimited("%s: invalid DAPM event %d\n", __func__, event);
 		return -EINVAL;
 	}
 	return 0;
@@ -1140,7 +1140,7 @@ static int msm_populate_dai_link_component_of_node(
 	struct snd_soc_dai_link_component *codecs_comp = NULL;
 
 	if (!cdev) {
-		dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
+		dev_err_ratelimited(cdev, "%s: Sound card device memory NULL\n", __func__);
 		return -ENODEV;
 	}
 
@@ -1164,7 +1164,8 @@ static int msm_populate_dai_link_component_of_node(
 						      "asoc-codec",
 						      index);
 				if (!np) {
-					dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
+					dev_err_ratelimited(cdev,
+						"%s: retrieving phandle for codec %s failed\n",
 						__func__,
 						dai_link[i].codecs[j].name);
 					ret = -ENODEV;
@@ -1186,7 +1187,7 @@ static int msm_populate_dai_link_component_of_node(
 
 				np = dai_link[i].codecs[j].of_node;
 				if (!of_device_is_available(np)) {
-				    dev_err(cdev, "%s: codec is disabled: %s\n",
+				    dev_err_ratelimited(cdev, "%s: codec is disabled: %s\n",
 								__func__,
 								np->full_name);
 							dai_link[i].codecs[j].of_node = NULL;
@@ -1201,7 +1202,8 @@ static int msm_populate_dai_link_component_of_node(
 				    sizeof(struct snd_soc_dai_link_component)
 				    * codecs_enabled, GFP_KERNEL);
 				if (!codecs_comp) {
-					dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
+					dev_err_ratelimited(cdev,
+						"%s: %s dailink codec component alloc failed\n",
 						__func__, dai_link[i].name);
 					ret = -ENOMEM;
 					goto err;
@@ -1328,7 +1330,7 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev, int w
 
 	match = of_match_node(kalama_asoc_machine_of_match, dev->of_node);
 	if (!match) {
-		dev_err(dev, "%s: No DT match found for sound card\n",
+		dev_err_ratelimited(dev, "%s: No DT match found for sound card\n",
 			__func__);
 		return NULL;
 	}
@@ -1622,7 +1624,7 @@ static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
 		ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
 
 	if (ret < 0) {
-		dev_err(component->dev, "%s: set fir capability failed: %d\n",
+		dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
 			__func__, ret);
 		return ret;
 	}
@@ -1642,7 +1644,7 @@ static int kalama_ssr_enable(struct device *dev, void *data)
 	int ret = 0;
 
 	if (!card) {
-		dev_err(dev, "%s: card is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
 		ret = -EINVAL;
 		goto err;
 	}
@@ -1693,7 +1695,7 @@ static int kalama_ssr_enable(struct device *dev, void *data)
 		else
 			rtd = rtd_wcd;
 	} else {
-		dev_err(card->dev, "%s: Invalid backend to set UPD config\n",
+		dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
 			__func__);
 		goto err;
 	}
@@ -1710,7 +1712,7 @@ static void kalama_ssr_disable(struct device *dev, void *data)
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
 
 	if (!card) {
-		dev_err(dev, "%s: card is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
 		return;
 	}
 

+ 23 - 21
dsp/audio_notifier.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2016-2017, 2020-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/init.h>
@@ -173,7 +174,7 @@ static int audio_notifier_reg_service(int service, int domain)
 
 	priv = platform_get_drvdata(pdev);
 	if (!priv) {
-		dev_err(&pdev->dev," %s: Private data get failed\n", __func__);
+		dev_err_ratelimited(&pdev->dev, " %s: Private data get failed\n", __func__);
 		return ret;;
 	}
 
@@ -192,13 +193,13 @@ static int audio_notifier_reg_service(int service, int domain)
 		curr_state = AUDIO_NOTIFIER_SERVICE_DOWN;
 		break;
 	default:
-		pr_err("%s: Invalid service %d\n",
+		pr_err_ratelimited("%s: Invalid service %d\n",
 			__func__, service);
 		ret = -EINVAL;
 		goto done;
 	}
 	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: handle is incorrect for service %s\n",
+		pr_err_ratelimited("%s: handle is incorrect for service %s\n",
 			__func__, service_data[service][domain].name);
 		ret = -EINVAL;
 		goto done;
@@ -231,13 +232,13 @@ static int audio_notifier_dereg_service(int service, int domain)
 			service_data[service][domain].domain_id);
 		break;
 	default:
-		pr_err("%s: Invalid service %d\n",
+		pr_err_ratelimited("%s: Invalid service %d\n",
 			__func__, service);
 		ret = -EINVAL;
 		goto done;
 	}
 	if (ret < 0) {
-		pr_err("%s: deregister failed for service %s, ret %d\n",
+		pr_err_ratelimited("%s: deregister failed for service %s, ret %d\n",
 			__func__, service_data[service][domain].name, ret);
 		goto done;
 	}
@@ -266,14 +267,14 @@ static int audio_notifier_reg_client_service(struct client_data *client_data,
 			ret = audio_notifier_reg_service(service, domain);
 		break;
 	default:
-		pr_err("%s: Invalid service for client %s, service %d, domain %d\n",
+		pr_err_ratelimited("%s: Invalid service for client %s, service %d, domain %d\n",
 			__func__, client_data->client_name, service, domain);
 		ret = -EINVAL;
 		goto done;
 	}
 
 	if (ret < 0) {
-		pr_err("%s: service registration failed on service %s for client %s\n",
+		pr_err_ratelimited("%s: service registration failed on service %s for client %s\n",
 			__func__, service_data[service][domain].name,
 			client_data->client_name);
 		goto done;
@@ -312,7 +313,7 @@ static int audio_notifier_reg_client(struct client_data *client_data)
 
 	service = audio_notifier_get_default_service(domain);
 	if (service < 0) {
-		pr_err("%s: service %d is incorrect\n", __func__, service);
+		pr_err_ratelimited("%s: service %d is incorrect\n", __func__, service);
 		ret = -EINVAL;
 		goto done;
 	}
@@ -342,7 +343,7 @@ static int audio_notifier_reg_client(struct client_data *client_data)
 
 		ret = audio_notifier_reg_client_service(client_data, service);
 		if (ret < 0)
-			pr_err("%s: client %s failed to register on service %s",
+			pr_err_ratelimited("%s: client %s failed to register on service %s",
 				__func__, client_data->client_name,
 				service_data[service][domain].name);
 	}
@@ -366,7 +367,7 @@ static int audio_notifier_dereg_client(struct client_data *client_data)
 	case NO_SERVICE:
 		goto done;
 	default:
-		pr_err("%s: Invalid service for client %s, service %d\n",
+		pr_err_ratelimited("%s: Invalid service for client %s, service %d\n",
 			__func__, client_data->client_name,
 			client_data->service);
 		ret = -EINVAL;
@@ -374,7 +375,7 @@ static int audio_notifier_dereg_client(struct client_data *client_data)
 	}
 
 	if (ret < 0) {
-		pr_err("%s: deregister failed for client %s on service %s, ret %d\n",
+		pr_err_ratelimited("%s: deregister failed for client %s on service %s, ret %d\n",
 			__func__, client_data->client_name,
 			service_data[service][domain].name, ret);
 		goto done;
@@ -383,7 +384,7 @@ static int audio_notifier_dereg_client(struct client_data *client_data)
 	ret = srcu_notifier_chain_unregister(&service_data[service][domain].
 					     client_nb_list, client_data->nb);
 	if (ret < 0) {
-		pr_err("%s: srcu_notifier_chain_unregister failed, ret %d\n",
+		pr_err_ratelimited("%s: srcu_notifier_chain_unregister failed, ret %d\n",
 			__func__, ret);
 		goto done;
 	}
@@ -410,8 +411,8 @@ static void audio_notifier_reg_all_clients(void)
 
 		ret = audio_notifier_reg_client(client_data);
 		if (ret < 0)
-			pr_err("%s: audio_notifier_reg_client failed for client %s, ret %d\n",
-				__func__, client_data->client_name,
+			pr_err_ratelimited("%s: audio_notifier_reg_client failed for client %s, \
+				ret %d\n", __func__, client_data->client_name,
 				ret);
 	}
 }
@@ -460,8 +461,8 @@ static int audio_notifier_service_cb(unsigned long opcode,
 	ret = srcu_notifier_call_chain(&service_data[service][domain].
 		client_nb_list, notifier_opcode, &data);
 	if (ret < 0)
-		pr_err("%s: srcu_notifier_call_chain returned %d, service %s, opcode 0x%lx\n",
-			__func__, ret, service_data[service][domain].name,
+		pr_err_ratelimited("%s: srcu_notifier_call_chain returned %d, service %s, \
+			opcode 0x%lx\n", __func__, ret, service_data[service][domain].name,
 			notifier_opcode);
 
 	mutex_unlock(&notifier_mutex);
@@ -498,7 +499,7 @@ int audio_notifier_deregister(char *client_name)
 	struct client_data *client_data = NULL;
 
 	if (client_name == NULL) {
-		pr_err("%s: client_name is NULL\n", __func__);
+		pr_err_ratelimited("%s: client_name is NULL\n", __func__);
 		ret = -EINVAL;
 		goto done;
 	}
@@ -508,7 +509,8 @@ int audio_notifier_deregister(char *client_name)
 		if (!strcmp(client_name, client_data->client_name)) {
 			ret2 = audio_notifier_dereg_client(client_data);
 			if (ret2 < 0) {
-				pr_err("%s: audio_notifier_dereg_client failed, ret %d\n, service %d, domain %d",
+				pr_err_ratelimited("%s: audio_notifier_dereg_client failed, \
+					ret %d\n, service %d, domain %d",
 					__func__, ret2, client_data->service,
 					client_data->domain);
 				ret = ret2;
@@ -531,11 +533,11 @@ int audio_notifier_register(char *client_name, int domain,
 	struct client_data *client_data;
 
 	if (client_name == NULL) {
-		pr_err("%s: client_name is NULL\n", __func__);
+		pr_err_ratelimited("%s: client_name is NULL\n", __func__);
 		ret = -EINVAL;
 		goto done;
 	} else if (nb == NULL) {
-		pr_err("%s: Notifier block is NULL\n", __func__);
+		pr_err_ratelimited("%s: Notifier block is NULL\n", __func__);
 		ret = -EINVAL;
 		goto done;
 	}
@@ -556,7 +558,7 @@ int audio_notifier_register(char *client_name, int domain,
 	ret = audio_notifier_reg_client(client_data);
 	if (ret < 0) {
 		mutex_unlock(&notifier_mutex);
-		pr_err("%s: audio_notifier_reg_client for client %s failed ret = %d\n",
+		pr_err_ratelimited("%s: audio_notifier_reg_client for client %s failed ret = %d\n",
 			__func__, client_data->client_name,
 			ret);
 		kfree(client_data);

+ 13 - 12
dsp/spf-core.c

@@ -1,4 +1,5 @@
 /* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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
@@ -75,18 +76,18 @@ static int spf_core_callback(struct gpr_device *adev, void *data)
 	struct gpr_hdr *hdr = data;
 
 
-	dev_info(&adev->dev ,"%s: Payload %x",__func__, hdr->opcode);
+	dev_info_ratelimited(&adev->dev, "%s: Payload %x", __func__, hdr->opcode);
 	switch (hdr->opcode) {
 	case GPR_IBASIC_RSP_RESULT:
 		basic_rsp = GPR_PKT_GET_PAYLOAD(
 				struct spf_cmd_basic_rsp,
 				data);
-		dev_info(&adev->dev ,"%s: op %x status %d", __func__,
+		dev_info_ratelimited(&adev->dev, "%s: op %x status %d", __func__,
 				basic_rsp->opcode, basic_rsp->status);
 		if (basic_rsp->opcode == APM_CMD_CLOSE_ALL) {
 			core->status = basic_rsp->status;
 		} else {
-			dev_err(&adev->dev ,"%s: Failed response received",
+			dev_err_ratelimited(&adev->dev, "%s: Failed response received",
 					__func__);
 		}
 		core->resp_received = true;
@@ -96,12 +97,12 @@ static int spf_core_callback(struct gpr_device *adev, void *data)
 				GPR_PKT_GET_PAYLOAD(
 					struct apm_cmd_rsp_get_spf_status_t,
 					data);
-		dev_info(&adev->dev ,"%s: sucess response received",__func__);
+		dev_info_ratelimited(&adev->dev, "%s: sucess response received", __func__);
 		core->status = spf_status_rsp->status;
 		core->resp_received = true;
 		break;
 	default:
-		dev_err(&adev->dev, "Message ID from apm: 0x%x\n",
+		dev_err_ratelimited(&adev->dev, "Message ID from apm: 0x%x\n",
 			hdr->opcode);
 		break;
 	}
@@ -128,7 +129,7 @@ static bool __spf_core_is_apm_ready(struct spf_core *core)
 	pkt.hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
 	pkt.hdr.opcode = APM_CMD_GET_SPF_STATE;
 
-	dev_err(spf_core_priv->dev, "%s: send_command ret\n",	__func__);
+	dev_err_ratelimited(spf_core_priv->dev, "%s: send_command ret\n", __func__);
 
 	rc = gpr_send_pkt(adev, &pkt);
 	if (rc < 0) {
@@ -143,7 +144,7 @@ static bool __spf_core_is_apm_ready(struct spf_core *core)
 	if (rc > 0 && core->resp_received) {
 		ret = core->status;
 	} else {
-		dev_err(spf_core_priv->dev, "%s: command timedout, ret\n",
+		dev_err_ratelimited(spf_core_priv->dev, "%s: command timedout, ret\n",
 			__func__);
         }
 done:
@@ -229,24 +230,24 @@ void spf_core_apm_close_all(void)
 	pkt.hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
 	pkt.hdr.opcode = APM_CMD_CLOSE_ALL;
 
-	dev_info(spf_core_priv->dev, "%s: send_command \n", __func__);
+	dev_info_ratelimited(spf_core_priv->dev, "%s: send_command \n", __func__);
 
 	rc = gpr_send_pkt(adev, &pkt);
 	if (rc < 0) {
-		dev_err(spf_core_priv->dev, "%s: send_pkt_failed %d\n",
+		dev_err_ratelimited(spf_core_priv->dev, "%s: send_pkt_failed %d\n",
 				__func__, rc);
 		goto done;
 	}
 
 	rc = wait_event_timeout(core->wait, (core->resp_received),
 				msecs_to_jiffies(Q6_READY_TIMEOUT_MS));
-	dev_info(spf_core_priv->dev, "%s: wait event unblocked \n", __func__);
+	dev_info_ratelimited(spf_core_priv->dev, "%s: wait event unblocked \n", __func__);
 	if (rc > 0 && core->resp_received) {
 		if (core->status != 0)
-			dev_err(spf_core_priv->dev, "%s, cmd failed status %d",
+			dev_err_ratelimited(spf_core_priv->dev, "%s, cmd failed status %d",
 					__func__, core->status);
 	} else {
-		dev_err(spf_core_priv->dev, "%s: command timedout, ret\n",
+		dev_err_ratelimited(spf_core_priv->dev, "%s: command timedout, ret\n",
 			__func__);
         }
 

+ 19 - 17
ipc/gpr-lite.c

@@ -1,5 +1,6 @@
 /* Copyright (c) 2011-2017, 2019-2021 The Linux Foundation. All rights reserved.
  * Copyright (c) 2018, Linaro Limited
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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
@@ -60,7 +61,7 @@ void gpr_subsys_notif_register(char *client_name, int domain,
 
 	ret = audio_notifier_register(client_name, domain, nb);
 	if (ret < 0)
-		dev_err(gpr_priv->dev, "%s: Audio notifier register failed for domain %d ret = %d\n",
+		dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier register failed for domain %d ret = %d\n",
 			__func__, domain, ret);
 }
 
@@ -70,7 +71,7 @@ void gpr_subsys_notif_deregister(char *client_name)
 
 	ret = audio_notifier_deregister(client_name);
 	if (ret < 0)
-		dev_err(gpr_priv->dev, "%s: Audio notifier de-register failed for client %s\n",
+		dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier de-register failed for client %s\n",
 			__func__, client_name);
 }
 
@@ -92,13 +93,13 @@ int gpr_send_pkt(struct gpr_device *adev, struct gpr_pkt *pkt)
 
 	if(!adev)
 	{
-		pr_err("%s: enter pointer adev[%pK] \n", __func__, adev);
+		pr_err_ratelimited("%s: enter pointer adev[%pK] \n", __func__, adev);
 		return -EINVAL;
 	}
 
 	if(!(adev->dev.parent))
 	{
-		pr_err("%s: enter pointer adev->dev.parent[%pK] \n",
+		pr_err_ratelimited("%s: enter pointer adev->dev.parent[%pK] \n",
 			__func__, adev->dev.parent);
 		return -EINVAL;
 	}
@@ -107,12 +108,12 @@ int gpr_send_pkt(struct gpr_device *adev, struct gpr_pkt *pkt)
 
 	if ((adev->domain_id == GPR_DOMAIN_ADSP) &&
 	    (gpr_get_q6_state() != GPR_SUBSYS_LOADED)) {
-		dev_err(gpr->dev,"%s: domain_id[%d], Still Dsp is not Up\n",
+		dev_err_ratelimited(gpr->dev, "%s: domain_id[%d], Still Dsp is not Up\n",
 			__func__, adev->domain_id);
 		return -ENETRESET;
 		} else if ((adev->domain_id == GPR_DOMAIN_MODEM) &&
 		   (gpr_get_modem_state() == GPR_SUBSYS_DOWN)) {
-		dev_err(gpr->dev, "%s: domain_id[%d], Still Modem is not Up\n",
+		dev_err_ratelimited(gpr->dev, "%s: domain_id[%d], Still Modem is not Up\n",
 			__func__, adev->domain_id );
 		return -ENETRESET;
 	}
@@ -181,14 +182,14 @@ static const struct snd_event_ops gpr_ssr_ops = {
 
 static void gpr_adsp_down(unsigned long opcode)
 {
-	dev_info(gpr_priv->dev,"%s: Q6 is Down\n", __func__);
+	dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Down\n", __func__);
 	gpr_set_q6_state(GPR_SUBSYS_DOWN);
 	snd_event_notify(gpr_priv->dev, SND_EVENT_DOWN);
 }
 
 static void gpr_adsp_up(void)
 {
-	dev_info(gpr_priv->dev,"%s: Q6 is Up\n", __func__);
+	dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Up\n", __func__);
 	gpr_set_q6_state(GPR_SUBSYS_LOADED);
 	snd_event_notify(gpr_priv->dev, SND_EVENT_UP);
 }
@@ -199,7 +200,7 @@ static int gpr_notifier_service_cb(struct notifier_block *this,
 	struct audio_notifier_cb_data *cb_data = data;
 
 	if (cb_data == NULL) {
-		dev_err(gpr_priv->dev,"%s: Callback data is NULL!\n", __func__);
+		dev_err_ratelimited(gpr_priv->dev, "%s: Callback data is NULL!\n", __func__);
 		goto done;
 	}
 
@@ -272,7 +273,7 @@ static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
 	//uint32_t opcode_type;
 
 	if (len <= GPR_HDR_SIZE) {
-		dev_err(gpr->dev, "GPR: Improper gpr pkt received:%p %d\n",
+		dev_err_ratelimited(gpr->dev, "GPR: Improper gpr pkt received:%p %d\n",
 			buf, len);
 		return -EINVAL;
 	}
@@ -281,7 +282,7 @@ static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
 
 	hdr_size = GPR_PKT_GET_HEADER_BYTE_SIZE(hdr->header);
 	if (hdr_size < GPR_HDR_SIZE) {
-		dev_err(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size);
+		dev_err_ratelimited(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size);
 		return -EINVAL;
 	}
 
@@ -289,7 +290,7 @@ static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
 	dev_dbg(gpr->dev,"Header %x", hdr->header);
 
 	if (pkt_size < GPR_HDR_SIZE || pkt_size != len) {
-		dev_err(gpr->dev, "GPR: Wrong packet size\n");
+		dev_err_ratelimited(gpr->dev, "GPR: Wrong packet size\n");
 		return -EINVAL;
 	}
 
@@ -310,7 +311,7 @@ static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
 	spin_unlock_irqrestore(&gpr->svcs_lock, flags);
 
 	if (!adrv) {
-		dev_err(gpr->dev, "GPR: service is not registered\n");
+		dev_err_ratelimited(gpr->dev, "GPR: service is not registered\n");
 		return -EINVAL;
 	}
 
@@ -429,11 +430,11 @@ static int gpr_add_device(struct device *dev, struct device_node *np,
 		  id->svc_id + 1, GFP_ATOMIC);
 	spin_unlock(&gpr->svcs_lock);
 
-	dev_info(dev, "Adding GPR dev: %s\n", dev_name(&adev->dev));
+	dev_info_ratelimited(dev, "Adding GPR dev: %s\n", dev_name(&adev->dev));
 
 	ret = device_register(&adev->dev);
 	if (ret) {
-		dev_err(dev, "device_register failed: %d\n", ret);
+		dev_err_ratelimited(dev, "device_register failed: %d\n", ret);
 		put_device(&adev->dev);
 	}
 
@@ -454,7 +455,7 @@ static void of_register_gpr_devices(struct device *dev)
 		id.domain_id = gpr->dest_domain_id;
 
 		if (gpr_add_device(dev, node, &id))
-			dev_err(dev, "Failed to add gpr %d svc\n", id.svc_id);
+			dev_err_ratelimited(dev, "Failed to add gpr %d svc\n", id.svc_id);
 	}
 }
 
@@ -470,7 +471,8 @@ static void gpr_notifier_register(struct work_struct *work)
 				       &modem_service_nb);
 	}
 
-	dev_info(gpr_priv->dev, "%s: registered via subsys_notif_register for domain id(%d)",
+	dev_info_ratelimited(gpr_priv->dev,
+		"%s: registered via subsys_notif_register for domain id(%d)",
 		__func__, gpr_priv->dest_domain_id  );
 	return;
 }

+ 7 - 7
soc/pinctrl-lpi.c

@@ -155,7 +155,7 @@ static int lpi_gpio_read(struct lpi_gpio_pad *pad, unsigned int addr)
 
 	if (!lpi_dev_up) {
 		if (__ratelimit(&rtl))
-			pr_err("%s: ADSP is down due to SSR, return\n",
+			pr_err_ratelimited("%s: ADSP is down due to SSR, return\n",
 				   __func__);
 		return 0;
 	}
@@ -163,7 +163,7 @@ static int lpi_gpio_read(struct lpi_gpio_pad *pad, unsigned int addr)
 	mutex_lock(&state->core_hw_vote_lock);
 	if (!state->core_hw_vote_status) {
 		if (__ratelimit(&rtl))
-			pr_err("%s: core hw vote clk is not enabled\n",
+			pr_err_ratelimited("%s: core hw vote clk is not enabled\n",
 				__func__);
 		ret = -EINVAL;
 		goto err;
@@ -171,7 +171,7 @@ static int lpi_gpio_read(struct lpi_gpio_pad *pad, unsigned int addr)
 
 	ret = ioread32(pad->base + pad->offset + addr);
 	if (ret < 0)
-		pr_err("%s: read 0x%x failed\n", __func__, addr);
+		pr_err_ratelimited("%s: read 0x%x failed\n", __func__, addr);
 
 err:
 	mutex_unlock(&state->core_hw_vote_lock);
@@ -194,7 +194,7 @@ static int lpi_gpio_write(struct lpi_gpio_pad *pad, unsigned int addr,
 	mutex_lock(&state->core_hw_vote_lock);
 	if (!state->core_hw_vote_status) {
 		if (__ratelimit(&rtl))
-			pr_err("%s: core hw vote clk is not enabled\n",
+			pr_err_ratelimited("%s: core hw vote clk is not enabled\n",
 				__func__);
 		ret = -EINVAL;
 		goto err;
@@ -372,8 +372,8 @@ static int lpi_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
 				goto set_gpio;
 			}
 			if (arg > LPI_SLEW_RATE_MAX) {
-				dev_err(pctldev->dev, "%s: invalid slew rate %u for pin: %d\n",
-					__func__, arg, pin);
+				dev_err_ratelimited(pctldev->dev, "%s: invalid slew rate %u for \
+					pin: %d\n", __func__, arg, pin);
 				goto set_gpio;
 			}
 			pad->base = pad->slew_base;
@@ -909,7 +909,7 @@ int lpi_pinctrl_runtime_resume(struct device *dev)
 	if (ret < 0) {
 		pm_runtime_set_autosuspend_delay(dev,
 						 LPI_AUTO_SUSPEND_DELAY_ERROR);
-		dev_err(dev, "%s:lpass core hw island enable failed\n",
+		dev_err_ratelimited(dev, "%s:lpass core hw island enable failed\n",
 			__func__);
 		goto exit;
 	} else {

+ 14 - 13
soc/regmap-swr.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/device.h>
@@ -27,16 +28,16 @@ static int regmap_swr_gather_write(void *context,
 	u8 *value;
 
 	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 	addr_bytes = map->format.reg_bytes;
 	if (swr == NULL) {
-		dev_err(dev, "%s: swr device is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: swr device is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (reg_size != addr_bytes) {
-		dev_err(dev, "%s: reg size %zd bytes not supported\n",
+		dev_err_ratelimited(dev, "%s: reg size %zd bytes not supported\n",
 			__func__, reg_size);
 		return -EINVAL;
 	}
@@ -47,7 +48,7 @@ static int regmap_swr_gather_write(void *context,
 		value = (u8 *)val + (val_bytes * i);
 		ret = swr_write(swr, swr->dev_num, (reg_addr + i), value);
 		if (ret < 0) {
-			dev_err(dev, "%s: write reg 0x%x failed, err %d\n",
+			dev_err_ratelimited(dev, "%s: write reg 0x%x failed, err %d\n",
 				__func__, (reg_addr + i), ret);
 			break;
 		}
@@ -72,12 +73,12 @@ static int regmap_swr_raw_multi_reg_write(void *context, const void *data,
 	u8 *buf;
 
 	if (swr == NULL) {
-		dev_err(dev, "%s: swr device is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: swr device is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -86,7 +87,7 @@ static int regmap_swr_raw_multi_reg_write(void *context, const void *data,
 	pad_bytes = map->format.pad_bytes;
 
 	if (addr_bytes + val_bytes + pad_bytes == 0) {
-		dev_err(dev, "%s: sum of addr, value and pad is 0\n", __func__);
+		dev_err_ratelimited(dev, "%s: sum of addr, value and pad is 0\n", __func__);
 		return -EINVAL;
 	}
 	num_regs = count / (addr_bytes + val_bytes + pad_bytes);
@@ -110,7 +111,7 @@ static int regmap_swr_raw_multi_reg_write(void *context, const void *data,
 	}
 	ret = swr_bulk_write(swr, swr->dev_num, reg, val, num_regs);
 	if (ret)
-		dev_err(dev, "%s: multi reg write failed\n", __func__);
+		dev_err_ratelimited(dev, "%s: multi reg write failed\n", __func__);
 
 	kfree(val);
 mem_fail:
@@ -127,7 +128,7 @@ static int regmap_swr_write(void *context, const void *data, size_t count)
 	size_t pad_bytes;
 
 	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 	addr_bytes = map->format.reg_bytes;
@@ -156,23 +157,23 @@ static int regmap_swr_read(void *context,
 	u16 reg_addr = 0;
 
 	if (map == NULL) {
-		dev_err(dev, "%s: regmap is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: regmap is NULL\n", __func__);
 		return -EINVAL;
 	}
 	addr_bytes = map->format.reg_bytes;
 	if (swr == NULL) {
-		dev_err(dev, "%s: swr is NULL\n", __func__);
+		dev_err_ratelimited(dev, "%s: swr is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (reg_size != addr_bytes) {
-		dev_err(dev, "%s: register size %zd bytes not supported\n",
+		dev_err_ratelimited(dev, "%s: register size %zd bytes not supported\n",
 			__func__, reg_size);
 		return -EINVAL;
 	}
 	reg_addr = *(u16 *)reg;
 	ret = swr_read(swr, swr->dev_num, reg_addr, val, val_size);
 	if (ret < 0)
-		dev_err(dev, "%s: codec reg 0x%x read failed %d\n",
+		dev_err_ratelimited(dev, "%s: codec reg 0x%x read failed %d\n",
 			__func__, reg_addr, ret);
 	return ret;
 }

+ 12 - 11
soc/snd_event.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/platform_device.h>
@@ -78,7 +79,7 @@ static int check_and_update_fwk_state(void)
 				if (c->ops->enable) {
 					ret = c->ops->enable(c->dev, c->data);
 					if (ret) {
-						dev_err(c->dev,
+						dev_err_ratelimited(c->dev,
 							"%s: enable failed\n",
 							__func__);
 						goto dev_en_failed;
@@ -89,7 +90,7 @@ static int check_and_update_fwk_state(void)
 				ret = master->ops->enable(master->dev,
 							  master->data);
 				if (ret) {
-					dev_err(master->dev,
+					dev_err_ratelimited(master->dev,
 						"%s: enable failed\n",
 						__func__);
 					goto mstr_en_failed;
@@ -132,7 +133,7 @@ static int snd_event_find_clients(struct snd_master *master)
 		struct snd_event_client *c;
 
 		if (c_arr->dev) {
-			pr_err("%s: client already present dev=%pK\n",
+			pr_err_ratelimited("%s: client already present dev=%pK\n",
 				 __func__, c_arr->dev);
 			continue;
 		}
@@ -181,7 +182,7 @@ int snd_event_client_register(struct device *dev,
 	struct snd_event_client *c;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -228,7 +229,7 @@ int snd_event_client_deregister(struct device *dev)
 	int i = 0;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -295,7 +296,7 @@ void snd_event_mstr_add_client(struct snd_event_clients **snd_clients,
 	struct snd_event_clients *client = *snd_clients;
 
 	if (IS_ERR(client)) {
-		pr_err("%s: snd_clients is invalid\n", __func__);
+		pr_err_ratelimited("%s: snd_clients is invalid\n", __func__);
 		return;
 	}
 
@@ -359,7 +360,7 @@ int snd_event_master_register(struct device *dev,
 	int ret = 0;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -418,7 +419,7 @@ int snd_event_master_deregister(struct device *dev)
 	int ret = 0;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -464,7 +465,7 @@ int snd_event_notify(struct device *dev, unsigned int state)
 	int ret = 0;
 
 	if (!dev) {
-		pr_err("%s: dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 
@@ -473,14 +474,14 @@ int snd_event_notify(struct device *dev, unsigned int state)
 
 	mutex_lock(&snd_event_mutex);
 	if (list_empty(&snd_event_client_list) && !master) {
-		dev_err(dev, "%s: No device registered\n", __func__);
+		dev_err_ratelimited(dev, "%s: No device registered\n", __func__);
 		ret = -ENODEV;
 		goto exit;
 	}
 
 	c = find_snd_event_client(dev);
 	if (!c && (!master || (master->dev != dev))) {
-		dev_err(dev, "%s: No snd dev entry found\n", __func__);
+		dev_err_ratelimited(dev, "%s: No snd dev entry found\n", __func__);
 		ret = -ENXIO;
 		goto exit;
 	}

+ 16 - 15
soc/soundwire.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/kernel.h>
@@ -105,7 +106,7 @@ struct swr_device *swr_new_device(struct swr_master *master,
 	struct swr_device *swr;
 
 	if (!master || !swr_master_get(master)) {
-		pr_err("%s: master is NULL\n", __func__);
+		pr_err_ratelimited("%s: master is NULL\n", __func__);
 		return NULL;
 	}
 
@@ -129,7 +130,7 @@ struct swr_device *swr_new_device(struct swr_master *master,
 	dev_set_name(&swr->dev, "%s.%lx", swr->name, swr->addr);
 	result = device_register(&swr->dev);
 	if (result) {
-		dev_err(&master->dev, "device [%s] register failed err %d\n",
+		dev_err_ratelimited(&master->dev, "device [%s] register failed err %d\n",
 			swr->name, result);
 		goto err_out;
 	}
@@ -141,7 +142,7 @@ err_out:
 	dev_dbg(&master->dev, "Failed to register swr device %s at 0x%lx %d\n",
 		swr->name, swr->addr, result);
 	swr_master_put(master);
-	list_del_init(&swr->dev_list);	
+	list_del_init(&swr->dev_list);
 	kfree(swr);
 	return NULL;
 }
@@ -170,12 +171,12 @@ int of_register_swr_devices(struct swr_master *master)
 		dev_dbg(&master->dev, "of_swr:register %s\n", node->full_name);
 
 		if (of_modalias_node(node, info.name, sizeof(info.name)) < 0) {
-			dev_err(&master->dev, "of_swr:modalias failure %s\n",
+			dev_err_ratelimited(&master->dev, "of_swr:modalias failure %s\n",
 				node->full_name);
 			continue;
 		}
 		if (of_property_read_u64(node, "reg", &addr)) {
-			dev_err(&master->dev, "of_swr:invalid reg %s\n",
+			dev_err_ratelimited(&master->dev, "of_swr:invalid reg %s\n",
 				node->full_name);
 			continue;
 		}
@@ -183,7 +184,7 @@ int of_register_swr_devices(struct swr_master *master)
 		info.of_node = of_node_get(node);
 		swr = swr_new_device(master, &info);
 		if (!swr) {
-			dev_err(&master->dev, "of_swr: Register failed %s\n",
+			dev_err_ratelimited(&master->dev, "of_swr: Register failed %s\n",
 				node->full_name);
 			of_node_put(node);
 			continue;
@@ -207,7 +208,7 @@ void swr_port_response(struct swr_master *mstr, u8 tid)
 	txn = mstr->port_txn[tid];
 
 	if (txn == NULL) {
-		dev_err(&mstr->dev, "%s: transaction is already NULL\n",
+		dev_err_ratelimited(&mstr->dev, "%s: transaction is already NULL\n",
 			__func__);
 		return;
 	}
@@ -310,11 +311,11 @@ int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 	struct swr_master *master = dev->master;
 
 	if (!master) {
-		pr_err("%s: Master is NULL\n", __func__);
+		pr_err_ratelimited("%s: Master is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (num_port > SWR_MAX_DEV_PORT_NUM) {
-		dev_err(&master->dev, "%s: num_port %d exceeds max port %d\n",
+		dev_err_ratelimited(&master->dev, "%s: num_port %d exceeds max port %d\n",
 			__func__, num_port, SWR_MAX_DEV_PORT_NUM);
 		return -EINVAL;
 	}
@@ -339,7 +340,7 @@ int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 		if (master->last_tid == 255) {
 			mutex_unlock(&master->mlock);
 			kfree(txn);
-			dev_err(&master->dev, "%s Max tid reached\n",
+			dev_err_ratelimited(&master->dev, "%s Max tid reached\n",
 				__func__);
 			return -ENOMEM;
 		}
@@ -349,7 +350,7 @@ int swr_connect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 		if (!temp_txn) {
 			mutex_unlock(&master->mlock);
 			kfree(txn);
-			dev_err(&master->dev, "%s Not able to allocate\n"
+			dev_err_ratelimited(&master->dev, "%s Not able to allocate\n"
 				"master port transaction memory\n",
 				__func__);
 			return -ENOMEM;
@@ -395,12 +396,12 @@ int swr_disconnect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 	struct swr_master *master = dev->master;
 
 	if (!master) {
-		pr_err("%s: Master is NULL\n", __func__);
+		pr_err_ratelimited("%s: Master is NULL\n", __func__);
 		return -EINVAL;
 	}
 
 	if (num_port > SWR_MAX_DEV_PORT_NUM) {
-		dev_err(&master->dev, "%s: num_port %d exceeds max port %d\n",
+		dev_err_ratelimited(&master->dev, "%s: num_port %d exceeds max port %d\n",
 			__func__, num_port, SWR_MAX_DEV_PORT_NUM);
 		return -EINVAL;
 	}
@@ -418,7 +419,7 @@ int swr_disconnect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 		if (master->last_tid == 255) {
 			mutex_unlock(&master->mlock);
 			kfree(txn);
-			dev_err(&master->dev, "%s Max tid reached\n",
+			dev_err_ratelimited(&master->dev, "%s Max tid reached\n",
 				__func__);
 			return -ENOMEM;
 		}
@@ -428,7 +429,7 @@ int swr_disconnect_port(struct swr_device *dev, u8 *port_id, u8 num_port,
 		if (!temp_txn) {
 			mutex_unlock(&master->mlock);
 			kfree(txn);
-			dev_err(&master->dev, "%s Not able to allocate\n"
+			dev_err_ratelimited(&master->dev, "%s Not able to allocate\n"
 				"master port transaction memory\n",
 				__func__);
 			return -ENOMEM;

+ 75 - 75
soc/swr-mstr-ctrl.c

@@ -235,14 +235,14 @@ static ssize_t swrm_reg_show(struct swr_mstr_ctrl *swrm, char __user *ubuf,
 		reg_val = swr_master_read(swrm, i);
 		len = snprintf(tmp_buf, 25, "0x%.3x: 0x%.2x\n", i, reg_val);
 		if (len < 0) {
-			pr_err("%s: fail to fill the buffer\n", __func__);
+			pr_err_ratelimited("%s: fail to fill the buffer\n", __func__);
 			total = -EFAULT;
 			goto copy_err;
 		}
 		if ((total + len) >= count - 1)
 			break;
 		if (copy_to_user((ubuf + total), tmp_buf, len)) {
-			pr_err("%s: fail to copy reg dump\n", __func__);
+			pr_err_ratelimited("%s: fail to copy reg dump\n", __func__);
 			total = -EFAULT;
 			goto copy_err;
 		}
@@ -329,7 +329,7 @@ static ssize_t swrm_debug_peek_write(struct file *file, const char __user *ubuf,
 	if (rc == 0)
 		rc = count;
 	else
-		dev_err(swrm->dev, "%s: rc = %d\n", __func__, rc);
+		dev_err_ratelimited(swrm->dev, "%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -368,7 +368,7 @@ static ssize_t swrm_debug_write(struct file *file,
 	if (rc == 0)
 		rc = count;
 	else
-		pr_err("%s: rc = %d\n", __func__, rc);
+		pr_err_ratelimited("%s: rc = %d\n", __func__, rc);
 
 	return rc;
 }
@@ -427,7 +427,7 @@ static int swrm_request_hw_vote(struct swr_mstr_ctrl *swrm,
 					   digital_cdc_rsc_mgr_hw_vote_enable(
 							swrm->lpass_core_hw_vote);
 					if (ret < 0) {
-						dev_err(swrm->dev,
+						dev_err_ratelimited(swrm->dev,
 							"%s:lpass core hw enable failed\n",
 							__func__);
 						--swrm->hw_core_clk_en;
@@ -459,7 +459,7 @@ static int swrm_request_hw_vote(struct swr_mstr_ctrl *swrm,
 					   digital_cdc_rsc_mgr_hw_vote_enable(
 							swrm->lpass_core_audio);
 					if (ret < 0) {
-						dev_err(swrm->dev,
+						dev_err_ratelimited(swrm->dev,
 							"%s:lpass audio hw enable failed\n",
 							__func__);
 						--swrm->aud_core_clk_en;
@@ -563,7 +563,7 @@ static int swrm_clk_request(struct swr_mstr_ctrl *swrm, bool enable)
 		complete(&swrm->clk_off_complete);
 	}
 	if (swrm->clk_ref_count < 0) {
-		dev_err(swrm->dev, "%s: swrm clk count mismatch\n", __func__);
+		dev_err_ratelimited(swrm->dev, "%s: swrm clk count mismatch\n", __func__);
 		swrm->clk_ref_count = 0;
 	}
 
@@ -716,7 +716,7 @@ static bool swrm_check_link_status(struct swr_mstr_ctrl *swrm, bool active)
 	} while (retry);
 
 	if (retry == 0)
-		dev_err(swrm->dev, "%s: link status not %s\n", __func__,
+		dev_err_ratelimited(swrm->dev, "%s: link status not %s\n", __func__,
 			active ? "connected" : "disconnected");
 
 	return ret;
@@ -785,7 +785,7 @@ static int swrm_pcm_port_config(struct swr_mstr_ctrl *swrm, u8 port_num,
 	u32 reg_val = 0;
 
 	if (!port_num || port_num > SWR_MSTR_PORT_LEN) {
-		dev_err(swrm->dev, "%s: invalid port: %d\n",
+		dev_err_ratelimited(swrm->dev, "%s: invalid port: %d\n",
 			__func__, port_num);
 		return -EINVAL;
 	}
@@ -816,7 +816,7 @@ static int swrm_get_master_port(struct swr_mstr_ctrl *swrm, u8 *mstr_port_id,
 	}
 found:
 	if (i > swrm->num_ports || j == SWR_MAX_CH_PER_PORT)  {
-		dev_err(swrm->dev, "%s: port type not supported by master\n",
+		dev_err_ratelimited(swrm->dev, "%s: port type not supported by master\n",
 					__func__);
 		return -EINVAL;
 	}
@@ -1002,11 +1002,11 @@ static int swrm_read(struct swr_master *master, u8 dev_num, u16 reg_addr,
 	u8 *reg_val = (u8 *)buf;
 
 	if (!swrm) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: swrm is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (!dev_num) {
-		dev_err(&master->dev, "%s: invalid slave dev num\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: invalid slave dev num\n", __func__);
 		return -EINVAL;
 	}
 	mutex_lock(&swrm->devlock);
@@ -1038,11 +1038,11 @@ static int swrm_write(struct swr_master *master, u8 dev_num, u16 reg_addr,
 	u8 reg_val = *(u8 *)buf;
 
 	if (!swrm) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: swrm is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (!dev_num) {
-		dev_err(&master->dev, "%s: invalid slave dev num\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: invalid slave dev num\n", __func__);
 		return -EINVAL;
 	}
 	mutex_lock(&swrm->devlock);
@@ -1073,7 +1073,7 @@ static int swrm_bulk_write(struct swr_master *master, u8 dev_num, void *reg,
 	u32 *swr_fifo_reg;
 
 	if (!swrm || !swrm->handle) {
-		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: swrm is NULL\n", __func__);
 		return -EINVAL;
 	}
 	if (len <= 0)
@@ -1107,12 +1107,12 @@ static int swrm_bulk_write(struct swr_master *master, u8 dev_num, void *reg,
 		}
 		ret = swr_master_bulk_write(swrm, swr_fifo_reg, val, len);
 		if (ret) {
-			dev_err(&master->dev, "%s: bulk write failed\n",
+			dev_err_ratelimited(&master->dev, "%s: bulk write failed\n",
 				__func__);
 			ret = -EINVAL;
 		}
 	} else {
-		dev_err(&master->dev,
+		dev_err_ratelimited(&master->dev,
 			"%s: No support of Bulk write for master regs\n",
 			__func__);
 		ret = -EINVAL;
@@ -1265,7 +1265,7 @@ static void swrm_disable_ports(struct swr_master *master,
 	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
 
 	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
+		pr_err_ratelimited("%s: swrm is null\n", __func__);
 		return;
 	}
 
@@ -1320,7 +1320,7 @@ static void swrm_cleanup_disabled_port_reqs(struct swr_master *master)
 	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
 
 	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
+		pr_err_ratelimited("%s: swrm is null\n", __func__);
 		return;
 	}
 	dev_dbg(swrm->dev, "%s: master num_port: %d\n", __func__,
@@ -1456,7 +1456,7 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
 	u8 dev_offset[SWRM_NUM_AUTO_ENUM_SLAVES];
 
 	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
+		pr_err_ratelimited("%s: swrm is null\n", __func__);
 		return;
 	}
 
@@ -1490,7 +1490,7 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
 				lane_ctrl = port_req->lane_ctrl;
 			} else if (sinterval != port_req->sinterval ||
 					lane_ctrl != port_req->lane_ctrl) {
-				dev_err(swrm->dev,
+				dev_err_ratelimited(swrm->dev,
 					"%s:slaves/slave ports attaching to mport%d"\
 					" are not using same SI or data lane, update slave tables,"\
 					"bailing out without setting port config\n",
@@ -1644,7 +1644,7 @@ static void swrm_apply_port_config(struct swr_master *master)
 	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
 
 	if (!swrm) {
-		pr_err("%s: Invalid handle to swr controller\n",
+		pr_err_ratelimited("%s: Invalid handle to swr controller\n",
 			__func__);
 		return;
 	}
@@ -1675,7 +1675,7 @@ static int swrm_slvdev_datapath_control(struct swr_master *master, bool enable)
 	int frame_sync = SWRM_FRAME_SYNC_SEL;
 
 	if (!swrm) {
-		pr_err("%s: swrm is null\n", __func__);
+		pr_err_ratelimited("%s: swrm is null\n", __func__);
 		return -EFAULT;
 	}
 
@@ -1818,7 +1818,7 @@ static int swrm_connect_port(struct swr_master *master,
 		return -EINVAL;
 
 	if (!swrm) {
-		dev_err(&master->dev,
+		dev_err_ratelimited(&master->dev,
 			"%s: Invalid handle to swr controller\n",
 			__func__);
 		return -EINVAL;
@@ -1841,7 +1841,7 @@ static int swrm_connect_port(struct swr_master *master,
 						portinfo->port_type[i],
 						portinfo->port_id[i]);
 		if (ret) {
-			dev_err(&master->dev,
+			dev_err_ratelimited(&master->dev,
 				"%s: mstr portid for slv port %d not found\n",
 				__func__, portinfo->port_id[i]);
 			goto port_fail;
@@ -1922,14 +1922,14 @@ static int swrm_disconnect_port(struct swr_master *master,
 	u8 mstr_port_id, mstr_ch_mask;
 
 	if (!swrm) {
-		dev_err(&master->dev,
+		dev_err_ratelimited(&master->dev,
 			"%s: Invalid handle to swr controller\n",
 			__func__);
 		return -EINVAL;
 	}
 
 	if (!portinfo) {
-		dev_err(&master->dev, "%s: portinfo is NULL\n", __func__);
+		dev_err_ratelimited(&master->dev, "%s: portinfo is NULL\n", __func__);
 		return -EINVAL;
 	}
 	mutex_lock(&swrm->mlock);
@@ -1939,7 +1939,7 @@ static int swrm_disconnect_port(struct swr_master *master,
 		ret = swrm_get_master_port(swrm, &mstr_port_id, &mstr_ch_mask,
 				portinfo->port_type[i], portinfo->port_id[i]);
 		if (ret) {
-			dev_err(&master->dev,
+			dev_err_ratelimited(&master->dev,
 				"%s: mstr portid for slv port %d not found\n",
 				__func__, portinfo->port_id[i]);
 			goto err;
@@ -1950,7 +1950,7 @@ static int swrm_disconnect_port(struct swr_master *master,
 					portinfo->dev_num);
 
 		if (!port_req) {
-			dev_err(&master->dev, "%s:port not enabled : port %d\n",
+			dev_err_ratelimited(&master->dev, "%s:port not enabled : port %d\n",
 					 __func__, portinfo->port_id[i]);
 			goto err;
 		}
@@ -2061,7 +2061,7 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
 
 	trace_printk("%s enter\n", __func__);
 	if (unlikely(swrm_lock_sleep(swrm) == false)) {
-		dev_err(swrm->dev, "%s Failed to hold suspend\n", __func__);
+		dev_err_ratelimited(swrm->dev, "%s Failed to hold suspend\n", __func__);
 		return IRQ_NONE;
 	}
 
@@ -2076,7 +2076,7 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
 	}
 	ret = swrm_clk_request(swrm, true);
 	if (ret) {
-		dev_err(dev, "%s: swrm clk failed\n", __func__);
+		dev_err_ratelimited(dev, "%s: swrm clk failed\n", __func__);
 		ret = IRQ_NONE;
 		goto err_audio_core_vote;
 	}
@@ -2188,19 +2188,19 @@ handle_irq:
 			break;
 		case SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW:
 			value = swr_master_read(swrm, SWRM_CMD_FIFO_STATUS(swrm->ee_val));
-			dev_err(swrm->dev,
+			dev_err_ratelimited(swrm->dev,
 				"%s: SWR read FIFO overflow fifo status %x\n",
 				__func__, value);
 			break;
 		case SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW:
 			value = swr_master_read(swrm, SWRM_CMD_FIFO_STATUS(swrm->ee_val));
-			dev_err(swrm->dev,
+			dev_err_ratelimited(swrm->dev,
 				"%s: SWR read FIFO underflow fifo status %x\n",
 				__func__, value);
 			break;
 		case SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW:
 			value = swr_master_read(swrm, SWRM_CMD_FIFO_STATUS(swrm->ee_val));
-			dev_err(swrm->dev,
+			dev_err_ratelimited(swrm->dev,
 				"%s: SWR write FIFO overflow fifo status %x\n",
 				__func__, value);
 			break;
@@ -2330,7 +2330,7 @@ static irqreturn_t swrm_wakeup_interrupt(int irq, void *dev)
 	int ret = IRQ_HANDLED;
 
 	if (!swrm || !(swrm->dev)) {
-		pr_err("%s: swrm or dev is null\n", __func__);
+		pr_err_ratelimited("%s: swrm or dev is null\n", __func__);
 		return IRQ_NONE;
 	}
 
@@ -2339,7 +2339,7 @@ static irqreturn_t swrm_wakeup_interrupt(int irq, void *dev)
 	if (swrm->state == SWR_MSTR_SSR || !swrm->dev_up) {
 		if (swrm->wake_irq > 0) {
 			if (unlikely(!irq_get_irq_data(swrm->wake_irq))) {
-				pr_err("%s: irq data is NULL\n", __func__);
+				pr_err_ratelimited("%s: irq data is NULL\n", __func__);
 				mutex_unlock(&swrm->devlock);
 				return IRQ_NONE;
 			}
@@ -2354,12 +2354,12 @@ static irqreturn_t swrm_wakeup_interrupt(int irq, void *dev)
 	}
 	mutex_unlock(&swrm->devlock);
 	if (unlikely(swrm_lock_sleep(swrm) == false)) {
-		dev_err(swrm->dev, "%s Failed to hold suspend\n", __func__);
+		dev_err_ratelimited(swrm->dev, "%s Failed to hold suspend\n", __func__);
 		goto exit;
 	}
 	if (swrm->wake_irq > 0) {
 		if (unlikely(!irq_get_irq_data(swrm->wake_irq))) {
-			pr_err("%s: irq data is NULL\n", __func__);
+			pr_err_ratelimited("%s: irq data is NULL\n", __func__);
 			return IRQ_NONE;
 		}
 		mutex_lock(&swrm->irq_lock);
@@ -2472,7 +2472,7 @@ static int swrm_get_logical_dev_num(struct swr_master *mstr, u64 dev_id,
 		}
 	}
 	if (ret)
-		dev_err_ratelimited(swrm->dev,
+		dev_err(swrm->dev,
 				"%s: device 0x%llx is not ready\n",
 				__func__, dev_id);
 
@@ -2507,19 +2507,19 @@ static void swrm_device_wakeup_vote(struct swr_master *mstr)
 	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
 
 	if (!swrm) {
-		pr_err("%s: Invalid handle to swr controller\n",
+		pr_err_ratelimited("%s: Invalid handle to swr controller\n",
 			__func__);
 		return;
 	}
 	if (unlikely(swrm_lock_sleep(swrm) == false)) {
-		dev_err(swrm->dev, "%s Failed to hold suspend\n", __func__);
+		dev_err_ratelimited(swrm->dev, "%s Failed to hold suspend\n", __func__);
 		return;
 	}
 	if (swrm_request_hw_vote(swrm, LPASS_HW_CORE, true))
-		dev_err(swrm->dev, "%s:lpass core hw enable failed\n",
+		dev_err_ratelimited(swrm->dev, "%s:lpass core hw enable failed\n",
 			__func__);
 	if (swrm_request_hw_vote(swrm, LPASS_AUDIO_CORE, true))
-		dev_err(swrm->dev, "%s:lpass audio hw enable failed\n",
+		dev_err_ratelimited(swrm->dev, "%s:lpass audio hw enable failed\n",
 			__func__);
 
 	pm_runtime_get_sync(swrm->dev);
@@ -2530,7 +2530,7 @@ static void swrm_device_wakeup_unvote(struct swr_master *mstr)
 	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(mstr);
 
 	if (!swrm) {
-		pr_err("%s: Invalid handle to swr controller\n",
+		pr_err_ratelimited("%s: Invalid handle to swr controller\n",
 			__func__);
 		return;
 	}
@@ -2655,7 +2655,7 @@ static int swrm_event_notify(struct notifier_block *self,
 						  event_notifier);
 
 	if (!swrm || !(swrm->dev)) {
-		pr_err("%s: swrm or dev is NULL\n", __func__);
+		pr_err_ratelimited("%s: swrm or dev is NULL\n", __func__);
 		return -EINVAL;
 	}
 	switch (action) {
@@ -2670,7 +2670,7 @@ static int swrm_event_notify(struct notifier_block *self,
 		}
 		break;
 	default:
-		dev_err(swrm->dev, "%s: invalid event type: %lu\n",
+		dev_err_ratelimited(swrm->dev, "%s: invalid event type: %lu\n",
 			__func__, action);
 		return -EINVAL;
 	}
@@ -2684,7 +2684,7 @@ static void swrm_notify_work_fn(struct work_struct *work)
 						  dc_presence_work);
 
 	if (!swrm || !swrm->pdev) {
-		pr_err("%s: swrm or pdev is NULL\n", __func__);
+		pr_err_ratelimited("%s: swrm or pdev is NULL\n", __func__);
 		return;
 	}
 	swrm_wcd_notify(swrm->pdev, SWR_DEVICE_DOWN, NULL);
@@ -3203,7 +3203,7 @@ static int swrm_runtime_resume(struct device *dev)
 	mutex_lock(&swrm->reslock);
 
 	if (swrm_request_hw_vote(swrm, LPASS_HW_CORE, true)) {
-		dev_err(dev, "%s:lpass core hw enable failed\n",
+		dev_err_ratelimited(dev, "%s:lpass core hw enable failed\n",
 			__func__);
 		hw_core_err = true;
 		pm_runtime_set_autosuspend_delay(&pdev->dev,
@@ -3216,7 +3216,7 @@ static int swrm_runtime_resume(struct device *dev)
 	}
 
 	if (swrm_request_hw_vote(swrm, LPASS_AUDIO_CORE, true)) {
-		dev_err(dev, "%s:lpass audio hw enable failed\n",
+		dev_err_ratelimited(dev, "%s:lpass audio hw enable failed\n",
 			__func__);
 		aud_core_err = true;
 	}
@@ -3227,7 +3227,7 @@ static int swrm_runtime_resume(struct device *dev)
 			if (swrm->wake_irq > 0) {
 				if (unlikely(!irq_get_irq_data
 				    (swrm->wake_irq))) {
-					pr_err("%s: irq data is NULL\n",
+					pr_err_ratelimited("%s: irq data is NULL\n",
 						__func__);
 					mutex_unlock(&swrm->reslock);
 					mutex_unlock(&swrm->runtime_lock);
@@ -3240,7 +3240,7 @@ static int swrm_runtime_resume(struct device *dev)
 				mutex_unlock(&swrm->irq_lock);
 			}
 			if (swrm->ipc_wakeup)
-				dev_err(dev, "%s:notifications disabled\n", __func__);
+				dev_err_ratelimited(dev, "%s:notifications disabled\n", __func__);
 			//	msm_aud_evt_blocking_notifier_call_chain(
 			//		SWR_WAKE_IRQ_DEREGISTER, (void *)swrm);
 		}
@@ -3265,7 +3265,7 @@ static int swrm_runtime_resume(struct device *dev)
 						__func__);
 					ret = 0;
 				} else if (ret) {
-					dev_err(dev,
+					dev_err_ratelimited(dev,
 						"%s: failed to wakeup swr dev %d\n",
 						__func__, swr_dev->dev_num);
 					swrm_clk_request(swrm, false);
@@ -3358,7 +3358,7 @@ static int swrm_runtime_suspend(struct device *dev)
 	mutex_unlock(&swrm->force_down_lock);
 
 	if (swrm_request_hw_vote(swrm, LPASS_HW_CORE, true)) {
-		dev_err(dev, "%s:lpass core hw enable failed\n",
+		dev_err_ratelimited(dev, "%s:lpass core hw enable failed\n",
 			__func__);
 		hw_core_err = true;
 	}
@@ -3376,7 +3376,7 @@ static int swrm_runtime_suspend(struct device *dev)
 			goto exit;
 		}
 		if (!swrm->clk_stop_mode0_supp || swrm->state == SWR_MSTR_SSR) {
-			dev_err(dev, "%s: clk stop mode not supported or SSR entry\n",
+			dev_err_ratelimited(dev, "%s: clk stop mode not supported or SSR entry\n",
 				__func__);
 			mutex_unlock(&swrm->reslock);
 			enable_bank_switch(swrm, 0, SWR_ROW_50, SWR_MIN_COL);
@@ -3394,7 +3394,7 @@ static int swrm_runtime_suspend(struct device *dev)
 						 __func__);
 					ret = 0;
 				} else if (ret) {
-					dev_err(dev,
+					dev_err_ratelimited(dev,
 						"%s: failed to shutdown swr dev %d\n",
 						__func__, swr_dev->dev_num);
 					trace_printk(
@@ -3422,7 +3422,7 @@ static int swrm_runtime_suspend(struct device *dev)
 				__func__);
 		ret = swrm_clk_request(swrm, false);
 		if (ret) {
-			dev_err(dev, "%s: swrmn clk failed\n", __func__);
+			dev_err_ratelimited(dev, "%s: swrmn clk failed\n", __func__);
 			ret = 0;
 			goto exit;
 		}
@@ -3435,7 +3435,7 @@ static int swrm_runtime_suspend(struct device *dev)
 			} else if (swrm->ipc_wakeup) {
 				//msm_aud_evt_blocking_notifier_call_chain(
 				//	SWR_WAKE_IRQ_REGISTER, (void *)swrm);
-				dev_err(dev, "%s:notifications disabled\n", __func__);
+				dev_err_ratelimited(dev, "%s:notifications disabled\n", __func__);
 				swrm->ipc_wakeup_triggered = false;
 			}
 		}
@@ -3513,7 +3513,7 @@ int swrm_register_wake_irq(struct swr_mstr_ctrl *swrm)
 		if (gpio_is_valid(irq)) {
 			swrm->wake_irq = gpio_to_irq(irq);
 			if (swrm->wake_irq < 0) {
-				dev_err(swrm->dev,
+				dev_err_ratelimited(swrm->dev,
 					"Unable to configure irq\n");
 				return swrm->wake_irq;
 			}
@@ -3521,7 +3521,7 @@ int swrm_register_wake_irq(struct swr_mstr_ctrl *swrm)
 			dir_apps_irq = platform_get_irq_byname(swrm->pdev,
 							"swr_wake_irq");
 			if (dir_apps_irq < 0) {
-				dev_err(swrm->dev,
+				dev_err_ratelimited(swrm->dev,
 					"TLMM connect gpio not found\n");
 				return -EINVAL;
 			}
@@ -3532,7 +3532,7 @@ int swrm_register_wake_irq(struct swr_mstr_ctrl *swrm)
 					   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 					   "swr_wake_irq", swrm);
 		if (ret) {
-			dev_err(swrm->dev, "%s: Failed to request irq %d\n",
+			dev_err_ratelimited(swrm->dev, "%s: Failed to request irq %d\n",
 				__func__, ret);
 			return -EINVAL;
 		}
@@ -3577,7 +3577,7 @@ static int swrm_copy_port_config(struct swr_mstr_ctrl *swrm,
 	for (idx = 0; idx < size; idx++) {
 		params = &((struct port_params *)port_cfg->params)[idx];
 		if (!params) {
-			dev_err(swrm->dev, "%s: Invalid params\n", __func__);
+			dev_err_ratelimited(swrm->dev, "%s: Invalid params\n", __func__);
 			ret = -EINVAL;
 			break;
 		}
@@ -3604,12 +3604,12 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 	struct swrm_port_config *port_cfg;
 
 	if (!pdev) {
-		pr_err("%s: pdev is NULL\n", __func__);
+		pr_err_ratelimited("%s: pdev is NULL\n", __func__);
 		return -EINVAL;
 	}
 	swrm = platform_get_drvdata(pdev);
 	if (!swrm) {
-		dev_err(&pdev->dev, "%s: swrm is NULL\n", __func__);
+		dev_err_ratelimited(&pdev->dev, "%s: swrm is NULL\n", __func__);
 		return -EINVAL;
 	}
 	mstr = &swrm->master;
@@ -3622,7 +3622,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		 * source.
 		 */
 		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL for id:%d\n",
+			dev_err_ratelimited(swrm->dev, "%s: data is NULL for id:%d\n",
 				__func__, id);
 			ret = -EINVAL;
 			break;
@@ -3641,7 +3641,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		break;
 	case SWR_CLK_FREQ:
 		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL\n", __func__);
+			dev_err_ratelimited(swrm->dev, "%s: data is NULL\n", __func__);
 			ret = -EINVAL;
 		} else {
 			mutex_lock(&swrm->mlock);
@@ -3694,7 +3694,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		if (swrm->clk_ref_count &&
 			 !wait_for_completion_timeout(&swrm->clk_off_complete,
 						   msecs_to_jiffies(500)))
-			dev_err(swrm->dev, "%s: clock voting not zero\n",
+			dev_err_ratelimited(swrm->dev, "%s: clock voting not zero\n",
 				__func__);
 
 		if (swrm->state == SWR_MSTR_UP ||
@@ -3746,7 +3746,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 					__func__);
 				ret = 0;
 			} else if (ret) {
-				dev_err(swrm->dev,
+				dev_err_ratelimited(swrm->dev,
 					"%s: failed to reset swr device %d\n",
 					__func__, swr_dev->dev_num);
 				swrm_clk_request(swrm, false);
@@ -3759,7 +3759,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		break;
 	case SWR_SET_NUM_RX_CH:
 		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL\n", __func__);
+			dev_err_ratelimited(swrm->dev, "%s: data is NULL\n", __func__);
 			ret = -EINVAL;
 		} else {
 			mutex_lock(&swrm->mlock);
@@ -3770,7 +3770,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 					ret = swr_set_device_group(swr_dev,
 								SWR_BROADCAST);
 					if (ret)
-						dev_err(swrm->dev,
+						dev_err_ratelimited(swrm->dev,
 							"%s: set num ch failed\n",
 							__func__);
 				}
@@ -3780,7 +3780,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 					ret = swr_set_device_group(swr_dev,
 								SWR_GROUP_NONE);
 					if (ret)
-						dev_err(swrm->dev,
+						dev_err_ratelimited(swrm->dev,
 							"%s: set num ch failed\n",
 							__func__);
 				}
@@ -3790,7 +3790,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		break;
 	case SWR_REGISTER_WAKE_IRQ:
 		if (!data) {
-			dev_err(swrm->dev, "%s: reg wake irq data is NULL\n",
+			dev_err_ratelimited(swrm->dev, "%s: reg wake irq data is NULL\n",
 				__func__);
 			ret = -EINVAL;
 		} else {
@@ -3798,7 +3798,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 			swrm->ipc_wakeup = *(u32 *)data;
 			ret = swrm_register_wake_irq(swrm);
 			if (ret)
-				dev_err(swrm->dev, "%s: register wake_irq failed\n",
+				dev_err_ratelimited(swrm->dev, "%s: register wake_irq failed\n",
 					__func__);
 			mutex_unlock(&swrm->mlock);
 		}
@@ -3813,7 +3813,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
 		break;
 	case SWR_SET_PORT_MAP:
 		if (!data) {
-			dev_err(swrm->dev, "%s: data is NULL for id=%d\n",
+			dev_err_ratelimited(swrm->dev, "%s: data is NULL for id=%d\n",
 				__func__, id);
 			ret = -EINVAL;
 		} else {
@@ -3833,7 +3833,7 @@ done:
 		}
 		break;
 	default:
-		dev_err(swrm->dev, "%s: swr master unknown id %d\n",
+		dev_err_ratelimited(swrm->dev, "%s: swr master unknown id %d\n",
 			__func__, id);
 		break;
 	}
@@ -3899,7 +3899,7 @@ static bool swrm_lock_sleep(struct swr_mstr_ctrl *swrm)
 					(os == SWRM_PM_AWAKE)),
 					msecs_to_jiffies(
 					SWRM_SYSTEM_RESUME_TIMEOUT_MS))) {
-		dev_err(swrm->dev, "%s: system didn't resume within %dms, s %d, w %d\n",
+		dev_err_ratelimited(swrm->dev, "%s: system didn't resume within %dms, s %d, w %d\n",
 			__func__, SWRM_SYSTEM_RESUME_TIMEOUT_MS, swrm->pm_state,
 				swrm->wlock_holders);
 		swrm_unlock_sleep(swrm);