Changeset eb1a2f4 in mainline for uspace/drv/usbmid/usbmid.c


Ignore:
Timestamp:
2011-02-22T23:30:56Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5d1535, a9c674e0
Parents:
dbe25f1 (diff), 664af708 (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:

Merge mainline changes (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmid/usbmid.c

    rdbe25f1 reb1a2f4  
    4545
    4646/** Callback for DDF USB interface. */
    47 static int usb_iface_get_address_impl(device_t *device, devman_handle_t handle,
     47static int usb_iface_get_address_impl(ddf_fun_t *fun, devman_handle_t handle,
    4848    usb_address_t *address)
    4949{
    50         assert(device);
    51         device_t *parent = device->parent;
    52 
    53         /* Default error, device does not support this operation. */
    54         int rc = ENOTSUP;
    55 
    56         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    57                 usb_iface_t *usb_iface
    58                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    59                 assert(usb_iface != NULL);
    60 
    61                 if (usb_iface->get_address) {
    62                         rc = usb_iface->get_address(parent, parent->handle,
    63                             address);
    64                 }
    65         }
    66 
    67         return rc;
     50        return usb_iface_get_address_hub_impl(fun, handle, address);
    6851}
    6952
    7053/** Callback for DDF USB interface. */
    71 static int usb_iface_get_interface_impl(device_t *device, devman_handle_t handle,
     54static int usb_iface_get_interface_impl(ddf_fun_t *fun, devman_handle_t handle,
    7255    int *iface_no)
    7356{
    74         assert(device);
    75 
    76         usbmid_interface_t *iface = device->driver_data;
     57        assert(fun);
     58
     59        usbmid_interface_t *iface = fun->driver_data;
    7760        assert(iface);
    7861
     
    9174
    9275
    93 static device_ops_t child_device_ops = {
     76static ddf_dev_ops_t child_device_ops = {
    9477        .interfaces[USB_DEV_IFACE] = &child_usb_iface
    9578};
    9679
    97 static device_ops_t mid_device_ops = {
     80static ddf_dev_ops_t mid_device_ops = {
    9881        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
    9982};
     
    10588 * @retval NULL Error occured.
    10689 */
    107 usbmid_device_t *usbmid_device_create(device_t *dev)
     90usbmid_device_t *usbmid_device_create(ddf_dev_t *dev)
    10891{
    10992        usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));
     
    133116
    134117        mid->dev = dev;
    135         dev->ops = &mid_device_ops;
     118        (void) &mid_device_ops;
    136119
    137120        return mid;
     
    145128 * @retval NULL Error occured.
    146129 */
    147 usbmid_interface_t *usbmid_interface_create(device_t *dev, int iface_no)
     130usbmid_interface_t *usbmid_interface_create(ddf_fun_t *fun, int iface_no)
    148131{
    149132        usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
     
    154137        }
    155138
    156         iface->dev = dev;
     139        iface->fun = fun;
    157140        iface->interface_no = iface_no;
    158141
     
    172155    const usb_standard_interface_descriptor_t *interface_descriptor)
    173156{
    174         device_t *child = NULL;
     157        ddf_fun_t *child = NULL;
    175158        char *child_name = NULL;
    176159        usbmid_interface_t *child_as_interface = NULL;
    177160        int rc;
    178 
    179         /* Create the device. */
    180         child = create_device();
    181         if (child == NULL) {
    182                 rc = ENOMEM;
    183                 goto error_leave;
    184         }
    185161
    186162        /*
     
    196172        }
    197173
     174        /* Create the device. */
     175        child = ddf_fun_create(parent->dev, fun_inner, child_name);
     176        if (child == NULL) {
     177                rc = ENOMEM;
     178                goto error_leave;
     179        }
     180
     181
     182
    198183        child_as_interface = usbmid_interface_create(child,
    199184            (int) interface_descriptor->interface_number);
     
    204189
    205190        child->driver_data = child_as_interface;
    206         child->parent = parent->dev;
    207         child->name = child_name;
    208191        child->ops = &child_device_ops;
    209192
     
    215198        }
    216199
    217         rc = child_device_register(child, parent->dev);
     200        rc = ddf_fun_bind(child);
    218201        if (rc != EOK) {
    219202                goto error_leave;
     
    226209                child->name = NULL;
    227210                /* This takes care of match_id deallocation as well. */
    228                 delete_device(child);
     211                ddf_fun_destroy(child);
    229212        }
    230213        if (child_name != NULL) {
Note: See TracChangeset for help on using the changeset viewer.