Ignore:
Timestamp:
2011-06-10T10:14:26Z (14 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab547063
Parents:
9536e6e (diff), 390d80d (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.
Message:

Merge mainline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/char_dev.c

    r9536e6e r41811af  
    4545 * using its character interface.
    4646 *
    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.
     47 * @param sess Session 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.
    5151 *
    52  * @return              Non-negative number of bytes actually read from or
    53  *                      written to the device on success, negative error number
    54  *                      otherwise.
     52 * @return Non-negative number of bytes actually read from or
     53 *         written to the device on success, negative error number
     54 *         otherwise.
     55 *
    5556 */
    56 static ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read)
     57static ssize_t char_dev_rw(async_sess_t *sess, void *buf, size_t size, bool read)
    5758{
    58         async_serialize_start();
    59        
    6059        ipc_call_t answer;
    6160        aid_t req;
    6261        int ret;
    6362       
     63        async_exch_t *exch = async_exchange_begin(sess);
     64       
    6465        if (read) {
    65                 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
     66                req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE),
    6667                    CHAR_DEV_READ, &answer);
    67                 ret = async_data_read_start(dev_phone, buf, size);
     68                ret = async_data_read_start(exch, buf, size);
    6869        } else {
    69                 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
     70                req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE),
    7071                    CHAR_DEV_WRITE, &answer);
    71                 ret = async_data_write_start(dev_phone, buf, size);
     72                ret = async_data_write_start(exch, buf, size);
    7273        }
     74       
     75        async_exchange_end(exch);
    7376       
    7477        sysarg_t rc;
    7578        if (ret != EOK) {
    7679                async_wait_for(req, &rc);
    77                 async_serialize_end();
    7880                if (rc == EOK)
    7981                        return (ssize_t) ret;
     
    8385       
    8486        async_wait_for(req, &rc);
    85         async_serialize_end();
    8687       
    8788        ret = (int) rc;
     
    9495/** Read from character device.
    9596 *
    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.
     97 * @param sess Session to the device.
     98 * @param buf  Output buffer for the data read from the device.
     99 * @param size Maximum size (in bytes) of the data to be read.
    99100 *
    100  * @return              Non-negative number of bytes actually read from the
    101  *                      device on success, negative error number otherwise.
     101 * @return Non-negative number of bytes actually read from the
     102 *         device on success, negative error number otherwise.
     103 *
    102104 */
    103 ssize_t char_dev_read(int dev_phone, void *buf, size_t size)
     105ssize_t char_dev_read(async_sess_t *sess, void *buf, size_t size)
    104106{
    105         return char_dev_rw(dev_phone, buf, size, true);
     107        return char_dev_rw(sess, buf, size, true);
    106108}
    107109
    108110/** Write to character device.
    109111 *
    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.
     112 * @param sess Session to the device.
     113 * @param buf  Input buffer containg the data to be written to the
     114 *             device.
     115 * @param size Maximum size (in bytes) of the data to be written.
    114116 *
    115  * @return              Non-negative number of bytes actually written to the
    116  *                      device on success, negative error number otherwise.
     117 * @return Non-negative number of bytes actually written to the
     118 *         device on success, negative error number otherwise.
     119 *
    117120 */
    118 ssize_t char_dev_write(int dev_phone, void *buf, size_t size)
     121ssize_t char_dev_write(async_sess_t *sess, void *buf, size_t size)
    119122{
    120         return char_dev_rw(dev_phone, buf, size, false);
     123        return char_dev_rw(sess, buf, size, false);
    121124}
    122125
Note: See TracChangeset for help on using the changeset viewer.