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