Changeset 89c57b6 in mainline for uspace/srv/hid/kbd/port/chardev.c
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/port/chardev.c
rcefb126 r89c57b6 35 35 */ 36 36 37 #include <ipc/ipc.h>38 37 #include <ipc/char.h> 39 38 #include <async.h> … … 41 40 #include <kbd.h> 42 41 #include <vfs/vfs.h> 42 #include <sys/stat.h> 43 43 #include <fcntl.h> 44 44 #include <errno.h> … … 50 50 #define NAME "kbd" 51 51 52 /** List of devices to try connecting to. */ 53 static const char *in_devs[] = { 54 "/dev/char/ps2a", 55 "/dev/char/s3c24ser" 56 }; 57 58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 59 52 60 int kbd_port_init(void) 53 61 { 54 const char *input = "/dev/char/ps2a";55 62 int input_fd; 63 int i; 56 64 57 printf(NAME ": open %s\n", input); 65 input_fd = -1; 66 for (i = 0; i < num_devs; i++) { 67 struct stat s; 58 68 59 input_fd = open(input, O_RDONLY); 69 if (stat(in_devs[i], &s) == EOK) 70 break; 71 } 72 73 if (i >= num_devs) { 74 printf(NAME ": Could not find any suitable input device.\n"); 75 return -1; 76 } 77 78 input_fd = open(in_devs[i], O_RDONLY); 60 79 if (input_fd < 0) { 61 printf(NAME ": Failed opening %s (%d)\n", input, input_fd); 62 return false; 80 printf(NAME ": failed opening device %s (%d).\n", in_devs[i], 81 input_fd); 82 return -1; 63 83 } 64 84 65 85 dev_phone = fd_phone(input_fd); 66 86 if (dev_phone < 0) { 67 printf(NAME ": Failed to connectto device\n");68 return false;87 printf(NAME ": Failed connecting to device\n"); 88 return -1; 69 89 } 70 90 71 91 /* NB: The callback connection is slotted for removal */ 72 ipcarg_t phonehash; 73 if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) { 92 if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 74 93 printf(NAME ": Failed to create callback from device\n"); 75 return false;94 return -1; 76 95 } 77 78 async_new_connection(phonehash, 0, NULL, kbd_port_events);79 96 80 97 return 0; … … 104 121 int retval; 105 122 106 switch (IPC_GET_ METHOD(call)) {123 switch (IPC_GET_IMETHOD(call)) { 107 124 case IPC_M_PHONE_HUNGUP: 108 125 /* TODO: Handle hangup */ … … 114 131 retval = ENOENT; 115 132 } 116 ipc_answer_0(callid, retval);133 async_answer_0(callid, retval); 117 134 } 118 135 }
Note:
See TracChangeset
for help on using the changeset viewer.