Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/staging/usbip/vhci_tx.c (Version 2.6.31.13) and /linux/drivers/staging/usbip/vhci_tx.c (Version 2.6.25.8)


  1 /*                                                  1 
  2  * Copyright (C) 2003-2008 Takahiro Hirofuchi     
  3  *                                                
  4  * This is free software; you can redistribute    
  5  * it under the terms of the GNU General Publi    
  6  * the Free Software Foundation; either versio    
  7  * (at your option) any later version.            
  8  *                                                
  9  * This is distributed in the hope that it wil    
 10  * but WITHOUT ANY WARRANTY; without even the     
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR    
 12  * GNU General Public License for more details    
 13  *                                                
 14  * You should have received a copy of the GNU     
 15  * along with this program; if not, write to t    
 16  * Foundation, Inc., 59 Temple Place - Suite 3    
 17  * USA.                                           
 18  */                                               
 19                                                   
 20 #include "usbip_common.h"                         
 21 #include "vhci.h"                                 
 22                                                   
 23                                                   
 24 static void setup_cmd_submit_pdu(struct usbip_    
 25 {                                                 
 26         struct vhci_priv *priv = ((struct vhci    
 27         struct vhci_device *vdev = priv->vdev;    
 28                                                   
 29         dbg_vhci_tx("URB, local devnum %u, rem    
 30                                 usb_pipedevice    
 31                                                   
 32         pdup->base.command = USBIP_CMD_SUBMIT;    
 33         pdup->base.seqnum  = priv->seqnum;        
 34         pdup->base.devid   = vdev->devid;         
 35         if (usb_pipein(urb->pipe))                
 36                 pdup->base.direction = USBIP_D    
 37         else                                      
 38                 pdup->base.direction = USBIP_D    
 39         pdup->base.ep      = usb_pipeendpoint(    
 40                                                   
 41         usbip_pack_pdu(pdup, urb, USBIP_CMD_SU    
 42                                                   
 43         if (urb->setup_packet)                    
 44                 memcpy(pdup->u.cmd_submit.setu    
 45 }                                                 
 46                                                   
 47 static struct vhci_priv *dequeue_from_priv_tx(    
 48 {                                                 
 49         unsigned long flags;                      
 50         struct vhci_priv *priv, *tmp;             
 51                                                   
 52         spin_lock_irqsave(&vdev->priv_lock, fl    
 53                                                   
 54         list_for_each_entry_safe(priv, tmp, &v    
 55                 list_move_tail(&priv->list, &v    
 56                 spin_unlock_irqrestore(&vdev->    
 57                 return priv;                      
 58         }                                         
 59                                                   
 60         spin_unlock_irqrestore(&vdev->priv_loc    
 61                                                   
 62         return NULL;                              
 63 }                                                 
 64                                                   
 65                                                   
 66                                                   
 67 static int vhci_send_cmd_submit(struct vhci_de    
 68 {                                                 
 69         struct vhci_priv *priv = NULL;            
 70                                                   
 71         struct msghdr msg;                        
 72         struct kvec iov[3];                       
 73         size_t txsize;                            
 74                                                   
 75         size_t total_size = 0;                    
 76                                                   
 77         while ((priv = dequeue_from_priv_tx(vd    
 78                 int ret;                          
 79                 struct urb *urb = priv->urb;      
 80                 struct usbip_header pdu_header    
 81                 void *iso_buffer = NULL;          
 82                                                   
 83                 txsize = 0;                       
 84                 memset(&pdu_header, 0, sizeof(    
 85                 memset(&msg, 0, sizeof(msg));     
 86                 memset(&iov, 0, sizeof(iov));     
 87                                                   
 88                 dbg_vhci_tx("setup txdata urb     
 89                                                   
 90                                                   
 91                 /* 1. setup usbip_header */       
 92                 setup_cmd_submit_pdu(&pdu_head    
 93                 usbip_header_correct_endian(&p    
 94                                                   
 95                 iov[0].iov_base = &pdu_header;    
 96                 iov[0].iov_len  = sizeof(pdu_h    
 97                 txsize += sizeof(pdu_header);     
 98                                                   
 99                 /* 2. setup transfer buffer */    
100                 if (!usb_pipein(urb->pipe) &&     
101                         iov[1].iov_base = urb-    
102                         iov[1].iov_len  = urb-    
103                         txsize += urb->transfe    
104                 }                                 
105                                                   
106                 /* 3. setup iso_packet_descrip    
107                 if (usb_pipetype(urb->pipe) ==    
108                         ssize_t len = 0;          
109                                                   
110                         iso_buffer = usbip_all    
111                         if (!iso_buffer) {        
112                                 usbip_event_ad    
113                                                   
114                                 return -1;        
115                         }                         
116                                                   
117                         iov[2].iov_base = iso_    
118                         iov[2].iov_len  = len;    
119                         txsize += len;            
120                 }                                 
121                                                   
122                 ret = kernel_sendmsg(vdev->ud.    
123                 if (ret != txsize) {              
124                         uerr("sendmsg failed!,    
125                                                   
126                         kfree(iso_buffer);        
127                         usbip_event_add(&vdev-    
128                         return -1;                
129                 }                                 
130                                                   
131                 kfree(iso_buffer);                
132                 dbg_vhci_tx("send txdata\n");     
133                                                   
134                 total_size += txsize;             
135         }                                         
136                                                   
137         return total_size;                        
138 }                                                 
139                                                   
140                                                   
141 /*--------------------------------------------    
142                                                   
143 static struct vhci_unlink *dequeue_from_unlink    
144 {                                                 
145         unsigned long flags;                      
146         struct vhci_unlink *unlink, *tmp;         
147                                                   
148         spin_lock_irqsave(&vdev->priv_lock, fl    
149                                                   
150         list_for_each_entry_safe(unlink, tmp,     
151                 list_move_tail(&unlink->list,     
152                 spin_unlock_irqrestore(&vdev->    
153                 return unlink;                    
154         }                                         
155                                                   
156         spin_unlock_irqrestore(&vdev->priv_loc    
157                                                   
158         return NULL;                              
159 }                                                 
160                                                   
161 static int vhci_send_cmd_unlink(struct vhci_de    
162 {                                                 
163         struct vhci_unlink *unlink = NULL;        
164                                                   
165         struct msghdr msg;                        
166         struct kvec iov[3];                       
167         size_t txsize;                            
168                                                   
169         size_t total_size = 0;                    
170                                                   
171         while ((unlink = dequeue_from_unlink_t    
172                 int ret;                          
173                 struct usbip_header pdu_header    
174                                                   
175                 txsize = 0;                       
176                 memset(&pdu_header, 0, sizeof(    
177                 memset(&msg, 0, sizeof(msg));     
178                 memset(&iov, 0, sizeof(iov));     
179                                                   
180                 dbg_vhci_tx("setup cmd unlink,    
181                                                   
182                                                   
183                 /* 1. setup usbip_header */       
184                 pdu_header.base.command = USBI    
185                 pdu_header.base.seqnum  = unli    
186                 pdu_header.base.devid   = vdev    
187                 pdu_header.base.ep      = 0;      
188                 pdu_header.u.cmd_unlink.seqnum    
189                                                   
190                 usbip_header_correct_endian(&p    
191                                                   
192                 iov[0].iov_base = &pdu_header;    
193                 iov[0].iov_len  = sizeof(pdu_h    
194                 txsize += sizeof(pdu_header);     
195                                                   
196                 ret = kernel_sendmsg(vdev->ud.    
197                 if (ret != txsize) {              
198                         uerr("sendmsg failed!,    
199                                                   
200                         usbip_event_add(&vdev-    
201                         return -1;                
202                 }                                 
203                                                   
204                                                   
205                 dbg_vhci_tx("send txdata\n");     
206                                                   
207                 total_size += txsize;             
208         }                                         
209                                                   
210         return total_size;                        
211 }                                                 
212                                                   
213                                                   
214 /*--------------------------------------------    
215                                                   
216 void vhci_tx_loop(struct usbip_task *ut)          
217 {                                                 
218         struct usbip_device *ud = container_of    
219         struct vhci_device *vdev = container_o    
220                                                   
221         while (1) {                               
222                 if (signal_pending(current)) {    
223                         uinfo("vhci_tx signal     
224                         break;                    
225                 }                                 
226                                                   
227                 if (vhci_send_cmd_submit(vdev)    
228                         break;                    
229                                                   
230                 if (vhci_send_cmd_unlink(vdev)    
231                         break;                    
232                                                   
233                 wait_event_interruptible(vdev-    
234                                 (!list_empty(&    
235                                  !list_empty(&    
236                                                   
237                 dbg_vhci_tx("pending urbs ?, n    
238         }                                         
239 }                                                 
240                                                   
  This page was automatically generated by the LXR engine.