On Fri, May 17, 2024 at 02:58:05PM +0200, Alvin Šipraga wrote: > +++ b/sound/soc/codecs/ad24xx-codec.c > @@ -0,0 +1,665 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * AD24xx codec driver Please make the whole comment a C++ comment. > +static const char *const ad24xx_codec_slot_size_text[] = { > + "8 bits", "12 bits", "16 bits", "20 bits", > + "24 bits", "28 bits", "32 bits", > +}; Why is this configured by the user rather than via set_tdm_slot(), and how would one usefully use this at runtime? > +static int ad24xx_codec_slot_config_put(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + } else if (priv == &ad24xx_codec_up_slot_format_enum || > + priv == &ad24xx_codec_dn_slot_format_enum) { > + if (val >= ARRAY_SIZE(ad24xx_codec_slot_format_text)) > + return -EINVAL; > + slot_config->format[direction] = val; > + } else > + return -ENOENT; If one side has {} both sides should, see coding-style.rst. > + > + return 0; > +} This won't flag changes by returning 1 which will mean no events are generated and break some UIs. Please show the output of the mixer-test selftest on new submissions, it will check for this and other issues. > + /* Main node must be BCLK/FSYNC consumer, subordinate node provider */ > + if ((fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != > + (is_a2b_main(adc->node) ? SND_SOC_DAIFMT_CBC_CFC : > + SND_SOC_DAIFMT_CBP_CFP)) > + return -EINVAL; Please don't use the ternery operator like this, it just makes things harder to read. > + val = bclk_invert ? A2B_I2SCFG_RXBCLKINV_MASK : > + A2B_I2SCFG_TXBCLKINV_MASK; Similarly, please use normal conditional statements. > +static int ad24xx_codec_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params, > + struct snd_soc_dai *dai) > + > + /* Finally, request slots */ > + ret = a2b_node_request_slots(adc->node, &slot_req); > + if (ret) > + return ret; Note that hw_params() can be called multiple times before starting the audio stream, will this leak? > + struct snd_soc_dai *dai) > +{ > + struct snd_soc_component *component = dai->component; > + struct ad24xx_codec *adc = snd_soc_component_get_drvdata(component); > + int ret; > + > + ret = a2b_node_free_slots(adc->node); > + if (ret) > + return ret; What if we close without having called hw_params()? > +static const struct snd_soc_dai_driver ad24xx_codec_dai_drv[] = { > + [AD24XX_DAI_I2S] = { > + .name = "ad24xx-i2s", > + .playback = { > + .stream_name = "I2S Playback", > + .channels_min = 1, > + .channels_max = 32, > + }, > + .capture = { > + .stream_name = "I2S Capture", > + .channels_min = 1, > + .channels_max = 32, > + }, > + .ops = &ad24xx_codec_dai_ops, > + .symmetric_rate = 1, > + }, > +}; Why is this an array? > +static const struct regmap_config ad24xx_codec_regmap_config = { > + .reg_bits = 8, > + .val_bits = 8, > + .cache_type = REGCACHE_RBTREE, > +}; New code should use _MAPLE unless there's a strong reason to use something else.
Attachment:
signature.asc
Description: PGP signature