Changeset 00aece0 in mainline for uspace/drv/bus/usb/usbmid/main.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/bus/usb/usbmid/main.c ¶
rbd5f3b7 r00aece0 49 49 * @return Error code. 50 50 */ 51 static int usbmid_ add_device(usb_device_t *dev)51 static int usbmid_device_add(usb_device_t *dev) 52 52 { 53 53 usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name); 54 54 55 usb_pipe_start_long_transfer(&dev->ctrl_pipe); 56 57 bool accept = usbmid_explore_device(dev); 58 59 usb_pipe_end_long_transfer(&dev->ctrl_pipe); 55 const bool accept = usbmid_explore_device(dev); 60 56 61 57 if (!accept) { … … 65 61 return EOK; 66 62 } 63 /*----------------------------------------------------------------------------*/ 64 /** Callback when a MID device is about to be removed from the host. 65 * 66 * @param dev USB device representing the removed device. 67 * @return Error code. 68 */ 69 static int usbmid_device_remove(usb_device_t *dev) 70 { 71 assert(dev); 72 usb_mid_t *usb_mid = dev->driver_data; 73 assert(usb_mid); 74 75 /* Remove ctl function */ 76 int ret = ddf_fun_unbind(usb_mid->ctl_fun); 77 if (ret != EOK) { 78 usb_log_error("Failed to unbind USB MID ctl function: %s.\n", 79 str_error(ret)); 80 return ret; 81 } 82 ddf_fun_destroy(usb_mid->ctl_fun); 83 84 /* Remove all children */ 85 while (!list_empty(&usb_mid->interface_list)) { 86 link_t *item = list_first(&usb_mid->interface_list); 87 list_remove(item); 88 89 usbmid_interface_t *iface = usbmid_interface_from_link(item); 90 91 usb_log_info("Removing child for interface %d (%s).\n", 92 iface->interface_no, 93 usb_str_class(iface->interface->interface_class)); 94 95 /* Tell the child to go off-line. */ 96 int pret = ddf_fun_offline(iface->fun); 97 if (pret != EOK) { 98 usb_log_warning("Failed to turn off child for interface" 99 " %d (%s): %s\n", iface->interface_no, 100 usb_str_class(iface->interface->interface_class), 101 str_error(pret)); 102 ret = pret; 103 } 104 105 /* Now remove the child. */ 106 pret = usbmid_interface_destroy(iface); 107 if (pret != EOK) { 108 usb_log_error("Failed to destroy child for interface " 109 "%d (%s): %s\n", iface->interface_no, 110 usb_str_class(iface->interface->interface_class), 111 str_error(pret)); 112 ret = pret; 113 } 114 } 115 return ret; 116 } 117 /*----------------------------------------------------------------------------*/ 118 /** Callback when a MID device was removed from the host. 119 * 120 * @param dev USB device representing the removed device. 121 * @return Error code. 122 */ 123 static int usbmid_device_gone(usb_device_t *dev) 124 { 125 assert(dev); 126 usb_mid_t *usb_mid = dev->driver_data; 127 assert(usb_mid); 128 129 usb_log_info("USB MID gone: `%s'.\n", dev->ddf_dev->name); 130 131 /* Remove ctl function */ 132 int ret = ddf_fun_unbind(usb_mid->ctl_fun); 133 if (ret != EOK) { 134 usb_log_error("Failed to unbind USB MID ctl function: %s.\n", 135 str_error(ret)); 136 return ret; 137 } 138 ddf_fun_destroy(usb_mid->ctl_fun); 139 140 /* Now remove all other functions */ 141 while (!list_empty(&usb_mid->interface_list)) { 142 link_t *item = list_first(&usb_mid->interface_list); 143 list_remove(item); 144 145 usbmid_interface_t *iface = usbmid_interface_from_link(item); 146 147 usb_log_info("Child for interface %d (%s) gone.\n", 148 iface->interface_no, 149 usb_str_class(iface->interface->interface_class)); 150 151 const int pret = usbmid_interface_destroy(iface); 152 if (pret != EOK) { 153 usb_log_error("Failed to remove child for interface " 154 "%d (%s): %s\n", 155 iface->interface_no, 156 usb_str_class(iface->interface->interface_class), 157 str_error(pret)); 158 ret = pret; 159 } 160 } 161 return ret; 162 } 67 163 68 164 /** USB MID driver ops. */ 69 static usb_driver_ops_t mid_driver_ops = { 70 .add_device = usbmid_add_device, 165 static const usb_driver_ops_t mid_driver_ops = { 166 .device_add = usbmid_device_add, 167 .device_rem = usbmid_device_remove, 168 .device_gone = usbmid_device_gone, 71 169 }; 72 170 73 171 /** USB MID driver. */ 74 static usb_driver_t mid_driver = {172 static const usb_driver_t mid_driver = { 75 173 .name = NAME, 76 174 .ops = &mid_driver_ops,
Note:
See TracChangeset
for help on using the changeset viewer.