]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dpll: zl3073x: use FIELD_MODIFY() for clear-and-set patterns
authorIvan Vecera <ivecera@redhat.com>
Wed, 8 Apr 2026 10:27:13 +0000 (12:27 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 15:27:33 +0000 (08:27 -0700)
Replace open-coded clear-and-set bitfield operations with
FIELD_MODIFY().

Reviewed-by: Petr Oros <poros@redhat.com>
Reviewed-by: Prathosh Satish <Prathosh.Satish@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Link: https://patch.msgid.link/20260408102716.443099-3-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/dpll/zl3073x/chan.h
drivers/dpll/zl3073x/core.c
drivers/dpll/zl3073x/flash.c

index e0f02d34320867254d16ee5f9e383279d7c67c0a..481da2133202beae76896685c458f771fcf96539 100644 (file)
@@ -66,8 +66,7 @@ static inline u8 zl3073x_chan_ref_get(const struct zl3073x_chan *chan)
  */
 static inline void zl3073x_chan_mode_set(struct zl3073x_chan *chan, u8 mode)
 {
-       chan->mode_refsel &= ~ZL_DPLL_MODE_REFSEL_MODE;
-       chan->mode_refsel |= FIELD_PREP(ZL_DPLL_MODE_REFSEL_MODE, mode);
+       FIELD_MODIFY(ZL_DPLL_MODE_REFSEL_MODE, &chan->mode_refsel, mode);
 }
 
 /**
@@ -77,8 +76,7 @@ static inline void zl3073x_chan_mode_set(struct zl3073x_chan *chan, u8 mode)
  */
 static inline void zl3073x_chan_ref_set(struct zl3073x_chan *chan, u8 ref)
 {
-       chan->mode_refsel &= ~ZL_DPLL_MODE_REFSEL_REF;
-       chan->mode_refsel |= FIELD_PREP(ZL_DPLL_MODE_REFSEL_REF, ref);
+       FIELD_MODIFY(ZL_DPLL_MODE_REFSEL_REF, &chan->mode_refsel, ref);
 }
 
 /**
@@ -110,13 +108,10 @@ zl3073x_chan_ref_prio_set(struct zl3073x_chan *chan, u8 ref, u8 prio)
 {
        u8 *val = &chan->ref_prio[ref / 2];
 
-       if (!(ref & 1)) {
-               *val &= ~ZL_DPLL_REF_PRIO_REF_P;
-               *val |= FIELD_PREP(ZL_DPLL_REF_PRIO_REF_P, prio);
-       } else {
-               *val &= ~ZL_DPLL_REF_PRIO_REF_N;
-               *val |= FIELD_PREP(ZL_DPLL_REF_PRIO_REF_N, prio);
-       }
+       if (!(ref & 1))
+               FIELD_MODIFY(ZL_DPLL_REF_PRIO_REF_P, val, prio);
+       else
+               FIELD_MODIFY(ZL_DPLL_REF_PRIO_REF_N, val, prio);
 }
 
 /**
index cb47a5db061aacdfa75b9891f127548e2ce68d17..5f1e70f3e40a0527ecdc033c70aff0638da69478 100644 (file)
@@ -805,8 +805,7 @@ int zl3073x_dev_phase_avg_factor_set(struct zl3073x_dev *zldev, u8 factor)
        value = (factor + 1) & 0x0f;
 
        /* Update phase measurement control register */
-       dpll_meas_ctrl &= ~ZL_DPLL_MEAS_CTRL_AVG_FACTOR;
-       dpll_meas_ctrl |= FIELD_PREP(ZL_DPLL_MEAS_CTRL_AVG_FACTOR, value);
+       FIELD_MODIFY(ZL_DPLL_MEAS_CTRL_AVG_FACTOR, &dpll_meas_ctrl, value);
        rc = zl3073x_write_u8(zldev, ZL_REG_DPLL_MEAS_CTRL, dpll_meas_ctrl);
        if (rc)
                return rc;
index 83452a77e3e98077df3d38b9b624b8c80f298165..f85535c8ad2469b8a53cd63694f4f919cce18d49 100644 (file)
@@ -194,8 +194,7 @@ zl3073x_flash_cmd_wait(struct zl3073x_dev *zldev, u32 operation,
        if (rc)
                return rc;
 
-       value &= ~ZL_WRITE_FLASH_OP;
-       value |= FIELD_PREP(ZL_WRITE_FLASH_OP, operation);
+       FIELD_MODIFY(ZL_WRITE_FLASH_OP, &value, operation);
 
        rc = zl3073x_write_u8(zldev, ZL_REG_WRITE_FLASH, value);
        if (rc)