From nobody Wed Oct 1 23:40:26 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 433492D59E8 for ; Sat, 27 Sep 2025 08:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758962980; cv=none; b=uwHC8Fi11/jSngZTFS5EPzTJXxs3sFmhhd110rFSf47F/Lephmz0NyIc8RDd6FiIIoTgyb9U5rZNbsob/S+QIdXgKj7FKRg6ixvG0NggrqvHhZHngHOo/T6r1Gs/OtCOcyURrawKhZP0SHny8iLdED64aPjU1Ih49WSFCkA+PVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758962980; c=relaxed/simple; bh=cRUDVTzhvUt3cZRMJciHl/Pqt0TO8UCUstDUWC56C6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GuZmi9RM1Mv64uHdK53TcqppXMm48GulL5wlNCElMKLjc0EPbUcJyGbNxyHayST/nfXS9j8N3Xw2NZ6NG+sjlSoqs3AUD2qDLXIIl4e/m7q/4vx7aBwGNhbWWTDTLJsmZd2zZ71C6WSGz4QLKf6CRd747/pA38s02t3i74JXibc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZC7aEbgz; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZC7aEbgz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758962978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zxl0TxLf25xUAMm4j2lJ8TNVEvxXadGeeqzjsC9P7KU=; b=ZC7aEbgzAfB7jGFF5HijcEZpKjVndM93uBmu4t6SYQAOCl5M9bAxGnWmhZnOjemYF6EoDl hIPnkyom6nNisPWV4A8NczlOI3690+5R9KUz4/BmcrnxOrJxXY6UUdtZs4yZYCLfvfMu7c zEoK7x2UQl7Bl5MRZKsgGAJGSTABKfY= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-v_1g_-S9NnK1glnByDxCzg-1; Sat, 27 Sep 2025 04:49:34 -0400 X-MC-Unique: v_1g_-S9NnK1glnByDxCzg-1 X-Mimecast-MFC-AGG-ID: v_1g_-S9NnK1glnByDxCzg_1758962972 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 14C34180034C; Sat, 27 Sep 2025 08:49:32 +0000 (UTC) Received: from p16v.redhat.com (unknown [10.45.225.247]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 96E7F19560AB; Sat, 27 Sep 2025 08:49:26 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , Jonathan Corbet , Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Prathosh Satish , Chuck Lever , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Schmidt , Petr Oros Subject: [PATCH net-next v2 2/3] dpll: add phase_offset_avg_factor_get/set callback ops Date: Sat, 27 Sep 2025 10:49:11 +0200 Message-ID: <20250927084912.2343597-3-ivecera@redhat.com> In-Reply-To: <20250927084912.2343597-1-ivecera@redhat.com> References: <20250927084912.2343597-1-ivecera@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" 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 v2: * do not require 'set' callback to retrieve current value * always call 'set' callback regardless of current value --- drivers/dpll/dpll_netlink.c | 66 +++++++++++++++++++++++++++++++++---- include/linux/dpll.h | 6 ++++ 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c index 0a852011653c4..74c1f0ca95f24 100644 --- a/drivers/dpll/dpll_netlink.c +++ b/drivers/dpll/dpll_netlink.c @@ -164,6 +164,27 @@ dpll_msg_add_phase_offset_monitor(struct sk_buff *msg,= struct dpll_device *dpll, return 0; } =20 +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 =3D dpll_device_ops(dpll); + u32 factor; + int ret; + + if (ops->phase_offset_avg_factor_get) { + ret =3D 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 dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll, 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)) return -EMSGSIZE; ret =3D dpll_msg_add_phase_offset_monitor(msg, dpll, extack); + if (ret) + return ret; + ret =3D dpll_msg_add_phase_offset_avg_factor(msg, dpll, extack); if (ret) return ret; =20 @@ -839,6 +863,23 @@ dpll_phase_offset_monitor_set(struct dpll_device *dpll= , struct nlattr *a, extack); } =20 +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 =3D dpll_device_ops(dpll); + u32 factor =3D 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 dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a, struct netlink_ext_ack *extack) @@ -1736,14 +1777,25 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, st= ruct genl_info *info) static int dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info) { - int ret; - - if (info->attrs[DPLL_A_PHASE_OFFSET_MONITOR]) { - struct nlattr *a =3D info->attrs[DPLL_A_PHASE_OFFSET_MONITOR]; + struct nlattr *a; + int rem, ret; =20 - ret =3D dpll_phase_offset_monitor_set(dpll, a, info->extack); - if (ret) - return ret; + nla_for_each_attr(a, genlmsg_data(info->genlhdr), + genlmsg_len(info->genlhdr), rem) { + switch (nla_type(a)) { + case DPLL_A_PHASE_OFFSET_MONITOR: + ret =3D dpll_phase_offset_monitor_set(dpll, a, + info->extack); + if (ret) + return ret; + break; + case DPLL_A_PHASE_OFFSET_AVG_FACTOR: + ret =3D dpll_phase_offset_avg_factor_set(dpll, a, + info->extack); + if (ret) + return ret; + break; + } } =20 return 0; diff --git a/include/linux/dpll.h b/include/linux/dpll.h index fa1e76920d0ee..25be745bf41f1 100644 --- a/include/linux/dpll.h +++ b/include/linux/dpll.h @@ -38,6 +38,12 @@ struct dpll_device_ops { void *dpll_priv, enum dpll_feature_state *state, 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); }; =20 struct dpll_pin_ops { --=20 2.49.1