Changes in uspace/srv/hid/input/ctl/kbdev.c [cce8a83:1875a0c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/ctl/kbdev.c
rcce8a83 r1875a0c 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 *); … … 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("%s: Failed starting session with '%s'\n", NAME, pathname); 119 close(fd); 106 120 return -1; 107 121 } … … 110 124 if (kbdev == NULL) { 111 125 printf("%s: Failed allocating device structure for '%s'.\n", 112 NAME, kdev->svc_name); 113 return -1; 114 } 115 126 NAME, 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("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 122 136 kbdev_destroy(kbdev); 123 137 return -1; … … 127 141 if (rc != EOK) { 128 142 printf("%s: Failed creating callback connection from '%s'.\n", 129 NAME, kdev->svc_name);143 NAME, pathname); 130 144 async_exchange_end(exch); 131 145 kbdev_destroy(kbdev);
Note:
See TracChangeset
for help on using the changeset viewer.