Changeset 7dddd7b in mainline for uspace/drv/hid/usbhid/main.c


Ignore:
Timestamp:
2018-01-13T20:47:58Z (6 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
71f211f
Parents:
2489353
git-author:
Petr Manek <petr.manek@…> (2018-01-13 19:20:41)
git-committer:
Petr Manek <petr.manek@…> (2018-01-13 20:47:58)
Message:

usbdev: refactor polling

Until now, device polling had to be executed by calling one of four
proxy functions, which served as a syntax sugar and had no clear
distinction between each other (not to mention misleading names and high
number of arguments).

In this commit, the four mentioned functions are discarded in favor of
one main function, which was proxied by them either way. The number of
arguments have decreased in favor of named struct fields in the auto
polling config structure.

Drivers, which make use of polling, such as usbhid and usbhub were
updated to the latest API design.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/usbhid/main.c

    r2489353 r7dddd7b  
    9090         * This will create a separate fibril that will query the device
    9191         * for the data continuously. */
    92         rc = usb_device_auto_poll_desc(dev,
    93            /* Index of the polling pipe. */
    94            hid_dev->poll_pipe_mapping->description,
    95            /* Callback when data arrives. */
    96            usb_hid_polling_callback,
    97            /* How much data to request. */
    98            hid_dev->poll_pipe_mapping->pipe.desc.max_transfer_size,
    99            /* Delay */
    100            -1,
    101            /* Callback when the polling fails. */
    102            usb_hid_polling_error_callback,
    103            /* Callback when the polling ends. */
    104            usb_hid_polling_ended_callback,
    105            /* Custom argument. */
    106            hid_dev);
     92        const usb_device_auto_polling_t auto_polling = {
     93                .debug = 1,
     94                .auto_clear_halt = true,
     95                .delay = -1,
     96                .max_failures = 3,
     97                .on_data = usb_hid_polling_callback,
     98                .on_polling_end = usb_hid_polling_ended_callback,
     99                .on_error = usb_hid_polling_error_callback,
     100                .arg = hid_dev,
     101        };
     102
     103        rc = usb_device_auto_polling(dev, hid_dev->poll_pipe_mapping,
     104            &auto_polling, hid_dev->poll_pipe_mapping->pipe.desc.max_transfer_size);
    107105
    108106        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.