Changeset ca4730a5 in mainline
- Timestamp:
- 2013-07-05T08:33:40Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b2010e2
- Parents:
- 882bc4b
- Location:
- uspace/drv/char/i8042
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/i8042.c
r882bc4b rca4730a5 63 63 #define i8042_AUX_DISABLE 0x20 64 64 #define i8042_KBD_TRANSLATE 0x40 /* Use this to switch to XT scancodes */ 65 66 #define CHECK_RET_DESTROY(ret, msg...) \67 do { \68 if (ret != EOK) { \69 ddf_msg(LVL_ERROR, msg); \70 if (dev->kbd_fun) { \71 dev->kbd_fun->driver_data = NULL; \72 ddf_fun_destroy(dev->kbd_fun); \73 } \74 if (dev->aux_fun) { \75 dev->aux_fun->driver_data = NULL; \76 ddf_fun_destroy(dev->aux_fun); \77 } \78 } \79 } while (0)80 81 #define CHECK_RET_UNBIND_DESTROY(ret, msg...) \82 do { \83 if (ret != EOK) { \84 ddf_msg(LVL_ERROR, msg); \85 if (dev->kbd_fun) { \86 ddf_fun_unbind(dev->kbd_fun); \87 dev->kbd_fun->driver_data = NULL; \88 ddf_fun_destroy(dev->kbd_fun); \89 } \90 if (dev->aux_fun) { \91 ddf_fun_unbind(dev->aux_fun); \92 dev->aux_fun->driver_data = NULL; \93 ddf_fun_destroy(dev->aux_fun); \94 } \95 } \96 } while (0)97 65 98 66 void default_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); -
uspace/drv/char/i8042/main.c
r882bc4b rca4730a5 45 45 #include <async.h> 46 46 #include "i8042.h" 47 48 #define CHECK_RET_RETURN(ret, message...) \49 do { \50 if (ret != EOK) { \51 ddf_msg(LVL_ERROR, message); \52 return ret; \53 } \54 } while (0)55 47 56 48 /** Get address of I/O registers. … … 112 104 static int i8042_dev_add(ddf_dev_t *device) 113 105 { 114 if (!device)115 return EINVAL;116 117 106 uintptr_t io_regs = 0; 118 107 size_t io_size = 0; 119 108 int kbd = 0; 120 109 int mouse = 0; 110 int rc; 121 111 122 int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 123 CHECK_RET_RETURN(ret, "Failed to get registers: %s.", 124 str_error(ret)); 112 if (!device) 113 return EINVAL; 114 115 rc = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse); 116 if (rc != EOK) { 117 ddf_msg(LVL_ERROR, "Failed to get registers: %s.", 118 str_error(rc)); 119 return rc; 120 } 121 125 122 ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.", 126 123 (void *) io_regs, io_size, kbd, mouse); 127 124 128 125 i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t)); 129 ret = (i8042 == NULL) ? ENOMEM : EOK; 130 CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance."); 126 if (i8042 == NULL) { 127 ddf_msg(LVL_ERROR, "Out of memory."); 128 return ENOMEM; 129 } 131 130 132 ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 133 CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.", 134 str_error(ret)); 131 rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device); 132 if (rc != EOK) { 133 ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.", 134 str_error(rc)); 135 return rc; 136 } 135 137 136 138 ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
Note:
See TracChangeset
for help on using the changeset viewer.