Changeset 61257f4 in mainline for uspace/drv/usbhid/main.c
- Timestamp:
- 2011-04-07T20:19:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f8e8738
- Parents:
- fd9ba204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
rfd9ba204 r61257f4 71 71 * @return Other error code inherited from one of functions usb_kbd_init(), 72 72 * ddf_fun_bind() and ddf_fun_add_to_class(). 73 *74 * @sa usb_kbd_fibril(), usb_kbd_repeat_fibril()75 73 */ 76 74 static int usb_hid_try_add_device(usb_device_t *dev) 77 75 { 76 /* 77 * Initialize device (get and process descriptors, get address, etc.) 78 */ 79 usb_log_debug("Initializing USB/HID device...\n"); 80 81 usb_hid_dev_t *hid_dev = usb_hid_new(); 82 if (hid_dev == NULL) { 83 usb_log_error("Error while creating USB/HID device " 84 "structure.\n"); 85 return ENOMEM; 86 } 87 88 int rc = usb_hid_init(hid_dev, dev); 89 90 if (rc != EOK) { 91 usb_log_error("Failed to initialize USB/HID device.\n"); 92 usb_hid_free(&hid_dev); 93 return rc; 94 } 95 96 usb_log_debug("USB/HID device structure initialized.\n"); 97 78 98 /* Create the function exposed under /dev/devices. */ 79 99 ddf_fun_t *hid_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, 80 "hid");100 usb_hid_get_function_name(hid_dev->device_type)); 81 101 if (hid_fun == NULL) { 82 102 usb_log_error("Could not create DDF function node.\n"); 103 usb_hid_free(&hid_dev); 83 104 return ENOMEM; 84 105 } 85 106 86 /*87 * Initialize device (get and process descriptors, get address, etc.)88 */89 usb_log_debug("Initializing USB/HID device...\n");90 91 // usb_kbd_t *kbd_dev = usb_kbd_new();92 // if (kbd_dev == NULL) {93 // usb_log_error("Error while creating USB/HID KBD device "94 // "structure.\n");95 // ddf_fun_destroy(hid_fun);96 // return ENOMEM; // TODO: some other code??97 // }98 99 // int rc = usb_kbd_init(kbd_dev, dev);100 101 // if (rc != EOK) {102 // usb_log_error("Failed to initialize USB/HID KBD device.\n");103 // ddf_fun_destroy(hid_fun);104 // usb_kbd_free(&kbd_dev);105 // return rc;106 // }107 108 // usb_log_debug("USB/HID KBD device structure initialized.\n");109 110 107 /* 111 * Store the initialized keyboard device and keyboardops108 * Store the initialized HID device and HID ops 112 109 * to the DDF function. 113 110 */ 114 //kbd_fun->driver_data = kbd_dev;115 hid_fun-> ops = &hid_ops;116 117 intrc = ddf_fun_bind(hid_fun);111 hid_fun->ops = &hid_dev->ops; 112 hid_fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data 113 114 rc = ddf_fun_bind(hid_fun); 118 115 if (rc != EOK) { 119 116 usb_log_error("Could not bind DDF function: %s.\n", … … 121 118 // TODO: Can / should I destroy the DDF function? 122 119 ddf_fun_destroy(hid_fun); 123 return rc; 124 } 125 126 rc = ddf_fun_add_to_class(hid_fun, "hid"); 120 usb_hid_free(&hid_dev); 121 return rc; 122 } 123 124 rc = ddf_fun_add_to_class(hid_fun, 125 usb_hid_get_class_name(hid_dev->device_type)); 127 126 if (rc != EOK) { 128 127 usb_log_error( … … 131 130 // TODO: Can / should I destroy the DDF function? 132 131 ddf_fun_destroy(hid_fun); 133 return rc;134 }135 136 132 usb_hid_free(&hid_dev); 133 return rc; 134 } 135 137 136 /* Start automated polling function. 138 137 * This will create a separate fibril that will query the device … … 141 140 rc = usb_device_auto_poll(dev, 142 141 /* Index of the polling pipe. */ 143 USB_HID_POLL_EP_NO,142 hid_dev->poll_pipe_index, 144 143 /* Callback when data arrives. */ 145 usb_hid_polling_callback,144 hid_dev->poll_callback, 146 145 /* How much data to request. */ 147 dev->pipes[ USB_HID_POLL_EP_NO].pipe->max_packet_size,146 dev->pipes[hid_dev->poll_pipe_index].pipe->max_packet_size, 148 147 /* Callback when the polling ends. */ 149 148 usb_hid_polling_ended_callback, 150 149 /* Custom argument. */ 151 NULL);150 hid_dev); 152 151 153 152 … … 157 156 return rc; 158 157 } 159 160 (void)hid_ops;161 158 162 159 /* … … 183 180 if (dev->interface_no < 0) { 184 181 usb_log_warning("Device is not a supported HID device.\n"); 185 usb_log_error("Failed to add HID device: endpoint not found."182 usb_log_error("Failed to add HID device: endpoints not found." 186 183 "\n"); 187 184 return ENOTSUP;
Note:
See TracChangeset
for help on using the changeset viewer.