aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon/mon_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/mon/mon_text.c')
-rw-r--r--drivers/usb/mon/mon_text.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 26266b30028e..417464dea9f6 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -91,25 +91,11 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
91 int len, char ev_type) 91 int len, char ev_type)
92{ 92{
93 int pipe = urb->pipe; 93 int pipe = urb->pipe;
94 unsigned char *data;
95
96 /*
97 * The check to see if it's safe to poke at data has an enormous
98 * number of corner cases, but it seems that the following is
99 * more or less safe.
100 *
101 * We do not even try to look transfer_buffer, because it can
102 * contain non-NULL garbage in case the upper level promised to
103 * set DMA for the HCD.
104 */
105 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
106 return 'D';
107 94
108 if (len <= 0) 95 if (len <= 0)
109 return 'L'; 96 return 'L';
110 97 if (len >= DATA_MAX)
111 if ((data = urb->transfer_buffer) == NULL) 98 len = DATA_MAX;
112 return 'Z'; /* '0' would be not as pretty. */
113 99
114 /* 100 /*
115 * Bulk is easy to shortcut reliably. 101 * Bulk is easy to shortcut reliably.
@@ -126,8 +112,21 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
126 } 112 }
127 } 113 }
128 114
129 if (len >= DATA_MAX) 115 /*
130 len = DATA_MAX; 116 * The check to see if it's safe to poke at data has an enormous
117 * number of corner cases, but it seems that the following is
118 * more or less safe.
119 *
120 * We do not even try to look transfer_buffer, because it can
121 * contain non-NULL garbage in case the upper level promised to
122 * set DMA for the HCD.
123 */
124 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
125 return mon_dmapeek(ep->data, urb->transfer_dma, len);
126
127 if (urb->transfer_buffer == NULL)
128 return 'Z'; /* '0' would be not as pretty. */
129
131 memcpy(ep->data, urb->transfer_buffer, len); 130 memcpy(ep->data, urb->transfer_buffer, len);
132 return 0; 131 return 0;
133} 132}