Loading sound/soc/codecs/audio-iio-aux.c +29 −54 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ // // Author: Herve Codina <herve.codina@bootlin.com> #include <linux/cleanup.h> #include <linux/iio/consumer.h> #include <linux/minmax.h> #include <linux/mod_devicetable.h> Loading Loading @@ -131,33 +132,27 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, struct audio_iio_aux_chan *chan) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); char *output_name; char *input_name; char *pga_name; int ret; input_name = kasprintf(GFP_KERNEL, "%s IN", chan->name); /* Allocated names are not needed afterwards (duplicated in ASoC internals) */ char *input_name __free(kfree) = kasprintf(GFP_KERNEL, "%s IN", chan->name); if (!input_name) return -ENOMEM; output_name = kasprintf(GFP_KERNEL, "%s OUT", chan->name); if (!output_name) { ret = -ENOMEM; goto out_free_input_name; } char *output_name __free(kfree) = kasprintf(GFP_KERNEL, "%s OUT", chan->name); if (!output_name) return -ENOMEM; pga_name = kasprintf(GFP_KERNEL, "%s PGA", chan->name); if (!pga_name) { ret = -ENOMEM; goto out_free_output_name; } char *pga_name __free(kfree) = kasprintf(GFP_KERNEL, "%s PGA", chan->name); if (!pga_name) return -ENOMEM; widgets[0] = SND_SOC_DAPM_INPUT(input_name); widgets[1] = SND_SOC_DAPM_OUTPUT(output_name); widgets[2] = SND_SOC_DAPM_PGA(pga_name, SND_SOC_NOPM, 0, 0, NULL, 0); ret = snd_soc_dapm_new_controls(dapm, widgets, 3); if (ret) goto out_free_pga_name; return ret; routes[0].sink = pga_name; routes[0].control = NULL; Loading @@ -165,17 +160,8 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, routes[1].sink = output_name; routes[1].control = NULL; routes[1].source = pga_name; ret = snd_soc_dapm_add_routes(dapm, routes, 2); /* Allocated names are no more needed (duplicated in ASoC internals) */ out_free_pga_name: kfree(pga_name); out_free_output_name: kfree(output_name); out_free_input_name: kfree(input_name); return ret; return snd_soc_dapm_add_routes(dapm, routes, 2); } static int audio_iio_aux_component_probe(struct snd_soc_component *component) Loading Loading @@ -244,8 +230,6 @@ static int audio_iio_aux_probe(struct platform_device *pdev) struct audio_iio_aux_chan *iio_aux_chan; struct device *dev = &pdev->dev; struct audio_iio_aux *iio_aux; const char **names; u32 *invert_ranges; int count; int ret; int i; Loading @@ -262,22 +246,22 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux->num_chans = count; names = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL); const char **names __free(kfree) = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL); if (!names) return -ENOMEM; invert_ranges = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL); if (!invert_ranges) { ret = -ENOMEM; goto out_free_names; } u32 *invert_ranges __free(kfree) = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL); if (!invert_ranges) return -ENOMEM; ret = device_property_read_string_array(dev, "io-channel-names", names, iio_aux->num_chans); if (ret < 0) { dev_err_probe(dev, ret, "failed to read io-channel-names\n"); goto out_free_invert_ranges; } if (ret < 0) return dev_err_probe(dev, ret, "failed to read io-channel-names\n"); /* * snd-control-invert-range is optional and can contain fewer items Loading @@ -288,10 +272,8 @@ static int audio_iio_aux_probe(struct platform_device *pdev) count = min_t(unsigned int, count, iio_aux->num_chans); ret = device_property_read_u32_array(dev, "snd-control-invert-range", invert_ranges, count); if (ret < 0) { dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); goto out_free_invert_ranges; } if (ret < 0) return dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); } for (i = 0; i < iio_aux->num_chans; i++) { Loading @@ -300,23 +282,16 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux_chan->is_invert_range = invert_ranges[i]; iio_aux_chan->iio_chan = devm_iio_channel_get(dev, iio_aux_chan->name); if (IS_ERR(iio_aux_chan->iio_chan)) { ret = PTR_ERR(iio_aux_chan->iio_chan); dev_err_probe(dev, ret, "get IIO channel '%s' failed\n", if (IS_ERR(iio_aux_chan->iio_chan)) return dev_err_probe(dev, PTR_ERR(iio_aux_chan->iio_chan), "get IIO channel '%s' failed\n", iio_aux_chan->name); goto out_free_invert_ranges; } } platform_set_drvdata(pdev, iio_aux); ret = devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, return devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, NULL, 0); out_free_invert_ranges: kfree(invert_ranges); out_free_names: kfree(names); return ret; } static const struct of_device_id audio_iio_aux_ids[] = { Loading sound/soc/codecs/wcd9335.c +9 −13 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/cleanup.h> #include <linux/device.h> #include <linux/wait.h> #include <linux/bitops.h> Loading Loading @@ -2714,25 +2715,23 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; char *wname; char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); if (!widget_name) char *wname __free(kfree) = kmemdup_nul(w->name, 15, GFP_KERNEL); if (!wname) return -ENOMEM; wname = widget_name; widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; return -EINVAL; } dec_adc_mux_name = widget_name; Loading @@ -2740,16 +2739,14 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; return -EINVAL; } tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator; Loading Loading @@ -2836,8 +2833,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, snd_soc_component_update_bits(comp, tx_vol_ctl_reg, 0x10, 0x00); break; } out: kfree(wname); return ret; } Loading sound/soc/codecs/wcd934x.c +9 −13 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019, Linaro Limited #include <linux/cleanup.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/interrupt.h> Loading Loading @@ -4973,25 +4974,23 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; char *wname; char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL); if (!wname) return -ENOMEM; wname = widget_name; widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; return -EINVAL; } dec_adc_mux_name = widget_name; Loading @@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; return -EINVAL; } tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; Loading Loading @@ -5101,8 +5098,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, WCD934X_DEC_PWR_LVL_DF); break; } out: kfree(wname); return ret; } Loading sound/soc/generic/audio-graph-card.c +2 −3 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ // // based on ${LINUX}/sound/soc/generic/simple-card.c #include <linux/cleanup.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/gpio/consumer.h> Loading Loading @@ -573,10 +574,9 @@ static int graph_get_dais_count(struct simple_util_priv *priv, int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) { struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info *li; int ret; li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; Loading Loading @@ -628,7 +628,6 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) if (ret < 0) goto err; devm_kfree(dev, li); return 0; err: Loading sound/soc/generic/audio-graph-card2.c +1 −4 Original line number Diff line number Diff line Loading @@ -1350,10 +1350,9 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, struct graph2_custom_hooks *hooks) { struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info *li; int ret; li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; Loading Loading @@ -1417,8 +1416,6 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ret = devm_snd_soc_register_card(dev, card); err: devm_kfree(dev, li); if (ret < 0) dev_err_probe(dev, ret, "parse error\n"); Loading Loading
sound/soc/codecs/audio-iio-aux.c +29 −54 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ // // Author: Herve Codina <herve.codina@bootlin.com> #include <linux/cleanup.h> #include <linux/iio/consumer.h> #include <linux/minmax.h> #include <linux/mod_devicetable.h> Loading Loading @@ -131,33 +132,27 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, struct audio_iio_aux_chan *chan) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); char *output_name; char *input_name; char *pga_name; int ret; input_name = kasprintf(GFP_KERNEL, "%s IN", chan->name); /* Allocated names are not needed afterwards (duplicated in ASoC internals) */ char *input_name __free(kfree) = kasprintf(GFP_KERNEL, "%s IN", chan->name); if (!input_name) return -ENOMEM; output_name = kasprintf(GFP_KERNEL, "%s OUT", chan->name); if (!output_name) { ret = -ENOMEM; goto out_free_input_name; } char *output_name __free(kfree) = kasprintf(GFP_KERNEL, "%s OUT", chan->name); if (!output_name) return -ENOMEM; pga_name = kasprintf(GFP_KERNEL, "%s PGA", chan->name); if (!pga_name) { ret = -ENOMEM; goto out_free_output_name; } char *pga_name __free(kfree) = kasprintf(GFP_KERNEL, "%s PGA", chan->name); if (!pga_name) return -ENOMEM; widgets[0] = SND_SOC_DAPM_INPUT(input_name); widgets[1] = SND_SOC_DAPM_OUTPUT(output_name); widgets[2] = SND_SOC_DAPM_PGA(pga_name, SND_SOC_NOPM, 0, 0, NULL, 0); ret = snd_soc_dapm_new_controls(dapm, widgets, 3); if (ret) goto out_free_pga_name; return ret; routes[0].sink = pga_name; routes[0].control = NULL; Loading @@ -165,17 +160,8 @@ static int audio_iio_aux_add_dapms(struct snd_soc_component *component, routes[1].sink = output_name; routes[1].control = NULL; routes[1].source = pga_name; ret = snd_soc_dapm_add_routes(dapm, routes, 2); /* Allocated names are no more needed (duplicated in ASoC internals) */ out_free_pga_name: kfree(pga_name); out_free_output_name: kfree(output_name); out_free_input_name: kfree(input_name); return ret; return snd_soc_dapm_add_routes(dapm, routes, 2); } static int audio_iio_aux_component_probe(struct snd_soc_component *component) Loading Loading @@ -244,8 +230,6 @@ static int audio_iio_aux_probe(struct platform_device *pdev) struct audio_iio_aux_chan *iio_aux_chan; struct device *dev = &pdev->dev; struct audio_iio_aux *iio_aux; const char **names; u32 *invert_ranges; int count; int ret; int i; Loading @@ -262,22 +246,22 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux->num_chans = count; names = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL); const char **names __free(kfree) = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL); if (!names) return -ENOMEM; invert_ranges = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL); if (!invert_ranges) { ret = -ENOMEM; goto out_free_names; } u32 *invert_ranges __free(kfree) = kcalloc(iio_aux->num_chans, sizeof(*invert_ranges), GFP_KERNEL); if (!invert_ranges) return -ENOMEM; ret = device_property_read_string_array(dev, "io-channel-names", names, iio_aux->num_chans); if (ret < 0) { dev_err_probe(dev, ret, "failed to read io-channel-names\n"); goto out_free_invert_ranges; } if (ret < 0) return dev_err_probe(dev, ret, "failed to read io-channel-names\n"); /* * snd-control-invert-range is optional and can contain fewer items Loading @@ -288,10 +272,8 @@ static int audio_iio_aux_probe(struct platform_device *pdev) count = min_t(unsigned int, count, iio_aux->num_chans); ret = device_property_read_u32_array(dev, "snd-control-invert-range", invert_ranges, count); if (ret < 0) { dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); goto out_free_invert_ranges; } if (ret < 0) return dev_err_probe(dev, ret, "failed to read snd-control-invert-range\n"); } for (i = 0; i < iio_aux->num_chans; i++) { Loading @@ -300,23 +282,16 @@ static int audio_iio_aux_probe(struct platform_device *pdev) iio_aux_chan->is_invert_range = invert_ranges[i]; iio_aux_chan->iio_chan = devm_iio_channel_get(dev, iio_aux_chan->name); if (IS_ERR(iio_aux_chan->iio_chan)) { ret = PTR_ERR(iio_aux_chan->iio_chan); dev_err_probe(dev, ret, "get IIO channel '%s' failed\n", if (IS_ERR(iio_aux_chan->iio_chan)) return dev_err_probe(dev, PTR_ERR(iio_aux_chan->iio_chan), "get IIO channel '%s' failed\n", iio_aux_chan->name); goto out_free_invert_ranges; } } platform_set_drvdata(pdev, iio_aux); ret = devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, return devm_snd_soc_register_component(dev, &audio_iio_aux_component_driver, NULL, 0); out_free_invert_ranges: kfree(invert_ranges); out_free_names: kfree(names); return ret; } static const struct of_device_id audio_iio_aux_ids[] = { Loading
sound/soc/codecs/wcd9335.c +9 −13 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/cleanup.h> #include <linux/device.h> #include <linux/wait.h> #include <linux/bitops.h> Loading Loading @@ -2714,25 +2715,23 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; char *wname; char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); if (!widget_name) char *wname __free(kfree) = kmemdup_nul(w->name, 15, GFP_KERNEL); if (!wname) return -ENOMEM; wname = widget_name; widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; return -EINVAL; } dec_adc_mux_name = widget_name; Loading @@ -2740,16 +2739,14 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; return -EINVAL; } tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator; Loading Loading @@ -2836,8 +2833,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, snd_soc_component_update_bits(comp, tx_vol_ctl_reg, 0x10, 0x00); break; } out: kfree(wname); return ret; } Loading
sound/soc/codecs/wcd934x.c +9 −13 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019, Linaro Limited #include <linux/cleanup.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/interrupt.h> Loading Loading @@ -4973,25 +4974,23 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; char *wname; char *widget_name; int ret = 0, amic_n; u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; char *dec; u8 hpf_coff_freq; widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL); if (!wname) return -ENOMEM; wname = widget_name; widget_name = wname; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; return -EINVAL; } dec_adc_mux_name = widget_name; Loading @@ -4999,16 +4998,14 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, if (!dec) { dev_err(comp->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; return -EINVAL; } ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { dev_err(comp->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; return -EINVAL; } tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; Loading Loading @@ -5101,8 +5098,7 @@ static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, WCD934X_DEC_PWR_LVL_DF); break; } out: kfree(wname); return ret; } Loading
sound/soc/generic/audio-graph-card.c +2 −3 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ // // based on ${LINUX}/sound/soc/generic/simple-card.c #include <linux/cleanup.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/gpio/consumer.h> Loading Loading @@ -573,10 +574,9 @@ static int graph_get_dais_count(struct simple_util_priv *priv, int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) { struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info *li; int ret; li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; Loading Loading @@ -628,7 +628,6 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) if (ret < 0) goto err; devm_kfree(dev, li); return 0; err: Loading
sound/soc/generic/audio-graph-card2.c +1 −4 Original line number Diff line number Diff line Loading @@ -1350,10 +1350,9 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, struct graph2_custom_hooks *hooks) { struct snd_soc_card *card = simple_priv_to_card(priv); struct link_info *li; int ret; li = devm_kzalloc(dev, sizeof(*li), GFP_KERNEL); struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); if (!li) return -ENOMEM; Loading Loading @@ -1417,8 +1416,6 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ret = devm_snd_soc_register_card(dev, card); err: devm_kfree(dev, li); if (ret < 0) dev_err_probe(dev, ret, "parse error\n"); Loading