linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] usb: host: Faraday fotg210-hcd driver
@ 2020-02-11 15:03 Dan Carpenter
  2020-02-11 15:24 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2020-02-11 15:03 UTC (permalink / raw)
  To: linux-usb; +Cc: john453

Hello USB devs,

The patch 7d50195f6c50: "usb: host: Faraday fotg210-hcd driver" from
Jul 29, 2013, leads to the following static checker warning:

	drivers/usb/host/fotg210-hcd.c:3945 iso_stream_init()
	warn: mask and shift to zero

drivers/usb/host/fotg210-hcd.c
  3922  static void iso_stream_init(struct fotg210_hcd *fotg210,
  3923                  struct fotg210_iso_stream *stream, struct usb_device *dev,
  3924                  int pipe, unsigned interval)
  3925  {
  3926          u32 buf1;
  3927          unsigned epnum, maxp;
  3928          int is_input;
  3929          long bandwidth;
  3930          unsigned multi;
  3931  
  3932          /*
  3933           * this might be a "high bandwidth" highspeed endpoint,
  3934           * as encoded in the ep descriptor's wMaxPacket field
  3935           */
  3936          epnum = usb_pipeendpoint(pipe);
  3937          is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
  3938          maxp = usb_maxpacket(dev, pipe, !is_input);
  3939          if (is_input)
  3940                  buf1 = (1 << 11);
  3941          else
  3942                  buf1 = 0;
  3943  
  3944          maxp = max_packet(maxp);
  3945          multi = hb_mult(maxp);
  3946          buf1 |= maxp;
  3947          maxp *= multi;
  3948  
  3949          stream->buf0 = cpu_to_hc32(fotg210, (epnum << 8) | dev->devnum);
  3950          stream->buf1 = cpu_to_hc32(fotg210, buf1);
  3951          stream->buf2 = cpu_to_hc32(fotg210, multi);

The problem is these two defines:

#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))

0x07ff >> 11 is always zero so multi is always 1.

Should we pass the original value that usb_maxpacket() returned instead
of the masked value?

regards,
dan carpenter

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

end of thread, other threads:[~2020-02-11 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 15:03 [bug report] usb: host: Faraday fotg210-hcd driver Dan Carpenter
2020-02-11 15:24 ` Alan Stern
2020-02-11 15:47   ` Alan Stern

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).