Hi Richard,

Yes, the new method to get the configuration instance is unnecessary, thanks 
for the review and comments. 

Regards,
Izunna

-----Original Message-----
From: Richard Cochran <richardcoch...@gmail.com> 
Sent: Saturday, October 15, 2022 1:17 AM
To: Izunna Otiji <izunna.otiji...@renesas.com>
Cc: linuxptp-devel@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH] ptp4l: Add profile_id configuration 
support for G.8275.1 and G.8275.2.

On Tue, Aug 16, 2022 at 01:08:35PM -0400, izunna.otiji...@renesas.com wrote:
> From: Izunna Otiji <izunna.otiji...@renesas.com>
> 
> Signed-off-by: Izunna Otiji <izunna.otiji...@renesas.com>
> ---
>  port.c      | 13 ++++++++++++-
>  transport.c |  5 +++++
>  transport.h |  5 +++++
>  3 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/port.c b/port.c
> index 871ad68..acdf1e5 100644
> --- a/port.c
> +++ b/port.c
> @@ -831,6 +831,8 @@ static void port_management_send_error(struct port 
> *p, struct port *ingress,
>  
>  static const Octet profile_id_drr[] = {0x00, 0x1B, 0x19, 0x00, 0x01, 
> 0x00};  static const Octet profile_id_p2p[] = {0x00, 0x1B, 0x19, 0x00, 
> 0x02, 0x00};
> +static const Octet profile_id_8275_1[] = {0x00, 0x19, 0xA7, 0x01, 
> +0x02, 0x01}; static const Octet profile_id_8275_2[] = {0x00, 0x19, 
> +0xA7, 0x02, 0x01, 0x00};
>  
>  static int port_management_fill_response(struct port *target,
>                                        struct ptp_message *rsp, int id) @@ 
> -926,7 +928,16 @@ static 
> int port_management_fill_response(struct port *target,
>               if (target->delayMechanism == DM_P2P) {
>                       memcpy(buf, profile_id_p2p, PROFILE_ID_LEN);
>               } else {
> -                     memcpy(buf, profile_id_drr, PROFILE_ID_LEN);
> +                     if (config_get_int(transport_config(target->trp), NULL, 
> +"dataset_comparison") ==

Please don't nest function calls in function arguments.

> +                         DS_CMP_G8275) {
> +                             if (transport_type(target->trp) == 
> TRANS_IEEE_802_3) {
> +                                     memcpy(buf, profile_id_8275_1, 
> PROFILE_ID_LEN);
> +                             } else {
> +                                     memcpy(buf, profile_id_8275_2, 
> PROFILE_ID_LEN);
> +                             }
> +                     } else {
> +                             memcpy(buf, profile_id_drr, PROFILE_ID_LEN);
> +                     }
>               }
>               buf += PROFILE_ID_LEN;
>               datalen = buf - tlv->data;
> diff --git a/transport.c b/transport.c index 9366fbf..41ca999 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -98,6 +98,11 @@ enum transport_type transport_type(struct transport *t)
>       return t->type;
>  }
>  
> +struct config* transport_config(struct transport *t) {
> +     return t->cfg;
> +}
> +

This new method is superfluous.

The port instance already has a pointer to the clock instance, and this, in 
turn, stores a pointer to the configuration instance.

So, in the case of port_management_fill_response(), you can do:

        struct config *cfg = clock_config(target->clock);

See?

Thanks,
Richard


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to