Changeset a40dea3 in mainline for uspace/srv/hid/input/port/chardev.c
- Timestamp:
- 2011-06-20T20:04:39Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a0ff7f4
- Parents:
- 5203e256
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/port/chardev.c
r5203e256 ra40dea3 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include <async_obsolete.h>40 39 #include <input.h> 41 40 #include <kbd_port.h> 42 41 #include <kbd.h> 43 42 #include <devmap.h> 44 #include <devmap_obsolete.h>45 43 #include <errno.h> 46 44 #include <stdio.h> … … 61 59 62 60 static kbd_dev_t *kbd_dev; 63 static int dev_phone;61 static async_sess_t *dev_sess; 64 62 65 63 /** List of devices to try connecting to. */ … … 74 72 { 75 73 devmap_handle_t handle; 74 async_exch_t *exch; 76 75 unsigned int i; 77 76 int rc; … … 90 89 } 91 90 92 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 93 if (dev_phone < 0) { 91 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 92 IPC_FLAG_BLOCKING); 93 if (dev_sess == NULL) { 94 94 printf("%s: Failed connecting to device\n", NAME); 95 95 return ENOENT; 96 96 } 97 97 98 exch = async_exchange_begin(dev_sess); 99 if (exch == NULL) { 100 printf("%s: Failed starting exchange with device\n", NAME); 101 async_hangup(dev_sess); 102 return ENOMEM; 103 } 104 98 105 /* NB: The callback connection is slotted for removal */ 99 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events, 100 NULL) != 0) { 106 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 107 async_exchange_end(exch); 108 109 if (rc != 0) { 101 110 printf(NAME ": Failed to create callback from device\n"); 111 async_hangup(dev_sess); 102 112 return -1; 103 113 } 104 114 105 115 return 0; 106 116 } … … 116 126 static void chardev_port_write(uint8_t data) 117 127 { 118 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 128 async_exch_t *exch = async_exchange_begin(dev_sess); 129 if (exch == NULL) { 130 printf("%s: Failed starting exchange with device\n", NAME); 131 return; 132 } 133 134 async_msg_1(exch, CHAR_WRITE_BYTE, data); 135 async_exchange_end(exch); 119 136 } 120 137
Note:
See TracChangeset
for help on using the changeset viewer.