aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-07-30 17:07:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:00 -0400
commit5e60a16139c2a48b9876b0ff910671eee5fb32ec (patch)
treec85abc5ea81f90cef975368dab0b7059c53f563b /drivers
parentfea3409112a93581db18da4c4332c8bf8d68af6b (diff)
USB: avoid using urb->pipe in usbcore
This patch (as946) eliminates many of the uses of urb->pipe in usbcore. Unfortunately there will have to be a significant API change, affecting all USB drivers, before we can remove it entirely. This patch contents itself with changing only the interface to usb_buffer_map_sg() and friends: The pipe argument is replaced with a direction flag. That can be done easily because those routines get used in only one place. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/hcd.c40
-rw-r--r--drivers/usb/core/message.c14
-rw-r--r--drivers/usb/core/usb.c19
3 files changed, 41 insertions, 32 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bcbaedc897d5..739c5e0aa3b8 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -635,9 +635,9 @@ static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb)
635 635
636static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb) 636static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb)
637{ 637{
638 if (usb_pipeint (urb->pipe)) 638 if (usb_endpoint_xfer_int(&urb->ep->desc))
639 return rh_queue_status (hcd, urb); 639 return rh_queue_status (hcd, urb);
640 if (usb_pipecontrol (urb->pipe)) 640 if (usb_endpoint_xfer_control(&urb->ep->desc))
641 return rh_call_control (hcd, urb); 641 return rh_call_control (hcd, urb);
642 return -EINVAL; 642 return -EINVAL;
643} 643}
@@ -651,7 +651,7 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
651{ 651{
652 unsigned long flags; 652 unsigned long flags;
653 653
654 if (usb_pipeendpoint(urb->pipe) == 0) { /* Control URB */ 654 if (usb_endpoint_num(&urb->ep->desc) == 0) { /* Control URB */
655 ; /* Do nothing */ 655 ; /* Do nothing */
656 656
657 } else { /* Status URB */ 657 } else { /* Status URB */
@@ -918,7 +918,7 @@ static void urb_unlink(struct usb_hcd *hcd, struct urb *urb)
918 spin_unlock_irqrestore(&hcd_urb_list_lock, flags); 918 spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
919 919
920 if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { 920 if (hcd->self.uses_dma && !is_root_hub(urb->dev)) {
921 if (usb_pipecontrol (urb->pipe) 921 if (usb_endpoint_xfer_control(&urb->ep->desc)
922 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 922 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
923 dma_unmap_single (hcd->self.controller, urb->setup_dma, 923 dma_unmap_single (hcd->self.controller, urb->setup_dma,
924 sizeof (struct usb_ctrlrequest), 924 sizeof (struct usb_ctrlrequest),
@@ -1001,7 +1001,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1001 * unless it uses pio or talks to another transport. 1001 * unless it uses pio or talks to another transport.
1002 */ 1002 */
1003 if (hcd->self.uses_dma) { 1003 if (hcd->self.uses_dma) {
1004 if (usb_pipecontrol (urb->pipe) 1004 if (usb_endpoint_xfer_control(&urb->ep->desc)
1005 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1005 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
1006 urb->setup_dma = dma_map_single ( 1006 urb->setup_dma = dma_map_single (
1007 hcd->self.controller, 1007 hcd->self.controller,
@@ -1201,11 +1201,13 @@ rescan:
1201 spin_lock(&hcd_urb_list_lock); 1201 spin_lock(&hcd_urb_list_lock);
1202 list_for_each_entry (urb, &ep->urb_list, urb_list) { 1202 list_for_each_entry (urb, &ep->urb_list, urb_list) {
1203 int tmp; 1203 int tmp;
1204 int is_in;
1204 1205
1205 /* the urb may already have been unlinked */ 1206 /* the urb may already have been unlinked */
1206 if (urb->status != -EINPROGRESS) 1207 if (urb->status != -EINPROGRESS)
1207 continue; 1208 continue;
1208 usb_get_urb (urb); 1209 usb_get_urb (urb);
1210 is_in = usb_urb_dir_in(urb);
1209 spin_unlock(&hcd_urb_list_lock); 1211 spin_unlock(&hcd_urb_list_lock);
1210 1212
1211 spin_lock (&urb->lock); 1213 spin_lock (&urb->lock);
@@ -1216,19 +1218,25 @@ rescan:
1216 1218
1217 /* kick hcd unless it's already returning this */ 1219 /* kick hcd unless it's already returning this */
1218 if (tmp == -EINPROGRESS) { 1220 if (tmp == -EINPROGRESS) {
1219 tmp = urb->pipe;
1220 unlink1 (hcd, urb); 1221 unlink1 (hcd, urb);
1221 dev_dbg (hcd->self.controller, 1222 dev_dbg (hcd->self.controller,
1222 "shutdown urb %p pipe %08x ep%d%s%s\n", 1223 "shutdown urb %p ep%d%s%s\n",
1223 urb, tmp, usb_pipeendpoint (tmp), 1224 urb, usb_endpoint_num(&ep->desc),
1224 (tmp & USB_DIR_IN) ? "in" : "out", 1225 is_in ? "in" : "out",
1225 ({ char *s; \ 1226 ({ char *s;
1226 switch (usb_pipetype (tmp)) { \ 1227
1227 case PIPE_CONTROL: s = ""; break; \ 1228 switch (usb_endpoint_type(&ep->desc)) {
1228 case PIPE_BULK: s = "-bulk"; break; \ 1229 case USB_ENDPOINT_XFER_CONTROL:
1229 case PIPE_INTERRUPT: s = "-intr"; break; \ 1230 s = ""; break;
1230 default: s = "-iso"; break; \ 1231 case USB_ENDPOINT_XFER_BULK:
1231 }; s;})); 1232 s = "-bulk"; break;
1233 case USB_ENDPOINT_XFER_INT:
1234 s = "-intr"; break;
1235 default:
1236 s = "-iso"; break;
1237 };
1238 s;
1239 }));
1232 } 1240 }
1233 usb_put_urb (urb); 1241 usb_put_urb (urb);
1234 1242
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 0d618647758e..a26a7292b61a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -59,8 +59,8 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
59 dev_dbg(&urb->dev->dev, 59 dev_dbg(&urb->dev->dev,
60 "%s timed out on ep%d%s len=%d/%d\n", 60 "%s timed out on ep%d%s len=%d/%d\n",
61 current->comm, 61 current->comm,
62 usb_pipeendpoint(urb->pipe), 62 usb_endpoint_num(&urb->ep->desc),
63 usb_pipein(urb->pipe) ? "in" : "out", 63 usb_urb_dir_in(urb) ? "in" : "out",
64 urb->actual_length, 64 urb->actual_length,
65 urb->transfer_buffer_length); 65 urb->transfer_buffer_length);
66 } else 66 } else
@@ -250,7 +250,8 @@ static void sg_clean (struct usb_sg_request *io)
250 io->urbs = NULL; 250 io->urbs = NULL;
251 } 251 }
252 if (io->dev->dev.dma_mask != NULL) 252 if (io->dev->dev.dma_mask != NULL)
253 usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents); 253 usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe),
254 io->sg, io->nents);
254 io->dev = NULL; 255 io->dev = NULL;
255} 256}
256 257
@@ -278,8 +279,8 @@ static void sg_complete (struct urb *urb)
278 dev_err (io->dev->bus->controller, 279 dev_err (io->dev->bus->controller,
279 "dev %s ep%d%s scatterlist error %d/%d\n", 280 "dev %s ep%d%s scatterlist error %d/%d\n",
280 io->dev->devpath, 281 io->dev->devpath,
281 usb_pipeendpoint (urb->pipe), 282 usb_endpoint_num(&urb->ep->desc),
282 usb_pipein (urb->pipe) ? "in" : "out", 283 usb_urb_dir_in(urb) ? "in" : "out",
283 status, io->status); 284 status, io->status);
284 // BUG (); 285 // BUG ();
285 } 286 }
@@ -379,7 +380,8 @@ int usb_sg_init (
379 */ 380 */
380 dma = (dev->dev.dma_mask != NULL); 381 dma = (dev->dev.dma_mask != NULL);
381 if (dma) 382 if (dma)
382 io->entries = usb_buffer_map_sg (dev, pipe, sg, nents); 383 io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe),
384 sg, nents);
383 else 385 else
384 io->entries = nents; 386 io->entries = nents;
385 387
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index d3c68d8eafb2..67e2e582e463 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -748,7 +748,7 @@ void usb_buffer_unmap(struct urb *urb)
748/** 748/**
749 * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint 749 * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
750 * @dev: device to which the scatterlist will be mapped 750 * @dev: device to which the scatterlist will be mapped
751 * @pipe: endpoint defining the mapping direction 751 * @is_in: mapping transfer direction
752 * @sg: the scatterlist to map 752 * @sg: the scatterlist to map
753 * @nents: the number of entries in the scatterlist 753 * @nents: the number of entries in the scatterlist
754 * 754 *
@@ -771,14 +771,13 @@ void usb_buffer_unmap(struct urb *urb)
771 * 771 *
772 * Reverse the effect of this call with usb_buffer_unmap_sg(). 772 * Reverse the effect of this call with usb_buffer_unmap_sg().
773 */ 773 */
774int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe, 774int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
775 struct scatterlist *sg, int nents) 775 struct scatterlist *sg, int nents)
776{ 776{
777 struct usb_bus *bus; 777 struct usb_bus *bus;
778 struct device *controller; 778 struct device *controller;
779 779
780 if (!dev 780 if (!dev
781 || usb_pipecontrol(pipe)
782 || !(bus = dev->bus) 781 || !(bus = dev->bus)
783 || !(controller = bus->controller) 782 || !(controller = bus->controller)
784 || !controller->dma_mask) 783 || !controller->dma_mask)
@@ -786,7 +785,7 @@ int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
786 785
787 // FIXME generic api broken like pci, can't report errors 786 // FIXME generic api broken like pci, can't report errors
788 return dma_map_sg(controller, sg, nents, 787 return dma_map_sg(controller, sg, nents,
789 usb_pipein(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 788 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
790} 789}
791 790
792/* XXX DISABLED, no users currently. If you wish to re-enable this 791/* XXX DISABLED, no users currently. If you wish to re-enable this
@@ -799,14 +798,14 @@ int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
799/** 798/**
800 * usb_buffer_dmasync_sg - synchronize DMA and CPU view of scatterlist buffer(s) 799 * usb_buffer_dmasync_sg - synchronize DMA and CPU view of scatterlist buffer(s)
801 * @dev: device to which the scatterlist will be mapped 800 * @dev: device to which the scatterlist will be mapped
802 * @pipe: endpoint defining the mapping direction 801 * @is_in: mapping transfer direction
803 * @sg: the scatterlist to synchronize 802 * @sg: the scatterlist to synchronize
804 * @n_hw_ents: the positive return value from usb_buffer_map_sg 803 * @n_hw_ents: the positive return value from usb_buffer_map_sg
805 * 804 *
806 * Use this when you are re-using a scatterlist's data buffers for 805 * Use this when you are re-using a scatterlist's data buffers for
807 * another USB request. 806 * another USB request.
808 */ 807 */
809void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe, 808void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in,
810 struct scatterlist *sg, int n_hw_ents) 809 struct scatterlist *sg, int n_hw_ents)
811{ 810{
812 struct usb_bus *bus; 811 struct usb_bus *bus;
@@ -819,20 +818,20 @@ void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
819 return; 818 return;
820 819
821 dma_sync_sg(controller, sg, n_hw_ents, 820 dma_sync_sg(controller, sg, n_hw_ents,
822 usb_pipein(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 821 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
823} 822}
824#endif 823#endif
825 824
826/** 825/**
827 * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist 826 * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist
828 * @dev: device to which the scatterlist will be mapped 827 * @dev: device to which the scatterlist will be mapped
829 * @pipe: endpoint defining the mapping direction 828 * @is_in: mapping transfer direction
830 * @sg: the scatterlist to unmap 829 * @sg: the scatterlist to unmap
831 * @n_hw_ents: the positive return value from usb_buffer_map_sg 830 * @n_hw_ents: the positive return value from usb_buffer_map_sg
832 * 831 *
833 * Reverses the effect of usb_buffer_map_sg(). 832 * Reverses the effect of usb_buffer_map_sg().
834 */ 833 */
835void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe, 834void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
836 struct scatterlist *sg, int n_hw_ents) 835 struct scatterlist *sg, int n_hw_ents)
837{ 836{
838 struct usb_bus *bus; 837 struct usb_bus *bus;
@@ -845,7 +844,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
845 return; 844 return;
846 845
847 dma_unmap_sg(controller, sg, n_hw_ents, 846 dma_unmap_sg(controller, sg, n_hw_ents,
848 usb_pipein(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 847 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
849} 848}
850 849
851/* format to disable USB on kernel command line is: nousb */ 850/* format to disable USB on kernel command line is: nousb */