]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dpll: zl3073x: add zl3073x_ref_state_update helper
authorIvan Vecera <ivecera@redhat.com>
Sun, 15 Mar 2026 17:42:20 +0000 (18:42 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 18 Mar 2026 02:05:12 +0000 (19:05 -0700)
Extract the per-reference monitor status HW read into a dedicated
zl3073x_ref_state_update() helper in the ref module. Rename
zl3073x_dev_ref_status_update() to zl3073x_dev_ref_states_update()
and use the new helper in it. Call it from zl3073x_ref_state_fetch()
as well so that mon_status is initialized at device startup. This
keeps direct register access and struct field writes behind the ref
module's interface, consistent with the state management pattern
used for other ref operations.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Link: https://patch.msgid.link/20260315174224.399074-3-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/dpll/zl3073x/core.c
drivers/dpll/zl3073x/ref.c
drivers/dpll/zl3073x/ref.h

index 10e036ccf08f05ad611f0a6cdf1702e2ab1d8951..07626082aae3b82e51d593f707899a1337b45b47 100644 (file)
@@ -543,13 +543,12 @@ zl3073x_dev_state_fetch(struct zl3073x_dev *zldev)
 }
 
 static void
-zl3073x_dev_ref_status_update(struct zl3073x_dev *zldev)
+zl3073x_dev_ref_states_update(struct zl3073x_dev *zldev)
 {
        int i, rc;
 
        for (i = 0; i < ZL3073X_NUM_REFS; i++) {
-               rc = zl3073x_read_u8(zldev, ZL_REG_REF_MON_STATUS(i),
-                                    &zldev->ref[i].mon_status);
+               rc = zl3073x_ref_state_update(zldev, i);
                if (rc)
                        dev_warn(zldev->dev,
                                 "Failed to get REF%u status: %pe\n", i,
@@ -679,8 +678,8 @@ zl3073x_dev_periodic_work(struct kthread_work *work)
        struct zl3073x_dpll *zldpll;
        int rc;
 
-       /* Update input references status */
-       zl3073x_dev_ref_status_update(zldev);
+       /* Update input references' states */
+       zl3073x_dev_ref_states_update(zldev);
 
        /* Update DPLL-to-connected-ref phase offsets registers */
        rc = zl3073x_ref_phase_offsets_update(zldev, -1);
index 8b4c4807bcc447b0f2bf23714863effb65ba2e8c..825ac30bcd6f74ed9bb6722202ca7739b52abed3 100644 (file)
@@ -51,6 +51,21 @@ zl3073x_ref_freq_factorize(u32 freq, u16 *base, u16 *mult)
        return -EINVAL;
 }
 
+/**
+ * zl3073x_ref_state_update - update input reference status from HW
+ * @zldev: pointer to zl3073x_dev structure
+ * @index: input reference index
+ *
+ * Return: 0 on success, <0 on error
+ */
+int zl3073x_ref_state_update(struct zl3073x_dev *zldev, u8 index)
+{
+       struct zl3073x_ref *ref = &zldev->ref[index];
+
+       return zl3073x_read_u8(zldev, ZL_REG_REF_MON_STATUS(index),
+                              &ref->mon_status);
+}
+
 /**
  * zl3073x_ref_state_fetch - fetch input reference state from hardware
  * @zldev: pointer to zl3073x_dev structure
@@ -79,6 +94,11 @@ int zl3073x_ref_state_fetch(struct zl3073x_dev *zldev, u8 index)
                return 0; /* Finish - no non-shared items for now */
        }
 
+       /* Read reference status */
+       rc = zl3073x_ref_state_update(zldev, index);
+       if (rc)
+               return rc;
+
        guard(mutex)(&zldev->multiop_lock);
 
        /* Read reference configuration */
index ab3a816c291089caf8f3b065bec36b5b3732c9e6..06d8d4d97ea261f9cbe7bb768cd5c9095b573ef5 100644 (file)
@@ -52,6 +52,8 @@ const struct zl3073x_ref *zl3073x_ref_state_get(struct zl3073x_dev *zldev,
 int zl3073x_ref_state_set(struct zl3073x_dev *zldev, u8 index,
                          const struct zl3073x_ref *ref);
 
+int zl3073x_ref_state_update(struct zl3073x_dev *zldev, u8 index);
+
 int zl3073x_ref_freq_factorize(u32 freq, u16 *base, u16 *mult);
 
 /**