Changeset 8b71f3e in mainline for uspace/drv/hid


Ignore:
Timestamp:
2018-01-14T21:16:03Z (8 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
17c1d9db
Parents:
edc51615
git-author:
Petr Manek <petr.manek@…> (2018-01-14 21:16:00)
git-committer:
Petr Manek <petr.manek@…> (2018-01-14 21:16:03)
Message:

usbdev: refactor polling more

For clarity, the opaque usb_device_polling_t and its complementary
configuration data structure usb_device_polling_config_t have been
merged into usb_polling_t. All related methods have dropped the
"device" from their prefix as well.

The usage semantics have transitioned to malloc-free model, where the
user is entirely responsible for (de)allocation of the polling structure
and its data buffer, and (de)initialization happens in designated
functions during its lifetime in the system.

In addition, the distinction between mandatory / optional / internal
parameters has been documented. Optional parameters now have default
values, which are set to sensible constants in order to allow dropping
some lines in USB driver implementations.

The drivers usbhid and usbhub were refactored to match the API
changes.

Location:
uspace/drv/hid/usbhid
Files:
3 edited

Legend:

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

    redc51615 r8b71f3e  
    8989         * This will create a separate fibril that will query the device
    9090         * for the data continuously. */
    91         const usb_device_polling_config_t config = {
    92                 .debug = 1,
    93                 .auto_clear_halt = true,
    94                 .delay = -1,
    95                 .max_failures = 3,
    96                 .on_data = usb_hid_polling_callback,
    97                 .on_polling_end = usb_hid_polling_ended_callback,
    98                 .on_error = usb_hid_polling_error_callback,
    99                 .arg = hid_dev,
    100         };
    101 
    102         rc = usb_device_poll(dev, hid_dev->poll_pipe_mapping, &config,
    103             hid_dev->poll_pipe_mapping->pipe.desc.max_transfer_size, &hid_dev->polling);
     91        rc = usb_polling_start(&hid_dev->polling);
    10492
    10593        if (rc != EOK) {
     
    122110        assert(hid_dev);
    123111
    124         /* Join polling fibril. */
    125         usb_device_poll_join(hid_dev->polling);
     112        /* Join polling fibril (ignoring error code). */
     113        usb_polling_join(&hid_dev->polling);
    126114
    127115        /* Clean up. */
  • uspace/drv/hid/usbhid/usbhid.c

    redc51615 r8b71f3e  
    445445                            ".\n");
    446446                }
     447
     448                usb_polling_t *polling = &hid_dev->polling;
     449                if ((rc = usb_polling_init(polling))) {
     450                        // FIXME
     451                }
     452
     453                polling->device = hid_dev->usb_dev;
     454                polling->ep_mapping = hid_dev->poll_pipe_mapping;
     455                polling->request_size = hid_dev->poll_pipe_mapping->pipe.desc.max_transfer_size;
     456                polling->buffer = malloc(polling->request_size);
     457                polling->on_data = usb_hid_polling_callback,
     458                polling->on_polling_end = usb_hid_polling_ended_callback,
     459                polling->on_error = usb_hid_polling_error_callback,
     460                polling->arg = hid_dev;
    447461        }
    448462
     
    537551        assert(hid_dev->subdrivers != NULL || hid_dev->subdriver_count == 0);
    538552
     553        free(hid_dev->polling.buffer);
     554        usb_polling_fini(&hid_dev->polling);
     555
    539556        usb_log_debug("Subdrivers: %p, subdriver count: %d\n",
    540557            hid_dev->subdrivers, hid_dev->subdriver_count);
  • uspace/drv/hid/usbhid/usbhid.h

    redc51615 r8b71f3e  
    107107        usb_endpoint_mapping_t *poll_pipe_mapping;
    108108
    109         /** Device polling handle. */
    110         usb_device_polling_t *polling;
     109        /** Device polling structure. */
     110        usb_polling_t polling;
    111111
    112112        /** Subdrivers. */
Note: See TracChangeset for help on using the changeset viewer.