Changes in uspace/drv/usbmouse/init.c [4a4c8bcf:b59ec8c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
r4a4c8bcf rb59ec8c 34 34 * Initialization routines for USB mouse driver. 35 35 */ 36 37 36 #include "mouse.h" 38 37 #include <usb/debug.h> … … 53 52 }; 54 53 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 54 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 81 55 /** Device ops for USB mouse. */ 82 56 static ddf_dev_ops_t mouse_ops = { 83 57 .default_handler = default_connection_handler 84 58 }; 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 } 85 89 86 90 /** Create USB mouse device. … … 94 98 { 95 99 usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t)); 96 if (mouse == NULL) 100 if (mouse == NULL) { 97 101 return ENOMEM; 98 102 } 99 103 mouse->dev = dev; 100 mouse->console_ sess = NULL;101 104 mouse->console_phone = -1; 105 102 106 int rc; 103 107 104 108 /* Create DDF function. */ 105 109 mouse->mouse_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "mouse"); … … 108 112 goto leave; 109 113 } 110 114 111 115 mouse->mouse_fun->ops = &mouse_ops; 112 116 113 117 rc = ddf_fun_bind(mouse->mouse_fun); 114 if (rc != EOK) 118 if (rc != EOK) { 115 119 goto leave; 116 120 } 121 117 122 /* Add the function to mouse class. */ 118 123 rc = ddf_fun_add_to_class(mouse->mouse_fun, "mouse"); 119 if (rc != EOK) 124 if (rc != EOK) { 120 125 goto leave; 126 } 121 127 122 128 /* Set the boot protocol. */ 123 129 rc = usbhid_req_set_protocol(&dev->ctrl_pipe, dev->interface_no, 124 130 USB_HID_PROTOCOL_BOOT); 125 if (rc != EOK) 131 if (rc != EOK) { 126 132 goto leave; 133 } 127 134 128 /* Everything all right. */135 /* Everything all right. */ 129 136 dev->driver_data = mouse; 130 137 mouse->mouse_fun->driver_data = mouse; 131 138 132 139 return EOK; 133 140 134 141 leave: 135 142 free(mouse); 143 136 144 return rc; 137 145 }
Note:
See TracChangeset
for help on using the changeset viewer.