mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
a680581f6a
commit
e28d5a68b6
|
|
@ -164,6 +164,27 @@ dpll_msg_add_phase_offset_monitor(struct sk_buff *msg, struct dpll_device *dpll,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dpll_msg_add_phase_offset_avg_factor(struct sk_buff *msg,
|
||||||
|
struct dpll_device *dpll,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
|
{
|
||||||
|
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
|
||||||
|
u32 factor;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (ops->phase_offset_avg_factor_get) {
|
||||||
|
ret = ops->phase_offset_avg_factor_get(dpll, dpll_priv(dpll),
|
||||||
|
&factor, extack);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
if (nla_put_u32(msg, DPLL_A_PHASE_OFFSET_AVG_FACTOR, factor))
|
||||||
|
return -EMSGSIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll,
|
dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
|
|
@ -675,6 +696,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
|
||||||
if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
|
if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
ret = dpll_msg_add_phase_offset_monitor(msg, dpll, extack);
|
ret = dpll_msg_add_phase_offset_monitor(msg, dpll, extack);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
ret = dpll_msg_add_phase_offset_avg_factor(msg, dpll, extack);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
@ -839,6 +863,23 @@ dpll_phase_offset_monitor_set(struct dpll_device *dpll, struct nlattr *a,
|
||||||
extack);
|
extack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dpll_phase_offset_avg_factor_set(struct dpll_device *dpll, struct nlattr *a,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
|
{
|
||||||
|
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
|
||||||
|
u32 factor = nla_get_u32(a);
|
||||||
|
|
||||||
|
if (!ops->phase_offset_avg_factor_set) {
|
||||||
|
NL_SET_ERR_MSG_ATTR(extack, a,
|
||||||
|
"device not capable of changing phase offset average factor");
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ops->phase_offset_avg_factor_set(dpll, dpll_priv(dpll), factor,
|
||||||
|
extack);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
|
dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
|
|
@ -1736,14 +1777,25 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)
|
||||||
static int
|
static int
|
||||||
dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info)
|
dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info)
|
||||||
{
|
{
|
||||||
int ret;
|
struct nlattr *a;
|
||||||
|
int rem, ret;
|
||||||
|
|
||||||
if (info->attrs[DPLL_A_PHASE_OFFSET_MONITOR]) {
|
nla_for_each_attr(a, genlmsg_data(info->genlhdr),
|
||||||
struct nlattr *a = info->attrs[DPLL_A_PHASE_OFFSET_MONITOR];
|
genlmsg_len(info->genlhdr), rem) {
|
||||||
|
switch (nla_type(a)) {
|
||||||
ret = dpll_phase_offset_monitor_set(dpll, a, info->extack);
|
case DPLL_A_PHASE_OFFSET_MONITOR:
|
||||||
if (ret)
|
ret = dpll_phase_offset_monitor_set(dpll, a,
|
||||||
return ret;
|
info->extack);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
case DPLL_A_PHASE_OFFSET_AVG_FACTOR:
|
||||||
|
ret = dpll_phase_offset_avg_factor_set(dpll, a,
|
||||||
|
info->extack);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@ struct dpll_device_ops {
|
||||||
void *dpll_priv,
|
void *dpll_priv,
|
||||||
enum dpll_feature_state *state,
|
enum dpll_feature_state *state,
|
||||||
struct netlink_ext_ack *extack);
|
struct netlink_ext_ack *extack);
|
||||||
|
int (*phase_offset_avg_factor_set)(const struct dpll_device *dpll,
|
||||||
|
void *dpll_priv, u32 factor,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
|
int (*phase_offset_avg_factor_get)(const struct dpll_device *dpll,
|
||||||
|
void *dpll_priv, u32 *factor,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dpll_pin_ops {
|
struct dpll_pin_ops {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue