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