Skip to content

Commit c5c1159

Browse files
vincent-mailholUlrich Hecht
authored andcommitted
usb: deprecate the third argument of usb_maxpacket()
[ Upstream commit 0f08c2e7458e25c967d844170f8ad1aac3b57a02 ] 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> Stable-dep-of: 69aeb5073123 ("Input: pegasus-notetaker - fix potential out-of-bounds access") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 7f3af94 commit c5c1159

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

include/linux/usb.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,30 +1953,24 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)
19531953
return eps[usb_pipeendpoint(pipe)];
19541954
}
19551955

1956-
/*-------------------------------------------------------------------------*/
1957-
1958-
static inline __u16
1959-
usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
1956+
static inline u16 usb_maxpacket(struct usb_device *udev, int pipe,
1957+
/* int is_out deprecated */ ...)
19601958
{
19611959
struct usb_host_endpoint *ep;
19621960
unsigned epnum = usb_pipeendpoint(pipe);
19631961

1964-
if (is_out) {
1965-
WARN_ON(usb_pipein(pipe));
1962+
if (usb_pipeout(pipe))
19661963
ep = udev->ep_out[epnum];
1967-
} else {
1968-
WARN_ON(usb_pipeout(pipe));
1964+
else
19691965
ep = udev->ep_in[epnum];
1970-
}
1966+
19711967
if (!ep)
19721968
return 0;
19731969

19741970
/* NOTE: only 0x07ff bits are for packet size... */
19751971
return usb_endpoint_maxp(&ep->desc);
19761972
}
19771973

1978-
/* ----------------------------------------------------------------------- */
1979-
19801974
/* translate USB error codes to codes user space understands */
19811975
static inline int usb_translate_errors(int error_code)
19821976
{

0 commit comments

Comments
 (0)