Changes in uspace/drv/usbmouse/init.c [79ae36dd:4a4c8bcf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
r79ae36dd r4a4c8bcf 43 43 #include <errno.h> 44 44 45 // FIXME: remove this header46 #include <kernel/ipc/ipc_methods.h>47 48 45 /** Mouse polling endpoint description for boot protocol subclass. */ 49 46 usb_endpoint_description_t poll_endpoint_description = { … … 56 53 }; 57 54 58 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 55 /** Default handler for IPC methods not handled by DDF. 56 * 57 * @param fun Device function handling the call. 58 * @param icallid Call ID. 59 * @param icall Call data. 60 * 61 */ 62 static void default_connection_handler(ddf_fun_t *fun, ipc_callid_t icallid, 63 ipc_call_t *icall) 64 { 65 usb_mouse_t *mouse = (usb_mouse_t *) fun->driver_data; 66 assert(mouse != NULL); 67 68 async_sess_t *callback = 69 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 70 71 if (callback) { 72 if (mouse->console_sess == NULL) { 73 mouse->console_sess = callback; 74 async_answer_0(icallid, EOK); 75 } else 76 async_answer_0(icallid, ELIMIT); 77 } else 78 async_answer_0(icallid, EINVAL); 79 } 80 59 81 /** Device ops for USB mouse. */ 60 82 static ddf_dev_ops_t mouse_ops = { 61 83 .default_handler = default_connection_handler 62 84 }; 63 64 /** Default handler for IPC methods not handled by DDF.65 *66 * @param fun Device function handling the call.67 * @param icallid Call id.68 * @param icall Call data.69 */70 void default_connection_handler(ddf_fun_t *fun,71 ipc_callid_t icallid, ipc_call_t *icall)72 {73 sysarg_t method = IPC_GET_IMETHOD(*icall);74 75 usb_mouse_t *mouse = (usb_mouse_t *) fun->driver_data;76 assert(mouse != NULL);77 78 if (method == IPC_M_CONNECT_TO_ME) {79 int callback = IPC_GET_ARG5(*icall);80 81 if (mouse->console_phone != -1) {82 async_answer_0(icallid, ELIMIT);83 return;84 }85 86 mouse->console_phone = callback;87 async_answer_0(icallid, EOK);88 return;89 }90 91 async_answer_0(icallid, EINVAL);92 }93 85 94 86 /** Create USB mouse device. … … 102 94 { 103 95 usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t)); 104 if (mouse == NULL) {96 if (mouse == NULL) 105 97 return ENOMEM; 106 }98 107 99 mouse->dev = dev; 108 mouse->console_ phone = -1;109 100 mouse->console_sess = NULL; 101 110 102 int rc; 111 103 112 104 /* Create DDF function. */ 113 105 mouse->mouse_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "mouse"); … … 116 108 goto leave; 117 109 } 118 110 119 111 mouse->mouse_fun->ops = &mouse_ops; 120 112 121 113 rc = ddf_fun_bind(mouse->mouse_fun); 122 if (rc != EOK) {114 if (rc != EOK) 123 115 goto leave; 124 } 125 116 126 117 /* Add the function to mouse class. */ 127 118 rc = ddf_fun_add_to_class(mouse->mouse_fun, "mouse"); 128 if (rc != EOK) {119 if (rc != EOK) 129 120 goto leave; 130 }131 121 132 122 /* Set the boot protocol. */ 133 123 rc = usbhid_req_set_protocol(&dev->ctrl_pipe, dev->interface_no, 134 124 USB_HID_PROTOCOL_BOOT); 135 if (rc != EOK) {125 if (rc != EOK) 136 126 goto leave; 137 }138 127 139 /* Everything all 128 /* Everything allright. */ 140 129 dev->driver_data = mouse; 141 130 mouse->mouse_fun->driver_data = mouse; 142 131 143 132 return EOK; 144 133 145 134 leave: 146 135 free(mouse); 147 148 136 return rc; 149 137 }
Note:
See TracChangeset
for help on using the changeset viewer.