Changeset 8b71f3e in mainline for uspace/drv/hid/usbhid/usbhid.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.