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

iio: buffer: initialize masklength accumulator to 0

Since masklength is marked as [INTERN], no drivers should assign it and
the value will always be 0. Therefore, the local ml accumulator variable
in iio_buffers_alloc_sysfs_and_mask() will always start out as 0.

This changes the code to explicitly set ml to 0 to make it clear that
drivers should not be trying to override the masklength field.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20240425-b4-iio-masklength-cleanup-v1-3-d3d16318274d@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
79df437b 75616d2e

+1 -1
+1 -1
drivers/iio/industrialio-buffer.c
··· 1744 1744 1745 1745 channels = indio_dev->channels; 1746 1746 if (channels) { 1747 - int ml = indio_dev->masklength; 1747 + int ml = 0; 1748 1748 1749 1749 for (i = 0; i < indio_dev->num_channels; i++) 1750 1750 ml = max(ml, channels[i].scan_index + 1);