summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCássio Gabriel <cassiogabrielcontato@gmail.com>2026-05-31 22:23:35 -0300
committerTakashi Iwai <tiwai@suse.de>2026-06-01 11:29:02 +0200
commite9c82f767f0f46ef90eeefccc0a8006cc86aff40 (patch)
tree0f2a30dfa45fb67d68a28817ed91b82cf79155c6 /include
parent8a2d0b5496850403d1105efbbe54aa8fc68cae6f (diff)
ALSA: core: Use flexible array for card private data
snd_card_new() and snd_devm_card_new() allocate struct snd_card together with optional driver-private storage. The storage is currently described only by open-coded sizeof(*card) + extra_size arithmetic, and snd_card_init() reaches it by manually adding sizeof(struct snd_card) to the card pointer. Make the trailing storage explicit with a flexible array member. Use kzalloc_flex() for the regular allocation path and struct_size() for the devres allocation size. This documents the layout and avoids open-coded variable-size object arithmetic. Align the flexible array to unsigned long long so the driver-private area does not become less aligned than the old sizeof(struct snd_card) tail address on 32-bit ABIs. Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260531-alsa-card-private-flex-array-v2-1-e4ff67f5bd23@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/sound/core.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/sound/core.h b/include/sound/core.h
index 4093ec82a0a1..4bb76c21c956 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -148,6 +148,8 @@ struct snd_card {
struct snd_mixer_oss *mixer_oss;
int mixer_oss_change_count;
#endif
+
+ unsigned char private_data_area[] __aligned(__alignof__(unsigned long long));
};
#define dev_to_snd_card(p) container_of(p, struct snd_card, card_dev)