summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/audio-iio-aux.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:35:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:31 +0000
commit85c675d0d09a45a135bddd15d7b385f8758c32fb (patch)
tree76267dbc9b9a130337be3640948fe397b04ac629 /sound/soc/codecs/audio-iio-aux.c
parentAdding upstream version 6.6.15. (diff)
downloadlinux-85c675d0d09a45a135bddd15d7b385f8758c32fb.tar.xz
linux-85c675d0d09a45a135bddd15d7b385f8758c32fb.zip
Adding upstream version 6.7.7.upstream/6.7.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sound/soc/codecs/audio-iio-aux.c')
-rw-r--r--sound/soc/codecs/audio-iio-aux.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-aux.c
index a8bf14239b..1e8e1effc2 100644
--- a/sound/soc/codecs/audio-iio-aux.c
+++ b/sound/soc/codecs/audio-iio-aux.c
@@ -26,8 +26,8 @@ struct audio_iio_aux_chan {
struct audio_iio_aux {
struct device *dev;
- struct audio_iio_aux_chan *chans;
unsigned int num_chans;
+ struct audio_iio_aux_chan chans[] __counted_by(num_chans);
};
static int audio_iio_aux_info_volsw(struct snd_kcontrol *kcontrol,
@@ -250,23 +250,18 @@ static int audio_iio_aux_probe(struct platform_device *pdev)
int ret;
int i;
- iio_aux = devm_kzalloc(dev, sizeof(*iio_aux), GFP_KERNEL);
+ count = device_property_string_array_count(dev, "io-channel-names");
+ if (count < 0)
+ return dev_err_probe(dev, count, "failed to count io-channel-names\n");
+
+ iio_aux = devm_kzalloc(dev, struct_size(iio_aux, chans, count), GFP_KERNEL);
if (!iio_aux)
return -ENOMEM;
iio_aux->dev = dev;
- count = device_property_string_array_count(dev, "io-channel-names");
- if (count < 0)
- return dev_err_probe(dev, count, "failed to count io-channel-names\n");
-
iio_aux->num_chans = count;
- iio_aux->chans = devm_kmalloc_array(dev, iio_aux->num_chans,
- sizeof(*iio_aux->chans), GFP_KERNEL);
- if (!iio_aux->chans)
- return -ENOMEM;
-
names = kcalloc(iio_aux->num_chans, sizeof(*names), GFP_KERNEL);
if (!names)
return -ENOMEM;