Changes in uspace/drv/bus/usb/usbhid/multimedia/multimedia.c [56fd7cf:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/multimedia/multimedia.c
r56fd7cf r9d58539 54 54 #define NAME "multimedia-keys" 55 55 56 56 /*----------------------------------------------------------------------------*/ 57 57 /** 58 58 * Logitech UltraX device type. … … 70 70 71 71 72 72 /*----------------------------------------------------------------------------*/ 73 73 /** 74 74 * Default handler for IPC methods not handled by DDF. … … 86 86 { 87 87 usb_log_debug(NAME " default_connection_handler()\n"); 88 89 usb_multimedia_t *multim_dev = ddf_fun_data_get(fun); 88 if (fun == NULL || fun->driver_data == NULL) { 89 async_answer_0(icallid, EINVAL); 90 return; 91 } 92 93 usb_multimedia_t *multim_dev = fun->driver_data; 90 94 91 95 async_sess_t *sess = … … 102 106 async_answer_0(icallid, EINVAL); 103 107 } 104 108 /*----------------------------------------------------------------------------*/ 105 109 static ddf_dev_ops_t multimedia_ops = { 106 110 .default_handler = default_connection_handler 107 111 }; 108 112 /*----------------------------------------------------------------------------*/ 109 113 /** 110 114 * Processes key events. … … 151 155 } 152 156 } 153 157 /*----------------------------------------------------------------------------*/ 154 158 int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data) 155 159 { … … 168 172 } 169 173 170 ddf_fun_set_ops(fun, &multimedia_ops);174 fun->ops = &multimedia_ops; 171 175 172 176 usb_multimedia_t *multim_dev = … … 190 194 191 195 usb_log_debug(NAME " function created (handle: %" PRIun ").\n", 192 ddf_fun_get_handle(fun));196 fun->handle); 193 197 194 198 rc = ddf_fun_add_to_category(fun, "keyboard"); … … 199 203 if (ddf_fun_unbind(fun) != EOK) { 200 204 usb_log_error("Failed to unbind %s, won't destroy.\n", 201 ddf_fun_get_name(fun));205 fun->name); 202 206 } else { 203 207 ddf_fun_destroy(fun); … … 212 216 return EOK; 213 217 } 214 218 /*----------------------------------------------------------------------------*/ 215 219 void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data) 216 220 { 217 221 ddf_fun_t *fun = data; 218 219 usb_multimedia_t *multim_dev = ddf_fun_data_get(fun); 220 221 /* Hangup session to the console */ 222 if (multim_dev->console_sess) 223 async_hangup(multim_dev->console_sess); 224 if (ddf_fun_unbind(fun) != EOK) { 225 usb_log_error("Failed to unbind %s, won't destroy.\n", 226 ddf_fun_get_name(fun)); 222 if (fun != NULL && fun->driver_data != NULL) { 223 usb_multimedia_t *multim_dev = fun->driver_data; 224 /* Hangup session to the console */ 225 if (multim_dev->console_sess) 226 async_hangup(multim_dev->console_sess); 227 if (ddf_fun_unbind(fun) != EOK) { 228 usb_log_error("Failed to unbind %s, won't destroy.\n", 229 fun->name); 230 } else { 231 usb_log_debug2("%s unbound.\n", fun->name); 232 /* This frees multim_dev too as it was stored in 233 * fun->data */ 234 ddf_fun_destroy(fun); 235 } 227 236 } else { 228 usb_log_debug2("%s unbound.\n", ddf_fun_get_name(fun)); 229 /* This frees multim_dev too as it was stored in 230 * fun->data */ 231 ddf_fun_destroy(fun); 232 } 233 } 234 237 usb_log_error( 238 "Failed to deinit multimedia subdriver, data missing.\n"); 239 } 240 } 241 /*----------------------------------------------------------------------------*/ 235 242 bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data) 236 243 { 237 244 // TODO: checks 238 245 ddf_fun_t *fun = data; 239 if (hid_dev == NULL ) {246 if (hid_dev == NULL || fun == NULL || fun->driver_data == NULL) { 240 247 return false; 241 248 } 242 249 243 usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);250 usb_multimedia_t *multim_dev = fun->driver_data; 244 251 245 252 usb_hid_report_path_t *path = usb_hid_report_path();
Note:
See TracChangeset
for help on using the changeset viewer.