Changeset cf2af94 in mainline for uspace/lib/drv/generic/remote_char_dev.c
- Timestamp:
- 2011-02-09T11:46:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cb15135a
- Parents:
- a49c4002 (diff), 0b37882 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_char_dev.c
ra49c4002 rcf2af94 33 33 */ 34 34 35 #include <ipc/ipc.h>36 35 #include <async.h> 37 36 #include <errno.h> 38 37 39 #include " char.h"38 #include "ops/char_dev.h" 40 39 #include "driver.h" 41 40 … … 46 45 47 46 /** Remote character interface operations. */ 48 static remote_iface_func_ptr_t remote_char_ iface_ops[] = {47 static remote_iface_func_ptr_t remote_char_dev_iface_ops[] = { 49 48 &remote_char_read, 50 49 &remote_char_write … … 56 55 * character interface. 57 56 */ 58 remote_iface_t remote_char_ iface = {59 .method_count = sizeof(remote_char_ iface_ops) /57 remote_iface_t remote_char_dev_iface = { 58 .method_count = sizeof(remote_char_dev_iface_ops) / 60 59 sizeof(remote_iface_func_ptr_t), 61 .methods = remote_char_ iface_ops60 .methods = remote_char_dev_iface_ops 62 61 }; 63 62 … … 69 68 * 70 69 * @param dev The device from which the data are read. 71 * @param iface The local interfacestructure.70 * @param ops The local ops structure. 72 71 */ 73 72 static void 74 remote_char_read(device_t *dev, void * iface, ipc_callid_t callid,73 remote_char_read(device_t *dev, void *ops, ipc_callid_t callid, 75 74 ipc_call_t *call) 76 { 77 char_ iface_t *char_iface = (char_iface_t *) iface;75 { 76 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 78 77 ipc_callid_t cid; 79 78 … … 81 80 if (!async_data_read_receive(&cid, &len)) { 82 81 /* TODO handle protocol error. */ 83 ipc_answer_0(callid, EINVAL);82 async_answer_0(callid, EINVAL); 84 83 return; 85 84 } 86 85 87 if (!char_ iface->read) {86 if (!char_dev_ops->read) { 88 87 async_data_read_finalize(cid, NULL, 0); 89 ipc_answer_0(callid, ENOTSUP);88 async_answer_0(callid, ENOTSUP); 90 89 return; 91 90 } … … 95 94 96 95 char buf[MAX_CHAR_RW_COUNT]; 97 int ret = (*char_ iface->read)(dev, buf, len);96 int ret = (*char_dev_ops->read)(dev, buf, len); 98 97 99 98 if (ret < 0) { 100 99 /* Some error occured. */ 101 100 async_data_read_finalize(cid, buf, 0); 102 ipc_answer_0(callid, ret);101 async_answer_0(callid, ret); 103 102 return; 104 103 } … … 106 105 /* The operation was successful, return the number of data read. */ 107 106 async_data_read_finalize(cid, buf, ret); 108 ipc_answer_1(callid, EOK, ret);107 async_answer_1(callid, EOK, ret); 109 108 } 110 109 … … 116 115 * 117 116 * @param dev The device to which the data are written. 118 * @param iface The local interfacestructure.117 * @param ops The local ops structure. 119 118 */ 120 119 static void 121 remote_char_write(device_t *dev, void * iface, ipc_callid_t callid,120 remote_char_write(device_t *dev, void *ops, ipc_callid_t callid, 122 121 ipc_call_t *call) 123 122 { 124 char_ iface_t *char_iface = (char_iface_t *) iface;123 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 125 124 ipc_callid_t cid; 126 125 size_t len; … … 128 127 if (!async_data_write_receive(&cid, &len)) { 129 128 /* TODO handle protocol error. */ 130 ipc_answer_0(callid, EINVAL);129 async_answer_0(callid, EINVAL); 131 130 return; 132 131 } 133 132 134 if (!char_ iface->write) {133 if (!char_dev_ops->write) { 135 134 async_data_write_finalize(cid, NULL, 0); 136 ipc_answer_0(callid, ENOTSUP);135 async_answer_0(callid, ENOTSUP); 137 136 return; 138 } 137 } 139 138 140 139 if (len > MAX_CHAR_RW_COUNT) … … 145 144 async_data_write_finalize(cid, buf, len); 146 145 147 int ret = (*char_ iface->write)(dev, buf, len);146 int ret = (*char_dev_ops->write)(dev, buf, len); 148 147 if (ret < 0) { 149 148 /* Some error occured. */ 150 ipc_answer_0(callid, ret);149 async_answer_0(callid, ret); 151 150 } else { 152 151 /* … … 154 153 * written. 155 154 */ 156 ipc_answer_1(callid, EOK, ret);155 async_answer_1(callid, EOK, ret); 157 156 } 158 157 }
Note:
See TracChangeset
for help on using the changeset viewer.