iio: light: zopt2201: Remove code duplication in scale write functions
authorBeatriz Viana Costa <beatrizvianacosta16@gmail.com>
Thu, 24 Apr 2025 00:21:44 +0000 (21:21 -0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 May 2025 13:20:28 +0000 (14:20 +0100)
commit50ed17cdfd7f32f1b0f87da0aaabcd5e8dd23f19
tree92c94a0a06d480ad5842bb0a1c2c29e8db410070
parent52c43d80fa8370eb877fc63b1fc1eec67e1b1410
iio: light: zopt2201: Remove code duplication in scale write functions

Consolidate duplicated logic from zopt2201_write_scale_als_by_idx() and
zopt2201_write_scale_uvb_by_idx() into a new generic helper function
zopt2201_write_scale_by_idx(). This function takes an additional
parameter: a pointer to a zopt2201_scale array.

To support this, the previously anonymous and duplicated struct used in
the scale arrays was promoted to a named struct: zopt2201_scale.

This change also corrects an incorrect array access that existed in
zopt2201_write_scale_uvb_by_idx().

Signed-off-by: Beatriz Viana Costa <beatrizvianacosta16@gmail.com>
Co-developed-by: Gabriela Victor <gabevictor333@gmail.com>
Signed-off-by: Gabriela Victor <gabevictor333@gmail.com>
Link: https://patch.msgid.link/20250424002144.23260-1-beatrizvianacosta16@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/zopt2201.c