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