usb: rework usb_maxpacket() and remove its third argument
Subsystems (27)
PATCH 1/1 usb: rework usb_maxpacket() and remove its third argument
Change 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 *dev, int pipe)
and rewrite the function.
Rationale:
* The third argument of usb_maxpacket(): is_out can be derived from its second one: pipe using usb_pipeout(pipe). Furthermore, usb_pipoout(pipe) is being called within usb_maxpacket() regardless to confirm the input.
* This function is not exposed to the UAPI so return type should be
u16, not __u16.
* Let's not reinvent the wheel and rely on usb_endpoint_maxp() to make this a one liner function.
All the users of usb_endpoint_maxp() are then updated.
Two of the users: oxu210hp-hcd.c and isp1760-hcd.c rely on a local
macro: max_packet() to mask the maximum size. Because this masking is already performed by usb_maxpacket(), this patch also removes these redundant sanitization and remove the local macro if not needed any more (keep it in oxu210hp-hcd.c which uses it elsewhere but remove it in isp1760-hcd.c).
--- drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- .../net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++-- drivers/usb/host/isp1362-hcd.c | 6 ++--- drivers/usb/host/max3421-hcd.c | 6 ++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 ++--- drivers/usb/isp1760/isp1760-hcd.c | 7 ++---- drivers/usb/misc/ftdi-elan.c | 15 ++++-------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- include/linux/usb.h | 23 ++----------------- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 ++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 46 files changed, 71 insertions(+), 102 deletions(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -387,7 +387,7 @@ static int hid_submit_ctrl(struct hid_device *hid) usbhid->urbctrl->pipe =usb_rcvctrlpipe (hid_to_usb_dev (hid),0 ); maxpacket =usb_maxpacket (hid_to_usb_dev (hid), - usbhid->urbctrl->pipe,0 ); + usbhid->urbctrl->pipe); len += (len ==0 );/* Don't allow 0-length reports */ len =round_up (len, maxpacket);if (len > usbhid->bufsize)
drivers/hid/usbhid/usbkbd.c +1 -1
@@ -279,7 +279,7 @@ static int usb_kbd_probe(struct usb_interface *iface,return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); kbd =kzalloc (sizeof (struct usb_kbd ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/hid/usbhid/usbmouse.c +1 -1
@@ -123,7 +123,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_ireturn -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); mouse =kzalloc (sizeof (struct usb_mouse ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/input/misc/ati_remote2.c +1 -1
@@ -639,7 +639,7 @@ static int ati_remote2_urb_init(struct ati_remote2 *ar2)return -ENOMEM ; pipe =usb_rcvintpipe (udev, ar2->ep[i]->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = maxp >4 ?4 : maxp; usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
drivers/input/misc/cm109.c +1 -1
@@ -745,7 +745,7 @@ static int cm109_usb_probe(struct usb_interface *intf,/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %d\n" , ret,USB_PKT_LEN );
drivers/input/misc/powermate.c +1 -1
@@ -374,7 +374,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe);if (maxp <POWERMATE_PAYLOAD_SIZE_MIN || maxp >POWERMATE_PAYLOAD_SIZE_MAX ) { printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
drivers/input/misc/yealink.c +1 -1
@@ -905,7 +905,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %zd\n" , ret,USB_PKT_LEN );
drivers/input/tablet/acecad.c +1 -1
@@ -130,7 +130,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); acecad =kzalloc (sizeof (struct usb_acecad ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/input/tablet/pegasus_notetaker.c +1 -1
@@ -296,7 +296,7 @@ static int pegasus_probe(struct usb_interface *intf, pegasus->intf = intf; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - pegasus->data_len =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + pegasus->data_len =usb_maxpacket (dev, pipe); pegasus->data =usb_alloc_coherent (dev, pegasus->data_len,GFP_KERNEL , &pegasus->data_dma);
drivers/media/rc/ati_remote.c +2 -2
@@ -773,7 +773,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, ati_remote->endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
@@ -784,7 +784,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up out_urb */ pipe =usb_sndintpipe (udev, ati_remote->endpoint_out->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
drivers/media/rc/mceusb.c +1 -1
@@ -1728,7 +1728,7 @@ static int mceusb_dev_probe(struct usb_interface *intf, pipe =usb_rcvintpipe (dev, ep_in->bEndpointAddress); else pipe =usb_rcvbulkpipe (dev, ep_in->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); ir =kzalloc (sizeof (struct mceusb_dev ),GFP_KERNEL );if (!ir)
drivers/media/rc/streamzap.c +1 -1
@@ -307,7 +307,7 @@ static int streamzap_probe(struct usb_interface *intf, } pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (usbdev, pipe);if (maxp ==0 ) { dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n",
drivers/media/rc/xbox_remote.c +1 -1
@@ -171,7 +171,7 @@ static int xbox_remote_initialize(struct xbox_remote *xbox_remote,/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(xbox_remote->irq_urb, udev, pipe, xbox_remote->inbuf,
drivers/media/usb/tm6000/tm6000-dvb.c +1 -1
@@ -120,7 +120,7 @@ static int tm6000_start_stream(struct tm6000_core *dev) pipe =usb_rcvbulkpipe (dev->udev, dev->bulk_in.endp->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe); size = size *15 ;/* 512 x 8 or 12 or 15 */ dvb->bulk_urb->transfer_buffer =kzalloc (size,GFP_KERNEL );
drivers/media/usb/tm6000/tm6000-input.c +1 -1
@@ -340,7 +340,7 @@ static int __tm6000_ir_int_start(struct rc_dev *rc) dev->int_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);dprintk (1 ,"IR max size: %d\n" , size); ir->int_urb->transfer_buffer =kzalloc (size,GFP_ATOMIC );
drivers/media/usb/tm6000/tm6000-video.c +1 -1
@@ -570,7 +570,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) dev->isoc_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);if (size > dev->isoc_in.maxsize) size = dev->isoc_in.maxsize;
drivers/net/usb/cdc_ncm.c +2 -2
@@ -441,7 +441,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)* .bind which is called before usbnet sets up dev->maxpacket */ if (val !=le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize) && - val %usb_maxpacket (dev->udev, dev->out,1 ) ==0 ) + val %usb_maxpacket (dev->udev, dev->out) ==0 ) val++;/* we might need to flush any pending tx buffers if running */
@@ -465,7 +465,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)usbnet_update_max_qlen (dev);/* never pad more than 3 full USB packets per transfer */ - ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out,1 ), + ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out),CDC_NCM_MIN_TX_PKT , ctx->tx_max); }
drivers/net/usb/lan78xx.c +2 -2
@@ -4426,7 +4426,7 @@ static int lan78xx_probe(struct usb_interface *intf, goto out4; period = ep_intr->desc.bInterval; - maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); + maxp =usb_maxpacket (dev->udev, dev->pipe_intr); buf =kmalloc (maxp,GFP_KERNEL );if (!buf) { ret = -ENOMEM ;
@@ -4444,7 +4444,7 @@ static int lan78xx_probe(struct usb_interface *intf, dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } - dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) {
drivers/net/usb/rndis_host.c +1 -1
@@ -333,7 +333,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) net->hard_header_len +=sizeof (struct rndis_data_hdr ); dev->hard_mtu = net->mtu + net->hard_header_len; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {netif_dbg (dev, probe, dev->net,"dev->maxpacket can't be 0\n" );
drivers/net/usb/usbnet.c +2 -2
@@ -229,7 +229,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) pipe =usb_rcvintpipe (dev->udev, dev->status->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - maxp =usb_maxpacket (dev->udev, pipe,0 ); + maxp =usb_maxpacket (dev->udev, pipe);/* avoid 1 msec chatter: min 8 msec poll rate */ period = max ((int) dev->status->desc.bInterval,
@@ -1789,7 +1789,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)if (!dev->rx_urb_size) dev->rx_urb_size = dev->hard_mtu; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {/* that is a broken device */ status = -ENODEV ;
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
@@ -1132,7 +1132,7 @@ int mt76u_init(struct mt76_dev *dev,INIT_WORK (&usb->stat_work, mt76u_tx_status_data); - usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ),1 ); + usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ));if (usb->data_len <32 ) usb->data_len =32 ;
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +2 -2
@@ -586,10 +586,10 @@ static void rt2x00usb_assign_endpoint(struct data_queue *queue,if (queue->qid ==QID_RX ) { pipe =usb_rcvbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,0 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }else { pipe =usb_sndbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,1 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }if (!queue->usb_maxpacket)
drivers/usb/atm/usbatm.c +1 -1
@@ -1091,7 +1091,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));/* rx buffer size must be a positive multiple of the endpoint maxpacket */ - maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint,0 ); + maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint);if ((maxpacket <1 ) || (maxpacket >UDSL_MAX_BUF_SIZE )) { dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
drivers/usb/c67x00/c67x00-sched.c +2 -2
@@ -655,7 +655,7 @@ static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) usb_pipeout(urb->pipe)); remaining = urb->transfer_buffer_length - urb->actual_length; - maxps =usb_maxpacket (urb->dev, urb->pipe,usb_pipeout (urb->pipe)); + maxps =usb_maxpacket (urb->dev, urb->pipe); need_empty = (urb->transfer_flags &URB_ZERO_PACKET ) &&usb_pipeout (urb->pipe) && !(remaining % maxps);
@@ -866,7 +866,7 @@ static inline int c67x00_end_of_data(struct c67x00_td *td)if (unlikely (!act_bytes))return 1 ;/* This was an empty packet */ - maxps =usb_maxpacket (td_udev (td), td->pipe,usb_pipeout (td->pipe)); + maxps =usb_maxpacket (td_udev (td), td->pipe);if (unlikely (act_bytes < maxps))return 1 ;/* Smaller then full packet */
drivers/usb/core/hub.c +1 -1
@@ -1635,7 +1635,7 @@ static int hub_configure(struct usb_hub *hub,* maxpktsize is defined in hcd.c's fake endpoint descriptors * to be big enough for at least USB_MAXCHILDREN ports. */ pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);if (maxp >sizeof (*hub->buffer)) maxp =sizeof (*hub->buffer);
drivers/usb/host/ehci-q.c +2 -2
@@ -645,7 +645,7 @@ qh_urb_transaction ( token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1218,7 +1218,7 @@ static int ehci_submit_single_step_set_feature( token |= (1 /* "in" */ <<8 );/*This is IN stage*/ - maxpacket =usb_maxpacket (urb->dev, urb->pipe,0 ); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);qtd_fill (ehci, qtd, buf, len, token, maxpacket);
drivers/usb/host/fhci-hcd.c +1 -2
@@ -408,8 +408,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket(urb->dev, pipe, - usb_pipeout(pipe))) != 0) + % usb_maxpacket(urb->dev, pipe)) != 0) size++;break ;case PIPE_ISOCHRONOUS :
drivers/usb/host/fotg210-hcd.c +1 -1
@@ -2596,7 +2596,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/host/isp116x-hcd.c +2 -3
@@ -726,7 +726,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe);usb_settoggle (udev, epnum, is_out,0 );if (type ==PIPE_CONTROL ) {
@@ -757,8 +757,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, ep->load =usb_calc_bus_time (udev->speed, !is_out, (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, - is_out)) / +usb_maxpacket (udev, pipe)) /1000 ; } hep->hcpriv = ep;
drivers/usb/host/isp1362-hcd.c +3 -3
@@ -1279,7 +1279,7 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->udev =usb_get_dev (udev); ep->hep = hep; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->ptd_offset = -EINVAL ; ep->ptd_index = -EINVAL ;usb_settoggle (udev, epnum, is_out,0 );
@@ -1299,8 +1299,8 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->interval = urb->interval; ep->branch =PERIODIC_SIZE ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) /1000 ; + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; } hep->hcpriv = ep;
drivers/usb/host/max3421-hcd.c +3 -3
@@ -546,7 +546,7 @@ max3421_transfer_out(struct usb_hcd *hcd, struct urb *urb, int fast_retransmit)return MAX3421_HXFR_BULK_OUT (epnum); } - max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/*
@@ -952,7 +952,7 @@ max3421_transfer_in_done(struct usb_hcd *hcd, struct urb *urb)* USB 2.0 Section 5.3.2 Pipes: packets must be full size * except for last one. */ - max_packet =usb_maxpacket (urb->dev, urb->pipe,0 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/* * We do not support isochronous transfers at this
@@ -998,7 +998,7 @@ max3421_transfer_out_done(struct usb_hcd *hcd, struct urb *urb)* max_packet as an indicator that the end of the * packet has been reached). */ -u32 max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); +u32 max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max3421_hcd->curr_len == max_packet)return 0 ;
drivers/usb/host/ohci-hcd.c +1 -2
@@ -181,8 +181,7 @@ static int ohci_urb_enqueue ( size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket (urb->dev, pipe, - usb_pipeout (pipe))) == 0) + % usb_maxpacket(urb->dev, pipe)) == 0) size++;break ;case PIPE_ISOCHRONOUS :/* number of packets from URB */
drivers/usb/host/oxu210hp-hcd.c +2 -2
@@ -1685,7 +1685,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =max_packet (usb_maxpacket (urb->dev, urb->pipe, !is_input)); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1796,7 +1796,7 @@ static struct ehci_qh *qh_make(struct oxu_hcd *oxu, is_input =usb_pipein (urb->pipe); type =usb_pipetype (urb->pipe); - maxp =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxp =usb_maxpacket (urb->dev, urb->pipe);/* Compute interrupt scheduling parameters just once, and save. * - allowing for high bandwidth, how many nsec/uframe are used?
drivers/usb/host/r8a66597-hcd.c +1 -2
@@ -1867,8 +1867,7 @@ static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, td->pipe = hep->hcpriv; td->urb = urb; td->address =get_urb_to_r8a66597_addr (r8a66597, urb); - td->maxpacket =usb_maxpacket (urb->dev, urb->pipe, - !usb_pipein (urb->pipe)); + td->maxpacket =usb_maxpacket (urb->dev, urb->pipe);if (usb_pipecontrol (urb->pipe)) td->type =USB_PID_SETUP ;else if (usb_pipein (urb->pipe))
drivers/usb/host/sl811-hcd.c +3 -3
@@ -842,7 +842,7 @@ static int sl811h_urb_enqueue(INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->defctrl =SL11H_HCTLMASK_ARM |SL11H_HCTLMASK_ENABLE ;usb_settoggle (udev, epnum, is_out,0 );
@@ -878,8 +878,8 @@ static int sl811h_urb_enqueue(if (type ==PIPE_ISOCHRONOUS ) ep->defctrl |=SL11H_HCTLMASK_ISOCH ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; }
drivers/usb/isp1760/isp1760-hcd.c +2 -5
@@ -825,8 +825,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,memset (ptd,0 ,sizeof (*ptd));/* according to 3.6.2, max packet len can not be > 0x400 */ - maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe, -usb_pipeout (qtd->urb->pipe)); + maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe); multi =1 + ((maxpacket >>11 ) &0x3 ); maxpacket &=0x7ff ;
@@ -1768,7 +1767,6 @@ static void qtd_list_free(struct list_head *qtd_list)* Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize. * Also calculate the PID type (SETUP/IN/OUT) for each packet. */ -#define max_packet (wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)static void packetize_urb (struct usb_hcd *hcd,struct urb *urb,struct list_head *head,gfp_t flags) {
@@ -1809,8 +1807,7 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =max_packet (usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe))); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/misc/ftdi-elan.c +5 -10
@@ -1449,8 +1449,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x8007 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =8 ; command->value =0 ; command->buffer = urb->setup_packet;
@@ -1514,8 +1513,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1571,8 +1569,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x0000 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1634,8 +1631,7 @@ wait:if (ftdi->disconnected > 0) { command->header =0x81 | (ed <<5 ); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =min_t (u32,1024 , urb->transfer_buffer_length - urb->actual_length);
@@ -1715,8 +1711,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
drivers/usb/misc/lvstest.c +1 -1
@@ -437,7 +437,7 @@ static int lvs_rh_probe(struct usb_interface *intf,INIT_WORK (&lvs->rh_work, lvs_rh_work); pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);usb_fill_int_urb (lvs->urb, hdev, pipe, &lvs->buffer[0 ], maxp, lvs_rh_irq, lvs, endpoint->bInterval);
drivers/usb/storage/onetouch.c +1 -1
@@ -180,7 +180,7 @@ static int onetouch_connect_input(struct us_data *ss)return -ENODEV ; pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp =min (maxp,ONETOUCH_PKT_LEN ); onetouch =kzalloc (sizeof (struct usb_onetouch ),GFP_KERNEL );
drivers/usb/storage/transport.c +1 -1
@@ -363,7 +363,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,usb_stor_dbg (us,"xfer %u bytes\n" , length);/* calculate the max packet size */ - maxp =usb_maxpacket (us->pusb_dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (us->pusb_dev, pipe);if (maxp > length) maxp = length;
include/linux/usb.h +2 -21
@@ -1969,30 +1969,11 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *dev,int pipe) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (is_out) { -WARN_ON (usb_pipein (pipe)); - ep = udev->ep_out[epnum]; - }else { -WARN_ON (usb_pipeout (pipe)); - ep = udev->ep_in[epnum]; - } -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (dev, pipe)->desc); } -/* ----------------------------------------------------------------------- */ -/* translate USB error codes to codes user space understands */ static inline int usb_translate_errors (int error_code) {
sound/usb/line6/pcm.c +2 -2
@@ -552,10 +552,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1285,7 +1285,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1374,7 +1374,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -421,7 +421,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerQuoted 22 lines · Vincent Mailhol
Change the prototype of
usb_maxpacket()from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *dev, int pipe)and rewrite the function.
Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipoout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.* Let's not reinvent the wheel and rely on
usb_endpoint_maxp()to make this a one liner function.
Quoted 8 lines
All the users of
usb_endpoint_maxp()are then updated.Two of the users:
oxu210hp-hcd.candisp1760-hcd.crely on a local
macro:max_packet()to mask the maximum size. Because this masking is already performed byusb_maxpacket(), this patch also removes these redundant sanitization and remove the local macro if not needed any more (keep it inoxu210hp-hcd.cwhich uses it elsewhere but remove it inisp1760-hcd.c).
This type of "change all callers of this function" is brutal to do like this, as is evident by the number of people you had to cc: here.
How about doing it the normal way. Create a new function, with the proper options you wish to see be used, and then move everyone over to it, and when that is done, remove the old function. Bonus points for doing this with some crazy macros to keep the old name in the end (it can be done, but I don't recommend it for the faint-of-heart, so it's not required.)
thanks,
greg k-h
<Removed people in CC>
Quoted 35 lines · Greg Kroah-Hartman
Quoted 22 lines · Vincent Mailhol
Change the prototype of
usb_maxpacket()from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *dev, int pipe)and rewrite the function.
Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipoout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.* Let's not reinvent the wheel and rely on
usb_endpoint_maxp()to make this a one liner function.Quoted 8 lines
All the users of
usb_endpoint_maxp()are then updated.Two of the users:
oxu210hp-hcd.candisp1760-hcd.crely on a local
macro:max_packet()to mask the maximum size. Because this masking is already performed byusb_maxpacket(), this patch also removes these redundant sanitization and remove the local macro if not needed any more (keep it inoxu210hp-hcd.cwhich uses it elsewhere but remove it inisp1760-hcd.c).This type of "change all callers of this function" is brutal to do like this, as is evident by the number of people you had to cc: here.
Quoted 6 lines
How about doing it the normal way. Create a new function, with the proper options you wish to see be used, and then move everyone over to it, and when that is done, remove the old function. Bonus points for doing this with some crazy macros to keep the old name in the end (it can be done, but I don't recommend it for the faint-of-heart, so it's not required.)
Thank you for the explanation :)
If I understand correctly, I should:
* First change linux/usb.h
* Wait for other trees to pull the patch
* Change the drivers
* Clean up linux/usb.h
I did not find the inspiration for a better name so I would like to keep the old one.
Would the below code meet your expectation of "doing some crazy macros"?
| static inline u16 __usb_maxpacket(struct usb_device *dev, int pipe)
| {
| return usb_endpoint_maxp(&usb_pipe_endpoint(dev, pipe)->desc);
| }
|
| #define usb_maxpacket(dev, pipe, deprecated...) __usb_maxpacket(dev, pipe)Thank you,
Yours sincerely,
Vincent Mailhol
Greg Kroah-Hartman
maintainerQuoted 46 lines · Vincent MAILHOL
<Removed people in CC>
Quoted 35 lines · Greg Kroah-Hartman
Quoted 22 lines · Vincent Mailhol
Change the prototype of
usb_maxpacket()from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *dev, int pipe)and rewrite the function.
Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipoout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.* Let's not reinvent the wheel and rely on
usb_endpoint_maxp()to make this a one liner function.Quoted 8 lines
All the users of
usb_endpoint_maxp()are then updated.Two of the users:
oxu210hp-hcd.candisp1760-hcd.crely on a local
macro:max_packet()to mask the maximum size. Because this masking is already performed byusb_maxpacket(), this patch also removes these redundant sanitization and remove the local macro if not needed any more (keep it inoxu210hp-hcd.cwhich uses it elsewhere but remove it inisp1760-hcd.c).This type of "change all callers of this function" is brutal to do like this, as is evident by the number of people you had to cc: here.
Quoted 6 lines
How about doing it the normal way. Create a new function, with the proper options you wish to see be used, and then move everyone over to it, and when that is done, remove the old function. Bonus points for doing this with some crazy macros to keep the old name in the end (it can be done, but I don't recommend it for the faint-of-heart, so it's not required.)
Quoted 4 lines
Thank you for the explanation :)
If I understand correctly, I should:
* First changelinux/usb.h
Yes.
Quoted 1 line
* Wait for other trees to pull the patch
Pull what?
Quoted 1 line
* Change the drivers
You can fix up many of these at the same time in a patch series. I can take many of them in the USB tree as well if needed.
Quoted 6 lines
* Clean up
linux/usb.hI did not find the inspiration for a better name so I would like to keep the old one.
Would the below code meet your expectation of "doing some crazy macros"?
Quoted 6 lines
| static inline u16 __usb_maxpacket(struct usb_device *dev, int pipe)
| {
| return usb_endpoint_maxp(&usb_pipe_endpoint(dev, pipe)->desc);
| }
|
| #define usb_maxpacket(dev, pipe, deprecated...) __usb_maxpacket(dev, pipe)Yeah, as you are just dropping the last argument, that might be all that is needed as this could be quite simpler than I was thinking.
Try it and see!
thanks,
greg k-h
v2 cover usb: rework usb_maxpacket() and remove its third argument
In reply to Vincent MailholThis series rework usb_maxpacket() to change its prototype from:
| static inline __u16
| usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
into:
| static inline u16 usb_maxpacket(struct usb_device *dev, int pipe)
and rewrite the function.
Rationale:
* The third argument of usb_maxpacket(): is_out can be derived from its second one: pipe using usb_pipeout(pipe). Furthermore, usb_pipeout(pipe) is being called within usb_maxpacket() regardless to confirm the input.
* This function is not exposed to the UAPI so return type should be
u16, not __u16.
* Let's not reinvent the wheel and rely on usb_endpoint_maxp() to make this a one liner function.
In order to do so, usb_maxpacket() is temporarily changed into a variadic function to ignore its third argument.
The series goes as follow:
* Patches 1 and 2: preparation, remove a redundant call to the local macro max_packet() in two drivers
* Patch 3: reword usb_maxpacket() and make it variadic to accommodate during the migration
* Patch 4 to 9: migrate all the users of usb_maxpacket() (one patch per tree)
* Patch 10: remove the third argument of usb_maxpacket() now that everyone is migrated
** Changelog: **
v1 -> v2:
* v1 contained a single patch, split it into a series. c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#m6d25529f1cab1332b45e3e24480d541963684446
Vincent Mailhol (10):
usb: oxu210hp-hcd: remove redundant call to max_packet() macro
usb: isp1760: remove redundant max_packet() macro
usb: rework usb_maxpacket() and deprecate its third argument
HID: usbhid: remove third argument of usb_maxpacket()
Input: remove third argument of usb_maxpacket()
media: remove third argument of usb_maxpacket()
net: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
sound: usb: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- .../net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++-- drivers/usb/host/isp1362-hcd.c | 6 ++--- drivers/usb/host/max3421-hcd.c | 6 ++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 ++--- drivers/usb/isp1760/isp1760-hcd.c | 7 ++---- drivers/usb/misc/ftdi-elan.c | 15 ++++-------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- include/linux/usb.h | 23 ++----------------- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 ++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 46 files changed, 71 insertions(+), 102 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/10 usb: oxu210hp-hcd: remove redundant call to max_packet() macro
The function usb_endpoint_maxp() (called by usb_maxpacket()) already does the sanitazation of the USB endpoint max packet size. The call to max_packet() does the same thing and is thus removed.
However, the macro max_packet() is kept because it is used elsewhere in the file.
--- drivers/usb/host/oxu210hp-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/oxu210hp-hcd.c +1 -1
@@ -1685,7 +1685,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =max_packet (usb_maxpacket (urb->dev, urb->pipe, !is_input)); + maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input);/* * buffer gets wrapped in one or more qtds;
Signature · 1 line
2.34.1
PATCH v2 2/10 usb: isp1760: remove redundant max_packet() macro
In reply to Vincent MailholThe function usb_endpoint_maxp() (called by usb_maxpacket()) already does the sanitazation of the USB endpoint max packet size. The call to max_packet() does the same thing and is thus removed.
The macro max_packet() not being used anymore also gets removed.
--- drivers/usb/isp1760/isp1760-hcd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/isp1760/isp1760-hcd.c +2 -3
@@ -1768,7 +1768,6 @@ static void qtd_list_free(struct list_head *qtd_list)* Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize. * Also calculate the PID type (SETUP/IN/OUT) for each packet. */ -#define max_packet (wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)static void packetize_urb (struct usb_hcd *hcd,struct urb *urb,struct list_head *head,gfp_t flags) {
@@ -1809,8 +1808,8 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =max_packet (usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe))); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe, +usb_pipeout (urb->pipe));/* * buffer gets wrapped in one or more qtds;
Signature · 1 line
2.34.1
Re: [PATCH v2 02/10] usb: isp1760: remove redundant max_packet() macro
Hi Vincent,
Thanks for the patch.
Quoted 8 lines · Vincent Mailhol
The function
usb_endpoint_maxp()(called byusb_maxpacket()) already does the sanitazation of the USB endpoint max packet size. The call tomax_packet()does the same thing and is thus removed.The macro
max_packet()not being used anymore also gets removed.CC Rui Miguel Silva <[email protected]>Signed-off-by Vincent Mailhol <[email protected]>
Thanks for the cleanup, looks good to me.
Cheers,
Rui
Quoted 29 lines
--- drivers/usb/isp1760/isp1760-hcd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/usb/isp1760/isp1760-hcd.c +2
-3@@ -1768,7 +1768,6 @@ static void qtd_list_free(struct list_head *qtd_list)* Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize. * Also calculate the PID type (SETUP/IN/OUT) for each packet. */ -#define max_packet (wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)static void packetize_urb (struct usb_hcd *hcd,struct urb *urb,struct list_head *head,gfp_t flags) {@@ -1809,8 +1808,8 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =max_packet (usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe))); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe, +usb_pipeout (urb->pipe));/* * buffer gets wrapped in one or more qtds; Signature · 1 line
2.34.1
PATCH v2 3/10 usb: rework usb_maxpacket() and deprecate its third argument
In reply to Vincent MailholThis is a transitional patch with the 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 *dev, 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 latter, once all the callers get updated.
Finally, the body of the function is reworked in order not to reinvent the wheel and just relies on the usb_pipe_endpoint() helper function instead.
--- include/linux/usb.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
include/linux/usb.h +3 -21
@@ -1969,30 +1969,12 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *dev,int pipe, +/* int is_out deprecated */ ...) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (is_out) { -WARN_ON (usb_pipein (pipe)); - ep = udev->ep_out[epnum]; - }else { -WARN_ON (usb_pipeout (pipe)); - ep = udev->ep_in[epnum]; - } -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (dev, pipe)->desc); } -/* ----------------------------------------------------------------------- */ -/* translate USB error codes to codes user space understands */ static inline int usb_translate_errors (int error_code) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerRe: [PATCH v2 03/10] usb: rework usb_maxpacket() and deprecate its third argument
Quoted 32 lines · Vincent Mailhol
This is a transitional patch with the 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 u16usb_maxpacket(struct usb_device *dev, int pipe)The third argument of
usb_maxpacket():is_outgets removed because it can be derived from its second argument: pipe usingusb_pipeout(pipe). Furthermore, in the current version,ubs_pipeout(pipe)is called regardless in order to sanitize theis_outparameter.In order to make a smooth change, we first deprecate the
is_outparameter by simply ignoring it (using a variadic function) and will remove it latter, once all the callers get updated.Finally, the body of the function is reworked in order not to reinvent the wheel and just relies on the
usb_pipe_endpoint()helper function instead.Signed-off-by Vincent Mailhol <[email protected]>--- include/linux/usb.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)include/linux/usb.h +0
-0
include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1973
Quoted 9 lines
include/linux/usb.h +2
-4@@ -1969,30 +1969,12 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *dev,int pipe, +/* int is_out deprecated */ ...)
No need to change from udev->dev, right?
Quoted 7 lines
include/linux/usb.h +0
-6{ -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (is_out) { -WARN_ON (usb_pipein (pipe)); - ep = udev->ep_out[epnum];
include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1975
Quoted 10 lines
include/linux/usb.h +1
-9- }else { -WARN_ON (usb_pipeout (pipe)); - ep = udev->ep_in[epnum]; - } -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (dev, pipe)->desc);
The change to use usb_pipe_endpoint() can be done separately.
Let's make these in tiny steps so that we can easily roll things back if things are not working.
thanks,
greg k-h
Re: [PATCH v2 03/10] usb: rework usb_maxpacket() and deprecate its third argument
Quoted 36 lines · Greg Kroah-Hartman
Quoted 35 lines · Vincent Mailhol
This is a transitional patch with the 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 u16usb_maxpacket(struct usb_device *dev, int pipe)The third argument of
usb_maxpacket():is_outgets removed because it can be derived from its second argument: pipe usingusb_pipeout(pipe). Furthermore, in the current version,ubs_pipeout(pipe)is called regardless in order to sanitize theis_outparameter.In order to make a smooth change, we first deprecate the
is_outparameter by simply ignoring it (using a variadic function) and will remove it latter, once all the callers get updated.Finally, the body of the function is reworked in order not to reinvent the wheel and just relies on the
usb_pipe_endpoint()helper function instead.Signed-off-by Vincent Mailhol <[email protected]>--- include/linux/usb.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)include/linux/usb.h +0
-0@@ -1969,30 +1969,12 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; }
Quoted 8 lines
include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1973
Quoted 6 lines
include/linux/usb.h +2
-4-/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *dev,int pipe, +/* int is_out deprecated */ ...)No need to change from
udev->dev, right?
Right. The motivation of this change was to align with other functions (the majority of the functions in linux/usb.h name it dev, not udev). Comment taken, I will keep the udev name in v3.
Quoted 20 lines
Quoted 7 lines
include/linux/usb.h +0
-6{ -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (is_out) { -WARN_ON (usb_pipein (pipe)); - ep = udev->ep_out[epnum];include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1975
Quoted 10 lines
include/linux/usb.h +1
-9- }else { -WARN_ON (usb_pipeout (pipe)); - ep = udev->ep_in[epnum]; - } -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (dev, pipe)->desc);The change to use
usb_pipe_endpoint()can be done separately.
Quoted 2 lines
Let's make these in tiny steps so that we can easily roll things back if things are not working.
ACK. I will respin the patch series as below:
* Make usb_maxpacket variadic
* Migrate the callers of usb_maxpacket()
* Suppress the third argument of usb_maxpacket()
* Change the body of usb_maxpacket() using usb_pipe_endpoint().
Quoted 3 lines
thanks,
greg k-h
PATCH v2 4/10 HID: usbhid: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -387,7 +387,7 @@ static int hid_submit_ctrl(struct hid_device *hid) usbhid->urbctrl->pipe =usb_rcvctrlpipe (hid_to_usb_dev (hid),0 ); maxpacket =usb_maxpacket (hid_to_usb_dev (hid), - usbhid->urbctrl->pipe,0 ); + usbhid->urbctrl->pipe); len += (len ==0 );/* Don't allow 0-length reports */ len =round_up (len, maxpacket);if (len > usbhid->bufsize)
drivers/hid/usbhid/usbkbd.c +1 -1
@@ -279,7 +279,7 @@ static int usb_kbd_probe(struct usb_interface *iface,return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); kbd =kzalloc (sizeof (struct usb_kbd ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/hid/usbhid/usbmouse.c +1 -1
@@ -123,7 +123,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_ireturn -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); mouse =kzalloc (sizeof (struct usb_mouse ),GFP_KERNEL ); input_dev =input_allocate_device ();
Signature · 1 line
2.34.1
PATCH v2 5/10 Input: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/input/misc/ati_remote2.c +1 -1
@@ -639,7 +639,7 @@ static int ati_remote2_urb_init(struct ati_remote2 *ar2)return -ENOMEM ; pipe =usb_rcvintpipe (udev, ar2->ep[i]->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = maxp >4 ?4 : maxp; usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
drivers/input/misc/cm109.c +1 -1
@@ -745,7 +745,7 @@ static int cm109_usb_probe(struct usb_interface *intf,/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %d\n" , ret,USB_PKT_LEN );
drivers/input/misc/powermate.c +1 -1
@@ -374,7 +374,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe);if (maxp <POWERMATE_PAYLOAD_SIZE_MIN || maxp >POWERMATE_PAYLOAD_SIZE_MAX ) { printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
drivers/input/misc/yealink.c +1 -1
@@ -905,7 +905,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %zd\n" , ret,USB_PKT_LEN );
drivers/input/tablet/acecad.c +1 -1
@@ -130,7 +130,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); acecad =kzalloc (sizeof (struct usb_acecad ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/input/tablet/pegasus_notetaker.c +1 -1
@@ -296,7 +296,7 @@ static int pegasus_probe(struct usb_interface *intf, pegasus->intf = intf; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - pegasus->data_len =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + pegasus->data_len =usb_maxpacket (dev, pipe); pegasus->data =usb_alloc_coherent (dev, pegasus->data_len,GFP_KERNEL , &pegasus->data_dma);
Signature · 1 line
2.34.1
PATCH v2 6/10 media: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/rc/ati_remote.c +2 -2
@@ -773,7 +773,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, ati_remote->endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
@@ -784,7 +784,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up out_urb */ pipe =usb_sndintpipe (udev, ati_remote->endpoint_out->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
drivers/media/rc/mceusb.c +1 -1
@@ -1728,7 +1728,7 @@ static int mceusb_dev_probe(struct usb_interface *intf, pipe =usb_rcvintpipe (dev, ep_in->bEndpointAddress); else pipe =usb_rcvbulkpipe (dev, ep_in->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); ir =kzalloc (sizeof (struct mceusb_dev ),GFP_KERNEL );if (!ir)
drivers/media/rc/streamzap.c +1 -1
@@ -307,7 +307,7 @@ static int streamzap_probe(struct usb_interface *intf, } pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (usbdev, pipe);if (maxp ==0 ) { dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n",
drivers/media/rc/xbox_remote.c +1 -1
@@ -171,7 +171,7 @@ static int xbox_remote_initialize(struct xbox_remote *xbox_remote,/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(xbox_remote->irq_urb, udev, pipe, xbox_remote->inbuf,
drivers/media/usb/tm6000/tm6000-dvb.c +1 -1
@@ -120,7 +120,7 @@ static int tm6000_start_stream(struct tm6000_core *dev) pipe =usb_rcvbulkpipe (dev->udev, dev->bulk_in.endp->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe); size = size *15 ;/* 512 x 8 or 12 or 15 */ dvb->bulk_urb->transfer_buffer =kzalloc (size,GFP_KERNEL );
drivers/media/usb/tm6000/tm6000-input.c +1 -1
@@ -340,7 +340,7 @@ static int __tm6000_ir_int_start(struct rc_dev *rc) dev->int_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);dprintk (1 ,"IR max size: %d\n" , size); ir->int_urb->transfer_buffer =kzalloc (size,GFP_ATOMIC );
drivers/media/usb/tm6000/tm6000-video.c +1 -1
@@ -570,7 +570,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) dev->isoc_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);if (size > dev->isoc_in.maxsize) size = dev->isoc_in.maxsize;
Signature · 1 line
2.34.1
PATCH v2 7/10 net: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/usb/cdc_ncm.c +2 -2
@@ -441,7 +441,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)* .bind which is called before usbnet sets up dev->maxpacket */ if (val !=le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize) && - val %usb_maxpacket (dev->udev, dev->out,1 ) ==0 ) + val %usb_maxpacket (dev->udev, dev->out) ==0 ) val++;/* we might need to flush any pending tx buffers if running */
@@ -465,7 +465,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)usbnet_update_max_qlen (dev);/* never pad more than 3 full USB packets per transfer */ - ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out,1 ), + ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out),CDC_NCM_MIN_TX_PKT , ctx->tx_max); }
drivers/net/usb/lan78xx.c +2 -2
@@ -4426,7 +4426,7 @@ static int lan78xx_probe(struct usb_interface *intf, goto out4; period = ep_intr->desc.bInterval; - maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); + maxp =usb_maxpacket (dev->udev, dev->pipe_intr); buf =kmalloc (maxp,GFP_KERNEL );if (!buf) { ret = -ENOMEM ;
@@ -4444,7 +4444,7 @@ static int lan78xx_probe(struct usb_interface *intf, dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } - dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) {
drivers/net/usb/rndis_host.c +1 -1
@@ -333,7 +333,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) net->hard_header_len +=sizeof (struct rndis_data_hdr ); dev->hard_mtu = net->mtu + net->hard_header_len; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {netif_dbg (dev, probe, dev->net,"dev->maxpacket can't be 0\n" );
drivers/net/usb/usbnet.c +2 -2
@@ -229,7 +229,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) pipe =usb_rcvintpipe (dev->udev, dev->status->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - maxp =usb_maxpacket (dev->udev, pipe,0 ); + maxp =usb_maxpacket (dev->udev, pipe);/* avoid 1 msec chatter: min 8 msec poll rate */ period = max ((int) dev->status->desc.bInterval,
@@ -1789,7 +1789,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)if (!dev->rx_urb_size) dev->rx_urb_size = dev->hard_mtu; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {/* that is a broken device */ status = -ENODEV ;
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
@@ -1132,7 +1132,7 @@ int mt76u_init(struct mt76_dev *dev,INIT_WORK (&usb->stat_work, mt76u_tx_status_data); - usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ),1 ); + usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ));if (usb->data_len <32 ) usb->data_len =32 ;
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +2 -2
@@ -586,10 +586,10 @@ static void rt2x00usb_assign_endpoint(struct data_queue *queue,if (queue->qid ==QID_RX ) { pipe =usb_rcvbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,0 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }else { pipe =usb_sndbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,1 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }if (!queue->usb_maxpacket)
Signature · 1 line
2.34.1
PATCH v2 8/10 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++--- drivers/usb/host/isp1362-hcd.c | 6 +++--- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++---- drivers/usb/misc/ftdi-elan.c | 15 +++++---------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- 18 files changed, 33 insertions(+), 44 deletions(-)
drivers/usb/atm/usbatm.c +1 -1
@@ -1091,7 +1091,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));/* rx buffer size must be a positive multiple of the endpoint maxpacket */ - maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint,0 ); + maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint);if ((maxpacket <1 ) || (maxpacket >UDSL_MAX_BUF_SIZE )) { dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
drivers/usb/c67x00/c67x00-sched.c +2 -2
@@ -655,7 +655,7 @@ static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) usb_pipeout(urb->pipe)); remaining = urb->transfer_buffer_length - urb->actual_length; - maxps =usb_maxpacket (urb->dev, urb->pipe,usb_pipeout (urb->pipe)); + maxps =usb_maxpacket (urb->dev, urb->pipe); need_empty = (urb->transfer_flags &URB_ZERO_PACKET ) &&usb_pipeout (urb->pipe) && !(remaining % maxps);
@@ -866,7 +866,7 @@ static inline int c67x00_end_of_data(struct c67x00_td *td)if (unlikely (!act_bytes))return 1 ;/* This was an empty packet */ - maxps =usb_maxpacket (td_udev (td), td->pipe,usb_pipeout (td->pipe)); + maxps =usb_maxpacket (td_udev (td), td->pipe);if (unlikely (act_bytes < maxps))return 1 ;/* Smaller then full packet */
drivers/usb/core/hub.c +1 -1
@@ -1635,7 +1635,7 @@ static int hub_configure(struct usb_hub *hub,* maxpktsize is defined in hcd.c's fake endpoint descriptors * to be big enough for at least USB_MAXCHILDREN ports. */ pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);if (maxp >sizeof (*hub->buffer)) maxp =sizeof (*hub->buffer);
drivers/usb/host/ehci-q.c +2 -2
@@ -645,7 +645,7 @@ qh_urb_transaction ( token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1218,7 +1218,7 @@ static int ehci_submit_single_step_set_feature( token |= (1 /* "in" */ <<8 );/*This is IN stage*/ - maxpacket =usb_maxpacket (urb->dev, urb->pipe,0 ); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);qtd_fill (ehci, qtd, buf, len, token, maxpacket);
drivers/usb/host/fhci-hcd.c +1 -2
@@ -408,8 +408,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket(urb->dev, pipe, - usb_pipeout(pipe))) != 0) + % usb_maxpacket(urb->dev, pipe)) != 0) size++;break ;case PIPE_ISOCHRONOUS :
drivers/usb/host/fotg210-hcd.c +1 -1
@@ -2596,7 +2596,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/host/isp116x-hcd.c +2 -3
@@ -726,7 +726,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe);usb_settoggle (udev, epnum, is_out,0 );if (type ==PIPE_CONTROL ) {
@@ -757,8 +757,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, ep->load =usb_calc_bus_time (udev->speed, !is_out, (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, - is_out)) / +usb_maxpacket (udev, pipe)) /1000 ; } hep->hcpriv = ep;
drivers/usb/host/isp1362-hcd.c +3 -3
@@ -1279,7 +1279,7 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->udev =usb_get_dev (udev); ep->hep = hep; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->ptd_offset = -EINVAL ; ep->ptd_index = -EINVAL ;usb_settoggle (udev, epnum, is_out,0 );
@@ -1299,8 +1299,8 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->interval = urb->interval; ep->branch =PERIODIC_SIZE ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) /1000 ; + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; } hep->hcpriv = ep;
drivers/usb/host/max3421-hcd.c +3 -3
@@ -546,7 +546,7 @@ max3421_transfer_out(struct usb_hcd *hcd, struct urb *urb, int fast_retransmit)return MAX3421_HXFR_BULK_OUT (epnum); } - max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/*
@@ -952,7 +952,7 @@ max3421_transfer_in_done(struct usb_hcd *hcd, struct urb *urb)* USB 2.0 Section 5.3.2 Pipes: packets must be full size * except for last one. */ - max_packet =usb_maxpacket (urb->dev, urb->pipe,0 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/* * We do not support isochronous transfers at this
@@ -998,7 +998,7 @@ max3421_transfer_out_done(struct usb_hcd *hcd, struct urb *urb)* max_packet as an indicator that the end of the * packet has been reached). */ -u32 max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); +u32 max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max3421_hcd->curr_len == max_packet)return 0 ;
drivers/usb/host/ohci-hcd.c +1 -2
@@ -181,8 +181,7 @@ static int ohci_urb_enqueue ( size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket (urb->dev, pipe, - usb_pipeout (pipe))) == 0) + % usb_maxpacket(urb->dev, pipe)) == 0) size++;break ;case PIPE_ISOCHRONOUS :/* number of packets from URB */
drivers/usb/host/oxu210hp-hcd.c +2 -2
@@ -1685,7 +1685,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1796,7 +1796,7 @@ static struct ehci_qh *qh_make(struct oxu_hcd *oxu, is_input =usb_pipein (urb->pipe); type =usb_pipetype (urb->pipe); - maxp =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxp =usb_maxpacket (urb->dev, urb->pipe);/* Compute interrupt scheduling parameters just once, and save. * - allowing for high bandwidth, how many nsec/uframe are used?
drivers/usb/host/r8a66597-hcd.c +1 -2
@@ -1867,8 +1867,7 @@ static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, td->pipe = hep->hcpriv; td->urb = urb; td->address =get_urb_to_r8a66597_addr (r8a66597, urb); - td->maxpacket =usb_maxpacket (urb->dev, urb->pipe, - !usb_pipein (urb->pipe)); + td->maxpacket =usb_maxpacket (urb->dev, urb->pipe);if (usb_pipecontrol (urb->pipe)) td->type =USB_PID_SETUP ;else if (usb_pipein (urb->pipe))
drivers/usb/host/sl811-hcd.c +3 -3
@@ -842,7 +842,7 @@ static int sl811h_urb_enqueue(INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->defctrl =SL11H_HCTLMASK_ARM |SL11H_HCTLMASK_ENABLE ;usb_settoggle (udev, epnum, is_out,0 );
@@ -878,8 +878,8 @@ static int sl811h_urb_enqueue(if (type ==PIPE_ISOCHRONOUS ) ep->defctrl |=SL11H_HCTLMASK_ISOCH ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; }
drivers/usb/isp1760/isp1760-hcd.c +2 -4
@@ -825,8 +825,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,memset (ptd,0 ,sizeof (*ptd));/* according to 3.6.2, max packet len can not be > 0x400 */ - maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe, -usb_pipeout (qtd->urb->pipe)); + maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe); multi =1 + ((maxpacket >>11 ) &0x3 ); maxpacket &=0x7ff ;
@@ -1808,8 +1807,7 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/misc/ftdi-elan.c +5 -10
@@ -1449,8 +1449,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x8007 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =8 ; command->value =0 ; command->buffer = urb->setup_packet;
@@ -1514,8 +1513,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1571,8 +1569,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x0000 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1634,8 +1631,7 @@ wait:if (ftdi->disconnected > 0) { command->header =0x81 | (ed <<5 ); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =min_t (u32,1024 , urb->transfer_buffer_length - urb->actual_length);
@@ -1715,8 +1711,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
drivers/usb/misc/lvstest.c +1 -1
@@ -437,7 +437,7 @@ static int lvs_rh_probe(struct usb_interface *intf,INIT_WORK (&lvs->rh_work, lvs_rh_work); pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);usb_fill_int_urb (lvs->urb, hdev, pipe, &lvs->buffer[0 ], maxp, lvs_rh_irq, lvs, endpoint->bInterval);
drivers/usb/storage/onetouch.c +1 -1
@@ -180,7 +180,7 @@ static int onetouch_connect_input(struct us_data *ss)return -ENODEV ; pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp =min (maxp,ONETOUCH_PKT_LEN ); onetouch =kzalloc (sizeof (struct usb_onetouch ),GFP_KERNEL );
drivers/usb/storage/transport.c +1 -1
@@ -363,7 +363,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,usb_stor_dbg (us,"xfer %u bytes\n" , length);/* calculate the max packet size */ - maxp =usb_maxpacket (us->pusb_dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (us->pusb_dev, pipe);if (maxp > length) maxp = length;
Signature · 1 line
2.34.1
PATCH v2 9/10 sound: usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/line6/pcm.c +2 -2
@@ -552,10 +552,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1285,7 +1285,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1374,7 +1374,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -421,7 +421,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.34.1
PATCH v2 10/10 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholNow that all users of usb_maxpacket() have been migrated to only use two arguments, remove the third variadic argument which was introduced for the transition.
--- include/linux/usb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/usb.h +1 -2
@@ -1969,8 +1969,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -static inline u16 usb_maxpacket (struct usb_device *dev,int pipe, -/* int is_out deprecated */ ...) +static inline u16 usb_maxpacket (struct usb_device *dev,int pipe) {return usb_endpoint_maxp (&usb_pipe_endpoint (dev, pipe)->desc); }
Signature · 1 line
2.34.1
v3 cover usb: rework usb_maxpacket() and remove its third argument
In reply to Vincent MailholThis series rework usb_maxpacket() to change its prototype 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)
and rewrite the function.
Rationale:
* The third argument of usb_maxpacket(): is_out can be derived from its second one: pipe using usb_pipeout(pipe). Furthermore, usb_pipeout(pipe) is being called within usb_maxpacket() regardless to confirm the input.
* This function is not exposed to the UAPI so return type should be
u16, not __u16.
* Let's not reinvent the wheel and rely on usb_endpoint_maxp() to make this a one liner function.
In order to do so, usb_maxpacket() is temporarily changed into a variadic function to ignore its third argument.
The series goes as follow:
* Patch 1: make usb_maxpacket() variadic to accommodate during the migration
* Patch 2 to 7: migrate all the users of usb_maxpacket() (one patch per tree)
* Patch 8: remove the third argument of usb_maxpacket() now that everyone is migrated
* Patch 9: fully rework usb_maxpacket()'s body using usb_pipe_endpoint()
** Changelog: **
v2 -> v3:
* remove patch 1 and 2 from the series because already applied to usb-testing.
* split the change on usb_maxpacket in tiny steps:
- a first patch to make the function variadic (patch 1 of this series)
- a second one to remove the third argrument (patch 8 of this series)
- a third and last one to fully rework the body and use usb_pipe_endpoint() (patch 9 of this series)
* keep current variable names (do not rename usb_maxpacket parameter from udev to dev).
c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#m6a218544713670448c156ead95e72e8e1aa2373b
v1 -> v2:
* v1 contained a single patch, split it into a series. c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#m6d25529f1cab1332b45e3e24480d541963684446
Vincent Mailhol (9):
usb: deprecate the third argument of usb_maxpacket()
HID: usbhid: remove third argument of usb_maxpacket()
Input: remove third argument of usb_maxpacket()
media: remove third argument of usb_maxpacket()
net: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
sound: usb: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
usb: rework usb_maxpacket() using usb_pipe_endpoint()
drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- .../net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++-- drivers/usb/host/isp1362-hcd.c | 6 ++--- drivers/usb/host/max3421-hcd.c | 6 ++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 ++--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++--- drivers/usb/misc/ftdi-elan.c | 15 ++++-------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- include/linux/usb.h | 23 ++----------------- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 ++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 46 files changed, 71 insertions(+), 101 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/9 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.
--- include/linux/usb.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
include/linux/usb.h +5 -11
@@ -1969,21 +1969,17 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *udev,int pipe, +/* int is_out deprecated */ ...) {struct usb_host_endpoint *ep;unsigned epnum =usb_pipeendpoint (pipe); -if (is_out) { -WARN_ON (usb_pipein (pipe)); +if (usb_pipeout (pipe)) ep = udev->ep_out[epnum]; - }else { -WARN_ON (usb_pipeout (pipe)); +else ep = udev->ep_in[epnum]; - } +if (!ep)return 0 ;
@@ -1991,8 +1987,6 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)return usb_endpoint_maxp (&ep->desc); } -/* ----------------------------------------------------------------------- */ -/* translate USB error codes to codes user space understands */ static inline int usb_translate_errors (int error_code) {
Signature · 1 line
2.34.1
PATCH v3 2/9 HID: usbhid: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -387,7 +387,7 @@ static int hid_submit_ctrl(struct hid_device *hid) usbhid->urbctrl->pipe =usb_rcvctrlpipe (hid_to_usb_dev (hid),0 ); maxpacket =usb_maxpacket (hid_to_usb_dev (hid), - usbhid->urbctrl->pipe,0 ); + usbhid->urbctrl->pipe); len += (len ==0 );/* Don't allow 0-length reports */ len =round_up (len, maxpacket);if (len > usbhid->bufsize)
drivers/hid/usbhid/usbkbd.c +1 -1
@@ -279,7 +279,7 @@ static int usb_kbd_probe(struct usb_interface *iface,return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); kbd =kzalloc (sizeof (struct usb_kbd ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/hid/usbhid/usbmouse.c +1 -1
@@ -123,7 +123,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_ireturn -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); mouse =kzalloc (sizeof (struct usb_mouse ),GFP_KERNEL ); input_dev =input_allocate_device ();
Signature · 1 line
2.34.1
PATCH v3 3/9 Input: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/input/misc/ati_remote2.c +1 -1
@@ -639,7 +639,7 @@ static int ati_remote2_urb_init(struct ati_remote2 *ar2)return -ENOMEM ; pipe =usb_rcvintpipe (udev, ar2->ep[i]->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = maxp >4 ?4 : maxp; usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
drivers/input/misc/cm109.c +1 -1
@@ -745,7 +745,7 @@ static int cm109_usb_probe(struct usb_interface *intf,/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %d\n" , ret,USB_PKT_LEN );
drivers/input/misc/powermate.c +1 -1
@@ -374,7 +374,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe);if (maxp <POWERMATE_PAYLOAD_SIZE_MIN || maxp >POWERMATE_PAYLOAD_SIZE_MAX ) { printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
drivers/input/misc/yealink.c +1 -1
@@ -905,7 +905,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %zd\n" , ret,USB_PKT_LEN );
drivers/input/tablet/acecad.c +1 -1
@@ -130,7 +130,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); acecad =kzalloc (sizeof (struct usb_acecad ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/input/tablet/pegasus_notetaker.c +1 -1
@@ -296,7 +296,7 @@ static int pegasus_probe(struct usb_interface *intf, pegasus->intf = intf; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - pegasus->data_len =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + pegasus->data_len =usb_maxpacket (dev, pipe); pegasus->data =usb_alloc_coherent (dev, pegasus->data_len,GFP_KERNEL , &pegasus->data_dma);
Signature · 1 line
2.34.1
PATCH v3 4/9 media: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/rc/ati_remote.c +2 -2
@@ -773,7 +773,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, ati_remote->endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
@@ -784,7 +784,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up out_urb */ pipe =usb_sndintpipe (udev, ati_remote->endpoint_out->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
drivers/media/rc/mceusb.c +1 -1
@@ -1728,7 +1728,7 @@ static int mceusb_dev_probe(struct usb_interface *intf, pipe =usb_rcvintpipe (dev, ep_in->bEndpointAddress); else pipe =usb_rcvbulkpipe (dev, ep_in->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); ir =kzalloc (sizeof (struct mceusb_dev ),GFP_KERNEL );if (!ir)
drivers/media/rc/streamzap.c +1 -1
@@ -307,7 +307,7 @@ static int streamzap_probe(struct usb_interface *intf, } pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (usbdev, pipe);if (maxp ==0 ) { dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n",
drivers/media/rc/xbox_remote.c +1 -1
@@ -171,7 +171,7 @@ static int xbox_remote_initialize(struct xbox_remote *xbox_remote,/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(xbox_remote->irq_urb, udev, pipe, xbox_remote->inbuf,
drivers/media/usb/tm6000/tm6000-dvb.c +1 -1
@@ -120,7 +120,7 @@ static int tm6000_start_stream(struct tm6000_core *dev) pipe =usb_rcvbulkpipe (dev->udev, dev->bulk_in.endp->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe); size = size *15 ;/* 512 x 8 or 12 or 15 */ dvb->bulk_urb->transfer_buffer =kzalloc (size,GFP_KERNEL );
drivers/media/usb/tm6000/tm6000-input.c +1 -1
@@ -340,7 +340,7 @@ static int __tm6000_ir_int_start(struct rc_dev *rc) dev->int_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);dprintk (1 ,"IR max size: %d\n" , size); ir->int_urb->transfer_buffer =kzalloc (size,GFP_ATOMIC );
drivers/media/usb/tm6000/tm6000-video.c +1 -1
@@ -570,7 +570,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) dev->isoc_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);if (size > dev->isoc_in.maxsize) size = dev->isoc_in.maxsize;
Signature · 1 line
2.34.1
PATCH v3 5/9 net: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/usb/cdc_ncm.c +2 -2
@@ -441,7 +441,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)* .bind which is called before usbnet sets up dev->maxpacket */ if (val !=le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize) && - val %usb_maxpacket (dev->udev, dev->out,1 ) ==0 ) + val %usb_maxpacket (dev->udev, dev->out) ==0 ) val++;/* we might need to flush any pending tx buffers if running */
@@ -465,7 +465,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)usbnet_update_max_qlen (dev);/* never pad more than 3 full USB packets per transfer */ - ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out,1 ), + ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out),CDC_NCM_MIN_TX_PKT , ctx->tx_max); }
drivers/net/usb/lan78xx.c +2 -2
@@ -4426,7 +4426,7 @@ static int lan78xx_probe(struct usb_interface *intf, goto out4; period = ep_intr->desc.bInterval; - maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); + maxp =usb_maxpacket (dev->udev, dev->pipe_intr); buf =kmalloc (maxp,GFP_KERNEL );if (!buf) { ret = -ENOMEM ;
@@ -4444,7 +4444,7 @@ static int lan78xx_probe(struct usb_interface *intf, dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } - dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) {
drivers/net/usb/rndis_host.c +1 -1
@@ -333,7 +333,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) net->hard_header_len +=sizeof (struct rndis_data_hdr ); dev->hard_mtu = net->mtu + net->hard_header_len; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {netif_dbg (dev, probe, dev->net,"dev->maxpacket can't be 0\n" );
drivers/net/usb/usbnet.c +2 -2
@@ -229,7 +229,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) pipe =usb_rcvintpipe (dev->udev, dev->status->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - maxp =usb_maxpacket (dev->udev, pipe,0 ); + maxp =usb_maxpacket (dev->udev, pipe);/* avoid 1 msec chatter: min 8 msec poll rate */ period = max ((int) dev->status->desc.bInterval,
@@ -1789,7 +1789,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)if (!dev->rx_urb_size) dev->rx_urb_size = dev->hard_mtu; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {/* that is a broken device */ status = -ENODEV ;
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
@@ -1132,7 +1132,7 @@ int mt76u_init(struct mt76_dev *dev,INIT_WORK (&usb->stat_work, mt76u_tx_status_data); - usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ),1 ); + usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ));if (usb->data_len <32 ) usb->data_len =32 ;
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +2 -2
@@ -586,10 +586,10 @@ static void rt2x00usb_assign_endpoint(struct data_queue *queue,if (queue->qid ==QID_RX ) { pipe =usb_rcvbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,0 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }else { pipe =usb_sndbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,1 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }if (!queue->usb_maxpacket)
Signature · 1 line
2.34.1
PATCH v3 6/9 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++--- drivers/usb/host/isp1362-hcd.c | 6 +++--- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++---- drivers/usb/misc/ftdi-elan.c | 15 +++++---------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- 18 files changed, 33 insertions(+), 44 deletions(-)
drivers/usb/atm/usbatm.c +1 -1
@@ -1091,7 +1091,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));/* rx buffer size must be a positive multiple of the endpoint maxpacket */ - maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint,0 ); + maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint);if ((maxpacket <1 ) || (maxpacket >UDSL_MAX_BUF_SIZE )) { dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
drivers/usb/c67x00/c67x00-sched.c +2 -2
@@ -655,7 +655,7 @@ static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) usb_pipeout(urb->pipe)); remaining = urb->transfer_buffer_length - urb->actual_length; - maxps =usb_maxpacket (urb->dev, urb->pipe,usb_pipeout (urb->pipe)); + maxps =usb_maxpacket (urb->dev, urb->pipe); need_empty = (urb->transfer_flags &URB_ZERO_PACKET ) &&usb_pipeout (urb->pipe) && !(remaining % maxps);
@@ -866,7 +866,7 @@ static inline int c67x00_end_of_data(struct c67x00_td *td)if (unlikely (!act_bytes))return 1 ;/* This was an empty packet */ - maxps =usb_maxpacket (td_udev (td), td->pipe,usb_pipeout (td->pipe)); + maxps =usb_maxpacket (td_udev (td), td->pipe);if (unlikely (act_bytes < maxps))return 1 ;/* Smaller then full packet */
drivers/usb/core/hub.c +1 -1
@@ -1635,7 +1635,7 @@ static int hub_configure(struct usb_hub *hub,* maxpktsize is defined in hcd.c's fake endpoint descriptors * to be big enough for at least USB_MAXCHILDREN ports. */ pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);if (maxp >sizeof (*hub->buffer)) maxp =sizeof (*hub->buffer);
drivers/usb/host/ehci-q.c +2 -2
@@ -645,7 +645,7 @@ qh_urb_transaction ( token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1218,7 +1218,7 @@ static int ehci_submit_single_step_set_feature( token |= (1 /* "in" */ <<8 );/*This is IN stage*/ - maxpacket =usb_maxpacket (urb->dev, urb->pipe,0 ); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);qtd_fill (ehci, qtd, buf, len, token, maxpacket);
drivers/usb/host/fhci-hcd.c +1 -2
@@ -408,8 +408,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket(urb->dev, pipe, - usb_pipeout(pipe))) != 0) + % usb_maxpacket(urb->dev, pipe)) != 0) size++;break ;case PIPE_ISOCHRONOUS :
drivers/usb/host/fotg210-hcd.c +1 -1
@@ -2596,7 +2596,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/host/isp116x-hcd.c +2 -3
@@ -726,7 +726,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe);usb_settoggle (udev, epnum, is_out,0 );if (type ==PIPE_CONTROL ) {
@@ -757,8 +757,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, ep->load =usb_calc_bus_time (udev->speed, !is_out, (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, - is_out)) / +usb_maxpacket (udev, pipe)) /1000 ; } hep->hcpriv = ep;
drivers/usb/host/isp1362-hcd.c +3 -3
@@ -1279,7 +1279,7 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->udev =usb_get_dev (udev); ep->hep = hep; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->ptd_offset = -EINVAL ; ep->ptd_index = -EINVAL ;usb_settoggle (udev, epnum, is_out,0 );
@@ -1299,8 +1299,8 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->interval = urb->interval; ep->branch =PERIODIC_SIZE ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) /1000 ; + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; } hep->hcpriv = ep;
drivers/usb/host/max3421-hcd.c +3 -3
@@ -546,7 +546,7 @@ max3421_transfer_out(struct usb_hcd *hcd, struct urb *urb, int fast_retransmit)return MAX3421_HXFR_BULK_OUT (epnum); } - max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/*
@@ -952,7 +952,7 @@ max3421_transfer_in_done(struct usb_hcd *hcd, struct urb *urb)* USB 2.0 Section 5.3.2 Pipes: packets must be full size * except for last one. */ - max_packet =usb_maxpacket (urb->dev, urb->pipe,0 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/* * We do not support isochronous transfers at this
@@ -998,7 +998,7 @@ max3421_transfer_out_done(struct usb_hcd *hcd, struct urb *urb)* max_packet as an indicator that the end of the * packet has been reached). */ -u32 max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); +u32 max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max3421_hcd->curr_len == max_packet)return 0 ;
drivers/usb/host/ohci-hcd.c +1 -2
@@ -181,8 +181,7 @@ static int ohci_urb_enqueue ( size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket (urb->dev, pipe, - usb_pipeout (pipe))) == 0) + % usb_maxpacket(urb->dev, pipe)) == 0) size++;break ;case PIPE_ISOCHRONOUS :/* number of packets from URB */
drivers/usb/host/oxu210hp-hcd.c +2 -2
@@ -1685,7 +1685,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1796,7 +1796,7 @@ static struct ehci_qh *qh_make(struct oxu_hcd *oxu, is_input =usb_pipein (urb->pipe); type =usb_pipetype (urb->pipe); - maxp =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxp =usb_maxpacket (urb->dev, urb->pipe);/* Compute interrupt scheduling parameters just once, and save. * - allowing for high bandwidth, how many nsec/uframe are used?
drivers/usb/host/r8a66597-hcd.c +1 -2
@@ -1867,8 +1867,7 @@ static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, td->pipe = hep->hcpriv; td->urb = urb; td->address =get_urb_to_r8a66597_addr (r8a66597, urb); - td->maxpacket =usb_maxpacket (urb->dev, urb->pipe, - !usb_pipein (urb->pipe)); + td->maxpacket =usb_maxpacket (urb->dev, urb->pipe);if (usb_pipecontrol (urb->pipe)) td->type =USB_PID_SETUP ;else if (usb_pipein (urb->pipe))
drivers/usb/host/sl811-hcd.c +3 -3
@@ -842,7 +842,7 @@ static int sl811h_urb_enqueue(INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->defctrl =SL11H_HCTLMASK_ARM |SL11H_HCTLMASK_ENABLE ;usb_settoggle (udev, epnum, is_out,0 );
@@ -878,8 +878,8 @@ static int sl811h_urb_enqueue(if (type ==PIPE_ISOCHRONOUS ) ep->defctrl |=SL11H_HCTLMASK_ISOCH ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; }
drivers/usb/isp1760/isp1760-hcd.c +2 -4
@@ -825,8 +825,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,memset (ptd,0 ,sizeof (*ptd));/* according to 3.6.2, max packet len can not be > 0x400 */ - maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe, -usb_pipeout (qtd->urb->pipe)); + maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe); multi =1 + ((maxpacket >>11 ) &0x3 ); maxpacket &=0x7ff ;
@@ -1808,8 +1807,7 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/misc/ftdi-elan.c +5 -10
@@ -1449,8 +1449,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x8007 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =8 ; command->value =0 ; command->buffer = urb->setup_packet;
@@ -1514,8 +1513,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1571,8 +1569,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x0000 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1634,8 +1631,7 @@ wait:if (ftdi->disconnected > 0) { command->header =0x81 | (ed <<5 ); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =min_t (u32,1024 , urb->transfer_buffer_length - urb->actual_length);
@@ -1715,8 +1711,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
drivers/usb/misc/lvstest.c +1 -1
@@ -437,7 +437,7 @@ static int lvs_rh_probe(struct usb_interface *intf,INIT_WORK (&lvs->rh_work, lvs_rh_work); pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);usb_fill_int_urb (lvs->urb, hdev, pipe, &lvs->buffer[0 ], maxp, lvs_rh_irq, lvs, endpoint->bInterval);
drivers/usb/storage/onetouch.c +1 -1
@@ -180,7 +180,7 @@ static int onetouch_connect_input(struct us_data *ss)return -ENODEV ; pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp =min (maxp,ONETOUCH_PKT_LEN ); onetouch =kzalloc (sizeof (struct usb_onetouch ),GFP_KERNEL );
drivers/usb/storage/transport.c +1 -1
@@ -363,7 +363,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,usb_stor_dbg (us,"xfer %u bytes\n" , length);/* calculate the max packet size */ - maxp =usb_maxpacket (us->pusb_dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (us->pusb_dev, pipe);if (maxp > length) maxp = length;
Signature · 1 line
2.34.1
PATCH v3 7/9 sound: usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/line6/pcm.c +2 -2
@@ -552,10 +552,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1285,7 +1285,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1374,7 +1374,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -421,7 +421,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.34.1
PATCH v3 8/9 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholNow that all users of usb_maxpacket() have been migrated to only use two arguments, remove the third variadic argument which was introduced for the transition.
--- include/linux/usb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/usb.h +1 -2
@@ -1969,8 +1969,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -static inline u16 usb_maxpacket (struct usb_device *udev,int pipe, -/* int is_out deprecated */ ...) +static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) {struct usb_host_endpoint *ep;unsigned epnum =usb_pipeendpoint (pipe);
Signature · 1 line
2.34.1
PATCH v3 9/9 usb: rework usb_maxpacket() using usb_pipe_endpoint()
In reply to Vincent MailholRework the body of usb_maxpacket() in order not to reinvent the wheel and just rely on the usb_pipe_endpoint() helper function instead.
--- include/linux/usb.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
include/linux/usb.h +1 -13
@@ -1971,19 +1971,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (usb_pipeout (pipe)) - ep = udev->ep_out[epnum]; -else - ep = udev->ep_in[epnum]; - -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (udev, pipe)->desc); }/* translate USB error codes to codes user space understands */
Signature · 1 line
2.34.1
Alan Stern
maintainerRe: [PATCH v3 9/9] usb: rework usb_maxpacket() using usb_pipe_endpoint()
Quoted 20 lines · Vincent Mailhol
Rework the body of
usb_maxpacket()in order not to reinvent the wheel and just rely on theusb_pipe_endpoint()helper function instead.Signed-off-by Vincent Mailhol <[email protected]>--- include/linux/usb.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)include/linux/usb.h +0
-4@@ -1971,19 +1971,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (usb_pipeout (pipe))
include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1974
Quoted 10 lines
include/linux/usb.h +1
-9- ep = udev->ep_out[epnum]; - else - ep = udev->ep_in[epnum]; - -if (!ep) -return 0 ; - -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (udev, pipe)->desc);
The original code was careful to handle the case where ep was a NULL pointer. What will your routine do if usb_pipe_endpoint(udev, pipe) returns NULL?
Alan Stern
Quoted 6 lines
include/linux/usb.h +0
-0}/* translate USB error codes to codes user space understands */ Signature · 1 line
2.34.1
Re: [PATCH v3 9/9] usb: rework usb_maxpacket() using usb_pipe_endpoint()
Quoted 27 lines · Alan Stern
Quoted 26 lines · Vincent Mailhol
Rework the body of
usb_maxpacket()in order not to reinvent the wheel and just rely on theusb_pipe_endpoint()helper function instead.Signed-off-by Vincent Mailhol <[email protected]>--- include/linux/usb.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)include/linux/usb.h +0
-10@@ -1971,19 +1971,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (usb_pipeout (pipe)) - ep = udev->ep_out[epnum]; -else - ep = udev->ep_in[epnum]; - -if (!ep) -return 0 ;
Quoted 8 lines
include/linux/usb.h usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) · line 1974
Quoted 4 lines
include/linux/usb.h +1
-3- -/* NOTE: only 0x07ff bits are for packet size... */ -return usb_endpoint_maxp (&ep->desc); +return usb_endpoint_maxp (&usb_pipe_endpoint (udev, pipe)->desc);The original code was careful to handle the case where ep was a NULL pointer. What will your routine do if
usb_pipe_endpoint(udev, pipe)returns NULL?
Sorry, you are absolutely right. Will send a v4.
Thank you!
Yours sincerely,
Vincent Maihol
v4 cover usb: rework usb_maxpacket() and remove its third argument
In reply to Vincent MailholThis series rework usb_maxpacket() to change its prototype 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)
and rewrite the function using usb_pipe_endpoint().
Rationale:
* The third argument of usb_maxpacket(): is_out can be derived from its second one: pipe using usb_pipeout(pipe). Furthermore, usb_pipeout(pipe) is being called within usb_maxpacket() regardless to confirm the input.
* This function is not exposed to the UAPI so return type should be
u16, not __u16.
* usb_pipe_endpoint() (defined a couple of lines before) does most of the work. Use it instead of reimplementing the same thing again.
In order to do so, usb_maxpacket() is temporarily changed into a variadic function to ignore its third argument.
The series goes as follow:
* Patch 1: make usb_maxpacket() variadic to accommodate during the migration
* Patch 2 to 7: migrate all the users of usb_maxpacket() (one patch per tree)
* Patch 8: remove the third argument of usb_maxpacket() now that everyone is migrated
* Patch 9: rework usb_maxpacket()'s body using usb_pipe_endpoint()
** Changelog: **
v3 -> v4:
* [Patch 9] check that the output of usb_pipe_endpoint() is not NULL.
c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#mb6f348628a0cdc104e6fb3b0d5212a71e60281e9
v2 -> v3:
* remove patch 1 and 2 from the series because already applied to usb-testing.
* split the change on usb_maxpacket in tiny steps:
- a first patch to make the function variadic (patch 1 of this series)
- a second one to remove the third argrument (patch 8 of this series)
- a third and last one to fully rework the body and use usb_pipe_endpoint() (patch 9 of this series)
* keep current variable names (do not rename usb_maxpacket parameter from udev to dev).
c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#m6a218544713670448c156ead95e72e8e1aa2373b
v1 -> v2:
* v1 contained a single patch, split it into a series. c.f.:
https://lore.kernel.org/linux-usb/[email protected]/T/#m6d25529f1cab1332b45e3e24480d541963684446
Vincent Mailhol (9):
usb: deprecate the third argument of usb_maxpacket()
HID: usbhid: remove third argument of usb_maxpacket()
Input: remove third argument of usb_maxpacket()
media: remove third argument of usb_maxpacket()
net: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
sound: usb: remove third argument of usb_maxpacket()
usb: remove third argument of usb_maxpacket()
usb: rework usb_maxpacket() using usb_pipe_endpoint()
drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++--- drivers/usb/host/isp1362-hcd.c | 6 +++--- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++---- drivers/usb/misc/ftdi-elan.c | 15 +++++---------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- include/linux/usb.h | 17 ++--------------- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 46 files changed, 71 insertions(+), 95 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/9 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.
--- include/linux/usb.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
include/linux/usb.h +5 -11
@@ -1969,21 +1969,17 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -/*-------------------------------------------------------------------------*/ - -static inline __u16 -usb_maxpacket (struct usb_device *udev,int pipe,int is_out) +static inline u16 usb_maxpacket (struct usb_device *udev,int pipe, +/* int is_out deprecated */ ...) {struct usb_host_endpoint *ep;unsigned epnum =usb_pipeendpoint (pipe); -if (is_out) { -WARN_ON (usb_pipein (pipe)); +if (usb_pipeout (pipe)) ep = udev->ep_out[epnum]; - }else { -WARN_ON (usb_pipeout (pipe)); +else ep = udev->ep_in[epnum]; - } +if (!ep)return 0 ;
@@ -1991,8 +1987,6 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)return usb_endpoint_maxp (&ep->desc); } -/* ----------------------------------------------------------------------- */ -/* translate USB error codes to codes user space understands */ static inline int usb_translate_errors (int error_code) {
Signature · 1 line
2.34.1
PATCH v4 2/9 HID: usbhid: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/hid/usbhid/hid-core.c | 2 +- drivers/hid/usbhid/usbkbd.c | 2 +- drivers/hid/usbhid/usbmouse.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -387,7 +387,7 @@ static int hid_submit_ctrl(struct hid_device *hid) usbhid->urbctrl->pipe =usb_rcvctrlpipe (hid_to_usb_dev (hid),0 ); maxpacket =usb_maxpacket (hid_to_usb_dev (hid), - usbhid->urbctrl->pipe,0 ); + usbhid->urbctrl->pipe); len += (len ==0 );/* Don't allow 0-length reports */ len =round_up (len, maxpacket);if (len > usbhid->bufsize)
drivers/hid/usbhid/usbkbd.c +1 -1
@@ -279,7 +279,7 @@ static int usb_kbd_probe(struct usb_interface *iface,return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); kbd =kzalloc (sizeof (struct usb_kbd ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/hid/usbhid/usbmouse.c +1 -1
@@ -123,7 +123,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_ireturn -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); mouse =kzalloc (sizeof (struct usb_mouse ),GFP_KERNEL ); input_dev =input_allocate_device ();
Signature · 1 line
2.34.1
PATCH v4 3/9 Input: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/input/misc/ati_remote2.c | 2 +- drivers/input/misc/cm109.c | 2 +- drivers/input/misc/powermate.c | 2 +- drivers/input/misc/yealink.c | 2 +- drivers/input/tablet/acecad.c | 2 +- drivers/input/tablet/pegasus_notetaker.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/input/misc/ati_remote2.c +1 -1
@@ -639,7 +639,7 @@ static int ati_remote2_urb_init(struct ati_remote2 *ar2)return -ENOMEM ; pipe =usb_rcvintpipe (udev, ar2->ep[i]->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = maxp >4 ?4 : maxp; usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
drivers/input/misc/cm109.c +1 -1
@@ -745,7 +745,7 @@ static int cm109_usb_probe(struct usb_interface *intf,/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %d\n" , ret,USB_PKT_LEN );
drivers/input/misc/powermate.c +1 -1
@@ -374,7 +374,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe);if (maxp <POWERMATE_PAYLOAD_SIZE_MIN || maxp >POWERMATE_PAYLOAD_SIZE_MAX ) { printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
drivers/input/misc/yealink.c +1 -1
@@ -905,7 +905,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)/* get a handle to the interrupt data pipe */ pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - ret =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + ret =usb_maxpacket (udev, pipe);if (ret !=USB_PKT_LEN )dev_err (&intf->dev,"invalid payload size %d, expected %zd\n" , ret,USB_PKT_LEN );
drivers/input/tablet/acecad.c +1 -1
@@ -130,7 +130,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_return -ENODEV ; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); acecad =kzalloc (sizeof (struct usb_acecad ),GFP_KERNEL ); input_dev =input_allocate_device ();
drivers/input/tablet/pegasus_notetaker.c +1 -1
@@ -296,7 +296,7 @@ static int pegasus_probe(struct usb_interface *intf, pegasus->intf = intf; pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); - pegasus->data_len =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + pegasus->data_len =usb_maxpacket (dev, pipe); pegasus->data =usb_alloc_coherent (dev, pegasus->data_len,GFP_KERNEL , &pegasus->data_dma);
Signature · 1 line
2.34.1
PATCH v4 4/9 media: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/media/rc/ati_remote.c | 4 ++-- drivers/media/rc/mceusb.c | 2 +- drivers/media/rc/streamzap.c | 2 +- drivers/media/rc/xbox_remote.c | 2 +- drivers/media/usb/tm6000/tm6000-dvb.c | 2 +- drivers/media/usb/tm6000/tm6000-input.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/rc/ati_remote.c +2 -2
@@ -773,7 +773,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, ati_remote->endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
@@ -784,7 +784,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)/* Set up out_urb */ pipe =usb_sndintpipe (udev, ati_remote->endpoint_out->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
drivers/media/rc/mceusb.c +1 -1
@@ -1728,7 +1728,7 @@ static int mceusb_dev_probe(struct usb_interface *intf, pipe =usb_rcvintpipe (dev, ep_in->bEndpointAddress); else pipe =usb_rcvbulkpipe (dev, ep_in->bEndpointAddress); - maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (dev, pipe); ir =kzalloc (sizeof (struct mceusb_dev ),GFP_KERNEL );if (!ir)
drivers/media/rc/streamzap.c +1 -1
@@ -307,7 +307,7 @@ static int streamzap_probe(struct usb_interface *intf, } pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (usbdev, pipe);if (maxp ==0 ) { dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n",
drivers/media/rc/xbox_remote.c +1 -1
@@ -171,7 +171,7 @@ static int xbox_remote_initialize(struct xbox_remote *xbox_remote,/* Set up irq_urb */ pipe =usb_rcvintpipe (udev, endpoint_in->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp = (maxp >DATA_BUFSIZE ) ?DATA_BUFSIZE : maxp; usb_fill_int_urb(xbox_remote->irq_urb, udev, pipe, xbox_remote->inbuf,
drivers/media/usb/tm6000/tm6000-dvb.c +1 -1
@@ -120,7 +120,7 @@ static int tm6000_start_stream(struct tm6000_core *dev) pipe =usb_rcvbulkpipe (dev->udev, dev->bulk_in.endp->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe); size = size *15 ;/* 512 x 8 or 12 or 15 */ dvb->bulk_urb->transfer_buffer =kzalloc (size,GFP_KERNEL );
drivers/media/usb/tm6000/tm6000-input.c +1 -1
@@ -340,7 +340,7 @@ static int __tm6000_ir_int_start(struct rc_dev *rc) dev->int_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);dprintk (1 ,"IR max size: %d\n" , size); ir->int_urb->transfer_buffer =kzalloc (size,GFP_ATOMIC );
drivers/media/usb/tm6000/tm6000-video.c +1 -1
@@ -570,7 +570,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) dev->isoc_in.endp->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - size =usb_maxpacket (dev->udev, pipe,usb_pipeout (pipe)); + size =usb_maxpacket (dev->udev, pipe);if (size > dev->isoc_in.maxsize) size = dev->isoc_in.maxsize;
Signature · 1 line
2.34.1
PATCH v4 5/9 net: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/net/usb/cdc_ncm.c | 4 ++-- drivers/net/usb/lan78xx.c | 4 ++-- drivers/net/usb/rndis_host.c | 2 +- drivers/net/usb/usbnet.c | 4 ++-- drivers/net/wireless/mediatek/mt76/usb.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/usb/cdc_ncm.c +2 -2
@@ -441,7 +441,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)* .bind which is called before usbnet sets up dev->maxpacket */ if (val !=le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize) && - val %usb_maxpacket (dev->udev, dev->out,1 ) ==0 ) + val %usb_maxpacket (dev->udev, dev->out) ==0 ) val++;/* we might need to flush any pending tx buffers if running */
@@ -465,7 +465,7 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)usbnet_update_max_qlen (dev);/* never pad more than 3 full USB packets per transfer */ - ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out,1 ), + ctx->min_tx_pkt =clamp_t (u16, ctx->tx_max -3 *usb_maxpacket (dev->udev, dev->out),CDC_NCM_MIN_TX_PKT , ctx->tx_max); }
drivers/net/usb/lan78xx.c +2 -2
@@ -4426,7 +4426,7 @@ static int lan78xx_probe(struct usb_interface *intf, goto out4; period = ep_intr->desc.bInterval; - maxp =usb_maxpacket (dev->udev, dev->pipe_intr,0 ); + maxp =usb_maxpacket (dev->udev, dev->pipe_intr); buf =kmalloc (maxp,GFP_KERNEL );if (!buf) { ret = -ENOMEM ;
@@ -4444,7 +4444,7 @@ static int lan78xx_probe(struct usb_interface *intf, dev->urb_intr->transfer_flags |=URB_FREE_BUFFER ; } - dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->pipe_out);/* Reject broken descriptors. */ if (dev->maxpacket ==0 ) {
drivers/net/usb/rndis_host.c +1 -1
@@ -333,7 +333,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) net->hard_header_len +=sizeof (struct rndis_data_hdr ); dev->hard_mtu = net->mtu + net->hard_header_len; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {netif_dbg (dev, probe, dev->net,"dev->maxpacket can't be 0\n" );
drivers/net/usb/usbnet.c +2 -2
@@ -229,7 +229,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf) pipe =usb_rcvintpipe (dev->udev, dev->status->desc.bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ); - maxp =usb_maxpacket (dev->udev, pipe,0 ); + maxp =usb_maxpacket (dev->udev, pipe);/* avoid 1 msec chatter: min 8 msec poll rate */ period = max ((int) dev->status->desc.bInterval,
@@ -1789,7 +1789,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)if (!dev->rx_urb_size) dev->rx_urb_size = dev->hard_mtu; - dev->maxpacket =usb_maxpacket (dev->udev, dev->out,1 ); + dev->maxpacket =usb_maxpacket (dev->udev, dev->out);if (dev->maxpacket ==0 ) {/* that is a broken device */ status = -ENODEV ;
drivers/net/wireless/mediatek/mt76/usb.c +1 -1
@@ -1132,7 +1132,7 @@ int mt76u_init(struct mt76_dev *dev,INIT_WORK (&usb->stat_work, mt76u_tx_status_data); - usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ),1 ); + usb->data_len =usb_maxpacket (udev,usb_sndctrlpipe (udev,0 ));if (usb->data_len <32 ) usb->data_len =32 ;
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +2 -2
@@ -586,10 +586,10 @@ static void rt2x00usb_assign_endpoint(struct data_queue *queue,if (queue->qid ==QID_RX ) { pipe =usb_rcvbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,0 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }else { pipe =usb_sndbulkpipe (usb_dev, queue->usb_endpoint); - queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe,1 ); + queue->usb_maxpacket =usb_maxpacket (usb_dev, pipe); }if (!queue->usb_maxpacket)
Signature · 1 line
2.34.1
PATCH v4 6/9 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- drivers/usb/atm/usbatm.c | 2 +- drivers/usb/c67x00/c67x00-sched.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/host/ehci-q.c | 4 ++-- drivers/usb/host/fhci-hcd.c | 3 +-- drivers/usb/host/fotg210-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 5 ++--- drivers/usb/host/isp1362-hcd.c | 6 +++--- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/oxu210hp-hcd.c | 4 ++-- drivers/usb/host/r8a66597-hcd.c | 3 +-- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/usb/isp1760/isp1760-hcd.c | 6 ++---- drivers/usb/misc/ftdi-elan.c | 15 +++++---------- drivers/usb/misc/lvstest.c | 2 +- drivers/usb/storage/onetouch.c | 2 +- drivers/usb/storage/transport.c | 2 +- 18 files changed, 33 insertions(+), 44 deletions(-)
drivers/usb/atm/usbatm.c +1 -1
@@ -1091,7 +1091,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));/* rx buffer size must be a positive multiple of the endpoint maxpacket */ - maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint,0 ); + maxpacket =usb_maxpacket (usb_dev, instance->rx_channel.endpoint);if ((maxpacket <1 ) || (maxpacket >UDSL_MAX_BUF_SIZE )) { dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
drivers/usb/c67x00/c67x00-sched.c +2 -2
@@ -655,7 +655,7 @@ static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) usb_pipeout(urb->pipe)); remaining = urb->transfer_buffer_length - urb->actual_length; - maxps =usb_maxpacket (urb->dev, urb->pipe,usb_pipeout (urb->pipe)); + maxps =usb_maxpacket (urb->dev, urb->pipe); need_empty = (urb->transfer_flags &URB_ZERO_PACKET ) &&usb_pipeout (urb->pipe) && !(remaining % maxps);
@@ -866,7 +866,7 @@ static inline int c67x00_end_of_data(struct c67x00_td *td)if (unlikely (!act_bytes))return 1 ;/* This was an empty packet */ - maxps =usb_maxpacket (td_udev (td), td->pipe,usb_pipeout (td->pipe)); + maxps =usb_maxpacket (td_udev (td), td->pipe);if (unlikely (act_bytes < maxps))return 1 ;/* Smaller then full packet */
drivers/usb/core/hub.c +1 -1
@@ -1635,7 +1635,7 @@ static int hub_configure(struct usb_hub *hub,* maxpktsize is defined in hcd.c's fake endpoint descriptors * to be big enough for at least USB_MAXCHILDREN ports. */ pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);if (maxp >sizeof (*hub->buffer)) maxp =sizeof (*hub->buffer);
drivers/usb/host/ehci-q.c +2 -2
@@ -645,7 +645,7 @@ qh_urb_transaction ( token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1218,7 +1218,7 @@ static int ehci_submit_single_step_set_feature( token |= (1 /* "in" */ <<8 );/*This is IN stage*/ - maxpacket =usb_maxpacket (urb->dev, urb->pipe,0 ); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);qtd_fill (ehci, qtd, buf, len, token, maxpacket);
drivers/usb/host/fhci-hcd.c +1 -2
@@ -408,8 +408,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket(urb->dev, pipe, - usb_pipeout(pipe))) != 0) + % usb_maxpacket(urb->dev, pipe)) != 0) size++;break ;case PIPE_ISOCHRONOUS :
drivers/usb/host/fotg210-hcd.c +1 -1
@@ -2596,7 +2596,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/host/isp116x-hcd.c +2 -3
@@ -726,7 +726,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe);usb_settoggle (udev, epnum, is_out,0 );if (type ==PIPE_CONTROL ) {
@@ -757,8 +757,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, ep->load =usb_calc_bus_time (udev->speed, !is_out, (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, - is_out)) / +usb_maxpacket (udev, pipe)) /1000 ; } hep->hcpriv = ep;
drivers/usb/host/isp1362-hcd.c +3 -3
@@ -1279,7 +1279,7 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->udev =usb_get_dev (udev); ep->hep = hep; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->ptd_offset = -EINVAL ; ep->ptd_index = -EINVAL ;usb_settoggle (udev, epnum, is_out,0 );
@@ -1299,8 +1299,8 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, ep->interval = urb->interval; ep->branch =PERIODIC_SIZE ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) /1000 ; + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; } hep->hcpriv = ep;
drivers/usb/host/max3421-hcd.c +3 -3
@@ -546,7 +546,7 @@ max3421_transfer_out(struct usb_hcd *hcd, struct urb *urb, int fast_retransmit)return MAX3421_HXFR_BULK_OUT (epnum); } - max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/*
@@ -952,7 +952,7 @@ max3421_transfer_in_done(struct usb_hcd *hcd, struct urb *urb)* USB 2.0 Section 5.3.2 Pipes: packets must be full size * except for last one. */ - max_packet =usb_maxpacket (urb->dev, urb->pipe,0 ); + max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max_packet >MAX3421_FIFO_SIZE ) {/* * We do not support isochronous transfers at this
@@ -998,7 +998,7 @@ max3421_transfer_out_done(struct usb_hcd *hcd, struct urb *urb)* max_packet as an indicator that the end of the * packet has been reached). */ -u32 max_packet =usb_maxpacket (urb->dev, urb->pipe,1 ); +u32 max_packet =usb_maxpacket (urb->dev, urb->pipe);if (max3421_hcd->curr_len == max_packet)return 0 ;
drivers/usb/host/ohci-hcd.c +1 -2
@@ -181,8 +181,7 @@ static int ohci_urb_enqueue ( size++; else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 && (urb->transfer_buffer_length - % usb_maxpacket (urb->dev, pipe, - usb_pipeout (pipe))) == 0) + % usb_maxpacket(urb->dev, pipe)) == 0) size++;break ;case PIPE_ISOCHRONOUS :/* number of packets from URB */
drivers/usb/host/oxu210hp-hcd.c +2 -2
@@ -1685,7 +1685,7 @@ static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu, token |= (1 /* "in" */ <<8 );/* else it's already initted to "out" pid (0 << 8) */ - maxpacket =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxpacket =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
@@ -1796,7 +1796,7 @@ static struct ehci_qh *qh_make(struct oxu_hcd *oxu, is_input =usb_pipein (urb->pipe); type =usb_pipetype (urb->pipe); - maxp =usb_maxpacket (urb->dev, urb->pipe, !is_input); + maxp =usb_maxpacket (urb->dev, urb->pipe);/* Compute interrupt scheduling parameters just once, and save. * - allowing for high bandwidth, how many nsec/uframe are used?
drivers/usb/host/r8a66597-hcd.c +1 -2
@@ -1867,8 +1867,7 @@ static struct r8a66597_td *r8a66597_make_td(struct r8a66597 *r8a66597, td->pipe = hep->hcpriv; td->urb = urb; td->address =get_urb_to_r8a66597_addr (r8a66597, urb); - td->maxpacket =usb_maxpacket (urb->dev, urb->pipe, - !usb_pipein (urb->pipe)); + td->maxpacket =usb_maxpacket (urb->dev, urb->pipe);if (usb_pipecontrol (urb->pipe)) td->type =USB_PID_SETUP ;else if (usb_pipein (urb->pipe))
drivers/usb/host/sl811-hcd.c +3 -3
@@ -842,7 +842,7 @@ static int sl811h_urb_enqueue(INIT_LIST_HEAD (&ep->schedule); ep->udev = udev; ep->epnum = epnum; - ep->maxpacket =usb_maxpacket (udev, urb->pipe, is_out); + ep->maxpacket =usb_maxpacket (udev, urb->pipe); ep->defctrl =SL11H_HCTLMASK_ARM |SL11H_HCTLMASK_ENABLE ;usb_settoggle (udev, epnum, is_out,0 );
@@ -878,8 +878,8 @@ static int sl811h_urb_enqueue(if (type ==PIPE_ISOCHRONOUS ) ep->defctrl |=SL11H_HCTLMASK_ISOCH ; ep->load =usb_calc_bus_time (udev->speed, !is_out, - (type ==PIPE_ISOCHRONOUS ), -usb_maxpacket (udev, pipe, is_out)) + type ==PIPE_ISOCHRONOUS , +usb_maxpacket (udev, pipe)) /1000 ;break ; }
drivers/usb/isp1760/isp1760-hcd.c +2 -4
@@ -825,8 +825,7 @@ static void create_ptd_atl(struct isp1760_qh *qh,memset (ptd,0 ,sizeof (*ptd));/* according to 3.6.2, max packet len can not be > 0x400 */ - maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe, -usb_pipeout (qtd->urb->pipe)); + maxpacket =usb_maxpacket (qtd->urb->dev, qtd->urb->pipe); multi =1 + ((maxpacket >>11 ) &0x3 ); maxpacket &=0x7ff ;
@@ -1808,8 +1807,7 @@ static void packetize_urb(struct usb_hcd *hcd, packet_type =IN_PID ; } - maxpacketsize =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + maxpacketsize =usb_maxpacket (urb->dev, urb->pipe);/* * buffer gets wrapped in one or more qtds;
drivers/usb/misc/ftdi-elan.c +5 -10
@@ -1449,8 +1449,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x8007 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =8 ; command->value =0 ; command->buffer = urb->setup_packet;
@@ -1514,8 +1513,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1571,8 +1569,7 @@ wait:if (ftdi->disconnected > 0) { command->length =0x0000 ; command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
@@ -1634,8 +1631,7 @@ wait:if (ftdi->disconnected > 0) { command->header =0x81 | (ed <<5 ); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =min_t (u32,1024 , urb->transfer_buffer_length - urb->actual_length);
@@ -1715,8 +1711,7 @@ wait:if (ftdi->disconnected > 0) { 1); command->address = (toggle_bits <<6 ) | (ep_number <<2 ) | (address <<0 ); - command->width =usb_maxpacket (urb->dev, urb->pipe, -usb_pipeout (urb->pipe)); + command->width =usb_maxpacket (urb->dev, urb->pipe); command->follows =0 ; command->value =0 ; command->buffer =NULL ;
drivers/usb/misc/lvstest.c +1 -1
@@ -437,7 +437,7 @@ static int lvs_rh_probe(struct usb_interface *intf,INIT_WORK (&lvs->rh_work, lvs_rh_work); pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (hdev, pipe);usb_fill_int_urb (lvs->urb, hdev, pipe, &lvs->buffer[0 ], maxp, lvs_rh_irq, lvs, endpoint->bInterval);
drivers/usb/storage/onetouch.c +1 -1
@@ -180,7 +180,7 @@ static int onetouch_connect_input(struct us_data *ss)return -ENODEV ; pipe =usb_rcvintpipe (udev, endpoint->bEndpointAddress); - maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (udev, pipe); maxp =min (maxp,ONETOUCH_PKT_LEN ); onetouch =kzalloc (sizeof (struct usb_onetouch ),GFP_KERNEL );
drivers/usb/storage/transport.c +1 -1
@@ -363,7 +363,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf,usb_stor_dbg (us,"xfer %u bytes\n" , length);/* calculate the max packet size */ - maxp =usb_maxpacket (us->pusb_dev, pipe,usb_pipeout (pipe)); + maxp =usb_maxpacket (us->pusb_dev, pipe);if (maxp > length) maxp = length;
Signature · 1 line
2.34.1
PATCH v4 7/9 sound: usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholThe third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
--- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/line6/pcm.c +2 -2
@@ -552,10 +552,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1285,7 +1285,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1374,7 +1374,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -421,7 +421,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.34.1
Re: [PATCH v4 7/9] sound: usb: remove third argument of usb_maxpacket()
Quoted 11 lines · Vincent Mailhol
The third argument of
usb_maxpacket():in_outhas been deprecated because it could be derived from the second argument (e.g. usingusb_pipeout(pipe)).N.B. function
usb_maxpacket()was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users ofusb_maxpacket()get migrated.
Quoted 4 lines
CC Jaroslav Kysela <[email protected]>CC Takashi Iwai <[email protected]>CC Clemens Ladisch <[email protected]>Signed-off-by Vincent Mailhol <[email protected]>
thanks,
Takashi
PATCH v4 8/9 usb: remove third argument of usb_maxpacket()
In reply to Vincent MailholNow that all users of usb_maxpacket() have been migrated to only use two arguments, remove the third variadic argument which was introduced for the transition.
--- include/linux/usb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/usb.h +1 -2
@@ -1969,8 +1969,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)return eps[usb_pipeendpoint (pipe)]; } -static inline u16 usb_maxpacket (struct usb_device *udev,int pipe, -/* int is_out deprecated */ ...) +static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) {struct usb_host_endpoint *ep;unsigned epnum =usb_pipeendpoint (pipe);
Signature · 1 line
2.34.1
PATCH v4 9/9 usb: rework usb_maxpacket() using usb_pipe_endpoint()
In reply to Vincent MailholRework the body of usb_maxpacket() and just rely on the usb_pipe_endpoint() helper function to retrieve the host endpoint instead of doing it by hand.
--- include/linux/usb.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
include/linux/usb.h +1 -7
@@ -1971,13 +1971,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)static inline u16 usb_maxpacket (struct usb_device *udev,int pipe) { -struct usb_host_endpoint *ep; -unsigned epnum =usb_pipeendpoint (pipe); - -if (usb_pipeout (pipe)) - ep = udev->ep_out[epnum]; -else - ep = udev->ep_in[epnum]; +struct usb_host_endpoint *ep =usb_pipe_endpoint (udev, pipe);if (!ep)return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerQuoted 31 lines · Vincent Mailhol
This series rework
usb_maxpacket()to change its prototype from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *udev, int pipe)and rewrite the function using
usb_pipe_endpoint().Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipeout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.*
usb_pipe_endpoint()(defined a couple of lines before) does most of the work. Use it instead of reimplementing the same thing again.In order to do so,
usb_maxpacket()is temporarily changed into a variadic function to ignore its third argument.The series goes as follow:
* Patch 1: make
usb_maxpacket()variadic to accommodate during the migration
Quoted 7 lines
* Patch 2 to 7: migrate all the users of
usb_maxpacket()(one patch per tree)* Patch 8: remove the third argument of
usb_maxpacket()now that everyone is migrated* Patch 9: rework usb_maxpacket()'s body using
usb_pipe_endpoint()
Now queued up, thanks for sticking with this!
Can you send the follow-up patch that removes the vararg? I'll keep that in my tree to try to catch any remaining things that come in and get it merged when it's ok to.
thanks,
greg k-h
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Vincent Mailhol
This series rework
usb_maxpacket()to change its prototype from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *udev, int pipe)and rewrite the function using
usb_pipe_endpoint().Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipeout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.*
usb_pipe_endpoint()(defined a couple of lines before) does most of the work. Use it instead of reimplementing the same thing again.In order to do so,
usb_maxpacket()is temporarily changed into a variadic function to ignore its third argument.The series goes as follow:
* Patch 1: make
usb_maxpacket()variadic to accommodate during the migration* Patch 2 to 7: migrate all the users of
usb_maxpacket()(one patch per tree)
Quoted 6 lines
Quoted 4 lines
* Patch 8: remove the third argument of
usb_maxpacket()now that everyone is migrated* Patch 9: rework usb_maxpacket()'s body using
usb_pipe_endpoint()Now queued up, thanks for sticking with this!
Thanks to you for your patience and explanations!
Quoted 3 lines
Can you send the follow-up patch that removes the vararg? I'll keep that in my tree to try to catch any remaining things that come in and get it merged when it's ok to.
It is this patch:
https://lore.kernel.org/linux-usb/[email protected]/
Or do you prefer me to resend it on the mailing list?
Yours sincerely,
Vincent Mailhol
Quoted 46 lines · Vincent MAILHOL
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Vincent Mailhol
This series rework
usb_maxpacket()to change its prototype from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *udev, int pipe)and rewrite the function using
usb_pipe_endpoint().Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipeout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.*
usb_pipe_endpoint()(defined a couple of lines before) does most of the work. Use it instead of reimplementing the same thing again.In order to do so,
usb_maxpacket()is temporarily changed into a variadic function to ignore its third argument.The series goes as follow:
* Patch 1: make
usb_maxpacket()variadic to accommodate during the migration* Patch 2 to 7: migrate all the users of
usb_maxpacket()(one patch per tree)Quoted 6 lines
Quoted 4 lines
* Patch 8: remove the third argument of
usb_maxpacket()now that everyone is migrated* Patch 9: rework usb_maxpacket()'s body using
usb_pipe_endpoint()Now queued up, thanks for sticking with this!
Thanks to you for your patience and explanations!
Quoted 8 lines
Quoted 3 lines
Can you send the follow-up patch that removes the vararg? I'll keep that in my tree to try to catch any remaining things that come in and get it merged when it's ok to.
It is this patch:
https://lore.kernel.org/linux-usb/[email protected]/Or do you prefer me to resend it on the mailing list?
Actually, you already added it to your tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=386311fd6ef976eb1e3febd836b4ce2425f0ef37
I am not sure I understand what you want me to do here. Sorry.
Greg Kroah-Hartman
maintainerQuoted 55 lines · Vincent MAILHOL
Quoted 53 lines · Vincent MAILHOL
Quoted 35 lines · Greg Kroah-Hartman
Quoted 34 lines · Vincent Mailhol
This series rework
usb_maxpacket()to change its prototype from:
| static inline__u16
|usb_maxpacket(struct usb_device *udev, int pipe, int is_out)into:
| static inline u16usb_maxpacket(struct usb_device *udev, int pipe)and rewrite the function using
usb_pipe_endpoint().Rationale:
* The third argument of
usb_maxpacket():is_outcan be derived from its second one: pipe usingusb_pipeout(pipe). Furthermore,usb_pipeout(pipe)is being called withinusb_maxpacket()regardless to confirm the input.* This function is not exposed to the UAPI so return type should be
u16, not __u16.*
usb_pipe_endpoint()(defined a couple of lines before) does most of the work. Use it instead of reimplementing the same thing again.In order to do so,
usb_maxpacket()is temporarily changed into a variadic function to ignore its third argument.The series goes as follow:
* Patch 1: make
usb_maxpacket()variadic to accommodate during the migration* Patch 2 to 7: migrate all the users of
usb_maxpacket()(one patch per tree)Quoted 6 lines
Quoted 4 lines
* Patch 8: remove the third argument of
usb_maxpacket()now that everyone is migrated* Patch 9: rework usb_maxpacket()'s body using
usb_pipe_endpoint()Now queued up, thanks for sticking with this!
Thanks to you for your patience and explanations!
Quoted 3 lines
Can you send the follow-up patch that removes the vararg? I'll keep that in my tree to try to catch any remaining things that come in and get it merged when it's ok to.
It is this patch:
https://lore.kernel.org/linux-usb/[email protected]/
Quoted 6 lines
Quoted 1 line
Or do you prefer me to resend it on the mailing list?
Actually, you already added it to your tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=386311fd6ef976eb1e3febd836b4ce2425f0ef37I am not sure I understand what you want me to do here. Sorry.
Ah, sorry, you are right, I was expecting it to be the last patch in the series, not second-to-last. All is good!