Changeset a40dea3 in mainline for uspace/srv/hid/char_mouse/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/char_mouse/chardev.c
r5203e256 ra40dea3 36 36 #include <ipc/char.h> 37 37 #include <async.h> 38 #include <async_obsolete.h>39 38 #include <vfs/vfs.h> 40 39 #include <fcntl.h> 41 40 #include <errno.h> 42 41 #include <devmap.h> 43 #include <devmap_obsolete.h>44 42 #include <char_mouse.h> 45 43 #include <mouse_port.h> … … 47 45 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 48 46 49 static int dev_phone;47 static async_sess_t *dev_sess; 50 48 51 49 #define NAME "char_mouse" … … 54 52 { 55 53 devmap_handle_t handle; 56 int rc = devmap_device_get_handle("char/ps2b", &handle, 54 async_exch_t *exch; 55 int rc; 56 57 rc = devmap_device_get_handle("char/ps2b", &handle, 57 58 IPC_FLAG_BLOCKING); 58 59 … … 62 63 } 63 64 64 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 65 if (dev_phone < 0) { 65 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 66 IPC_FLAG_BLOCKING); 67 if (dev_sess == NULL) { 66 68 printf("%s: Failed connecting to PS/2\n", NAME); 67 69 return ENOENT; 68 70 } 69 71 72 exch = async_exchange_begin(dev_sess); 73 if (exch == NULL) { 74 printf("%s: Failed starting exchange with PS/2\n", NAME); 75 async_hangup(dev_sess); 76 return ENOMEM; 77 } 78 70 79 /* NB: The callback connection is slotted for removal */ 71 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events, 72 NULL) != 0) { 80 rc = async_connect_to_me(exch, 0, 0, 0, chardev_events, NULL); 81 async_exchange_end(exch); 82 83 if (rc != 0) { 73 84 printf(NAME ": Failed to create callback from device\n"); 85 async_hangup(dev_sess); 74 86 return false; 75 87 } … … 88 100 void mouse_port_write(uint8_t data) 89 101 { 90 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 102 async_exch_t *exch = async_exchange_begin(dev_sess); 103 if (exch == NULL) { 104 printf("%s: Failed starting exchange with PS/2\n", NAME); 105 return; 106 } 107 108 async_msg_1(exch, CHAR_WRITE_BYTE, data); 109 110 async_exchange_end(exch); 91 111 } 92 112
Note:
See TracChangeset
for help on using the changeset viewer.