Changeset b371844 in mainline for uspace/srv/hw/bus/usb/hcd/virtual/devices.c
- Timestamp:
- 2010-10-10T11:53:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b8100da
- Parents:
- bc9a629
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/devices.c
rbc9a629 rb371844 31 31 */ 32 32 /** @file 33 * @brief 33 * @brief Virtual device management (implementation). 34 34 */ 35 35 … … 53 53 LIST_INITIALIZE(devices); 54 54 55 /** Recognise device by id. 56 * 57 * @param id Device id. 58 * @param phone Callback phone. 59 */ 60 virtdev_connection_t *virtdev_recognise(int id, int phone) 61 { 62 virtdev_connection_t * dev = NULL; 63 switch (id) { 64 case USB_VIRTDEV_KEYBOARD_ID: 65 dev = virtdev_add_device( 66 USB_VIRTDEV_KEYBOARD_ADDRESS, phone); 67 break; 68 default: 69 break; 70 } 71 72 /* 73 * We do not want to mess-up the virtdev_add_device() as 74 * the id is needed only before device probing/detection 75 * is implemented. 76 * 77 * However, that does not mean that this will happen soon. 78 */ 79 if (dev) { 80 dev->id = id; 81 } 82 83 return dev; 84 } 85 86 /** Find virtual device by its USB address. 87 * 88 * @retval NULL No virtual device at given address. 89 */ 55 90 virtdev_connection_t *virtdev_find_by_address(usb_address_t address) 56 91 { … … 67 102 } 68 103 104 /** Create virtual device. 105 * 106 * @param address USB address. 107 * @param phone Callback phone. 108 * @return New device. 109 * @retval NULL Out of memory or address already occupied. 110 */ 69 111 virtdev_connection_t *virtdev_add_device(usb_address_t address, int phone) 70 112 { 113 link_t *pos; 114 list_foreach(pos, &devices) { 115 virtdev_connection_t *dev 116 = list_get_instance(pos, virtdev_connection_t, link); 117 if (dev->address == address) { 118 return NULL; 119 } 120 } 121 71 122 virtdev_connection_t *dev = (virtdev_connection_t *) 72 123 malloc(sizeof(virtdev_connection_t)); … … 78 129 } 79 130 80 void virtdev_destroy_device(virtdev_connection_t *dev) 131 /** Destroy virtual device. 132 */ 133 void virtdev_destroy_device(virtdev_connection_t *dev) 81 134 { 82 135 list_remove(&dev->link);
Note:
See TracChangeset
for help on using the changeset viewer.