From patchwork Tue Nov 17 19:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 327913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A99C63697 for ; Tue, 17 Nov 2020 19:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84FD524631 for ; Tue, 17 Nov 2020 19:33:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729543AbgKQTco (ORCPT ); Tue, 17 Nov 2020 14:32:44 -0500 Received: from mailout11.rmx.de ([94.199.88.76]:43794 "EHLO mailout11.rmx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgKQTco (ORCPT ); Tue, 17 Nov 2020 14:32:44 -0500 Received: from kdin01.retarus.com (kdin01.dmz1.retloc [172.19.17.48]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout11.rmx.de (Postfix) with ESMTPS id 4CbGLH5FB1z3yV3; Tue, 17 Nov 2020 20:32:39 +0100 (CET) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin01.retarus.com (Postfix) with ESMTPS id 4CbGKV6zcVz2xZR; Tue, 17 Nov 2020 20:31:58 +0100 (CET) Received: from N95HX1G2.wgnetz.xx (192.168.54.38) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 17 Nov 2020 20:31:58 +0100 From: Christian Eggers To: Richard Cochran , Andrew Lunn , Heiner Kallweit , Jakub Kicinski CC: Vladimir Oltean , Russell King , "David S . Miller" , , , Christian Eggers , "Kurt Kanzenbach" Subject: [PATCH net-next 1/4] net: ptp: introduce enum ptp_msg_type Date: Tue, 17 Nov 2020 20:31:21 +0100 Message-ID: <20201117193124.9789-1-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Originating-IP: [192.168.54.38] X-RMX-ID: 20201117-203158-4CbGKV6zcVz2xZR-0@kdin01 X-RMX-SOURCE: 217.111.95.66 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Using a PTP wide enum will obsolete different driver internal defines and uses of magic numbers. Signed-off-by: Christian Eggers Cc: Kurt Kanzenbach --- include/linux/ptp_classify.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h index 56b2d7d66177..83024220cb42 100644 --- a/include/linux/ptp_classify.h +++ b/include/linux/ptp_classify.h @@ -93,6 +93,13 @@ unsigned int ptp_classify_raw(const struct sk_buff *skb); */ struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type); +enum ptp_msg_type { + PTP_MSGTYPE_SYNC = 0x0, + PTP_MSGTYPE_DELAY_REQ = 0x1, + PTP_MSGTYPE_PDELAY_REQ = 0x2, + PTP_MSGTYPE_PDELAY_RESP = 0x3, +}; + /** * ptp_get_msgtype - Extract ptp message type from given header * @hdr: ptp header @@ -103,10 +110,10 @@ struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type); * * Return: The message type */ -static inline u8 ptp_get_msgtype(const struct ptp_header *hdr, +static inline enum ptp_msg_type ptp_get_msgtype(const struct ptp_header *hdr, unsigned int type) { - u8 msgtype; + enum ptp_msg_type msgtype; if (unlikely(type & PTP_CLASS_V1)) { /* msg type is located at the control field for ptp v1 */ @@ -132,13 +139,13 @@ static inline struct ptp_header *ptp_parse_header(struct sk_buff *skb, { return NULL; } -static inline u8 ptp_get_msgtype(const struct ptp_header *hdr, +static inline enum ptp_msg_type ptp_get_msgtype(const struct ptp_header *hdr, unsigned int type) { /* The return is meaningless. The stub function would not be * executed since no available header from ptp_parse_header. */ - return 0; + return PTP_MSGTYPE_SYNC; } #endif #endif /* _PTP_CLASSIFY_H_ */ From patchwork Tue Nov 17 19:31:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 327912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AE56C64E7D for ; Tue, 17 Nov 2020 19:35:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7DBF2463B for ; Tue, 17 Nov 2020 19:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730351AbgKQTfG (ORCPT ); Tue, 17 Nov 2020 14:35:06 -0500 Received: from mailout08.rmx.de ([94.199.90.85]:37941 "EHLO mailout08.rmx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728666AbgKQTfF (ORCPT ); Tue, 17 Nov 2020 14:35:05 -0500 Received: from kdin01.retarus.com (kdin01.dmz1.retloc [172.19.17.48]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout08.rmx.de (Postfix) with ESMTPS id 4CbGP00LtzzMm7K; Tue, 17 Nov 2020 20:35:00 +0100 (CET) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin01.retarus.com (Postfix) with ESMTPS id 4CbGN71y83z2xDp; Tue, 17 Nov 2020 20:34:15 +0100 (CET) Received: from N95HX1G2.wgnetz.xx (192.168.54.38) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 17 Nov 2020 20:33:48 +0100 From: Christian Eggers To: Richard Cochran , Andrew Lunn , Heiner Kallweit , Jakub Kicinski CC: Vladimir Oltean , Russell King , "David S . Miller" , , , Christian Eggers , "Kurt Kanzenbach" Subject: [PATCH net-next 4/4] ptp: ptp_ines: use enum ptp_msg_type Date: Tue, 17 Nov 2020 20:31:24 +0100 Message-ID: <20201117193124.9789-4-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201117193124.9789-1-ceggers@arri.de> References: <20201117193124.9789-1-ceggers@arri.de> MIME-Version: 1.0 X-Originating-IP: [192.168.54.38] X-RMX-ID: 20201117-203419-4CbGN71y83z2xDp-0@kdin01 X-RMX-SOURCE: 217.111.95.66 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use new return type of ptp_get_msgtype(). Remove driver internal defines for this. Signed-off-by: Christian Eggers Cc: Richard Cochran Cc: Kurt Kanzenbach --- drivers/ptp/ptp_ines.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/ptp/ptp_ines.c b/drivers/ptp/ptp_ines.c index 4700ffbdfced..4836c9c35604 100644 --- a/drivers/ptp/ptp_ines.c +++ b/drivers/ptp/ptp_ines.c @@ -108,11 +108,6 @@ MODULE_LICENSE("GPL"); #define MESSAGE_TYPE_P_DELAY_RESP 3 #define MESSAGE_TYPE_DELAY_REQ 4 -#define SYNC 0x0 -#define DELAY_REQ 0x1 -#define PDELAY_REQ 0x2 -#define PDELAY_RESP 0x3 - static LIST_HEAD(ines_clocks); static DEFINE_MUTEX(ines_clocks_lock); @@ -442,7 +437,7 @@ static bool ines_match(struct sk_buff *skb, unsigned int ptp_class, { struct ptp_header *hdr; u16 portn, seqid; - u8 msgtype; + enum ptp_msg_type msgtype; u64 clkid; if (unlikely(ptp_class & PTP_CLASS_V1)) @@ -675,7 +670,7 @@ static void ines_txtstamp_work(struct work_struct *work) static bool is_sync_pdelay_resp(struct sk_buff *skb, int type) { struct ptp_header *hdr; - u8 msgtype; + enum ptp_msg_type msgtype; hdr = ptp_parse_header(skb, type); if (!hdr) @@ -683,26 +678,26 @@ static bool is_sync_pdelay_resp(struct sk_buff *skb, int type) msgtype = ptp_get_msgtype(hdr, type); - switch ((msgtype & 0xf)) { - case SYNC: - case PDELAY_RESP: + switch (msgtype) { + case PTP_MSGTYPE_SYNC: + case PTP_MSGTYPE_PDELAY_RESP: return true; default: return false; } } -static u8 tag_to_msgtype(u8 tag) +static enum ptp_msg_type tag_to_msgtype(u8 tag) { switch (tag) { case MESSAGE_TYPE_SYNC: - return SYNC; + return PTP_MSGTYPE_SYNC; case MESSAGE_TYPE_P_DELAY_REQ: - return PDELAY_REQ; + return PTP_MSGTYPE_PDELAY_REQ; case MESSAGE_TYPE_P_DELAY_RESP: - return PDELAY_RESP; + return PTP_MSGTYPE_PDELAY_RESP; case MESSAGE_TYPE_DELAY_REQ: - return DELAY_REQ; + return PTP_MSGTYPE_DELAY_REQ; } return 0xf; }