Changes in uspace/srv/hid/input/ctl/kbdev.c [cce8a83:854eddd6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/ctl/kbdev.c
rcce8a83 r854eddd6 48 48 #include <kbd_ctl.h> 49 49 #include <kbd_port.h> 50 #include <loc.h>51 50 #include <stdlib.h> 52 51 #include <vfs/vfs_sess.h> 53 #include <sys/typefmt.h> 52 54 53 55 54 static int kbdev_ctl_init(kbd_dev_t *); 56 static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned int);55 static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned); 57 56 58 57 static void kbdev_callback_conn(ipc_callid_t, ipc_call_t *, void *arg); 59 58 60 59 kbd_ctl_ops_t kbdev_ctl = { 61 .parse = NULL,60 .parse_scancode = NULL, 62 61 .init = kbdev_ctl_init, 63 62 .set_ind = kbdev_ctl_set_ind … … 71 70 /** Session with kbdev device */ 72 71 async_sess_t *sess; 72 73 /** File descriptor of open kbdev device */ 74 int fd; 73 75 } kbdev_t; 74 76 … … 82 84 83 85 kbdev->kbd_dev = kdev; 86 kbdev->fd = -1; 84 87 85 88 return kbdev; … … 90 93 if (kbdev->sess != NULL) 91 94 async_hangup(kbdev->sess); 95 if (kbdev->fd >= 0) 96 close(kbdev->fd); 92 97 free(kbdev); 93 98 } … … 95 100 static int kbdev_ctl_init(kbd_dev_t *kdev) 96 101 { 102 const char *pathname; 97 103 async_sess_t *sess; 98 104 async_exch_t *exch; 99 105 kbdev_t *kbdev; 106 int fd; 100 107 int rc; 101 108 102 sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0); 109 pathname = kdev->dev_path; 110 111 fd = open(pathname, O_RDWR); 112 if (fd < 0) { 113 return -1; 114 } 115 116 sess = fd_session(EXCHANGE_SERIALIZE, fd); 103 117 if (sess == NULL) { 104 printf( "%s: Failed starting session with '%s.'\n", NAME,105 kdev->svc_name);118 printf(NAME ": Failed starting session with '%s'\n", pathname); 119 close(fd); 106 120 return -1; 107 121 } … … 109 123 kbdev = kbdev_new(kdev); 110 124 if (kbdev == NULL) { 111 printf("%s: Failed allocating device structure for '%s'.\n", 112 NAME, kdev->svc_name); 113 return -1; 114 } 115 125 printf(NAME ": Failed allocating device structure for '%s'.\n", 126 pathname); 127 return -1; 128 } 129 130 kbdev->fd = fd; 116 131 kbdev->sess = sess; 117 132 118 133 exch = async_exchange_begin(sess); 119 134 if (exch == NULL) { 120 printf("%s: Failed starting exchange with '%s'.\n", NAME, 121 kdev->svc_name); 135 printf(NAME ": Failed starting exchange with '%s'.\n", pathname); 122 136 kbdev_destroy(kbdev); 123 137 return -1; … … 126 140 rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev); 127 141 if (rc != EOK) { 128 printf( "%s: Failed creating callback connection from '%s'.\n",129 NAME, kdev->svc_name);142 printf(NAME ": Failed creating callback connection from '%s'.\n", 143 pathname); 130 144 async_exchange_end(exch); 131 145 kbdev_destroy(kbdev); … … 179 193 type = IPC_GET_ARG1(call); 180 194 key = IPC_GET_ARG2(call); 181 kbd_push_ev ent(kbdev->kbd_dev, type, key);195 kbd_push_ev(kbdev->kbd_dev, type, key); 182 196 break; 183 197 default:
Note:
See TracChangeset
for help on using the changeset viewer.