Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs42l42: Some small code improvements

Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>:

This is a collection of minor improvements to the code or comments.

+21 -16
+16 -8
sound/soc/codecs/cs42l42.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/moduleparam.h> 14 14 #include <linux/version.h> 15 - #include <linux/kernel.h> 15 + #include <linux/types.h> 16 16 #include <linux/init.h> 17 17 #include <linux/delay.h> 18 18 #include <linux/i2c.h> ··· 36 36 37 37 #include "cs42l42.h" 38 38 #include "cirrus_legacy.h" 39 + 40 + static const char * const cs42l42_supply_names[] = { 41 + "VA", 42 + "VP", 43 + "VCP", 44 + "VD_FILT", 45 + "VL", 46 + }; 39 47 40 48 static const struct reg_default cs42l42_reg_defaults[] = { 41 49 { CS42L42_FRZ_CTL, 0x00 }, ··· 403 395 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); 404 396 u8 val; 405 397 406 - /* all bits of SLOW_START_EN much change together */ 398 + /* all bits of SLOW_START_EN must change together */ 407 399 switch (ucontrol->value.integer.value[0]) { 408 400 case 0: 409 401 val = 0; ··· 893 885 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); 894 886 unsigned int channels = params_channels(params); 895 887 unsigned int width = (params_width(params) / 8) - 1; 888 + unsigned int slot_width = 0; 896 889 unsigned int val = 0; 897 890 int ret; 898 891 899 892 cs42l42->srate = params_rate(params); 900 - cs42l42->bclk = snd_soc_params_to_bclk(params); 901 - 902 - /* I2S frame always has 2 channels even for mono audio */ 903 - if (channels == 1) 904 - cs42l42->bclk *= 2; 905 893 906 894 /* 907 895 * Assume 24-bit samples are in 32-bit slots, to prevent SCLK being 908 896 * more than assumed (which would result in overclocking). 909 897 */ 910 898 if (params_width(params) == 24) 911 - cs42l42->bclk = (cs42l42->bclk / 3) * 4; 899 + slot_width = 32; 900 + 901 + /* I2S frame always has multiple of 2 channels */ 902 + cs42l42->bclk = snd_soc_tdm_params_to_bclk(params, slot_width, 0, 2); 912 903 913 904 switch (substream->stream) { 914 905 case SNDRV_PCM_STREAM_CAPTURE: ··· 2221 2214 return ret; 2222 2215 } 2223 2216 2217 + BUILD_BUG_ON(ARRAY_SIZE(cs42l42_supply_names) != ARRAY_SIZE(cs42l42->supplies)); 2224 2218 for (i = 0; i < ARRAY_SIZE(cs42l42->supplies); i++) 2225 2219 cs42l42->supplies[i].supply = cs42l42_supply_names[i]; 2226 2220
+5 -8
sound/soc/codecs/cs42l42.h
··· 12 12 #ifndef __CS42L42_H__ 13 13 #define __CS42L42_H__ 14 14 15 + #include <dt-bindings/sound/cs42l42.h> 16 + #include <linux/device.h> 17 + #include <linux/gpio.h> 15 18 #include <linux/mutex.h> 19 + #include <linux/regmap.h> 20 + #include <linux/regulator/consumer.h> 16 21 #include <sound/jack.h> 17 22 #include <sound/cs42l42.h> 18 - 19 - static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = { 20 - "VA", 21 - "VP", 22 - "VCP", 23 - "VD_FILT", 24 - "VL", 25 - }; 26 23 27 24 struct cs42l42_private { 28 25 struct regmap *regmap;