⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbdcore.lst

📁 OMAP1510的USB驱动程序
💻 LST
📖 第 1 页 / 共 4 页
字号:
 468          }
 469          
 470          /*
 471           * Return the first urb_link in a list with a distinguished
 472           * head "hd", or NULL if the list is empty.  This will also
 473           * work as a predicate, returning NULL if empty, and non-NULL
 474           * otherwise.
 475           */
 476          urb_link *first_urb_link (urb_link * hd)
 477          {
 478                  urb_link *nx;
C51 COMPILER V8.09   USBDCORE                                                              05/05/2008 19:48:28 PAGE 12  

 479                  if (NULL != hd && NULL != (nx = hd->next) && nx != hd) {
 480                          /* There is at least one element in the list */
 481                          /* (besides the distinguished head). */
 482                          return (nx);
 483                  }
 484                  /* The list is empty */
 485                  return (NULL);
 486          }
 487          
 488          /*
 489           * Return the first urb in a list with a distinguished
 490           * head "hd", or NULL if the list is empty.
 491           */
 492          struct urb *first_urb (urb_link * hd)
 493          {
 494                  urb_link *nx;
 495                  if (NULL == (nx = first_urb_link (hd))) {
 496                          /* The list is empty */
 497                          return (NULL);
 498                  }
 499                  return (p2surround (struct urb, link, nx));
 500          }
 501          
 502          /*
 503           * Detach and return the first urb in a list with a distinguished
 504           * head "hd", or NULL if the list is empty.
 505           *
 506           */
 507          struct urb *first_urb_detached (urb_link * hd)
 508          {
 509                  struct urb *urb;
 510                  if ((urb = first_urb (hd))) {
 511                          urb_detach (urb);
 512                  }
 513                  return urb;
 514          }
 515          
 516          
 517          /*
 518           * Append an urb_link (or a whole list of
 519           * urb_links) to the tail of another list
 520           * of urb_links.
 521           */
 522          void urb_append (urb_link * hd, struct urb *urb)
 523          {
 524                  if (hd && urb) {
 525                          urb_link *new = &urb->link;
 526          
 527                          /* This allows the new urb to be a list of urbs, */
 528                          /* with new pointing at the first, but the link */
 529                          /* must be initialized. */
 530                          /* Order is important here... */
 531                          urb_link *pul = hd->prev;
 532                          new->prev->next = hd;
 533                          hd->prev = new->prev;
 534                          new->prev = pul;
 535                          pul->next = new;
 536                  }
 537          }
 538          
 539          /* URB create/destroy functions ***************************************************** */
 540          
C51 COMPILER V8.09   USBDCORE                                                              05/05/2008 19:48:28 PAGE 13  

 541          /**
 542           * usbd_alloc_urb - allocate an URB appropriate for specified endpoint
 543           * @device: device instance
 544           * @endpoint: endpoint
 545           *
 546           * Allocate an urb structure. The usb device urb structure is used to
 547           * contain all data associated with a transfer, including a setup packet for
 548           * control transfers.
 549           *
 550           * NOTE: endpoint_address MUST contain a direction flag.
 551           */
 552          struct urb *usbd_alloc_urb (struct usb_device_instance *device, struct usb_endpoint_instance *endpoint)
 553          {
 554                  struct urb *urb;
 555          
 556                  if( !(urb = (struct urb*)malloc(sizeof(struct urb))) ) {
 557                    usberr(" F A T A L:  malloc(%u) FAILED!!!!", sizeof(struct urb));
 558                    return NULL;
 559                  }
 560          
 561                  /* Fill in known fields */
 562                  memset(urb, 0, sizeof(struct urb));
 563                  urb->endpoint = endpoint;
 564                  urb->device = device;
 565                  urb->buffer = (u8*)urb->buffer_data;
 566                  urb->buffer_length = sizeof(urb->buffer_data);
 567          
 568                  urb_link_init (&urb->link);
 569          
 570                  return urb;
 571          }
 572          
 573          /**
 574           * usbd_dealloc_urb - deallocate an URB and associated buffer
 575           * @urb: pointer to an urb structure
 576           *
 577           * Deallocate an urb structure and associated data.
 578           */
 579          void usbd_dealloc_urb (struct urb *urb)
 580          {
 581                  if (urb) {
 582                          free (urb);
 583                  }
 584          }
 585          
 586          /* Event signaling functions ***************************************************** */
 587          
 588          /**
 589           * usbd_device_event - called to respond to various usb events
 590           * @device: pointer to struct device
 591           * @event: event to respond to
 592           *
 593           * Used by a Bus driver to indicate an event.
 594           */
 595          void usbd_device_event_irq (struct usb_device_instance *device, usb_device_event_t event, int data)
 596          {
 597                  usb_device_state_t state;
 598          
 599                  if (!device || !device->bus) {
 600                          usberr("(%p,%d) NULL device or device->bus", device, event);
 601                          return;
 602                  }
C51 COMPILER V8.09   USBDCORE                                                              05/05/2008 19:48:28 PAGE 14  

 603          
 604                  state = device->device_state;
 605          
 606                  usbinfo("%s", usbd_device_events[event]);
 607          
 608                  switch (event) {
 609                  case DEVICE_UNKNOWN:
 610                          break;
 611                  case DEVICE_INIT:
 612                          device->device_state = STATE_INIT;
 613                          break;
 614          
 615                  case DEVICE_CREATE:
 616                          device->device_state = STATE_ATTACHED;
 617                          break;
 618          
 619                  case DEVICE_HUB_CONFIGURED:
 620                          device->device_state = STATE_POWERED;
 621                          break;
 622          
 623                  case DEVICE_RESET:
 624                          device->device_state = STATE_DEFAULT;
 625                          device->address = 0;
 626                          break;
 627          
 628                  case DEVICE_ADDRESS_ASSIGNED:
 629                          device->device_state = STATE_ADDRESSED;
 630                          break;
 631          
 632                  case DEVICE_CONFIGURED:
 633                          device->device_state = STATE_CONFIGURED;
 634                          break;
 635          
 636                  case DEVICE_DE_CONFIGURED:
 637                          device->device_state = STATE_ADDRESSED;
 638                          break;
 639          
 640                  case DEVICE_BUS_INACTIVE:
 641                          if (device->status != USBD_CLOSING) {
 642                                  device->status = USBD_SUSPENDED;
 643                          }
 644                          break;
 645                  case DEVICE_BUS_ACTIVITY:
 646                          if (device->status != USBD_CLOSING) {
 647                                  device->status = USBD_OK;
 648                          }
 649                          break;
 650          
 651                  case DEVICE_SET_INTERFACE:
 652                          break;
 653                  case DEVICE_SET_FEATURE:
 654                          break;
 655                  case DEVICE_CLEAR_FEATURE:
 656                          break;
 657          
 658                  case DEVICE_POWER_INTERRUPTION:
 659                          device->device_state = STATE_POWERED;
 660                          break;
 661                  case DEVICE_HUB_RESET:
 662                          device->device_state = STATE_ATTACHED;
 663                          break;
 664                  case DEVICE_DESTROY:
C51 COMPILER V8.09   USBDCORE                                                              05/05/2008 19:48:28 PAGE 15  

 665                          device->device_state = STATE_UNKNOWN;
 666                          break;
 667          
 668                  case DEVICE_FUNCTION_PRIVATE:
 669                          break;
 670          
 671                  default:
 672                          usbdbg("event %d - not handled",event);
 673                          break;
 674                  }
 675                  /*usbdbg("%s event: %d oldstate: %d newstate: %d status: %d address: %d",
 676                          device->name, event, state,
 677                          device->device_state, device->status, device->address); */
 678          
 679                  /* tell the bus interface driver */
 680                  if( device->event ) {
 681                          /* usbdbg("calling device->event"); */
 682                          device->event(device, event, data);
 683                  }
 684          }

C51 COMPILATION COMPLETE.  12 WARNING(S),  175 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -