From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Prathosh Satish <Prathosh.Satish@microchip.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Jiri Pirko <jiri@resnulli.us>, Petr Oros <poros@redhat.com>,
Michal Schmidt <mschmidt@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 6/6] dpll: zl3073x: drop selected and simplify connected ref getter
Date: Wed, 11 Mar 2026 20:00:55 +0100 [thread overview]
Message-ID: <20260311190055.139006-7-ivecera@redhat.com> (raw)
In-Reply-To: <20260311190055.139006-1-ivecera@redhat.com>
The HW reports the currently selected reference in the
dpll_refsel_status register regardless of the DPLL mode. Use this to
delete zl3073x_dpll_selected_ref_get() and have callers read the
register directly via the cached channel state.
Simplify zl3073x_dpll_connected_ref_get() to check refsel_state for
LOCK directly and return the reference index, changing the return
type from int to u8. The redundant ref_is_status_ok check is removed
since the DPLL cannot be in LOCK state with a failed reference.
In zl3073x_dpll_mode_set(), replace the selected_ref_get() call with
zl3073x_chan_refsel_ref_get() to read the currently selected
reference directly from the cached channel state.
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
drivers/dpll/zl3073x/dpll.c | 94 +++++++------------------------------
1 file changed, 18 insertions(+), 76 deletions(-)
diff --git a/drivers/dpll/zl3073x/dpll.c b/drivers/dpll/zl3073x/dpll.c
index 31e4ccff96d89..8a85e8be2d829 100644
--- a/drivers/dpll/zl3073x/dpll.c
+++ b/drivers/dpll/zl3073x/dpll.c
@@ -243,72 +243,27 @@ zl3073x_dpll_input_pin_frequency_set(const struct dpll_pin *dpll_pin,
return zl3073x_ref_state_set(zldev, ref_id, &ref);
}
-/**
- * zl3073x_dpll_selected_ref_get - get currently selected reference
- * @zldpll: pointer to zl3073x_dpll
- * @ref: place to store selected reference
- *
- * Check for currently selected reference the DPLL should be locked to
- * and stores its index to given @ref.
- *
- * Return: 0 on success, <0 on error
- */
-static int
-zl3073x_dpll_selected_ref_get(struct zl3073x_dpll *zldpll, u8 *ref)
-{
- const struct zl3073x_chan *chan;
-
- chan = zl3073x_chan_state_get(zldpll->dev, zldpll->id);
-
- switch (zl3073x_chan_mode_get(chan)) {
- case ZL_DPLL_MODE_REFSEL_MODE_AUTO:
- /* Return the reference only if the DPLL is locked to it */
- if (zl3073x_chan_refsel_state_get(chan) ==
- ZL_DPLL_REFSEL_STATUS_STATE_LOCK)
- *ref = zl3073x_chan_refsel_ref_get(chan);
- else
- *ref = ZL3073X_DPLL_REF_NONE;
- break;
- case ZL_DPLL_MODE_REFSEL_MODE_REFLOCK:
- /* For manual mode return stored value */
- *ref = zl3073x_chan_ref_get(chan);
- break;
- default:
- /* For other modes like NCO, freerun... there is no input ref */
- *ref = ZL3073X_DPLL_REF_NONE;
- break;
- }
-
- return 0;
-}
-
/**
* zl3073x_dpll_connected_ref_get - get currently connected reference
* @zldpll: pointer to zl3073x_dpll
- * @ref: place to store selected reference
*
- * Looks for currently connected the DPLL is locked to and stores its index
- * to given @ref.
+ * Looks for currently connected reference the DPLL is locked to.
*
- * Return: 0 on success, <0 on error
+ * Return: reference index if locked, ZL3073X_DPLL_REF_NONE otherwise
*/
-static int
-zl3073x_dpll_connected_ref_get(struct zl3073x_dpll *zldpll, u8 *ref)
+static u8
+zl3073x_dpll_connected_ref_get(struct zl3073x_dpll *zldpll)
{
- struct zl3073x_dev *zldev = zldpll->dev;
- int rc;
-
- /* Get currently selected input reference */
- rc = zl3073x_dpll_selected_ref_get(zldpll, ref);
- if (rc)
- return rc;
+ const struct zl3073x_chan *chan = zl3073x_chan_state_get(zldpll->dev,
+ zldpll->id);
+ u8 state;
- /* If the monitor indicates an error nothing is connected */
- if (ZL3073X_DPLL_REF_IS_VALID(*ref) &&
- !zl3073x_dev_ref_is_status_ok(zldev, *ref))
- *ref = ZL3073X_DPLL_REF_NONE;
+ /* A reference is connected only when the DPLL is locked to it */
+ state = zl3073x_chan_refsel_state_get(chan);
+ if (state == ZL_DPLL_REFSEL_STATUS_STATE_LOCK)
+ return zl3073x_chan_refsel_ref_get(chan);
- return 0;
+ return ZL3073X_DPLL_REF_NONE;
}
static int
@@ -324,12 +279,9 @@ zl3073x_dpll_input_pin_phase_offset_get(const struct dpll_pin *dpll_pin,
const struct zl3073x_ref *ref;
u8 conn_id, ref_id;
s64 ref_phase;
- int rc;
/* Get currently connected reference */
- rc = zl3073x_dpll_connected_ref_get(zldpll, &conn_id);
- if (rc)
- return rc;
+ conn_id = zl3073x_dpll_connected_ref_get(zldpll);
/* Report phase offset only for currently connected pin if the phase
* monitor feature is disabled and only if the input pin signal is
@@ -367,7 +319,7 @@ zl3073x_dpll_input_pin_phase_offset_get(const struct dpll_pin *dpll_pin,
*phase_offset = ref_phase * DPLL_PHASE_OFFSET_DIVIDER;
- return rc;
+ return 0;
}
static int
@@ -447,18 +399,13 @@ zl3073x_dpll_ref_state_get(struct zl3073x_dpll_pin *pin,
struct zl3073x_dpll *zldpll = pin->dpll;
struct zl3073x_dev *zldev = zldpll->dev;
const struct zl3073x_chan *chan;
- u8 ref, ref_conn;
- int rc;
+ u8 ref;
chan = zl3073x_chan_state_get(zldev, zldpll->id);
ref = zl3073x_input_pin_ref_get(pin->id);
- /* Get currently connected reference */
- rc = zl3073x_dpll_connected_ref_get(zldpll, &ref_conn);
- if (rc)
- return rc;
-
- if (ref == ref_conn) {
+ /* Check if the pin reference is connected */
+ if (ref == zl3073x_dpll_connected_ref_get(zldpll)) {
*state = DPLL_PIN_STATE_CONNECTED;
return 0;
}
@@ -1087,13 +1034,8 @@ zl3073x_dpll_mode_set(const struct dpll_device *dpll, void *dpll_priv,
u8 hw_mode, ref;
int rc;
- rc = zl3073x_dpll_selected_ref_get(zldpll, &ref);
- if (rc) {
- NL_SET_ERR_MSG_MOD(extack, "failed to get selected reference");
- return rc;
- }
-
chan = *zl3073x_chan_state_get(zldpll->dev, zldpll->id);
+ ref = zl3073x_chan_refsel_ref_get(&chan);
if (mode == DPLL_MODE_MANUAL) {
/* We are switching from automatic to manual mode:
--
2.52.0
prev parent reply other threads:[~2026-03-11 19:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 19:00 [PATCH net-next 0/6] dpll: zl3073x: refactor state management Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 1/6] dpll: zl3073x: use struct_group to partition states Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 2/6] dpll: zl3073x: add zl3073x_ref_state_update helper Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 3/6] dpll: zl3073x: introduce zl3073x_chan for DPLL channel state Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 4/6] dpll: zl3073x: add DPLL channel status fields to zl3073x_chan Ivan Vecera
2026-03-11 19:00 ` [PATCH net-next 5/6] dpll: zl3073x: add reference priority " Ivan Vecera
2026-03-14 19:53 ` [net-next,5/6] " Jakub Kicinski
2026-03-15 17:38 ` Ivan Vecera
2026-03-11 19:00 ` Ivan Vecera [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260311190055.139006-7-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=Prathosh.Satish@microchip.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=linux-kernel@vger.kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=poros@redhat.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox