Changeset b2263e6a in mainline


Ignore:
Timestamp:
2011-01-09T12:44:16Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f724e82
Parents:
0adddea
Message:

Clean up character device client interface.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/hw/misc/virtchar1.c

    r0adddea rb2263e6a  
    7979        size_t i;
    8080        char buffer[BUFFER_SIZE];
    81         read_dev(phone, buffer, BUFFER_SIZE);
     81        char_dev_read(phone, buffer, BUFFER_SIZE);
    8282        TPRINTF(" ...verifying that we read zeroes only...\n");
    8383        for (i = 0; i < BUFFER_SIZE; i++) {
  • uspace/app/tester/hw/serial/serial1.c

    r0adddea rb2263e6a  
    121121        size_t total = 0;
    122122        while (total < cnt) {
    123                 ssize_t read = read_dev(phone, buf, cnt - total);
     123                ssize_t read = char_dev_read(phone, buf, cnt - total);
    124124               
    125125                if (read < 0) {
     
    152152                         * direction of data transfer.
    153153                         */
    154                         ssize_t written = write_dev(phone, buf, read);
     154                        ssize_t written = char_dev_write(phone, buf, read);
    155155                       
    156156                        if (written < 0) {
     
    181181       
    182182        size_t eot_size = str_size(EOT);
    183         ssize_t written = write_dev(phone, (void *) EOT, eot_size);
     183        ssize_t written = char_dev_write(phone, (void *) EOT, eot_size);
    184184       
    185185        ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
  • uspace/lib/c/generic/device/char.c

    r0adddea rb2263e6a  
    4545 * using its character interface.
    4646 *
    47  * @param dev_phone Phone to the device.
    48  * @param buf       Buffer for the data read
    49  *                  from or written to the device.
    50  * @param len       Maximum length of the data to be
    51  *                  read or written.
    52  * @param read      Read from the device if true,
    53  *                  write to it otherwise.
     47 * @param dev_phone     Phone to the device.
     48 * @param buf           Buffer for the data read from or written to the device.
     49 * @param size          Maximum size of data (in bytes) to be read or written.
     50 * @param read          Read from the device if true, write to it otherwise.
    5451 *
    55  * @return Non-negative number of bytes actually read
    56  *         from or written to the device on success,
    57  *         negative error number otherwise.
    58  *
     52 * @return              Non-negative number of bytes actually read from or
     53 *                      written to the device on success, negative error number
     54 *                      otherwise.
    5955 */
    60 static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)
     56static ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read)
    6157{
    6258        async_serialize_start();
     
    6864        if (read) {
    6965                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
    70                     CHAR_READ_DEV, &answer);
    71                 ret = async_data_read_start(dev_phone, buf, len);
     66                    CHAR_DEV_READ, &answer);
     67                ret = async_data_read_start(dev_phone, buf, size);
    7268        } else {
    7369                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
    74                     CHAR_WRITE_DEV, &answer);
    75                 ret = async_data_write_start(dev_phone, buf, len);
     70                    CHAR_DEV_WRITE, &answer);
     71                ret = async_data_write_start(dev_phone, buf, size);
    7672        }
    7773       
     
    9692}
    9793
    98 /** Read from device using its character interface.
     94/** Read from character device.
    9995 *
    100  * @param dev_phone Phone to the device.
    101  * @param buf       Output buffer for the data
    102  *                  read from the device.
    103  * @param len       Maximum length of the data to be read.
     96 * @param dev_phone     Phone to the device.
     97 * @param buf           Output buffer for the data read from the device.
     98 * @param size          Maximum size (in bytes) of the data to be read.
    10499 *
    105  * @return Non-negative number of bytes actually read
    106  *         from the device on success, negative error
    107  *         number otherwise.
    108  *
     100 * @return              Non-negative number of bytes actually read from the
     101 *                      device on success, negative error number otherwise.
    109102 */
    110 ssize_t read_dev(int dev_phone, void *buf, size_t len)
     103ssize_t char_dev_read(int dev_phone, void *buf, size_t size)
    111104{
    112         return rw_dev(dev_phone, buf, len, true);
     105        return char_dev_rw(dev_phone, buf, size, true);
    113106}
    114107
    115 /** Write to device using its character interface.
     108/** Write to character device.
    116109 *
    117  * @param dev_phone Phone to the device.
    118  * @param buf       Input buffer containg the data
    119  *                  to be written to the device.
    120  * @param len       Maximum length of the data to be written.
     110 * @param dev_phone     Phone to the device.
     111 * @param buf           Input buffer containg the data to be written to the
     112 *                      device.
     113 * @param size          Maximum size (in bytes) of the data to be written.
    121114 *
    122  * @return Non-negative number of bytes actually written
    123  *         to the device on success, negative error number
    124  *         otherwise.
    125  *
     115 * @return              Non-negative number of bytes actually written to the
     116 *                      device on success, negative error number otherwise.
    126117 */
    127 ssize_t write_dev(int dev_phone, void *buf, size_t len)
     118ssize_t char_dev_write(int dev_phone, void *buf, size_t size)
    128119{
    129         return rw_dev(dev_phone, buf, len, false);
     120        return char_dev_rw(dev_phone, buf, size, false);
    130121}
    131122
  • uspace/lib/c/include/device/char.h

    r0adddea rb2263e6a  
    3737
    3838typedef enum {
    39         CHAR_READ_DEV = 0,
    40         CHAR_WRITE_DEV
     39        CHAR_DEV_READ = 0,
     40        CHAR_DEV_WRITE
    4141} hw_res_funcs_t;
    4242
    43 ssize_t read_dev(int dev_phone, void *buf, size_t len);
    44 ssize_t write_dev(int dev_phone, void *buf, size_t len);
     43ssize_t char_dev_read(int dev_phone, void *buf, size_t len);
     44ssize_t char_dev_write(int dev_phone, void *buf, size_t len);
    4545
    4646#endif
  • uspace/lib/c/include/ipc/dev_iface.h

    r0adddea rb2263e6a  
    3535#include <libarch/types.h>
    3636
    37 typedef enum { 
    38         HW_RES_DEV_IFACE = 0,   
     37typedef enum {
     38        HW_RES_DEV_IFACE = 0,
    3939        CHAR_DEV_IFACE,
    40         // TODO add more interfaces
    4140        DEV_IFACE_MAX
    4241} dev_inferface_idx_t;
Note: See TracChangeset for help on using the changeset viewer.