Changeset 1f1fa64 in mainline


Ignore:
Timestamp:
2014-07-28T21:53:11Z (10 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3b25985, f2f4c00
Parents:
cbfece7 (diff), 7eb6c96 (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:

Make MAC address change possible on ethip side. Merge mainline changes.

Location:
uspace
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    rcbfece7 r1f1fa64  
    193193        instance->rh.address = 1;
    194194        rc = usb_device_manager_request_address(
    195             &instance->generic.dev_manager, &instance->rh.address, false,
     195            &instance->generic->dev_manager, &instance->rh.address, false,
    196196            USB_SPEED_FULL);
    197197        if (rc != EOK) {
     
    204204
    205205        rc = usb_endpoint_manager_add_ep(
    206             &instance->generic.ep_manager, instance->rh.address, 0,
     206            &instance->generic->ep_manager, instance->rh.address, 0,
    207207            USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
    208208            0, NULL, NULL);
     
    231231        fun_bound = true;
    232232
    233         rc = usb_device_manager_bind_address(&instance->generic.dev_manager,
     233        rc = usb_device_manager_bind_address(&instance->generic->dev_manager,
    234234            instance->rh.address, ddf_fun_get_handle(hub_fun));
    235235        if (rc != EOK) {
     
    244244        if (ep_added) {
    245245                usb_endpoint_manager_remove_ep(
    246                     &instance->generic.ep_manager, instance->rh.address, 0,
     246                    &instance->generic->ep_manager, instance->rh.address, 0,
    247247                    USB_DIRECTION_BOTH, NULL, NULL);
    248248        }
    249249        if (addr_reqd) {
    250250                usb_device_manager_release_address(
    251                     &instance->generic.dev_manager, instance->rh.address);
     251                    &instance->generic->dev_manager, instance->rh.address);
    252252        }
    253253        return rc;
     
    257257 *
    258258 * @param[in] instance Memory place for the structure.
     259 * @param[in] HC function node
    259260 * @param[in] regs Device's I/O registers range.
    260261 * @param[in] interrupts True if w interrupts should be used
    261262 * @return Error code
    262263 */
    263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     264int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts)
    264265{
    265266        assert(instance);
     
    274275        list_initialize(&instance->pending_batches);
    275276
    276         hcd_init(&instance->generic, USB_SPEED_FULL,
     277        instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t));
     278        if (instance->generic == NULL) {
     279                usb_log_error("Out of memory.\n");
     280                return ENOMEM;
     281        }
     282
     283        hcd_init(instance->generic, USB_SPEED_FULL,
    277284            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    278         instance->generic.private_data = instance;
    279         instance->generic.schedule = hc_schedule;
    280         instance->generic.ep_add_hook = ohci_endpoint_init;
    281         instance->generic.ep_remove_hook = ohci_endpoint_fini;
     285        instance->generic->private_data = instance;
     286        instance->generic->schedule = hc_schedule;
     287        instance->generic->ep_add_hook = ohci_endpoint_init;
     288        instance->generic->ep_remove_hook = ohci_endpoint_fini;
    282289
    283290        rc = hc_init_memory(instance);
  • uspace/drv/bus/usb/ohci/hc.h

    rcbfece7 r1f1fa64  
    3535#define DRV_OHCI_HC_H
    3636
     37#include <ddf/driver.h>
    3738#include <ddf/interrupt.h>
    3839#include <fibril.h>
     
    5354typedef struct hc {
    5455        /** Generic USB hc driver */
    55         hcd_t generic;
     56        hcd_t *generic;
    5657
    5758        /** Memory mapped I/O registers area */
     
    7980int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int,
    8081    interrupt_handler_t);
    81 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    82 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
     82int hc_register_hub(hc_t *, ddf_fun_t *);
     83int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool);
    8384
    8485/** Safely dispose host controller internal structures
  • uspace/drv/bus/usb/ohci/ohci.c

    rcbfece7 r1f1fa64  
    3434 */
    3535
    36 /* XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    38 
    3936#include <errno.h>
    4037#include <str_error.h>
     
    165162
    166163        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    167         ddf_fun_data_implant(instance->hc_fun, &instance->hc);
    168164
    169165        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
     
    214210        }
    215211
    216         rc = hc_init(&instance->hc, &regs, interrupts);
     212        rc = hc_init(&instance->hc, instance->hc_fun, &regs, interrupts);
    217213        if (rc != EOK) {
    218214                usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc));
  • uspace/drv/bus/usb/uhci/hc.c

    rcbfece7 r1f1fa64  
    230230 *
    231231 * @param[in] instance Memory place to initialize.
     232 * @param[in] HC function node
    232233 * @param[in] regs Range of device's I/O control registers.
    233234 * @param[in] interrupts True if hw interrupts should be used.
     
    238239 * interrupt fibrils.
    239240 */
    240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     241int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts)
    241242{
    242243        assert(regs->size >= sizeof(uhci_regs_t));
     
    266267        }
    267268
    268         hcd_init(&instance->generic, USB_SPEED_FULL,
     269        instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t));
     270        if (instance->generic == NULL) {
     271                usb_log_error("Out of memory.\n");
     272                return ENOMEM;
     273        }
     274
     275        hcd_init(instance->generic, USB_SPEED_FULL,
    269276            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    270277
    271         instance->generic.private_data = instance;
    272         instance->generic.schedule = hc_schedule;
    273         instance->generic.ep_add_hook = NULL;
     278        instance->generic->private_data = instance;
     279        instance->generic->schedule = hc_schedule;
     280        instance->generic->ep_add_hook = NULL;
    274281
    275282        hc_init_hw(instance);
  • uspace/drv/bus/usb/uhci/hc.h

    rcbfece7 r1f1fa64  
    3636#define DRV_UHCI_HC_H
    3737
     38#include <ddf/driver.h>
    3839#include <ddf/interrupt.h>
    3940#include <device/hw_res_parsed.h>
     
    9394typedef struct hc {
    9495        /** Generic HCD driver structure */
    95         hcd_t generic;
     96        hcd_t *generic;
    9697
    9798        /** Addresses of I/O registers */
     
    126127    addr_range_t *);
    127128void hc_interrupt(hc_t *instance, uint16_t status);
    128 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);
     129int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool);
    129130
    130131/** Safely dispose host controller internal structures
  • uspace/drv/bus/usb/uhci/uhci.c

    rcbfece7 r1f1fa64  
    3434 */
    3535
    36 /* XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    38 
    3936#include <errno.h>
    4037#include <stdbool.h>
     
    6259        hc_t hc;
    6360        /** Internal driver's representation of UHCI root hub */
    64         rh_t rh;
     61        rh_t *rh;
    6562} uhci_t;
    6663
     
    186183
    187184        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    188         ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);
    189185
    190186        instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh");
     
    196192
    197193        ddf_fun_set_ops(instance->rh_fun, &rh_ops);
    198         ddf_fun_data_implant(instance->rh_fun, &instance->rh);
     194        instance->rh = ddf_fun_data_alloc(instance->rh_fun, sizeof(rh_t));
    199195
    200196        addr_range_t regs;
     
    236232        }
    237233
    238         rc = hc_init(&instance->hc, &regs, interrupts);
     234        rc = hc_init(&instance->hc, instance->hc_fun, &regs, interrupts);
    239235        if (rc != EOK) {
    240236                usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc));
     
    260256        }
    261257
    262         rc = rh_init(&instance->rh, instance->rh_fun, &regs, 0x10, 4);
     258        rc = rh_init(instance->rh, instance->rh_fun, &regs, 0x10, 4);
    263259        if (rc != EOK) {
    264260                usb_log_error("Failed to setup UHCI root hub: %s.\n",
  • uspace/drv/bus/usb/uhcirh/port.c

    rcbfece7 r1f1fa64  
    269269        int ret, count = MAX_ERROR_COUNT;
    270270        do {
    271                 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
     271                port->attached_device.fun = ddf_fun_create(port->rh, fun_inner,
     272                    NULL);
     273                if (port->attached_device.fun == NULL) {
     274                        ret = ENOMEM;
     275                        continue;
     276                }
     277
     278                ret = usb_hc_new_device_wrapper(port->rh,
     279                    port->attached_device.fun,
     280                    &port->hc_connection,
    272281                    speed, uhci_port_reset_enable, port,
    273                     &port->attached_device.address, NULL, NULL,
    274                     &port->attached_device.fun);
     282                    &port->attached_device.address, NULL);
     283
     284                if (ret != EOK) {
     285                        ddf_fun_destroy(port->attached_device.fun);
     286                        port->attached_device.fun = NULL;
     287                }
     288
    275289        } while (ret != EOK && count-- > 0);
    276290
  • uspace/drv/bus/usb/usbhid/usbhid.c

    rcbfece7 r1f1fa64  
    415415        }
    416416
    417         /*
    418          * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da
    419          *    do nej.
    420          * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi
    421          *    vyplnenu strukturu usbhid_iface_t.
    422          * 3) klientska aplikacia - musi si rucne vytvorit telefon
    423          *    (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az
    424          *    k tej fcii.
    425          *    pouzit usb/classes/hid/iface.h - prvy int je telefon
    426          */
     417        /* Initialize subdrivers */
    427418        bool ok = false;
    428419        for (unsigned i = 0; i < hid_dev->subdriver_count; ++i) {
  • uspace/drv/bus/usb/usbhub/port.c

    rcbfece7 r1f1fa64  
    424424        ddf_fun_t *child_fun;
    425425
     426        child_fun = ddf_fun_create(data->hub->usb_device->ddf_dev,
     427            fun_inner, NULL);
     428        if (child_fun == NULL)
     429                return ENOMEM;
     430
    426431        const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
    427             &data->hub->usb_device->hc_conn, data->speed, enable_port_callback,
    428             data->port, &new_address, NULL, NULL, &child_fun);
     432            child_fun, &data->hub->usb_device->hc_conn, data->speed,
     433            enable_port_callback, data->port, &new_address, NULL);
    429434
    430435        if (rc == EOK) {
     
    440445                    ddf_fun_get_handle(child_fun));
    441446        } else {
     447                ddf_fun_destroy(child_fun);
    442448                usb_log_error("Failed registering device on port %zu: %s.\n",
    443449                    data->port->port_number, str_error(rc));
  • uspace/drv/bus/usb/usbmid/explore.c

    rcbfece7 r1f1fa64  
    3434 * Exploration of available interfaces in the USB device.
    3535 */
     36#include <ddf/driver.h>
    3637#include <errno.h>
    3738#include <str_error.h>
     
    7071 * @param config_descriptor_size Size of configuration descriptor in bytes.
    7172 * @param list List where to add the interfaces.
    72  */
    73 static void create_interfaces(const uint8_t *config_descriptor,
    74     size_t config_descriptor_size, list_t *list)
     73 * @return EOK on success, ENOMEM if out of memory.
     74 */
     75static int create_interfaces(usb_mid_t *mid, const uint8_t *config_descriptor,
     76    size_t config_descriptor_size)
    7577{
    7678        const usb_dp_parser_data_t data = {
     
    101103
    102104                /* Skip alternate interfaces. */
    103                 if (interface_in_list(list, interface->interface_number)) {
     105                if (interface_in_list(&mid->interface_list,
     106                    interface->interface_number)) {
    104107                        /* TODO: add the alternatives and create match ids
    105108                         * for them. */
    106109                        continue;
    107110                }
    108                 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
    109                 if (iface == NULL) {
    110                         //TODO: Do something about that failure.
    111                         break;
    112                 }
     111
     112                /* Create the function */
     113                ddf_fun_t *fun = ddf_fun_create(mid->dev, fun_inner, NULL);
     114                if (fun == NULL)
     115                        goto error;
     116
     117                usbmid_interface_t *iface = ddf_fun_data_alloc(fun,
     118                    sizeof(usbmid_interface_t));
     119                if (iface == NULL)
     120                        goto error;
    113121
    114122                link_initialize(&iface->link);
    115                 iface->fun = NULL;
     123                iface->fun = fun;
    116124                iface->interface_no = interface->interface_number;
    117125                iface->interface = interface;
    118126
    119                 list_append(&iface->link, list);
    120         }
     127                list_append(&iface->link, &mid->interface_list);
     128        }
     129
     130        return EOK;
     131error:
     132        while (!list_empty(&mid->interface_list)) {
     133                link_t *link = list_first(&mid->interface_list);
     134                usbmid_interface_t *iface = list_get_instance(link,
     135                    usbmid_interface_t, link);
     136
     137                ddf_fun_destroy(iface->fun);
     138        }
     139
     140        return ENOMEM;
    121141}
    122142
     
    165185        }
    166186
     187        usb_mid->dev = dev->ddf_dev;
     188
    167189        /* Create control function. */
    168190        usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
     
    182204        }
    183205
    184 
    185206        /* Create interface children. */
    186207        list_initialize(&usb_mid->interface_list);
    187         create_interfaces(config_descriptor_raw, config_descriptor_size,
    188             &usb_mid->interface_list);
     208        create_interfaces(usb_mid, config_descriptor_raw, config_descriptor_size);
    189209
    190210        /* Start child function for every interface. */
  • uspace/drv/bus/usb/usbmid/usbmid.c

    rcbfece7 r1f1fa64  
    3030 * @{
    3131 */
    32 
    33 /* XXX Fix this */
    34 #define _DDF_DATA_IMPLANT
    3532
    3633/**
     
    10299    const usb_standard_interface_descriptor_t *interface_descriptor)
    103100{
    104         ddf_fun_t *child = NULL;
    105101        char *child_name = NULL;
    106102        int rc;
     
    114110            usb_str_class(interface_descriptor->interface_class),
    115111            interface_descriptor->interface_number);
    116         if (rc < 0) {
     112        if (rc < 0)
    117113                return ENOMEM;
    118         }
    119114
    120         /* Create the device. */
    121         child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
     115        rc = ddf_fun_set_name(iface->fun, child_name);
    122116        free(child_name);
    123         if (child == NULL) {
     117        if (rc != EOK)
    124118                return ENOMEM;
    125         }
    126119
    127120        match_id_list_t match_ids;
     
    130123        rc = usb_device_create_match_ids_from_interface(device_descriptor,
    131124            interface_descriptor, &match_ids);
    132         if (rc != EOK) {
    133                 ddf_fun_destroy(child);
     125        if (rc != EOK)
    134126                return rc;
    135         }
    136127
    137128        list_foreach(match_ids.ids, link, match_id_t, match_id) {
    138                 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
     129                rc = ddf_fun_add_match_id(iface->fun, match_id->id, match_id->score);
    139130                if (rc != EOK) {
    140131                        clean_match_ids(&match_ids);
    141                         ddf_fun_destroy(child);
    142132                        return rc;
    143133                }
     
    145135        clean_match_ids(&match_ids);
    146136
    147         rc = ddf_fun_bind(child);
    148         if (rc != EOK) {
    149                 /* This takes care of match_id deallocation as well. */
    150                 ddf_fun_destroy(child);
     137        ddf_fun_set_ops(iface->fun, &child_device_ops);
     138
     139        rc = ddf_fun_bind(iface->fun);
     140        if (rc != EOK)
    151141                return rc;
    152         }
    153 
    154         iface->fun = child;
    155         ddf_fun_data_implant(child, iface);
    156         ddf_fun_set_ops(child, &child_device_ops);
    157142
    158143        return EOK;
  • uspace/drv/bus/usb/usbmid/usbmid.h

    rcbfece7 r1f1fa64  
    6060/** Container to hold all the function pointers */
    6161typedef struct usb_mid {
     62        ddf_dev_t *dev;
    6263        ddf_fun_t *ctl_fun;
    6364        list_t interface_list;
  • uspace/drv/bus/usb/vhc/hub.c

    rcbfece7 r1f1fa64  
    9494{
    9595        ddf_fun_t *hc_dev = (ddf_fun_t *) arg;
    96 
    97         /*
    98          * Wait until parent device is properly initialized.
    99          */
    100         async_sess_t *sess;
    101         do {
    102                 sess = devman_device_connect(EXCHANGE_SERIALIZE,
    103                     ddf_fun_get_handle(hc_dev), 0);
    104         } while (!sess);
    105         async_hangup(sess);
    106 
    10796        int rc;
    10897
     
    114103
    115104        ddf_fun_t *hub_dev;
    116         rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL,
    117             pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev);
     105
     106        hub_dev = ddf_fun_create(ddf_fun_get_dev(hc_dev), fun_inner, NULL);
     107        if (hub_dev == NULL) {
     108                rc = ENOMEM;
     109                usb_log_fatal("Failed to create root hub: %s.\n",
     110                    str_error(rc));
     111                return rc;
     112        }
     113
     114        rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), hub_dev,
     115            &hc_conn, USB_SPEED_FULL, pretend_port_rest, NULL, NULL, &rh_ops);
    118116        if (rc != EOK) {
    119117                usb_log_fatal("Failed to create root hub: %s.\n",
    120118                    str_error(rc));
     119                ddf_fun_destroy(hub_dev);
    121120        }
    122121
  • uspace/drv/nic/e1k/e1k.c

    rcbfece7 r1f1fa64  
    7171/** ddf_fun_t * -> nic_driver_data_t* cast */
    7272#define NIC_DATA_FUN(fun) \
    73         ((nic_t *) ddf_fun_data_get(fun))
     73        ((nic_t *) ddf_dev_data_get(ddf_fun_get_dev(fun)))
    7474
    7575/** ddf_dev_t * -> nic_driver_data_t* cast */
  • uspace/drv/nic/rtl8169/driver.c

    rcbfece7 r1f1fa64  
    439439        nic_set_ddf_fun(nic_data, fun);
    440440        ddf_fun_set_ops(fun, &rtl8169_dev_ops);
    441         ddf_fun_data_implant(fun, nic_data);
     441//      ddf_fun_data_implant(fun, nic_data);
    442442
    443443        rc = ddf_fun_bind(fun);
  • uspace/lib/drv/generic/driver.c

    rcbfece7 r1f1fa64  
    3636/** @file
    3737 */
    38 
    39 #define _DDF_DATA_IMPLANT
    4038
    4139#include <assert.h>
     
    596594}
    597595
    598 /** Implant foreign driver-specific device data.
    599  *
    600  * XXX This is used to transition USB to new interface. Do not use
    601  * in new code. Use of this function must be removed.
    602  */
    603 void ddf_fun_data_implant(ddf_fun_t *fun, void *data)
    604 {
    605         assert(fun->driver_data == NULL);
    606         fun->driver_data = data;
    607 }
    608 
    609596/** Return driver-specific device data. */
    610597void *ddf_dev_data_get(ddf_dev_t *dev)
  • uspace/lib/drv/include/ddf/driver.h

    rcbfece7 r1f1fa64  
    111111} driver_t;
    112112
    113 /** XXX Only to transition USB */
    114 #ifdef _DDF_DATA_IMPLANT
    115 extern void ddf_fun_data_implant(ddf_fun_t *, void *);
    116 #endif
    117 
    118113extern int ddf_driver_main(const driver_t *);
    119114
  • uspace/lib/nic/src/nic_driver.c

    rcbfece7 r1f1fa64  
    4747#include <ops/nic.h>
    4848#include <errno.h>
     49
     50#include <io/log.h>
    4951
    5052#include "nic_driver.h"
     
    436438                int rc = nic_ev_addr_changed(nic_data->client_session,
    437439                    address);
     440                log_msg(LOG_DEFAULT, LVL_WARN, "rc=%d", rc);
     441
    438442                if (rc != EOK) {
    439443                        fibril_rwlock_write_unlock(&nic_data->main_lock);
  • uspace/lib/nic/src/nic_impl.c

    rcbfece7 r1f1fa64  
    179179
    180180        nic_data->send_frame(nic_data, data, size);
     181        fibril_rwlock_read_unlock(&nic_data->main_lock);
    181182        return EOK;
    182183}
  • uspace/lib/usbdev/include/usb/dev/hub.h

    rcbfece7 r1f1fa64  
    4444#include <usb/hc.h>
    4545
    46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
    47     int (*)(void *), void *, usb_address_t *, ddf_dev_ops_t *, void *,
    48     ddf_fun_t **);
     46extern int usb_hc_new_device_wrapper(ddf_dev_t *, ddf_fun_t *,
     47    usb_hc_connection_t *, usb_speed_t, int (*)(void *), void *,
     48    usb_address_t *, ddf_dev_ops_t *);
    4949
    5050/** Info about device attached to host controller.
  • uspace/lib/usbdev/include/usb/dev/recognise.h

    rcbfece7 r1f1fa64  
    5252
    5353extern int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
    54     ddf_dev_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
     54    ddf_dev_t *, ddf_fun_t *, ddf_dev_ops_t *);
    5555
    5656#endif
  • uspace/lib/usbdev/src/hub.c

    rcbfece7 r1f1fa64  
    155155 *      request or requests for descriptors when creating match ids).
    156156 */
    157 int usb_hc_new_device_wrapper(ddf_dev_t *parent,
     157int usb_hc_new_device_wrapper(ddf_dev_t *parent, ddf_fun_t *fun,
    158158    usb_hc_connection_t *hc_conn, usb_speed_t dev_speed,
    159159    int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address,
    160     ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
     160    ddf_dev_ops_t *dev_ops)
    161161{
    162         if ((new_fun == NULL) || (hc_conn == NULL))
     162        if (hc_conn == NULL)
    163163                return EINVAL;
    164164
     
    271271        /* Register the device with devman. */
    272272        /* FIXME: create device_register that will get opened ctrl pipe. */
    273         ddf_fun_t *child_fun;
    274273        rc = usb_device_register_child_in_devman(&ctrl_pipe,
    275             parent, dev_ops, new_dev_data, &child_fun);
     274            parent, fun, dev_ops);
    276275        if (rc != EOK) {
    277276                goto leave_release_free_address;
     
    280279        const usb_hub_attached_device_t new_device = {
    281280                .address = dev_addr,
    282                 .fun = child_fun,
     281                .fun = fun,
    283282        };
    284283
     
    288287        if (rc != EOK) {
    289288                /* The child function is already created. */
    290                 ddf_fun_destroy(child_fun);
    291289                rc = EDESTADDRREQ;
    292290                goto leave_release_free_address;
     
    296294                *assigned_address = dev_addr;
    297295        }
    298 
    299         *new_fun = child_fun;
    300296
    301297        rc = EOK;
  • uspace/lib/usbdev/src/recognise.c

    rcbfece7 r1f1fa64  
    3333 * Functions for recognition of attached devices.
    3434 */
    35 
    36 /** XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    3835
    3936#include <sys/types.h>
     
    318315 */
    319316int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
    320     ddf_dev_t *parent, ddf_dev_ops_t *dev_ops, void *dev_data,
    321     ddf_fun_t **child_fun)
    322 {
    323         if (child_fun == NULL || ctrl_pipe == NULL)
     317    ddf_dev_t *parent, ddf_fun_t *fun, ddf_dev_ops_t *dev_ops)
     318{
     319        if (ctrl_pipe == NULL)
    324320                return EINVAL;
    325321       
    326         if (!dev_ops && dev_data) {
     322        if (!dev_ops && ddf_fun_data_get(fun) != NULL) {
    327323                usb_log_warning("Using standard fun ops with arbitrary "
    328324                    "driver data. This does not have to work.\n");
     
    334330            (size_t) atomic_preinc(&device_name_index);
    335331       
    336         ddf_fun_t *child = NULL;
    337332        int rc;
    338333       
     
    348343        }
    349344       
    350         child = ddf_fun_create(parent, fun_inner, child_name);
    351         if (child == NULL) {
    352                 rc = ENOMEM;
     345        rc = ddf_fun_set_name(fun, child_name);
     346        if (rc != EOK)
    353347                goto failure;
    354         }
    355348       
    356349        if (dev_ops != NULL)
    357                 ddf_fun_set_ops(child, dev_ops);
     350                ddf_fun_set_ops(fun, dev_ops);
    358351        else
    359                 ddf_fun_set_ops(child, &child_ops);
    360        
    361         ddf_fun_data_implant(child, dev_data);
     352                ddf_fun_set_ops(fun, &child_ops);
    362353       
    363354        /*
     
    365356         * driver data if there is no other data
    366357         */
    367         if (!dev_data) {
     358        if (ddf_fun_data_get(fun) == NULL) {
    368359                usb_hub_attached_device_t *new_device = ddf_fun_data_alloc(
    369                     child, sizeof(usb_hub_attached_device_t));
     360                    fun, sizeof(usb_hub_attached_device_t));
    370361                if (!new_device) {
    371362                        rc = ENOMEM;
     
    374365               
    375366                new_device->address = ctrl_pipe->wire->address;
    376                 new_device->fun = child;
     367                new_device->fun = fun;
    377368        }
    378369       
     
    384375       
    385376        list_foreach(match_ids.ids, link, match_id_t, match_id) {
    386                 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score);
     377                rc = ddf_fun_add_match_id(fun, match_id->id, match_id->score);
    387378                if (rc != EOK) {
    388379                        clean_match_ids(&match_ids);
     
    393384        clean_match_ids(&match_ids);
    394385       
    395         rc = ddf_fun_bind(child);
     386        rc = ddf_fun_bind(fun);
    396387        if (rc != EOK)
    397388                goto failure;
    398389       
    399         *child_fun = child;
    400390        return EOK;
    401391       
    402392failure:
    403         if (child != NULL) {
    404                 /* This takes care of match_id deallocation as well. */
    405                 ddf_fun_destroy(child);
    406         }
    407        
    408393        return rc;
    409394}
  • uspace/srv/net/ethip/ethip_nic.c

    rcbfece7 r1f1fa64  
    231231    ipc_call_t *call)
    232232{
    233         log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed()");
    234         async_answer_0(callid, ENOTSUP);
     233        uint8_t *addr;
     234        size_t size;
     235        int rc;
     236
     237        rc = async_data_write_accept((void **)&addr, false, 0, 0, 0, &size);
     238        if (rc != EOK) {
     239                log_msg(LOG_DEFAULT, LVL_DEBUG, "data_write_accept() failed");
     240                return;
     241        }
     242
     243        log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed(): "
     244            "new addr=%02x:%02x:%02x:%02x:%02x:%02x",
     245            addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
     246
     247        free(addr);
     248        async_answer_0(callid, EOK);
    235249}
    236250
     
    295309                        break;
    296310                default:
     311                        log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", IPC_GET_IMETHOD(call));
    297312                        async_answer_0(callid, ENOTSUP);
    298313                }
Note: See TracChangeset for help on using the changeset viewer.