[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200802151809.GB14759@hoboy>
Date: Sun, 2 Aug 2020 08:18:09 -0700
From: Richard Cochran <richardcochran@...il.com>
To: Kurt Kanzenbach <kurt@...utronix.de>
Cc: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jiri Pirko <jiri@...lanox.com>,
Ido Schimmel <idosch@...lanox.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Grygorii Strashko <grygorii.strashko@...com>,
Ivan Khoronzhuk <ivan.khoronzhuk@...aro.org>,
Samuel Zou <zou_wei@...wei.com>, netdev@...r.kernel.org,
Petr Machata <petrm@...lanox.com>
Subject: Re: [PATCH v3 2/9] ptp: Add generic ptp message type function
On Thu, Jul 30, 2020 at 10:00:41AM +0200, Kurt Kanzenbach wrote:
> The message type is located at different offsets within the ptp header depending
> on the ptp version (v1 or v2). Therefore, drivers which also deal with ptp v1
> have some code for it.
>
> Extract this into a helper function for drivers to be used.
>
> Signed-off-by: Kurt Kanzenbach <kurt@...utronix.de>
Reviewed-by: Richard Cochran <richardcochran@...il.com>
CodingStyle nit below...
> ---
> include/linux/ptp_classify.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h
> index 26fd38a4bd67..f4dd42fddc0c 100644
> --- a/include/linux/ptp_classify.h
> +++ b/include/linux/ptp_classify.h
> @@ -90,6 +90,30 @@ unsigned int ptp_classify_raw(const struct sk_buff *skb);
> */
> struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type);
>
> +/**
> + * ptp_get_msgtype - Extract ptp message type from given header
> + * @hdr: ptp header
> + * @type: type of the packet (see ptp_classify_raw())
> + *
> + * This function returns the message type for a given ptp header. It takes care
> + * of the different ptp header versions (v1 or v2).
> + *
> + * Return: The message type
> + */
> +static inline u8 ptp_get_msgtype(const struct ptp_header *hdr,
> + unsigned int type)
> +{
> + u8 msgtype;
> +
> + if (unlikely(type & PTP_CLASS_V1))
> + /* msg type is located at the control field for ptp v1 */
> + msgtype = hdr->control;
With the comment, it looks like two statements, and so please use
if (...) {
/**/
...
} else {
...
}
here.
> + else
> + msgtype = hdr->tsmt & 0x0f;
> +
> + return msgtype;
> +}
> +
> void __init ptp_classifier_init(void);
> #else
> static inline void ptp_classifier_init(void)
> --
> 2.20.1
>
Powered by blists - more mailing lists