Changeset 3faf416c in mainline


Ignore:
Timestamp:
2011-03-04T17:34:16Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
019cff6
Parents:
5dd9209
Message:

Hack for unplugged USB mouse

Very rough but at least UHCI driver is not polluted by requests to
non-existent device.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmouse/mouse.c

    r5dd9209 r3faf416c  
    3737#include <usb/debug.h>
    3838#include <errno.h>
     39#include <str_error.h>
    3940#include <ipc/mouse.h>
    4041
     
    6465
    6566                size_t actual_size;
     67                int rc;
    6668
    67                 /* FIXME: check for errors. */
    68                 usb_endpoint_pipe_start_session(&mouse->poll_pipe);
     69                /*
     70                 * Error checking note:
     71                 * - failure when starting a session is considered
     72                 *   temporary (e.g. out of phones, next try might succeed)
     73                 * - failure of transfer considered fatal (probably the
     74                 *   device was unplugged)
     75                 * - session closing not checked (shall not fail anyway)
     76                 */
    6977
    70                 usb_endpoint_pipe_read(&mouse->poll_pipe,
     78                rc = usb_endpoint_pipe_start_session(&mouse->poll_pipe);
     79                if (rc != EOK) {
     80                        usb_log_warning("Failed to start session, will try again: %s.\n",
     81                            str_error(rc));
     82                        continue;
     83                }
     84
     85                rc = usb_endpoint_pipe_read(&mouse->poll_pipe,
    7186                    buffer, buffer_size, &actual_size);
    7287
    7388                usb_endpoint_pipe_end_session(&mouse->poll_pipe);
     89
     90                if (rc != EOK) {
     91                        usb_log_error("Failed reading mouse input: %s.\n",
     92                            str_error(rc));
     93                        break;
     94                }
    7495
    7596                uint8_t butt = buffer[0];
     
    115136        }
    116137
     138        /*
     139         * Device was probably unplugged.
     140         * Hang-up the phone to the console.
     141         * FIXME: release allocated memory.
     142         */
     143        async_hangup(mouse->console_phone);
     144        mouse->console_phone = -1;
     145
     146        usb_log_error("Mouse polling fibril terminated.\n");
     147
    117148        return EOK;
    118149}
Note: See TracChangeset for help on using the changeset viewer.