Lines Matching defs:ed
106 /* search for the right schedule branch to use for a periodic ed.
143 static void periodic_link (struct ohci_hcd *ohci, struct ed *ed)
148 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
149 ed, ed->branch, ed->load, ed->interval);
151 for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
152 struct ed **prev = &ohci->periodic [i];
154 struct ed *here = *prev;
160 while (here && ed != here) {
161 if (ed->interval > here->interval)
167 if (ed != here) {
168 ed->ed_next = here;
170 ed->hwNextED = *prev_p;
172 *prev = ed;
173 *prev_p = cpu_to_hc32(ohci, ed->dma);
176 ohci->load [i] += ed->load;
178 ohci_to_hcd(ohci)->self.bandwidth_allocated += ed->load / ed->interval;
181 /* link an ed into one of the HC chains */
183 static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
187 ed->ed_prev = NULL;
188 ed->ed_next = NULL;
189 ed->hwNextED = 0;
202 switch (ed->type) {
206 ohci_writel (ohci, ed->dma,
209 ohci->ed_controltail->ed_next = ed;
211 ed->dma);
213 ed->ed_prev = ohci->ed_controltail;
221 ohci->ed_controltail = ed;
227 ohci_writel (ohci, ed->dma, &ohci->regs->ed_bulkhead);
229 ohci->ed_bulktail->ed_next = ed;
231 ed->dma);
233 ed->ed_prev = ohci->ed_bulktail;
241 ohci->ed_bulktail = ed;
247 branch = balance (ohci, ed->interval, ed->load);
251 branch, ed->interval, ed->load);
255 ed->branch = branch;
256 periodic_link (ohci, ed);
263 ed->state = ED_OPER;
270 static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
274 for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
275 struct ed *temp;
276 struct ed **prev = &ohci->periodic [i];
279 while (*prev && (temp = *prev) != ed) {
284 *prev_p = ed->hwNextED;
285 *prev = ed->ed_next;
287 ohci->load [i] -= ed->load;
289 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval;
292 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
293 ed, ed->branch, ed->load, ed->interval);
296 /* unlink an ed from one of the HC chains.
297 * just the link to the ed is unlinked.
298 * the link from the ed still points to another operational ed or 0
299 * so the HC can eventually finish the processing of the unlinked ed
317 static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed)
319 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
321 ed->state = ED_UNLINK;
333 switch (ed->type) {
336 if (ed->ed_prev == NULL) {
337 if (!ed->hwNextED) {
344 hc32_to_cpup (ohci, &ed->hwNextED),
347 ed->ed_prev->ed_next = ed->ed_next;
348 ed->ed_prev->hwNextED = ed->hwNextED;
351 if (ohci->ed_controltail == ed) {
352 ohci->ed_controltail = ed->ed_prev;
355 } else if (ed->ed_next) {
356 ed->ed_next->ed_prev = ed->ed_prev;
362 if (ed->ed_prev == NULL) {
363 if (!ed->hwNextED) {
370 hc32_to_cpup (ohci, &ed->hwNextED),
373 ed->ed_prev->ed_next = ed->ed_next;
374 ed->ed_prev->hwNextED = ed->hwNextED;
377 if (ohci->ed_bulktail == ed) {
378 ohci->ed_bulktail = ed->ed_prev;
381 } else if (ed->ed_next) {
382 ed->ed_next->ed_prev = ed->ed_prev;
389 periodic_unlink (ohci, ed);
400 static struct ed *ed_get (
407 struct ed *ed;
412 ed = ep->hcpriv;
413 if (!ed) {
418 ed = ed_alloc (ohci, GFP_ATOMIC);
419 if (!ed) {
424 /* dummy td; end of td list for ed */
428 ed_free (ohci, ed);
429 ed = NULL;
432 ed->dummy = td;
433 ed->hwTailP = cpu_to_hc32 (ohci, td->td_dma);
434 ed->hwHeadP = ed->hwTailP; /* ED_C, ED_H zeroed */
435 ed->state = ED_IDLE;
443 ed->type = usb_pipetype(pipe);
450 if (ed->type != PIPE_CONTROL) {
452 if (ed->type != PIPE_BULK) {
454 if (ed->type == PIPE_ISOCHRONOUS)
458 ed->interval = interval;
459 ed->load = usb_calc_bus_time (
461 ed->type == PIPE_ISOCHRONOUS,
466 ed->hwINFO = cpu_to_hc32(ohci, info);
468 ep->hcpriv = ed;
473 return ed;
482 * and that ed->state is ED_OPER
484 static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed)
486 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE);
487 ed_deschedule (ohci, ed);
490 ed->ed_next = ohci->ed_rm_list;
491 ed->ed_prev = NULL;
492 ohci->ed_rm_list = ed;
505 ed->tick = ohci_frame_no(ohci) + 1;
546 td = urb_priv->td [index] = urb_priv->ed->dummy;
547 urb_priv->ed->dummy = td_pt;
549 td->ed = urb_priv->ed;
572 list_add_tail (&td->td_list, &td->ed->td_list);
581 td->ed->hwTailP = td->hwNextTD;
613 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
641 switch (urb_priv->ed->type) {
685 if (urb_priv->ed->type == PIPE_BULK) {
837 struct ed *ed = td->ed;
839 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C);
841 /* clear ed halt; this is the td that caused it, but keep it inactive
844 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
846 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H);
850 * Also patch the ed so it looks as if those tds completed normally.
852 while (tmp != &ed->td_list) {
863 * in that segment (TD_R clear), this ed halted because
871 ed->hwHeadP = next->hwNextTD | toggle;
902 struct ed *ed;
908 ed = td->ed;
910 list_for_each_entry_continue_reverse(td2, &ed->td_list, td_list) {
929 td2 = ed->pending_td;
931 ed->pending_td = NULL;
945 * add to ours. ed->td_list changes later.
964 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H)))
978 struct ed *ed, **last;
981 for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) {
990 tick_before(tick, ed->tick)) {
992 last = &ed->ed_next;
995 if (!list_empty(&ed->td_list)) {
999 td = list_first_entry(&ed->td_list, struct td, td_list);
1002 head = hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK;
1013 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
1014 ed->hwNextED = 0;
1016 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE);
1022 *last = ed->ed_next;
1023 ed->ed_next = NULL;
1030 * When we get here, the HC doesn't see this ed. But it
1036 prev = &ed->hwHeadP;
1037 list_for_each_safe (entry, tmp, &ed->td_list) {
1064 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_C);
1066 ed->hwHeadP |= cpu_to_hc32(ohci, ED_C);
1078 if (completed && !list_empty (&ed->td_list))
1087 if (list_empty(&ed->td_list)) {
1088 ed->state = ED_IDLE;
1089 list_del(&ed->in_use_list);
1091 ed_schedule(ohci, ed);
1093 ed->ed_next = ohci->ed_rm_list;
1094 ohci->ed_rm_list = ed;
1097 last = &ed->ed_next;
1154 struct ed *ed = td->ed;
1166 if (list_empty(&ed->td_list)) {
1167 if (ed->state == ED_OPER)
1168 start_ed_unlink(ohci, ed);
1171 } else if ((ed->hwINFO & cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE))
1173 td = list_entry(ed->td_list.next, struct td, td_list);
1175 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP);
1177 switch (ed->type) {