Changes in uspace/srv/hid/isdv4_tablet/isdv4.c [74017ce:c4c6025] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/isdv4_tablet/isdv4.c
r74017ce rc4c6025 27 27 */ 28 28 29 #include <char_dev_iface.h> 29 30 #include <errno.h> 30 #include <io/chardev.h>31 #include <mem.h>32 31 #include <stdbool.h> 33 32 #include <stdint.h> 34 33 #include <stdlib.h> 34 #include <mem.h> 35 35 #include <thread.h> 36 36 … … 298 298 bool reading = true; 299 299 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) 306 303 return EIO; 307 state->buf_end += nread;304 state->buf_end += read; 308 305 309 306 size_t i = 0; … … 360 357 return EOK; 361 358 } 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; 359 static bool write_command(async_sess_t *sess, uint8_t command) 360 { 361 return char_dev_write(sess, &command, 1) == 1; 370 362 } 371 363 … … 373 365 isdv4_event_fn event_fn) 374 366 { 375 chardev_t *chardev;376 int rc;377 378 rc = chardev_open(sess, &chardev);379 if (rc != EOK)380 return rc;381 382 367 memset(state, 0, sizeof(isdv4_state_t)); 383 384 368 state->sess = sess; 385 state->chardev = chardev;386 387 369 state->buf = malloc(BUF_SIZE); 388 if (state->buf == NULL) { 389 chardev_close(chardev); 370 if (state->buf == NULL) 390 371 return ENOMEM; 391 }392 393 372 state->buf_size = BUF_SIZE; 394 373 state->emit_event_fn = event_fn; … … 398 377 int isdv4_init_tablet(isdv4_state_t *state) 399 378 { 400 if (!write_command(state-> chardev, CMD_STOP))379 if (!write_command(state->sess, CMD_STOP)) 401 380 return EIO; 402 381 … … 404 383 405 384 // 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)) 407 386 return EIO; 408 387 … … 411 390 return rc; 412 391 413 if (!write_command(state-> chardev, CMD_QUERY_TOUCH))392 if (!write_command(state->sess, CMD_QUERY_TOUCH)) 414 393 return EIO; 415 394 … … 418 397 return rc; 419 398 420 if (!write_command(state-> chardev, CMD_START))399 if (!write_command(state->sess, CMD_START)) 421 400 return EIO; 422 401
Note:
See TracChangeset
for help on using the changeset viewer.