Changeset c657bd7 in mainline for uspace/lib/c/generic/io/chardev.c
- Timestamp:
- 2017-11-20T10:06:59Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19ea61d
- Parents:
- 5d50c419
- git-author:
- Jiri Svoboda <jiri@…> (2017-11-19 22:05:26)
- git-committer:
- Jiri Svoboda <jiri@…> (2017-11-20 10:06:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/chardev.c
r5d50c419 rc657bd7 77 77 } 78 78 79 int chardev_read(chardev_t *chardev, void *data, size_t size, size_t *nread) 79 /** Read from character device. 80 * 81 * Read as much data as is available from character device up to @a size 82 * bytes into @a buf. On success EOK is returned and at least one byte 83 * is read (if no byte is available the function blocks). The number 84 * of bytes read is stored in @a *nread. 85 * 86 * On error a non-zero error code is returned and @a *nread is filled with 87 * the number of bytes that were successfully transferred. 88 * 89 * @param chardev Character device 90 * @param buf Destination buffer 91 * @param size Maximum number of bytes to read 92 * @param nread Place to store actual number of bytes read 93 * 94 * @return EOK on success or non-zero error code 95 */ 96 int chardev_read(chardev_t *chardev, void *buf, size_t size, size_t *nread) 80 97 { 81 98 if (size > 4 * sizeof(sysarg_t)) … … 88 105 async_exchange_end(exch); 89 106 if (ret > 0 && (size_t)ret <= size) 90 memcpy( data, message, size);107 memcpy(buf, message, size); 91 108 92 109 if (ret < 0) { … … 99 116 } 100 117 118 /** Write to character device. 119 * 120 * Write @a size bytes from @a data to character device. On success EOK 121 * is returned, all bytes were written and @a *nwritten is set to @a size. 122 * 123 * On error a non-zero error code is returned and @a *nwritten is filled with 124 * the number of bytes that were successfully transferred. 125 * 126 * @param chardev Character device 127 * @param buf Destination buffer 128 * @param size Maximum number of bytes to read 129 * @param nwritten Place to store actual number of bytes written 130 * 131 * @return EOK on success or non-zero error code 132 */ 101 133 int chardev_write(chardev_t *chardev, const void *data, size_t size, 102 134 size_t *nwritten)
Note:
See TracChangeset
for help on using the changeset viewer.