[PATCH v4 07/15] iio: adc: xilinx-xadc: Simplify common coding patterns
From: Dileep Kumar Nagavarapu
Date: Mon Oct 05 2026 - 05:53:02 EST
- Use pointers directly instead of comparing them against NULL.
- Use logical negation instead of comparing bit masks against zero.
- 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 | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 0234c8301c2e..43d3fc46c05f 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -124,9 +124,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]);
}
@@ -144,8 +142,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);
}
@@ -653,7 +650,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) {
ret = -EBUSY;
goto err_out;
} else {
@@ -698,7 +695,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;
@@ -749,7 +746,7 @@ static int xadc_get_seq_mode(struct xadc *xadc, unsigned long scan_mode)
if (xadc->external_mux_mode == XADC_EXTERNAL_MUX_DUAL)
return XADC_CONF1_SEQ_SIMULTANEOUS;
- if ((aux_scan_mode & 0xff00) == 0 || (aux_scan_mode & 0x00ff) == 0)
+ if (!(aux_scan_mode & 0xff00) || !(aux_scan_mode & 0x00ff))
return XADC_CONF1_SEQ_CONTINUOUS;
return XADC_CONF1_SEQ_SIMULTANEOUS;
--
2.34.1