Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: deprecate the third argument of usb_maxpacket()

This is a transitional patch with the ultimate goal of changing the
prototype of usb_maxpacket() from:
| static inline __u16
| usb_maxpacket(struct usb_device *udev, int pipe, int is_out)

into:
| static inline u16 usb_maxpacket(struct usb_device *udev, int pipe)

The third argument of usb_maxpacket(): is_out gets removed because it
can be derived from its second argument: pipe using
usb_pipeout(pipe). Furthermore, in the current version,
ubs_pipeout(pipe) is called regardless in order to sanitize the is_out
parameter.

In order to make a smooth change, we first deprecate the is_out
parameter by simply ignoring it (using a variadic function) and will
remove it later, once all the callers get updated.

The body of the function is reworked accordingly and is_out is
replaced by usb_pipeout(pipe). The WARN_ON() calls become unnecessary
and get removed.

Finally, the return type is changed from __u16 to u16 because this is
not a UAPI function.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20220317035514.6378-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vincent Mailhol and committed by
Greg Kroah-Hartman
0f08c2e7 63acaa8e

+5 -11
+5 -11
include/linux/usb.h
··· 1969 1969 return eps[usb_pipeendpoint(pipe)]; 1970 1970 } 1971 1971 1972 - /*-------------------------------------------------------------------------*/ 1973 - 1974 - static inline __u16 1975 - usb_maxpacket(struct usb_device *udev, int pipe, int is_out) 1972 + static inline u16 usb_maxpacket(struct usb_device *udev, int pipe, 1973 + /* int is_out deprecated */ ...) 1976 1974 { 1977 1975 struct usb_host_endpoint *ep; 1978 1976 unsigned epnum = usb_pipeendpoint(pipe); 1979 1977 1980 - if (is_out) { 1981 - WARN_ON(usb_pipein(pipe)); 1978 + if (usb_pipeout(pipe)) 1982 1979 ep = udev->ep_out[epnum]; 1983 - } else { 1984 - WARN_ON(usb_pipeout(pipe)); 1980 + else 1985 1981 ep = udev->ep_in[epnum]; 1986 - } 1982 + 1987 1983 if (!ep) 1988 1984 return 0; 1989 1985 1990 1986 /* NOTE: only 0x07ff bits are for packet size... */ 1991 1987 return usb_endpoint_maxp(&ep->desc); 1992 1988 } 1993 - 1994 - /* ----------------------------------------------------------------------- */ 1995 1989 1996 1990 /* translate USB error codes to codes user space understands */ 1997 1991 static inline int usb_translate_errors(int error_code)