linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: can: kvaser_usb: Add support for Kvaser CAN/USB devices
@ 2015-11-19 12:42 Dan Carpenter
  2015-11-19 13:23 ` Marc Kleine-Budde
  2015-11-20  8:19 ` Olivier Sobrie
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2015-11-19 12:42 UTC (permalink / raw)
  To: olivier; +Cc: linux-can

Hello Olivier Sobrie,

The patch 080f40a6fa28: "can: kvaser_usb: Add support for Kvaser
CAN/USB devices" from Nov 21, 2012, leads to the following static
checker warning:

	drivers/net/can/usb/kvaser_usb.c:949 kvaser_usb_rx_error()
	0x08 | 0x18 has 0x08 set on both sides

drivers/net/can/usb/kvaser_usb.c
   941          switch (dev->family) {
   942          case KVASER_LEAF:
   943                  if (es->leaf.error_factor) {
   944                          cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
   945  
   946                          if (es->leaf.error_factor & M16C_EF_ACKE)
   947                                  cf->data[3] |= (CAN_ERR_PROT_LOC_ACK);
   948                          if (es->leaf.error_factor & M16C_EF_CRCE)
   949                                  cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
   950                                                  CAN_ERR_PROT_LOC_CRC_DEL);

CAN_ERR_PROT_LOC_CRC_SEQ is 0x08
CAN_ERR_PROT_LOC_CRC_DEL is 0x18

It's weird that the bits overlap.  Was that intentional?  Why isn't it
enough to just say?:
					cf->data[3] |= CAN_ERR_PROT_LOC_CRC_DEL;

The static checker complains about most places where
CAN_ERR_PROT_LOC_CRC_SEQ is used.  I see us setting the flag but not I
don't see where we test for this so I'm not sure.

   951                          if (es->leaf.error_factor & M16C_EF_FORME)
   952                                  cf->data[2] |= CAN_ERR_PROT_FORM;
   953                          if (es->leaf.error_factor & M16C_EF_STFE)
   954                                  cf->data[2] |= CAN_ERR_PROT_STUFF;
   955                          if (es->leaf.error_factor & M16C_EF_BITE0)
   956                                  cf->data[2] |= CAN_ERR_PROT_BIT0;
   957                          if (es->leaf.error_factor & M16C_EF_BITE1)
   958                                  cf->data[2] |= CAN_ERR_PROT_BIT1;
   959                          if (es->leaf.error_factor & M16C_EF_TRE)
   960                                  cf->data[2] |= CAN_ERR_PROT_TX;
   961                  }
   962                  break;
   963          case KVASER_USBCAN:

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-21 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 12:42 can: kvaser_usb: Add support for Kvaser CAN/USB devices Dan Carpenter
2015-11-19 13:23 ` Marc Kleine-Budde
2015-11-19 13:46   ` Oliver Hartkopp
2015-11-20  8:19 ` Olivier Sobrie
2015-11-20 11:10   ` Dan Carpenter
2015-11-21 12:40   ` Oliver Hartkopp
2015-11-21 13:39     ` Olivier Sobrie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).