Skip to content

Commit 061fade

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: SDCA: Fix some holes in the regmap readable/writeable helpers
The current regmap readable/writeable helper functions always allow the Next flag and allows any Control Number. Mask the Next flag based on SDCA_ACCESS_MODE_DUAL which is the only Mode that supports it. Also check that the Control Number is valid for the given control. Fixes: e3f7caf ("ASoC: SDCA: Add generic regmap SDCA helpers") Signed-off-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c58c35e commit 061fade

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

sound/soc/sdca/sdca_regmap.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ bool sdca_regmap_readable(struct sdca_function_data *function, unsigned int reg)
7272
if (!control)
7373
return false;
7474

75+
if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list))
76+
return false;
77+
7578
switch (control->mode) {
7679
case SDCA_ACCESS_MODE_RW:
7780
case SDCA_ACCESS_MODE_RO:
78-
case SDCA_ACCESS_MODE_DUAL:
7981
case SDCA_ACCESS_MODE_RW1S:
8082
case SDCA_ACCESS_MODE_RW1C:
83+
if (SDW_SDCA_NEXT_CTL(0) & reg)
84+
return false;
85+
fallthrough;
86+
case SDCA_ACCESS_MODE_DUAL:
8187
/* No access to registers marked solely for device use */
8288
return control->layers & ~SDCA_ACCESS_LAYER_DEVICE;
8389
default:
@@ -104,11 +110,17 @@ bool sdca_regmap_writeable(struct sdca_function_data *function, unsigned int reg
104110
if (!control)
105111
return false;
106112

113+
if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list))
114+
return false;
115+
107116
switch (control->mode) {
108117
case SDCA_ACCESS_MODE_RW:
109-
case SDCA_ACCESS_MODE_DUAL:
110118
case SDCA_ACCESS_MODE_RW1S:
111119
case SDCA_ACCESS_MODE_RW1C:
120+
if (SDW_SDCA_NEXT_CTL(0) & reg)
121+
return false;
122+
fallthrough;
123+
case SDCA_ACCESS_MODE_DUAL:
112124
/* No access to registers marked solely for device use */
113125
return control->layers & ~SDCA_ACCESS_LAYER_DEVICE;
114126
default:

0 commit comments

Comments
 (0)