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

ASoC: cs35l56: Set access permissions on volatile

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

The CAL_SET_STATUS and CAL_DATA_RB controls are volatile and read-only, but
the existing ASoC macros to define controls don't allow setting access
permissions, so those controls were marked as non-volatile read/write.
These four patches fix that.

The first two patches add two new control macros to soc.h. I really don't
like codec drivers open-coding a kcontrol_new content for a control that
will be managed by the ASoC info/get/put handlers. If a new type of ASoC
control definition is needed it's better to have it in soc.h so all the
dependencies between ASoC and the kcontrol_new content are in one place.

+23 -6
+14
include/sound/soc.h
··· 319 319 #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ 320 320 SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) 321 321 322 + #define SOC_ENUM_EXT_ACC(xname, xenum, xhandler_get, xhandler_put, xaccess) \ 323 + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 324 + .access = xaccess, \ 325 + .info = snd_soc_info_enum_double, \ 326 + .get = xhandler_get, .put = xhandler_put, \ 327 + .private_value = (unsigned long)&xenum } 328 + 322 329 #define SND_SOC_BYTES(xname, xbase, xregs) \ 323 330 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 324 331 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ ··· 334 327 {.base = xbase, .num_regs = xregs }) } 335 328 #define SND_SOC_BYTES_E(xname, xbase, xregs, xhandler_get, xhandler_put) \ 336 329 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 330 + .info = snd_soc_bytes_info, .get = xhandler_get, \ 331 + .put = xhandler_put, .private_value = \ 332 + ((unsigned long)&(struct soc_bytes) \ 333 + {.base = xbase, .num_regs = xregs }) } 334 + #define SND_SOC_BYTES_E_ACC(xname, xbase, xregs, xhandler_get, xhandler_put, xaccess) \ 335 + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 336 + .access = xaccess, \ 337 337 .info = snd_soc_bytes_info, .get = xhandler_get, \ 338 338 .put = xhandler_put, .private_value = \ 339 339 ((unsigned long)&(struct soc_bytes) \
+9 -6
sound/soc/codecs/cs35l56.c
··· 95 95 SOC_SINGLE_EXT("Posture Number", CS35L56_MAIN_POSTURE_NUMBER, 96 96 0, 255, 0, 97 97 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 98 - SOC_ENUM_EXT("CAL_SET_STATUS", cs35l56_cal_set_status_enum, 99 - cs35l56_cal_set_status_ctl_get, NULL), 98 + SOC_ENUM_EXT_ACC("CAL_SET_STATUS", cs35l56_cal_set_status_enum, 99 + cs35l56_cal_set_status_ctl_get, NULL, 100 + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), 100 101 }; 101 102 102 103 static const struct snd_kcontrol_new cs35l63_controls[] = { ··· 117 116 SOC_SINGLE_EXT("Posture Number", CS35L63_MAIN_POSTURE_NUMBER, 118 117 0, 255, 0, 119 118 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 120 - SOC_ENUM_EXT("CAL_SET_STATUS", cs35l56_cal_set_status_enum, 121 - cs35l56_cal_set_status_ctl_get, NULL), 119 + SOC_ENUM_EXT_ACC("CAL_SET_STATUS", cs35l56_cal_set_status_enum, 120 + cs35l56_cal_set_status_ctl_get, NULL, 121 + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), 122 122 }; 123 123 124 124 static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx1_enum, ··· 1099 1097 static const struct snd_kcontrol_new cs35l56_cal_data_restore_controls[] = { 1100 1098 SND_SOC_BYTES_E("CAL_DATA", 0, sizeof(struct cirrus_amp_cal_data) / sizeof(u32), 1101 1099 cs35l56_cal_data_ctl_get, cs35l56_cal_data_ctl_set), 1102 - SND_SOC_BYTES_E("CAL_DATA_RB", 0, sizeof(struct cirrus_amp_cal_data) / sizeof(u32), 1103 - cs35l56_cal_data_rb_ctl_get, NULL), 1100 + SND_SOC_BYTES_E_ACC("CAL_DATA_RB", 0, sizeof(struct cirrus_amp_cal_data) / sizeof(u32), 1101 + cs35l56_cal_data_rb_ctl_get, NULL, 1102 + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), 1104 1103 }; 1105 1104 1106 1105 static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56)