lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1615168716.32109.6.camel@mhfsdcap03>
Date:   Mon, 8 Mar 2021 09:58:36 +0800
From:   Chunfeng Yun <chunfeng.yun@...iatek.com>
To:     Alan Stern <stern@...land.harvard.edu>
CC:     Mathias Nyman <mathias.nyman@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Ikjoon Jang <ikjn@...omium.org>,
        "Matthias Brugger" <matthias.bgg@...il.com>,
        <linux-usb@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        Nicolas Boichat <drinkcat@...omium.org>,
        Eddie Hung <eddie.hung@...iatek.com>
Subject: Re: [PATCH 16/17] usb: common: add function to get interval
 expressed in us unit

On Fri, 2021-03-05 at 10:33 -0500, Alan Stern wrote:
> On Fri, Mar 05, 2021 at 05:02:54PM +0800, Chunfeng Yun wrote:
> > Add a new function to convert bInterval into the time expressed
> > in 1us unit.
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
> > ---
> 
> > --- a/drivers/usb/common/common.c
> > +++ b/drivers/usb/common/common.c
> > @@ -165,6 +165,39 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev)
> >  }
> >  EXPORT_SYMBOL_GPL(usb_get_dr_mode);
> >  
> > +unsigned int usb_decode_interval(const struct usb_endpoint_descriptor *epd,
> > +				 enum usb_device_speed speed)
> > +{
> > +	unsigned int interval = 0;
> > +
> > +	switch (usb_endpoint_type(epd)) {
> > +	case USB_ENDPOINT_XFER_CONTROL:
> > +		/* uframes per NAK */
> > +		if (speed == USB_SPEED_HIGH)
> > +			interval = epd->bInterval;
> > +		break;
> > +	case USB_ENDPOINT_XFER_ISOC:
> > +		interval = 1 << (epd->bInterval - 1);
> > +		break;
> > +	case USB_ENDPOINT_XFER_BULK:
> > +		/* uframes per NAK */
> > +		if (speed == USB_SPEED_HIGH && usb_endpoint_dir_out(epd))
> > +			interval = epd->bInterval;
> > +		break;
> > +	case USB_ENDPOINT_XFER_INT:
> > +		if (speed >= USB_SPEED_HIGH)
> > +			interval = 1 << (epd->bInterval - 1);
> > +		else
> > +			interval = epd->bInterval;
> > +		break;
> > +	}
> > +
> > +	interval *= (speed >= USB_SPEED_HIGH) ? 125 : 1000;
> > +
> > +	return interval;
> > +}
> > +EXPORT_SYMBOL_GPL(usb_decode_interval);
> 
> > --- a/include/linux/usb/ch9.h
> > +++ b/include/linux/usb/ch9.h
> > @@ -90,6 +90,17 @@ extern enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev);
> >   */
> >  extern const char *usb_state_string(enum usb_device_state state);
> >  
> > +/**
> > + * usb_decode_interval - Decode bInterval into the time expressed in 1us unit
> > + * @epd: The descriptor of the endpoint
> > + * @speed: The speed that the endpoint works as
> > + *
> > + * Function returns the interval expressed in 1us unit for servicing
> > + * endpoint for data transfers.
> > + */
> > +unsigned int usb_decode_interval(const struct usb_endpoint_descriptor *epd,
> > +				 enum usb_device_speed speed);
> 
> As a general rule, I believe people expect to find the kerneldoc for a 
> function next to the function's definition, not next to the declaration 
> in a header file.
Got it, thanks

> 
> Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ