Changes in uspace/srv/hid/input/ctl/kbdev.c [cc574511:1875a0c] in mainline
- File:
-
- 1 edited
-
uspace/srv/hid/input/ctl/kbdev.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/ctl/kbdev.c
rcc574511 r1875a0c 48 48 #include <kbd_ctl.h> 49 49 #include <kbd_port.h> 50 #include <loc.h>51 50 #include <stdlib.h> 52 #include <sys/typefmt.h>53 51 #include <vfs/vfs_sess.h> 54 52 … … 72 70 /** Session with kbdev device */ 73 71 async_sess_t *sess; 72 73 /** File descriptor of open kbdev device */ 74 int fd; 74 75 } kbdev_t; 75 76 … … 83 84 84 85 kbdev->kbd_dev = kdev; 86 kbdev->fd = -1; 85 87 86 88 return kbdev; … … 91 93 if (kbdev->sess != NULL) 92 94 async_hangup(kbdev->sess); 95 if (kbdev->fd >= 0) 96 close(kbdev->fd); 93 97 free(kbdev); 94 98 } … … 96 100 static int kbdev_ctl_init(kbd_dev_t *kdev) 97 101 { 102 const char *pathname; 98 103 async_sess_t *sess; 99 104 async_exch_t *exch; 100 105 kbdev_t *kbdev; 101 char *svc_name;106 int fd; 102 107 int rc; 103 108 104 if (asprintf(&svc_name, "devname%" PRIun, kdev->service_id) > 0) 105 svc_name = (char *) "unknown"; 106 107 sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->service_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); 108 117 if (sess == NULL) { 109 printf("%s: Failed starting session with '%s .'\n", NAME,110 svc_name);118 printf("%s: Failed starting session with '%s'\n", NAME, pathname); 119 close(fd); 111 120 return -1; 112 121 } … … 115 124 if (kbdev == NULL) { 116 125 printf("%s: Failed allocating device structure for '%s'.\n", 117 NAME, svc_name); 118 return -1; 119 } 120 126 NAME, pathname); 127 return -1; 128 } 129 130 kbdev->fd = fd; 121 131 kbdev->sess = sess; 122 132 123 133 exch = async_exchange_begin(sess); 124 134 if (exch == NULL) { 125 printf("%s: Failed starting exchange with '%s'.\n", NAME, 126 svc_name); 135 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 127 136 kbdev_destroy(kbdev); 128 137 return -1; … … 132 141 if (rc != EOK) { 133 142 printf("%s: Failed creating callback connection from '%s'.\n", 134 NAME, svc_name);143 NAME, pathname); 135 144 async_exchange_end(exch); 136 145 kbdev_destroy(kbdev);
Note:
See TracChangeset
for help on using the changeset viewer.
