Changeset 65ceb4b in mainline
- Timestamp:
- 2011-12-25T23:29:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba551ba7
- Parents:
- 4d8e203
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/xtkbd/xtkbd.c
r4d8e203 r65ceb4b 37 37 #include <device/char_dev.h> 38 38 #include <ddf/log.h> 39 #include <ipc/kbdev.h> 40 #include <abi/ipc/methods.h> 39 41 40 42 #include "xtkbd.h" 41 43 42 44 static int polling(void *); 45 static void default_connection_handler(ddf_fun_t *fun, 46 ipc_callid_t icallid, ipc_call_t *icall); 47 48 static ddf_dev_ops_t kbd_ops = { 49 .default_handler = default_connection_handler 50 }; 43 51 44 52 int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev) … … 57 65 return ENOMEM; 58 66 } 67 kbd->kbd_fun->ops = &kbd_ops; 68 kbd->kbd_fun->driver_data = kbd; 59 69 60 constint ret = ddf_fun_bind(kbd->kbd_fun);70 int ret = ddf_fun_bind(kbd->kbd_fun); 61 71 if (ret != EOK) { 62 72 async_hangup(kbd->parent_sess); 73 kbd->kbd_fun->driver_data = NULL; 74 ddf_fun_destroy(kbd->kbd_fun); 75 return ENOMEM; 76 } 77 78 ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard"); 79 if (ret != EOK) { 80 async_hangup(kbd->parent_sess); 81 ddf_fun_unbind(kbd->kbd_fun); 82 kbd->kbd_fun->driver_data = NULL; 63 83 ddf_fun_destroy(kbd->kbd_fun); 64 84 return ENOMEM; … … 69 89 async_hangup(kbd->parent_sess); 70 90 ddf_fun_unbind(kbd->kbd_fun); 91 kbd->kbd_fun->driver_data = NULL; 71 92 ddf_fun_destroy(kbd->kbd_fun); 72 93 return ENOMEM; … … 88 109 } 89 110 } 111 /*----------------------------------------------------------------------------*/ 112 void default_connection_handler(ddf_fun_t *fun, 113 ipc_callid_t icallid, ipc_call_t *icall) 114 { 115 if (fun == NULL || fun->driver_data == NULL) { 116 ddf_msg(LVL_ERROR, "%s: Missing parameter.\n", __FUNCTION__); 117 async_answer_0(icallid, EINVAL); 118 return; 119 } 120 121 const sysarg_t method = IPC_GET_IMETHOD(*icall); 122 xt_kbd_t *kbd = fun->driver_data; 123 124 switch (method) { 125 case KBDEV_SET_IND: 126 /* XT keyboards do not support setting mods */ 127 async_answer_0(icallid, ENOTSUP); 128 break; 129 /* This might be ugly but async_callback_receive_start makes no 130 * difference for incorrect call and malloc failure. */ 131 case IPC_M_CONNECT_TO_ME: { 132 async_sess_t *sess = 133 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 134 /* Probably ENOMEM error, try again. */ 135 if (sess == NULL) { 136 ddf_msg(LVL_WARN, 137 "Failed to create start input session"); 138 async_answer_0(icallid, EAGAIN); 139 break; 140 } 141 if (kbd->input_sess == NULL) { 142 kbd->input_sess = sess; 143 ddf_msg(LVL_DEBUG, "Set input session"); 144 async_answer_0(icallid, EOK); 145 } else { 146 ddf_msg(LVL_ERROR, "Input session already set"); 147 async_answer_0(icallid, ELIMIT); 148 } 149 break; 150 } 151 default: 152 ddf_msg(LVL_ERROR, 153 "Unknown method: %d.\n", (int)method); 154 async_answer_0(icallid, EINVAL); 155 break; 156 } 157 }
Note:
See TracChangeset
for help on using the changeset viewer.