Changes in uspace/srv/hid/input/proto/mousedev.c [1875a0c:cc574511] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/proto/mousedev.c
r1875a0c rcc574511 44 44 #include <ipc/mouseev.h> 45 45 #include <input.h> 46 #include <loc.h> 46 47 #include <mouse.h> 47 48 #include <mouse_port.h> 48 49 #include <mouse_proto.h> 50 #include <sys/typefmt.h> 49 51 50 52 /** Mousedev softstate */ … … 55 57 /** Session to mouse device */ 56 58 async_sess_t *sess; 57 58 /** File descriptor of open mousedev device */59 int fd;60 59 } mousedev_t; 61 60 … … 67 66 68 67 mousedev->mouse_dev = mdev; 69 mousedev->fd = -1;70 68 71 69 return mousedev; … … 76 74 if (mousedev->sess != NULL) 77 75 async_hangup(mousedev->sess); 78 79 if (mousedev->fd >= 0)80 close(mousedev->fd);81 76 82 77 free(mousedev); … … 122 117 static int mousedev_proto_init(mouse_dev_t *mdev) 123 118 { 124 c onst char *pathname = mdev->dev_path;119 char *svc_name; 125 120 126 int fd = open(pathname, O_RDWR); 127 if (fd < 0) 128 return -1; 121 if (asprintf(&svc_name, "devname%" PRIun, mdev->service_id) > 0) 122 svc_name = (char *) "unknown"; 129 123 130 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 124 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, 125 mdev->service_id, 0); 131 126 if (sess == NULL) { 132 printf("%s: Failed starting session with '%s'\n", NAME, pathname); 133 close(fd); 127 printf("%s: Failed starting session with '%s'\n", NAME, svc_name); 134 128 return -1; 135 129 } … … 138 132 if (mousedev == NULL) { 139 133 printf("%s: Failed allocating device structure for '%s'.\n", 140 NAME, pathname);134 NAME, svc_name); 141 135 return -1; 142 136 } 143 137 144 mousedev->fd = fd;145 138 mousedev->sess = sess; 146 139 147 140 async_exch_t *exch = async_exchange_begin(sess); 148 141 if (exch == NULL) { 149 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 142 printf("%s: Failed starting exchange with '%s'.\n", NAME, 143 svc_name); 150 144 mousedev_destroy(mousedev); 151 145 return -1; … … 157 151 if (rc != EOK) { 158 152 printf("%s: Failed creating callback connection from '%s'.\n", 159 NAME, pathname);153 NAME, svc_name); 160 154 mousedev_destroy(mousedev); 161 155 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.