Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/isdv4_tablet/isdv4.c

    r74017ce rc4c6025  
    2727 */
    2828
     29#include <char_dev_iface.h>
    2930#include <errno.h>
    30 #include <io/chardev.h>
    31 #include <mem.h>
    3231#include <stdbool.h>
    3332#include <stdint.h>
    3433#include <stdlib.h>
     34#include <mem.h>
    3535#include <thread.h>
    3636
     
    298298        bool reading = true;
    299299        while (reading) {
    300                 size_t nread;
    301                 int rc;
    302 
    303                 rc = chardev_read(state->chardev, state->buf + state->buf_end,
    304                     state->buf_size - state->buf_end, &nread);
    305                 if (rc != EOK && nread == 0)
     300                ssize_t read = char_dev_read(state->sess, state->buf + state->buf_end,
     301                    state->buf_size - state->buf_end);
     302                if (read < 0)
    306303                        return EIO;
    307                 state->buf_end += nread;
     304                state->buf_end += read;
    308305
    309306                size_t i = 0;
     
    360357        return EOK;
    361358}
    362 
    363 static bool write_command(chardev_t *chardev, uint8_t command)
    364 {
    365         int rc;
    366         size_t nwr;
    367 
    368         rc = chardev_write(chardev, &command, 1, &nwr);
    369         return rc == EOK;
     359static bool write_command(async_sess_t *sess, uint8_t command)
     360{
     361        return char_dev_write(sess, &command, 1) == 1;
    370362}
    371363
     
    373365    isdv4_event_fn event_fn)
    374366{
    375         chardev_t *chardev;
    376         int rc;
    377 
    378         rc = chardev_open(sess, &chardev);
    379         if (rc != EOK)
    380                 return rc;
    381 
    382367        memset(state, 0, sizeof(isdv4_state_t));
    383 
    384368        state->sess = sess;
    385         state->chardev = chardev;
    386 
    387369        state->buf = malloc(BUF_SIZE);
    388         if (state->buf == NULL) {
    389                 chardev_close(chardev);
     370        if (state->buf == NULL)
    390371                return ENOMEM;
    391         }
    392 
    393372        state->buf_size = BUF_SIZE;
    394373        state->emit_event_fn = event_fn;
     
    398377int isdv4_init_tablet(isdv4_state_t *state)
    399378{
    400         if (!write_command(state->chardev, CMD_STOP))
     379        if (!write_command(state->sess, CMD_STOP))
    401380                return EIO;
    402381
     
    404383
    405384        // FIXME: Read all possible garbage before sending commands
    406         if (!write_command(state->chardev, CMD_QUERY_STYLUS))
     385        if (!write_command(state->sess, CMD_QUERY_STYLUS))
    407386                return EIO;
    408387
     
    411390                return rc;
    412391
    413         if (!write_command(state->chardev, CMD_QUERY_TOUCH))
     392        if (!write_command(state->sess, CMD_QUERY_TOUCH))
    414393                return EIO;
    415394
     
    418397                return rc;
    419398
    420         if (!write_command(state->chardev, CMD_START))
     399        if (!write_command(state->sess, CMD_START))
    421400                return EIO;
    422401
Note: See TracChangeset for help on using the changeset viewer.