Changeset 8e9becf6 in mainline for uspace/drv/usbmouse/mouse.c


Ignore:
Timestamp:
2011-03-08T20:00:47Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
021351c
Parents:
0588062e (diff), d2fc1c2 (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:

Merged branch lelian/hidd

File:
1 edited

Legend:

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

    r0588062e r8e9becf6  
    3737#include <usb/debug.h>
    3838#include <errno.h>
     39#include <str_error.h>
    3940#include <ipc/mouse.h>
    4041
     42/** Fibril function for polling the mouse device.
     43 *
     44 * This function shall not terminate unless the device breaks and fails
     45 * to send data (e.g. stalls on data request).
     46 *
     47 * @param arg ddf_dev_t type representing the mouse device.
     48 * @return EOK Always.
     49 */
    4150int usb_mouse_polling_fibril(void *arg)
    4251{
     
    6473
    6574                size_t actual_size;
     75                int rc;
    6676
    67                 /* FIXME: check for errors. */
    68                 usb_endpoint_pipe_start_session(&mouse->poll_pipe);
     77                /*
     78                 * Error checking note:
     79                 * - failure when starting a session is considered
     80                 *   temporary (e.g. out of phones, next try might succeed)
     81                 * - failure of transfer considered fatal (probably the
     82                 *   device was unplugged)
     83                 * - session closing not checked (shall not fail anyway)
     84                 */
    6985
    70                 usb_endpoint_pipe_read(&mouse->poll_pipe,
     86                rc = usb_endpoint_pipe_start_session(&mouse->poll_pipe);
     87                if (rc != EOK) {
     88                        usb_log_warning("Failed to start session, will try again: %s.\n",
     89                            str_error(rc));
     90                        continue;
     91                }
     92
     93                rc = usb_endpoint_pipe_read(&mouse->poll_pipe,
    7194                    buffer, buffer_size, &actual_size);
    7295
    7396                usb_endpoint_pipe_end_session(&mouse->poll_pipe);
     97
     98                if (rc != EOK) {
     99                        usb_log_error("Failed reading mouse input: %s.\n",
     100                            str_error(rc));
     101                        break;
     102                }
     103
     104                usb_log_debug2("got buffer: %s.\n",
     105                    usb_debug_str_buffer(buffer, buffer_size, 0));
    74106
    75107                uint8_t butt = buffer[0];
     
    115147        }
    116148
     149        /*
     150         * Device was probably unplugged.
     151         * Hang-up the phone to the console.
     152         * FIXME: release allocated memory.
     153         */
     154        async_hangup(mouse->console_phone);
     155        mouse->console_phone = -1;
     156
     157        usb_log_error("Mouse polling fibril terminated.\n");
     158
    117159        return EOK;
    118160}
Note: See TracChangeset for help on using the changeset viewer.