I am trying to modify and compile usbmouse.c
While compiling it is saying that the function usb_maxpackets
requires 3 arguments but the code I copied from the torvald git is passing only 2 arguments to this function
the code can be found here:
https://github.com/torvalds/linux/blob/master/drivers/hid/usbhid/usbmouse.c
I am using debian gnu/linux 10
with kernel version 4.19.94-ti-r42
The number of parameters of the
usb_maxpacket()
function was changed from 3 to 2 in Linux kernel 5.19 onwards. The third parameter indicated the direction of the pipe, but that information was redundant because the direction can be derived from the other two parameters.For compatibility with the 4.19 kernel, the new function call
maxp = usb_maxpacket(dev, pipe);
needs to be changed tomaxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
. (usb_pipeout(pipe)
is the pipe direction.)To make the code compatible with old and new kernels, the code can be conditionally compiled according to the kernel version:
Alternatively, some compatibility code could be added before the function that calls
usb_maxpacket
: