[PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design

Guilherme Ivo Bozi posted 3 patches 2 months ago
drivers/iio/adc/xilinx-ams.c | 190 +++++++++++++----------------------
1 file changed, 71 insertions(+), 119 deletions(-)
[PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design
Posted by Guilherme Ivo Bozi 2 months ago
This series addresses significant code duplication in alarm handling
logic across the Xilinx AMS IIO driver.

To address this, the series introduces a centralized table-driven
mapping (alarm_map) that replaces multiple switch statements spread
across the driver.

This improves:
- maintainability (single source of truth for mappings)
- readability (removes repeated switch logic)
- extensibility (new alarms require only table updates)

No functional changes are intended.

Series overview:
- Patch 1: fix out-of-bounds channel lookup 
- Patch 2: convert mutex handling to guard(mutex) 
- Patch 3: introduce table-driven alarm mapping

v1 -> v2:
- Fixed Fixes tag format
- Replaced AMS_ALARM_INVALID with AMS_ALARM_NONE
- Changed alarm_map base_offset type

v2 -> v3:
- Replace 'i >= num_channels' with 'i == num_channels'
- Add missing trailing comma in alarm_map array initializer

Guilherme Ivo Bozi (3):
  iio: adc: xilinx-ams: fix out-of-bounds channel lookup in event
    handling
  iio: adc: xilinx-ams: use guard(mutex) for automatic locking
  iio: adc: xilinx-ams: refactor alarm mapping to table-driven approach

 drivers/iio/adc/xilinx-ams.c | 190 +++++++++++++----------------------
 1 file changed, 71 insertions(+), 119 deletions(-)

-- 
2.47.3
Re: [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design
Posted by Salih Erim 1 month ago
Hi Guilherme,

Thanks for working on this. The refactoring approach looks good overall,
but all three patches have indentation issues and patch 3 has one
semantic issue. Please see my comments on each patch.

On 4/14/2026 11:40 PM, Guilherme Ivo Bozi wrote:
> This series addresses significant code duplication in alarm handling
> logic across the Xilinx AMS IIO driver.
> 
> To address this, the series introduces a centralized table-driven
> mapping (alarm_map) that replaces multiple switch statements spread
> across the driver.
> 
> This improves:
> - maintainability (single source of truth for mappings)
> - readability (removes repeated switch logic)
> - extensibility (new alarms require only table updates)
> 
> No functional changes are intended.
> 
> Series overview:
> - Patch 1: fix out-of-bounds channel lookup
> - Patch 2: convert mutex handling to guard(mutex)
> - Patch 3: introduce table-driven alarm mapping
> 
> v1 -> v2:
> - Fixed Fixes tag format
> - Replaced AMS_ALARM_INVALID with AMS_ALARM_NONE
> - Changed alarm_map base_offset type
> 
> v2 -> v3:
> - Replace 'i >= num_channels' with 'i == num_channels'
> - Add missing trailing comma in alarm_map array initializer
> 
> Guilherme Ivo Bozi (3):
>    iio: adc: xilinx-ams: fix out-of-bounds channel lookup in event
>      handling
>    iio: adc: xilinx-ams: use guard(mutex) for automatic locking
>    iio: adc: xilinx-ams: refactor alarm mapping to table-driven approach
> 
>   drivers/iio/adc/xilinx-ams.c | 190 +++++++++++++----------------------
>   1 file changed, 71 insertions(+), 119 deletions(-)
> 
> --
> 2.47.3
> 

Salih
Re: [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design
Posted by Jonathan Cameron 1 month, 3 weeks ago
On Tue, 14 Apr 2026 19:40:32 -0300
Guilherme Ivo Bozi <guilherme.bozi@usp.br> wrote:

> This series addresses significant code duplication in alarm handling
> logic across the Xilinx AMS IIO driver.
> 
> To address this, the series introduces a centralized table-driven
> mapping (alarm_map) that replaces multiple switch statements spread
> across the driver.
> 
> This improves:
> - maintainability (single source of truth for mappings)
> - readability (removes repeated switch logic)
> - extensibility (new alarms require only table updates)
> 
> No functional changes are intended.
This series looks fine to me.

Given the AMD Xilinx folk are fairly active reviewers I'm just
waiting on them taking a look.


> 
> Series overview:
> - Patch 1: fix out-of-bounds channel lookup 
> - Patch 2: convert mutex handling to guard(mutex) 
> - Patch 3: introduce table-driven alarm mapping
> 
> v1 -> v2:
> - Fixed Fixes tag format
> - Replaced AMS_ALARM_INVALID with AMS_ALARM_NONE
> - Changed alarm_map base_offset type
> 
> v2 -> v3:
> - Replace 'i >= num_channels' with 'i == num_channels'
> - Add missing trailing comma in alarm_map array initializer
> 
> Guilherme Ivo Bozi (3):
>   iio: adc: xilinx-ams: fix out-of-bounds channel lookup in event
>     handling
>   iio: adc: xilinx-ams: use guard(mutex) for automatic locking
>   iio: adc: xilinx-ams: refactor alarm mapping to table-driven approach
> 
>  drivers/iio/adc/xilinx-ams.c | 190 +++++++++++++----------------------
>  1 file changed, 71 insertions(+), 119 deletions(-)
>
Re: [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design
Posted by Guilherme Ivo Bozi 1 month ago
> This series looks fine to me.
>
> Given the AMD Xilinx folk are fairly active reviewers I'm just
> waiting on them taking a look.
Hi, just checking in on this series since it’s been some time.
Any updates from AMD Xilinx review or anything else needed from
my side?

--
Thanks,
Guilherme Ivo
Re: [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design
Posted by Michal Simek 1 month ago
Hi Ivo,

On 5/12/26 13:00, Guilherme Ivo Bozi wrote:
>> This series looks fine to me.
>>
>> Given the AMD Xilinx folk are fairly active reviewers I'm just
>> waiting on them taking a look.
> Hi, just checking in on this series since it’s been some time.
> Any updates from AMD Xilinx review or anything else needed from
> my side?

Checking internally who can test this. Please give me some time.

Thanks,
Michal