Skip to content

Commit ea35012

Browse files
committed
ALSA: intel-nhlt: Change struct nhlt_fmt.fmt_config struct array to u8
The struct nhlt_fmt_cfg is a flexible array, because: struct nhlt_fmt { ... struct nhlt_fmt_cfg fmt_config[] { <- This ... struct nhlt_specific_cfg { ... u8 caps[]; <- Because of this }; }; }; Strangely sparse did not complain about this, but it was misused by drivers, treating it as a normal array and not a flexible one. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 5a5ed50 commit ea35012

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/sound/intel-nhlt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct nhlt_fmt_cfg {
5858

5959
struct nhlt_fmt {
6060
u8 fmt_count;
61-
struct nhlt_fmt_cfg fmt_config[];
61+
u8 fmt_config[]; /* flexible array of 'struct nhlt_fmt_cfg' */
6262
} __packed;
6363

6464
struct nhlt_endpoint {

sound/hda/intel-nhlt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
5656

5757
/* find max number of channels based on format_configuration */
5858
if (fmt_configs->fmt_count) {
59-
struct nhlt_fmt_cfg *fmt_cfg = fmt_configs->fmt_config;
59+
struct nhlt_fmt_cfg *fmt_cfg;
6060

6161
dev_dbg(dev, "found %d format definitions\n",
6262
fmt_configs->fmt_count);
6363

64+
fmt_cfg = (struct nhlt_fmt_cfg *)fmt_configs->fmt_config;
6465
for (i = 0; i < fmt_configs->fmt_count; i++) {
6566
struct wav_fmt_ext *fmt_ext;
6667

@@ -189,7 +190,7 @@ int intel_nhlt_ssp_mclk_mask(struct nhlt_acpi_table *nhlt, int ssp_num)
189190
epnt->virtual_bus_id == ssp_num) {
190191

191192
fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);
192-
cfg = fmt->fmt_config;
193+
cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config;
193194

194195
/*
195196
* In theory all formats should use the same MCLK but it doesn't hurt to
@@ -241,7 +242,7 @@ static struct nhlt_specific_cfg *
241242
nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
242243
u32 rate, u8 vbps, u8 bps, bool ignore_vbps)
243244
{
244-
struct nhlt_fmt_cfg *cfg = fmt->fmt_config;
245+
struct nhlt_fmt_cfg *cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config;
245246
struct wav_fmt *wfmt;
246247
u16 _bps, _vbps;
247248
int i;

0 commit comments

Comments
 (0)