Skip to content

Commit faa7826

Browse files
committed
dpll: add phase_offset_avg_factor_get/set callback ops
JIRA: https://issues.redhat.com/browse/RHEL-126529 Conflicts: - adjusted a context conflict caused by RH_KABI_RESERVE macros in struct dpll_device_ops. Upstream commit(s): commit e28d5a6 Author: Ivan Vecera <ivecera@redhat.com> Date: Sat Sep 27 10:49:11 2025 +0200 dpll: add phase_offset_avg_factor_get/set callback ops Add new callback operations for a dpll device: - phase_offset_avg_factor_get(...) - to obtain current phase offset averaging factor from dpll device, - phase_offset_avg_factor_set(...) - to set phase offset averaging factor Obtain the factor value using the get callback and provide it to the user if the device driver implement this callback. Execute the set callback upon user requests, if the driver implement it. Signed-off-by: Ivan Vecera <ivecera@redhat.com> v2: * do not require 'set' callback to retrieve current value * always call 'set' callback regardless of current value Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20250927084912.2343597-3-ivecera@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent 64ed0fc commit faa7826

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

drivers/dpll/dpll_netlink.c

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,27 @@ dpll_msg_add_phase_offset_monitor(struct sk_buff *msg, struct dpll_device *dpll,
164164
return 0;
165165
}
166166

167+
static int
168+
dpll_msg_add_phase_offset_avg_factor(struct sk_buff *msg,
169+
struct dpll_device *dpll,
170+
struct netlink_ext_ack *extack)
171+
{
172+
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
173+
u32 factor;
174+
int ret;
175+
176+
if (ops->phase_offset_avg_factor_get) {
177+
ret = ops->phase_offset_avg_factor_get(dpll, dpll_priv(dpll),
178+
&factor, extack);
179+
if (ret)
180+
return ret;
181+
if (nla_put_u32(msg, DPLL_A_PHASE_OFFSET_AVG_FACTOR, factor))
182+
return -EMSGSIZE;
183+
}
184+
185+
return 0;
186+
}
187+
167188
static int
168189
dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll,
169190
struct netlink_ext_ack *extack)
@@ -675,6 +696,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
675696
if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
676697
return -EMSGSIZE;
677698
ret = dpll_msg_add_phase_offset_monitor(msg, dpll, extack);
699+
if (ret)
700+
return ret;
701+
ret = dpll_msg_add_phase_offset_avg_factor(msg, dpll, extack);
678702
if (ret)
679703
return ret;
680704

@@ -839,6 +863,23 @@ dpll_phase_offset_monitor_set(struct dpll_device *dpll, struct nlattr *a,
839863
extack);
840864
}
841865

866+
static int
867+
dpll_phase_offset_avg_factor_set(struct dpll_device *dpll, struct nlattr *a,
868+
struct netlink_ext_ack *extack)
869+
{
870+
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
871+
u32 factor = nla_get_u32(a);
872+
873+
if (!ops->phase_offset_avg_factor_set) {
874+
NL_SET_ERR_MSG_ATTR(extack, a,
875+
"device not capable of changing phase offset average factor");
876+
return -EOPNOTSUPP;
877+
}
878+
879+
return ops->phase_offset_avg_factor_set(dpll, dpll_priv(dpll), factor,
880+
extack);
881+
}
882+
842883
static int
843884
dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
844885
struct netlink_ext_ack *extack)
@@ -1736,14 +1777,25 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)
17361777
static int
17371778
dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info)
17381779
{
1739-
int ret;
1740-
1741-
if (info->attrs[DPLL_A_PHASE_OFFSET_MONITOR]) {
1742-
struct nlattr *a = info->attrs[DPLL_A_PHASE_OFFSET_MONITOR];
1780+
struct nlattr *a;
1781+
int rem, ret;
17431782

1744-
ret = dpll_phase_offset_monitor_set(dpll, a, info->extack);
1745-
if (ret)
1746-
return ret;
1783+
nla_for_each_attr(a, genlmsg_data(info->genlhdr),
1784+
genlmsg_len(info->genlhdr), rem) {
1785+
switch (nla_type(a)) {
1786+
case DPLL_A_PHASE_OFFSET_MONITOR:
1787+
ret = dpll_phase_offset_monitor_set(dpll, a,
1788+
info->extack);
1789+
if (ret)
1790+
return ret;
1791+
break;
1792+
case DPLL_A_PHASE_OFFSET_AVG_FACTOR:
1793+
ret = dpll_phase_offset_avg_factor_set(dpll, a,
1794+
info->extack);
1795+
if (ret)
1796+
return ret;
1797+
break;
1798+
}
17471799
}
17481800

17491801
return 0;

include/linux/dpll.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ struct dpll_device_ops {
4040
void *dpll_priv,
4141
enum dpll_feature_state *state,
4242
struct netlink_ext_ack *extack);
43+
int (*phase_offset_avg_factor_set)(const struct dpll_device *dpll,
44+
void *dpll_priv, u32 factor,
45+
struct netlink_ext_ack *extack);
46+
int (*phase_offset_avg_factor_get)(const struct dpll_device *dpll,
47+
void *dpll_priv, u32 *factor,
48+
struct netlink_ext_ack *extack);
4349

4450
RH_KABI_RESERVE(1)
4551
RH_KABI_RESERVE(2)

0 commit comments

Comments
 (0)