[PATCH v5 08/16] iio: adc: xilinx-xadc: Simplify common coding patterns
From: Dileep Kumar Nagavarapu
Date: Tue Nov 10 2026 - 00:18:44 EST
- Use pointers directly instead of comparing them against NULL.
- Declare loop counters within the scope of the for() loops.
- Replace the interrupt mask update expression with a
simpler form that updates only the bits selected by the mask.
The last two items were bundled per Andy Shevchenko's suggestion
during upstream review.
No functional change intended.
Co-developed-by: Sai Krishna Potthuri <sai.krishna.potthuri@xxxxxxx>
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@xxxxxxx>
Signed-off-by: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@xxxxxxx>
---
drivers/iio/adc/xilinx-xadc-core.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 093a7172cc06..7dc43a3bf3c3 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -149,9 +149,7 @@ static void xadc_read_reg(struct xadc *xadc, unsigned int reg, u32 *val)
*/
static void xadc_zynq_write_fifo(struct xadc *xadc, u32 *cmd, unsigned int n)
{
- unsigned int i;
-
- for (i = 0; i < n; i++)
+ for (unsigned int i = 0; i < n; i++)
xadc_write_reg(xadc, XADC_ZYNQ_REG_CFIFO, cmd[i]);
}
@@ -169,8 +167,7 @@ static void xadc_zynq_drain_fifo(struct xadc *xadc)
static void xadc_zynq_update_intmsk(struct xadc *xadc, unsigned int mask, unsigned int val)
{
- xadc->zynq_intmask &= ~mask;
- xadc->zynq_intmask |= val;
+ xadc->zynq_intmask = (xadc->zynq_intmask & ~mask) | (val & mask);
xadc_write_reg(xadc, XADC_ZYNQ_REG_INTMSK, xadc->zynq_intmask | xadc->zynq_masked_alarm);
}
@@ -678,7 +675,7 @@ static int xadc_trigger_set_state(struct iio_trigger *trigger, bool state)
if (state) {
/* Only one of the two triggers can be active at a time. */
- if (xadc->trigger != NULL) {
+ if (xadc->trigger) {
return -EBUSY;
} else {
xadc->trigger = trigger;
@@ -719,7 +716,7 @@ static struct iio_trigger *xadc_alloc_trigger(struct iio_dev *indio_dev, const c
trig = devm_iio_trigger_alloc(dev, "%s%d-%s", indio_dev->name,
iio_device_id(indio_dev), name);
- if (trig == NULL)
+ if (!trig)
return ERR_PTR(-ENOMEM);
trig->ops = &xadc_trigger_ops;
--
2.34.1