Changes in uspace/drv/usbmouse/init.c [4a4c8bcf:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
r4a4c8bcf r79ae36dd 43 43 #include <errno.h> 44 44 45 // FIXME: remove this header 46 #include <kernel/ipc/ipc_methods.h> 47 45 48 /** Mouse polling endpoint description for boot protocol subclass. */ 46 49 usb_endpoint_description_t poll_endpoint_description = { … … 53 56 }; 54 57 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 58 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 81 59 /** Device ops for USB mouse. */ 82 60 static ddf_dev_ops_t mouse_ops = { 83 61 .default_handler = default_connection_handler 84 62 }; 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 } 85 93 86 94 /** Create USB mouse device. … … 94 102 { 95 103 usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t)); 96 if (mouse == NULL) 104 if (mouse == NULL) { 97 105 return ENOMEM; 98 106 } 99 107 mouse->dev = dev; 100 mouse->console_ sess = NULL;101 108 mouse->console_phone = -1; 109 102 110 int rc; 103 111 104 112 /* Create DDF function. */ 105 113 mouse->mouse_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "mouse"); … … 108 116 goto leave; 109 117 } 110 118 111 119 mouse->mouse_fun->ops = &mouse_ops; 112 120 113 121 rc = ddf_fun_bind(mouse->mouse_fun); 114 if (rc != EOK) 122 if (rc != EOK) { 115 123 goto leave; 116 124 } 125 117 126 /* Add the function to mouse class. */ 118 127 rc = ddf_fun_add_to_class(mouse->mouse_fun, "mouse"); 119 if (rc != EOK) 128 if (rc != EOK) { 120 129 goto leave; 130 } 121 131 122 132 /* Set the boot protocol. */ 123 133 rc = usbhid_req_set_protocol(&dev->ctrl_pipe, dev->interface_no, 124 134 USB_HID_PROTOCOL_BOOT); 125 if (rc != EOK) 135 if (rc != EOK) { 126 136 goto leave; 137 } 127 138 128 /* Everything all right. */139 /* Everything all right. */ 129 140 dev->driver_data = mouse; 130 141 mouse->mouse_fun->driver_data = mouse; 131 142 132 143 return EOK; 133 144 134 145 leave: 135 146 free(mouse); 147 136 148 return rc; 137 149 }
Note:
See TracChangeset
for help on using the changeset viewer.