mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-13 07:31:07 +00:00
iio: adc: xilinx-ams: refactor alarm mapping to table-driven approach
Replace multiple open-coded switch statements that map between scan_index, alarm bits, and register offsets with a centralized table-driven approach. Introduce a struct-based alarm_map to describe the relationship between scan indices and alarm offsets, and add a helper to translate scan_index to event IDs. This removes duplicated logic across ams_get_alarm_offset(), ams_event_to_channel(), and ams_get_alarm_mask(). The new approach improves maintainability, reduces code size, and makes it easier to extend or modify alarm mappings in the future, while preserving existing behavior. Signed-off-by: Guilherme Ivo Bozi <guilherme.bozi@usp.br> Reviewed-by: Salih Erim <salih.erim@amd.com> Tested-by: Salih Erim <salih.erim@amd.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
f3c1ef2bca
commit
43a66cae2e
1 changed files with 58 additions and 103 deletions
Loading…
Add table
Add a link
Reference in a new issue