lkml.org 
[lkml]   [2022]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] can: mcba_usb: Fix termination command argument
On Thu. 24 Nov. 2022 at 18:52, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote:
> On Thu, Nov 24, 2022 at 9:53 AM Vincent Mailhol
> <vincent.mailhol@gmail.com> wrote:
> > > diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
> > > index 218b098b261d..67beff1a3876 100644
> > > --- a/drivers/net/can/usb/mcba_usb.c
> > > +++ b/drivers/net/can/usb/mcba_usb.c
> > > @@ -785,9 +785,9 @@ static int mcba_set_termination(struct net_device *netdev, u16 term)
> > > };
> > >
> > > if (term == MCBA_TERMINATION_ENABLED)
> > > - usb_msg.termination = 1;
> > > - else
> > > usb_msg.termination = 0;
> > > + else
> > > + usb_msg.termination = 1;
> > >
> > > mcba_usb_xmit_cmd(priv, (struct mcba_usb_msg *)&usb_msg);
> >
> > Nitpick: does it make sense to rename the field to something like
> > usb_msg.termination_disable or usb_msg.termination_off? This would
> > make it more explicit that this is a "reverse" boolean.
>
> I'd rather define the values like
>
> #define TERMINATION_ON (0)
> #define TERMINATION_OFF (1)
>
> So the block becomes
>
> if (term == MCBA_TERMINATION_ENABLED)
> usb_msg.termination = TERMINATION_ON;
> else
> usb_msg.termination = TERMINATION_OFF;

That also works! Thank you.

\
 
 \ /
  Last update: 2022-11-24 10:55    [W:0.064 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site