Changeset 56fd7cf in mainline for uspace/lib/usbdev/src


Ignore:
Timestamp:
2012-08-17T11:37:03Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d5a540
Parents:
be2a38ad
Message:

Make ddf_dev_t and ddf_fun_t opaque. This further tighthens the DDF interface.

Location:
uspace/lib/usbdev/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/devdrv.c

    rbe2a38ad r56fd7cf  
    105105        if (dev == NULL) {
    106106                usb_log_error("USB device `%s' structure allocation failed.\n",
    107                     gen_dev->name);
     107                    ddf_dev_get_name(gen_dev));
    108108                return ENOMEM;
    109109        }
     
    114114        if (rc != EOK) {
    115115                usb_log_error("USB device `%s' init failed (%s): %s.\n",
    116                     gen_dev->name, err_msg, str_error(rc));
     116                    ddf_dev_get_name(gen_dev), err_msg, str_error(rc));
    117117                return rc;
    118118        }
     
    139139                return ENOTSUP;
    140140        /* Just tell the driver to stop whatever it is doing */
    141         usb_device_t *usb_dev = gen_dev->driver_data;
     141        usb_device_t *usb_dev = ddf_dev_data_get(gen_dev);
    142142        const int ret = driver->ops->device_rem(usb_dev);
    143143        if (ret != EOK)
     
    160160        if (driver->ops->device_gone == NULL)
    161161                return ENOTSUP;
    162         usb_device_t *usb_dev = gen_dev->driver_data;
     162        usb_device_t *usb_dev = ddf_dev_data_get(gen_dev);
    163163        const int ret = driver->ops->device_gone(usb_dev);
    164164        if (ret == EOK)
     
    415415        usb_address_t address;
    416416
    417         int rc = usb_get_info_by_handle(ddf_dev->handle,
     417        int rc = usb_get_info_by_handle(ddf_dev_get_handle(ddf_dev),
    418418            &hc_handle, &address, &usb_dev->interface_no);
    419419        if (rc != EOK) {
  • uspace/lib/usbdev/src/devpoll.c

    rbe2a38ad r56fd7cf  
    8080                usb_log_debug("Poll%p: started polling of `%s' - " \
    8181                    "interface %d (%s,%d,%d), %zuB/%zu.\n",
    82                     data, data->dev->ddf_dev->name,
     82                    data, ddf_dev_get_name(data->dev->ddf_dev),
    8383                    (int) mapping->interface->interface_number,
    8484                    usb_str_class(mapping->interface->interface_class),
     
    159159                if (failed) {
    160160                        usb_log_error("Polling of device `%s' terminated: "
    161                             "recurring failures.\n", data->dev->ddf_dev->name);
     161                            "recurring failures.\n", ddf_dev_get_name(
     162                            data->dev->ddf_dev));
    162163                } else {
    163164                        usb_log_debug("Polling of device `%s' terminated: "
    164                             "driver request.\n", data->dev->ddf_dev->name);
     165                            "driver request.\n", ddf_dev_get_name(
     166                            data->dev->ddf_dev));
    165167                }
    166168        }
  • uspace/lib/usbdev/src/hub.c

    rbe2a38ad r56fd7cf  
    6363                return EBADMEM;
    6464        return usb_hc_bind_address(connection,
    65             attached_device->address, attached_device->fun->handle);
     65            attached_device->address, ddf_fun_get_handle(attached_device->fun));
    6666}
    6767
     
    287287        rc = usb_hub_register_device(hc_conn, &new_device);
    288288        if (rc != EOK) {
    289                 /* We know nothing about that data. */
    290                 if (new_dev_data)
    291                         child_fun->driver_data = NULL;
    292289                /* The child function is already created. */
    293290                ddf_fun_destroy(child_fun);
  • uspace/lib/usbdev/src/recognise.c

    rbe2a38ad r56fd7cf  
    3333 * Functions for recognition of attached devices.
    3434 */
     35
     36/** XXX Fix this */
     37#define _DDF_DATA_IMPLANT
    3538
    3639#include <sys/types.h>
     
    352355       
    353356        if (dev_ops != NULL)
    354                 child->ops = dev_ops;
     357                ddf_fun_set_ops(child, dev_ops);
    355358        else
    356                 child->ops = &child_ops;
    357        
    358         child->driver_data = dev_data;
     359                ddf_fun_set_ops(child, &child_ops);
     360       
     361        ddf_fun_data_implant(child, dev_data);
     362       
    359363        /*
    360364         * Store the attached device in fun
     
    373377        }
    374378       
    375         rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
     379        match_id_list_t match_ids;
     380        init_match_ids(&match_ids);
     381        rc = usb_device_create_match_ids(ctrl_pipe, &match_ids);
    376382        if (rc != EOK)
    377383                goto failure;
     384       
     385        list_foreach(match_ids.ids, id_link) {
     386                match_id_t *match_id = list_get_instance(id_link, match_id_t, link);
     387                rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
     388                if (rc != EOK) {
     389                        clean_match_ids(&match_ids);
     390                        goto failure;
     391                }
     392        }
     393       
     394        clean_match_ids(&match_ids);
    378395       
    379396        rc = ddf_fun_bind(child);
     
    386403failure:
    387404        if (child != NULL) {
    388                 /* We know nothing about the data if it came from outside. */
    389                 if (dev_data)
    390                         child->driver_data = NULL;
    391                
    392405                /* This takes care of match_id deallocation as well. */
    393406                ddf_fun_destroy(child);
Note: See TracChangeset for help on using the changeset viewer.