这篇教程C++ usb_pipecontrol函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_pipecontrol函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_pipecontrol函数的具体用法?C++ usb_pipecontrol怎么用?C++ usb_pipecontrol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_pipecontrol函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: interpret_urb_result/* * Interpret the results of a URB transfer * * This function prints appropriate debugging messages, clears halts on * non-control endpoints, and translates the status to the corresponding * USB_STOR_XFER_xxx return code. */static int interpret_urb_result(struct us_data *us, unsigned int pipe, unsigned int length, int result, unsigned int partial){ US_DEBUGP("Status code %d; transferred %u/%u/n", result, partial, length); switch (result) { /* no error code; did we send all the data? */ case 0: if (partial != length) { US_DEBUGP("-- short transfer/n"); return USB_STOR_XFER_SHORT; } US_DEBUGP("-- transfer complete/n"); return USB_STOR_XFER_GOOD; /* stalled */ case -EPIPE: /* for control endpoints, (used by CB[I]) a stall indicates * a failed command */ if (usb_pipecontrol(pipe)) { US_DEBUGP("-- stall on control pipe/n"); return USB_STOR_XFER_STALLED; } /* for other sorts of endpoint, clear the stall */ US_DEBUGP("clearing endpoint halt for pipe 0x%x/n", pipe); if (usb_stor_clear_halt(us, pipe) < 0) return USB_STOR_XFER_ERROR; return USB_STOR_XFER_STALLED; /* babble - the device tried to send more than we wanted to read */ case -EOVERFLOW: US_DEBUGP("-- babble/n"); return USB_STOR_XFER_LONG; /* the transfer was cancelled by abort, disconnect, or timeout */ case -ECONNRESET: US_DEBUGP("-- transfer cancelled/n"); return USB_STOR_XFER_ERROR; /* short scatter-gather read transfer */ case -EREMOTEIO: US_DEBUGP("-- short read transfer/n"); return USB_STOR_XFER_SHORT; /* abort or disconnect in progress */ case -EIO: US_DEBUGP("-- abort or disconnect in progress/n"); return USB_STOR_XFER_ERROR; /* the catch-all error case */ default: US_DEBUGP("-- unknown error/n"); return USB_STOR_XFER_ERROR; }}
开发者ID:vovan888,项目名称:p750-kernel,代码行数:65,
示例2: usb_submit_urb//.........这里部分代码省略......... * some URB is always on the endpoint's queue (except possibly for short * periods during completion callacks). When there is no longer an urb * queued, the endpoint's bandwidth reservation is canceled. This means * drivers can use their completion handlers to ensure they keep bandwidth * they need, by reinitializing and resubmitting the just-completed urb * until the driver longer needs that periodic bandwidth. * * Memory Flags: * * The general rules for how to decide which mem_flags to use * are the same as for kmalloc. There are four * different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and * GFP_ATOMIC. * * GFP_NOFS is not ever used, as it has not been implemented yet. * * GFP_ATOMIC is used when * (a) you are inside a completion handler, an interrupt, bottom half, * tasklet or timer, or * (b) you are holding a spinlock or rwlock (does not apply to * semaphores), or * (c) current->state != TASK_RUNNING, this is the case only after * you've changed it. * * GFP_NOIO is used in the block io path and error handling of storage * devices. * * All other situations use GFP_KERNEL. * * Some more specific rules for mem_flags can be inferred, such as * (1) start_xmit, timeout, and receive methods of network drivers must * use GFP_ATOMIC (they are called with a spinlock held); * (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also * called with a spinlock held); * (3) If you use a kernel thread with a network driver you must use * GFP_NOIO, unless (b) or (c) apply; * (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c) * apply or your are in a storage driver's block io path; * (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and * (6) changing firmware on a running storage or net device uses * GFP_NOIO, unless b) or c) apply * */int usb_submit_urb(struct urb *urb, gfp_t mem_flags){ int pipe, temp, max; struct usb_device *dev; int is_out; if (!urb || urb->hcpriv || !urb->complete) return -EINVAL; if (!(dev = urb->dev) || (dev->state < USB_STATE_DEFAULT) || (!dev->bus) || (dev->devnum <= 0)) return -ENODEV; if (dev->bus->controller->power.power_state.event != PM_EVENT_ON || dev->state == USB_STATE_SUSPENDED) return -EHOSTUNREACH; urb->status = -EINPROGRESS; urb->actual_length = 0; /* Lots of sanity checks, so HCDs can rely on clean data * and don't need to duplicate tests */ pipe = urb->pipe; temp = usb_pipetype(pipe); is_out = usb_pipeout(pipe); if (!usb_pipecontrol(pipe) && dev->state < USB_STATE_CONFIGURED) return -ENODEV; /* FIXME there should be a sharable lock protecting us against * config/altsetting changes and disconnects, kicking in here. * (here == before maxpacket, and eventually endpoint type, * checks get made.) */ max = usb_maxpacket(dev, pipe, is_out); if (max <= 0) { dev_dbg(&dev->dev, "bogus endpoint ep%d%s in %s (bad maxpacket %d)/n", usb_pipeendpoint(pipe), is_out ? "out" : "in", __FUNCTION__, max); return -EMSGSIZE; } /* periodic transfers limit size per frame/uframe, * but drivers only control those sizes for ISO. * while we're checking, initialize return status. */ if (temp == PIPE_ISOCHRONOUS) { int n, len; /* "high bandwidth" mode, 1-3 packets/uframe? */ if (dev->speed == USB_SPEED_HIGH) { int mult = 1 + ((max >> 11) & 0x03); max &= 0x07ff; max *= mult; }
开发者ID:cilynx,项目名称:dd-wrt,代码行数:101,
示例3: timeout_killstatic void timeout_kill(unsigned long data){ struct urb *urb = (struct urb *) data; dev_warn(&urb->dev->dev, "%s timeout on ep%d%s/n", usb_pipecontrol(urb->pipe) ? "control" : "bulk", usb_pipeendpoint(urb->pipe), usb_pipein(urb->pipe) ? "in" : "out"); usb_unlink_urb(urb);}
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:10,
示例4: mon_text_get_setupstatic inline char mon_text_get_setup(struct mon_event_text *ep, struct urb *urb, char ev_type){ if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') return '-'; if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP) return mon_dmapeek(ep->setup, urb->setup_dma, SETUP_MAX); if (urb->setup_packet == NULL) return 'Z'; /* '0' would be not as pretty. */ memcpy(ep->setup, urb->setup_packet, SETUP_MAX); return 0;}
开发者ID:ena30,项目名称:snake-os,代码行数:15,
示例5: usb_buffer_map_sg/**ltl功能:把要传输usb设备的数据进行dma映射。参数:返回值:聚散列表元素个数说明:这个接口给usb_storage驱动使用*/int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int nents){ struct usb_bus *bus; struct device *controller; if (!dev || usb_pipecontrol (pipe) || !(bus = dev->bus) || !(controller = bus->controller) || !controller->dma_mask) return -1; // FIXME generic api broken like pci, can't report errors return dma_map_sg (controller, sg, nents, usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);}
开发者ID:laitianli,项目名称:kernel-analyze_linux-2.6.18,代码行数:23,
示例6: mon_text_get_datastatic inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, int len, char ev_type){ int pipe = urb->pipe; if (len <= 0) return 'L'; if (len >= DATA_MAX) len = DATA_MAX; /* * Bulk is easy to shortcut reliably. * XXX Other pipe types need consideration. Currently, we overdo it * and collect garbage for them: better more than less. */ if (usb_pipebulk(pipe) || usb_pipecontrol(pipe)) { if (usb_pipein(pipe)) { if (ev_type == 'S') return '<'; } else { if (ev_type == 'C') return '>'; } } /* * The check to see if it's safe to poke at data has an enormous * number of corner cases, but it seems that the following is * more or less safe. * * We do not even try to look transfer_buffer, because it can * contain non-NULL garbage in case the upper level promised to * set DMA for the HCD. */ if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) return mon_dmapeek(ep->data, urb->transfer_dma, len); if (urb->transfer_buffer == NULL) return 'Z'; /* '0' would be not as pretty. */ memcpy(ep->data, urb->transfer_buffer, len); return 0;}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:43,
示例7: usbhsh_endpoint_sequence_save/* * pipe control */static void usbhsh_endpoint_sequence_save(struct usbhsh_hpriv *hpriv, struct urb *urb, struct usbhs_pkt *pkt){ int len = urb->actual_length; int maxp = usb_endpoint_maxp(&urb->ep->desc); int t = 0; /* DCP is out of sequence control */ if (usb_pipecontrol(urb->pipe)) return; /* * renesas_usbhs pipe has a limitation in a number. * So, driver should re-use the limited pipe for each device/endpoint. * DATA0/1 sequence should be saved for it. * see [image of mod_host] * [HARDWARE LIMITATION] */ /* * next sequence depends on actual_length * * ex) actual_length = 1147, maxp = 512 * data0 : 512 * data1 : 512 * data0 : 123 * data1 is the next sequence */ t = len / maxp; if (len % maxp) t++; if (pkt->zero) t++; t %= 2; if (t) usb_dotoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe));}
开发者ID:513855417,项目名称:linux,代码行数:44,
示例8: interpret_urb_result//----- interpret_urb_result() ---------------------static int interpret_urb_result(struct us_data *us, unsigned int pipe, unsigned int length, int result, unsigned int partial){ //printk("transport --- interpret_urb_result/n"); switch (result) { /* no error code; did we send all the data? */ case 0: if (partial != length) { //printk("-- short transfer/n"); return USB_STOR_XFER_SHORT; } //printk("-- transfer complete/n"); return USB_STOR_XFER_GOOD; case -EPIPE: if (usb_pipecontrol(pipe)) { //printk("-- stall on control pipe/n"); return USB_STOR_XFER_STALLED; } //printk("clearing endpoint halt for pipe 0x%x/n", pipe); if (usb_stor_clear_halt(us, pipe) < 0) return USB_STOR_XFER_ERROR; return USB_STOR_XFER_STALLED; case -EOVERFLOW: //printk("-- babble/n"); return USB_STOR_XFER_LONG; case -ECONNRESET: //printk("-- transfer cancelled/n"); return USB_STOR_XFER_ERROR; case -EREMOTEIO: //printk("-- short read transfer/n"); return USB_STOR_XFER_SHORT; case -EIO: //printk("-- abort or disconnect in progress/n"); return USB_STOR_XFER_ERROR; default: //printk("-- unknown error/n"); return USB_STOR_XFER_ERROR; }}
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:42,
示例9: dwc_otg_hcd_qtd_init/** * Initializes a QTD structure. * * @param[in] qtd The QTD to initialize. * @param[in] urb The URB to use for initialization. */void dwc_otg_hcd_qtd_init (dwc_otg_qtd_t *qtd, struct urb *urb){ memset (qtd, 0, sizeof (dwc_otg_qtd_t)); qtd->urb = urb; if (usb_pipecontrol(urb->pipe)) { /* * The only time the QTD data toggle is used is on the data * phase of control transfers. This phase always starts with * DATA1. */ qtd->data_toggle = DWC_OTG_HC_PID_DATA1; qtd->control_phase = DWC_OTG_CONTROL_SETUP; } /* start split */ qtd->complete_split = 0; qtd->isoc_split_pos = DWC_HCSPLIT_XACTPOS_ALL; qtd->isoc_split_offset = 0; /* Store the qtd ptr in the urb to reference what QTD. */ urb->hcpriv = qtd; return;}
开发者ID:4pao,项目名称:openwrt,代码行数:28,
示例10: usb_buffer_dmasync/** * usb_buffer_dmasync - synchronize DMA and CPU view of buffer(s) * @urb: urb whose transfer_buffer/setup_packet will be synchronized */void usb_buffer_dmasync(struct urb *urb){ struct usb_bus *bus; struct device *controller; if (!urb || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) || !(controller = bus->controller)) return; if (controller->dma_mask) { dma_sync_single(controller, urb->transfer_dma, urb->transfer_buffer_length, usb_pipein(urb->pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); if (usb_pipecontrol(urb->pipe)) dma_sync_single(controller, urb->setup_dma, sizeof(struct usb_ctrlrequest), DMA_TO_DEVICE); }}
开发者ID:vovan888,项目名称:p750-kernel,代码行数:28,
示例11: usb_sg_init/** * usb_sg_init - initializes scatterlist-based bulk/interrupt I/O request * @io: request block being initialized. until usb_sg_wait() returns, * treat this as a pointer to an opaque block of memory, * @dev: the usb device that will send or receive the data * @pipe: endpoint "pipe" used to transfer the data * @period: polling rate for interrupt endpoints, in frames or * (for high speed endpoints) microframes; ignored for bulk * @sg: scatterlist entries * @nents: how many entries in the scatterlist * @length: how many bytes to send from the scatterlist, or zero to * send every byte identified in the list. * @mem_flags: SLAB_* flags affecting memory allocations in this call * * Returns zero for success, else a negative errno value. This initializes a * scatter/gather request, allocating resources such as I/O mappings and urb * memory (except maybe memory used by USB controller drivers). * * The request must be issued using usb_sg_wait(), which waits for the I/O to * complete (or to be canceled) and then cleans up all resources allocated by * usb_sg_init(). * * The request may be canceled with usb_sg_cancel(), either before or after * usb_sg_wait() is called. */int usb_sg_init ( struct usb_sg_request *io, struct usb_device *dev, unsigned pipe, unsigned period, struct scatterlist *sg, int nents, size_t length, int mem_flags){ int i; int urb_flags; int dma; if (!io || !dev || !sg || usb_pipecontrol (pipe) || usb_pipeisoc (pipe) || nents <= 0) return -EINVAL; spin_lock_init (&io->lock); io->dev = dev; io->pipe = pipe; io->sg = sg; io->nents = nents; /* not all host controllers use DMA (like the mainstream pci ones); * they can use PIO (sl811) or be software over another transport. */ dma = (dev->dev.dma_mask != 0); if (dma) io->entries = usb_buffer_map_sg (dev, pipe, sg, nents); else io->entries = nents; /* initialize all the urbs we'll use */ if (io->entries <= 0) return io->entries; io->count = 0; io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); if (!io->urbs) goto nomem; urb_flags = URB_ASYNC_UNLINK | URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; if (usb_pipein (pipe)) urb_flags |= URB_SHORT_NOT_OK; for (i = 0; i < io->entries; i++, io->count = i) { unsigned len; io->urbs [i] = usb_alloc_urb (0, mem_flags); if (!io->urbs [i]) { io->entries = i; goto nomem; } io->urbs [i]->dev = NULL; io->urbs [i]->pipe = pipe; io->urbs [i]->interval = period; io->urbs [i]->transfer_flags = urb_flags; io->urbs [i]->complete = sg_complete; io->urbs [i]->context = io; io->urbs [i]->status = -EINPROGRESS; io->urbs [i]->actual_length = 0; if (dma) { /* hc may use _only_ transfer_dma */ io->urbs [i]->transfer_dma = sg_dma_address (sg + i); len = sg_dma_len (sg + i); } else { /* hc may use _only_ transfer_buffer *///.........这里部分代码省略.........
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:101,
示例12: usb_submit_urb//.........这里部分代码省略......... * are the same as for kmalloc. There are four * different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and * GFP_ATOMIC. * * GFP_NOFS is not ever used, as it has not been implemented yet. * * GFP_ATOMIC is used when * (a) you are inside a completion handler, an interrupt, bottom half, * tasklet or timer, or * (b) you are holding a spinlock or rwlock (does not apply to * semaphores), or * (c) current->state != TASK_RUNNING, this is the case only after * you've changed it. * * GFP_NOIO is used in the block io path and error handling of storage * devices. * * All other situations use GFP_KERNEL. * * Some more specific rules for mem_flags can be inferred, such as * (1) start_xmit, timeout, and receive methods of network drivers must * use GFP_ATOMIC (they are called with a spinlock held); * (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also * called with a spinlock held); * (3) If you use a kernel thread with a network driver you must use * GFP_NOIO, unless (b) or (c) apply; * (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c) * apply or your are in a storage driver's block io path; * (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and * (6) changing firmware on a running storage or net device uses * GFP_NOIO, unless b) or c) apply * */int usb_submit_urb(struct urb *urb, int mem_flags){ int pipe, temp, max; struct usb_device *dev; struct usb_operations *op; int is_out;// printk("sub dev %p bus %p num %i op %p sub %p/n",// urb->dev, urb->dev->bus,urb->dev->devnum,urb->dev->bus->op, urb->dev->bus->op->submit_urb); if (!urb || urb->hcpriv || !urb->complete) return -EINVAL; if (!(dev = urb->dev) || (dev->state < USB_STATE_DEFAULT) || (!dev->bus) || (dev->devnum <= 0)) return -ENODEV; if (!(op = dev->bus->op) || !op->submit_urb) return -ENODEV; urb->status = -EINPROGRESS; urb->actual_length = 0; urb->bandwidth = 0; /* Lots of sanity checks, so HCDs can rely on clean data * and don't need to duplicate tests */ pipe = urb->pipe; temp = usb_pipetype (pipe); is_out = usb_pipeout (pipe); if (!usb_pipecontrol (pipe) && dev->state < USB_STATE_CONFIGURED) return -ENODEV; /* (actually HCDs may need to duplicate this, endpoint might yet * stall due to queued bulk/intr transactions that complete after * we check) */ if (usb_endpoint_halted (dev, usb_pipeendpoint (pipe), is_out)) return -EPIPE; /* FIXME there should be a sharable lock protecting us against * config/altsetting changes and disconnects, kicking in here. * (here == before maxpacket, and eventually endpoint type, * checks get made.) */ max = usb_maxpacket (dev, pipe, is_out); if (max <= 0) { dbg ("%s: bogus endpoint %d-%s on usb-%s-%s (bad maxpacket %d)", __FUNCTION__, usb_pipeendpoint (pipe), is_out ? "OUT" : "IN", dev->bus->bus_name, dev->devpath, max); return -EMSGSIZE; } /* periodic transfers limit size per frame/uframe, * but drivers only control those sizes for ISO. * while we're checking, initialize return status. */ if (temp == PIPE_ISOCHRONOUS) { int n, len; /* "high bandwidth" mode, 1-3 packets/uframe? */ if (dev->speed == USB_SPEED_HIGH) { int mult = 1 + ((max >> 11) & 0x03); max &= 0x03ff; max *= mult; }
开发者ID:Halofreak1990,项目名称:OpenXDK,代码行数:101,
示例13: qu_pipeindexstatic inline int qu_pipeindex (__u32 pipe) { return (usb_pipeendpoint (pipe) << 1) | (usb_pipecontrol (pipe) ? 0 : usb_pipeout (pipe));}
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:5,
示例14: prepare_ptd/* Set up PTD's.*/static void prepare_ptd(struct isp1362_hcd *isp1362_hcd, struct urb *urb, struct isp1362_ep *ep, struct isp1362_ep_queue *epq, u16 fno){ struct ptd *ptd; int toggle; int dir; u16 len; size_t buf_len = urb->transfer_buffer_length - urb->actual_length; DBG(3, "%s: %s ep %p/n", __func__, epq->name, ep); ptd = &ep->ptd; ep->data = (unsigned char *)urb->transfer_buffer + urb->actual_length; switch (ep->nextpid) { case USB_PID_IN: toggle = usb_gettoggle(urb->dev, ep->epnum, 0); dir = PTD_DIR_IN; if (usb_pipecontrol(urb->pipe)) { len = min_t(size_t, ep->maxpacket, buf_len); } else if (usb_pipeisoc(urb->pipe)) { len = min_t(size_t, urb->iso_frame_desc[fno].length, MAX_XFER_SIZE); ep->data = urb->transfer_buffer + urb->iso_frame_desc[fno].offset; } else len = max_transfer_size(epq, buf_len, ep->maxpacket); DBG(1, "%s: IN len %d/%d/%d from URB/n", __func__, len, ep->maxpacket, (int)buf_len); break; case USB_PID_OUT: toggle = usb_gettoggle(urb->dev, ep->epnum, 1); dir = PTD_DIR_OUT; if (usb_pipecontrol(urb->pipe)) len = min_t(size_t, ep->maxpacket, buf_len); else if (usb_pipeisoc(urb->pipe)) len = min_t(size_t, urb->iso_frame_desc[0].length, MAX_XFER_SIZE); else len = max_transfer_size(epq, buf_len, ep->maxpacket); if (len == 0) pr_info("%s: Sending ZERO packet: %d/n", __func__, urb->transfer_flags & URB_ZERO_PACKET); DBG(1, "%s: OUT len %d/%d/%d from URB/n", __func__, len, ep->maxpacket, (int)buf_len); break; case USB_PID_SETUP: toggle = 0; dir = PTD_DIR_SETUP; len = sizeof(struct usb_ctrlrequest); DBG(1, "%s: SETUP len %d/n", __func__, len); ep->data = urb->setup_packet; break; case USB_PID_ACK: toggle = 1; len = 0; dir = (urb->transfer_buffer_length && usb_pipein(urb->pipe)) ? PTD_DIR_OUT : PTD_DIR_IN; DBG(1, "%s: ACK len %d/n", __func__, len); break; default: toggle = dir = len = 0; pr_err("%[email C++ usb_pipeendpoint函数代码示例 C++ usb_phy_shutdown函数代码示例
|