Changeset 3123d2a in mainline
- Timestamp:
- 2012-06-01T19:26:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 520acaf, 85a4350, c573e0f, e1e4192
- Parents:
- 2f90b46
- Location:
- uspace/srv/hid
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/ctl/kbdev.c
r2f90b46 r3123d2a 68 68 /** Link to generic keyboard device */ 69 69 kbd_dev_t *kbd_dev; 70 70 71 71 /** Session with kbdev device */ 72 72 async_sess_t *sess; … … 75 75 static kbdev_t *kbdev_new(kbd_dev_t *kdev) 76 76 { 77 kbdev_t *kbdev; 78 79 kbdev = calloc(1, sizeof(kbdev_t)); 77 kbdev_t *kbdev = calloc(1, sizeof(kbdev_t)); 80 78 if (kbdev == NULL) 81 79 return NULL; 82 80 83 81 kbdev->kbd_dev = kdev; 84 82 … … 90 88 if (kbdev->sess != NULL) 91 89 async_hangup(kbdev->sess); 90 92 91 free(kbdev); 93 92 } … … 95 94 static int kbdev_ctl_init(kbd_dev_t *kdev) 96 95 { 97 async_sess_t *sess; 98 async_exch_t *exch; 99 kbdev_t *kbdev; 100 int rc; 101 102 sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0); 96 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, 97 kdev->svc_id, 0); 103 98 if (sess == NULL) { 104 99 printf("%s: Failed starting session with '%s.'\n", NAME, 105 100 kdev->svc_name); 106 return -1;101 return ENOENT; 107 102 } 108 109 kbdev = kbdev_new(kdev);103 104 kbdev_t *kbdev = kbdev_new(kdev); 110 105 if (kbdev == NULL) { 111 106 printf("%s: Failed allocating device structure for '%s'.\n", 112 107 NAME, kdev->svc_name); 113 108 async_hangup(sess); 114 return -1;109 return ENOMEM; 115 110 } 116 111 117 112 kbdev->sess = sess; 118 119 exch = async_exchange_begin(sess);113 114 async_exch_t *exch = async_exchange_begin(sess); 120 115 if (exch == NULL) { 121 116 printf("%s: Failed starting exchange with '%s'.\n", NAME, 122 117 kdev->svc_name); 123 118 kbdev_destroy(kbdev); 124 return -1;119 return ENOENT; 125 120 } 126 127 rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);121 122 int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev); 128 123 if (rc != EOK) { 129 124 printf("%s: Failed creating callback connection from '%s'.\n", … … 131 126 async_exchange_end(exch); 132 127 kbdev_destroy(kbdev); 133 return -1;128 return rc; 134 129 } 135 130 136 131 async_exchange_end(exch); 137 132 138 133 kdev->ctl_private = (void *) kbdev; 139 134 return 0; … … 142 137 static void kbdev_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 143 138 { 144 async_sess_t *sess; 145 async_exch_t *exch; 146 147 sess = ((kbdev_t *) kdev->ctl_private)->sess; 148 149 exch = async_exchange_begin(sess); 139 async_sess_t *sess = ((kbdev_t *) kdev->ctl_private)->sess; 140 async_exch_t *exch = async_exchange_begin(sess); 150 141 if (!exch) 151 142 return; 152 143 153 144 async_msg_1(exch, KBDEV_SET_IND, mods); 154 145 async_exchange_end(exch); -
uspace/srv/hid/input/generic/input.c
r2f90b46 r3123d2a 662 662 async_set_client_connection(client_connection); 663 663 int rc = loc_server_register(NAME); 664 if (rc < 0) {665 printf("%s: Unable to register server (%d)\n", NAME, rc);666 return -1;664 if (rc != EOK) { 665 printf("%s: Unable to register server\n", NAME); 666 return rc; 667 667 } 668 668 … … 671 671 672 672 service_id_t service_id; 673 if (loc_service_register(kbd, &service_id) != EOK) { 673 rc = loc_service_register(kbd, &service_id); 674 if (rc != EOK) { 674 675 printf("%s: Unable to register service %s\n", NAME, kbd); 675 return -1;676 return rc; 676 677 } 677 678 -
uspace/srv/hid/input/port/adb.c
r2f90b46 r3123d2a 65 65 static int adb_port_init(kbd_dev_t *kdev) 66 66 { 67 kbd_dev = kdev; 68 67 69 const char *dev = "adb/kbd"; 68 70 service_id_t service_id; 69 async_exch_t *exch; 70 int rc; 71 72 kbd_dev = kdev; 73 74 rc = loc_service_get_id(dev, &service_id, 0); 71 int rc = loc_service_get_id(dev, &service_id, 0); 75 72 if (rc != EOK) 76 73 return rc; … … 82 79 } 83 80 84 exch = async_exchange_begin(dev_sess);81 async_exch_t *exch = async_exchange_begin(dev_sess); 85 82 if (exch == NULL) { 86 83 printf("%s: Failed starting exchange with device\n", NAME); … … 89 86 } 90 87 91 /* NB: The callback connection is slotted for removal */92 88 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 89 async_exchange_end(exch); -
uspace/srv/hid/input/proto/mousedev.c
r2f90b46 r3123d2a 117 117 printf("%s: Failed starting session with '%s'\n", NAME, 118 118 mdev->svc_name); 119 return -1;119 return ENOENT; 120 120 } 121 121 … … 125 125 NAME, mdev->svc_name); 126 126 async_hangup(sess); 127 return -1;127 return ENOMEM; 128 128 } 129 129 … … 134 134 mousedev_destroy(mousedev); 135 135 async_hangup(sess); 136 return -1;136 return ENOENT; 137 137 } 138 138 … … 145 145 NAME, mdev->svc_name); 146 146 mousedev_destroy(mousedev); 147 return -1;147 return rc; 148 148 } 149 149 150 return 0;150 return EOK; 151 151 } 152 152 -
uspace/srv/hid/remcons/remcons.c
r2f90b46 r3123d2a 71 71 TELNET_IAC, TELNET_WONT, TELNET_LINEMODE 72 72 }; 73 73 74 static const size_t telnet_force_character_mode_command_count = 74 75 sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t); … … 272 273 static int network_user_fibril(void *arg) 273 274 { 274 int rc;275 275 telnet_user_t *user = arg; 276 276 277 rc = loc_service_register(user->service_name, &user->service_id);277 int rc = loc_service_register(user->service_name, &user->service_id); 278 278 if (rc != EOK) { 279 279 telnet_user_error(user, "Unable to register %s with loc: %s.", … … 284 284 telnet_user_log(user, "Service %s registerd with id %" PRIun ".", 285 285 user->service_name, user->service_id); 286 286 287 287 fid_t spawn_fibril = fibril_create(spawn_task_fibril, user); 288 288 assert(spawn_fibril); 289 289 fibril_add_ready(spawn_fibril); 290 290 291 291 /* Wait for all clients to exit. */ 292 292 fibril_mutex_lock(&user->guard); … … 304 304 } 305 305 fibril_mutex_unlock(&user->guard); 306 306 307 307 rc = loc_service_unregister(user->service_id); 308 308 if (rc != EOK) { … … 324 324 async_set_client_connection(client_connection); 325 325 int rc = loc_server_register(NAME); 326 if (rc < 0) { 327 fprintf(stderr, NAME ": Unable to register server: %s.\n", 328 str_error(rc)); 329 return 1; 330 } 331 326 if (rc != EOK) { 327 fprintf(stderr, "%s: Unable to register server\n", NAME); 328 return rc; 329 } 330 332 331 struct sockaddr_in addr; 333 332 334 333 addr.sin_family = AF_INET; 335 334 addr.sin_port = htons(port); 336 335 337 336 rc = inet_pton(AF_INET, "127.0.0.1", (void *) 338 337 &addr.sin_addr.s_addr); -
uspace/srv/hid/remcons/telnet.h
r2f90b46 r3123d2a 57 57 #define TELNET_LINEMODE 34 58 58 59 60 59 #endif 61 60 -
uspace/srv/hid/remcons/user.h
r2f90b46 r3123d2a 76 76 } telnet_user_t; 77 77 78 telnet_user_t *telnet_user_create(int socket);79 void telnet_user_destroy(telnet_user_t *user);80 telnet_user_t *telnet_user_get_for_client_connection(service_id_t id);81 bool telnet_user_is_zombie(telnet_user_t *user);82 void telnet_user_notify_client_disconnected(telnet_user_t *user);83 int telnet_user_get_next_keyboard_event(telnet_user_t *user, kbd_event_t *event);84 int telnet_user_send_data(telnet_user_t *user, uint8_t *data, size_t size);85 void telnet_user_update_cursor_x(telnet_user_t *user, int new_x);78 extern telnet_user_t *telnet_user_create(int); 79 extern void telnet_user_destroy(telnet_user_t *); 80 extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t); 81 extern bool telnet_user_is_zombie(telnet_user_t *); 82 extern void telnet_user_notify_client_disconnected(telnet_user_t *); 83 extern int telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *); 84 extern int telnet_user_send_data(telnet_user_t *, uint8_t *, size_t); 85 extern void telnet_user_update_cursor_x(telnet_user_t *, int); 86 86 87 87 /** Print informational message about connected user. */ 88 88 #ifdef CONFIG_DEBUG 89 89 #define telnet_user_log(user, fmt, ...) \ 90 printf(NAME " [console %d (%d)]: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__) 90 printf(NAME " [console %d (%d)]: " fmt "\n", \ 91 user->id, (int) user->service_id, ##__VA_ARGS__) 91 92 #else 92 #define telnet_user_log(user, fmt, ...) ( void)093 #define telnet_user_log(user, fmt, ...) ((void) 0) 93 94 #endif 94 95 95 96 /** Print error message associated with connected user. */ 96 97 #define telnet_user_error(user, fmt, ...) \ 97 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__) 98 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \ 99 user->id, (int) user->service_id, ##__VA_ARGS__) 98 100 99 101 #endif -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
r2f90b46 r3123d2a 84 84 int main(int argc, char *argv[]) 85 85 { 86 int rc; 87 88 printf(NAME ": S3C24xx touchscreen driver\n"); 86 printf("%s: S3C24xx touchscreen driver\n", NAME); 89 87 90 88 async_set_client_connection(s3c24xx_ts_connection); 91 rc = loc_server_register(NAME);92 if (rc < 0) {93 printf( NAME ": Unable to register driver.\n");94 return -1;89 int rc = loc_server_register(NAME); 90 if (rc != EOK) { 91 printf("%s: Unable to register driver.\n", NAME); 92 return rc; 95 93 } 96 94
Note:
See TracChangeset
for help on using the changeset viewer.