Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7ed5b576 in mainline


Ignore:
Timestamp:
2010-12-12T13:28:16Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
0c05496, a66225f
Parents:
03e02248
Message:

USB child device registration

Wrapper for adding child device (i.e. registration with devman) is ready. It takes care
of correct match id creation.

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/usbdrv.h

    r03e02248 r7ed5b576  
    9595
    9696int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
     97int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
     98    devman_handle_t *);
     99
    97100
    98101#endif
  • uspace/lib/usb/src/recognise.c

    r03e02248 r7ed5b576  
    174174}
    175175
    176 #if 0
     176
    177177/** Probe for device kind and register it in devman.
    178178 *
    179179 * @param hc Open phone to the host controller.
    180  * @param dev Parent device.
     180 * @param parent Parent device.
    181181 * @param address Address of the (unknown) attached device.
    182182 * @return Error code.
    183183 */
    184 int usb_drv_register_child_in_devman(int hc, device_t *dev,
    185     usb_address_t address)
     184int usb_drv_register_child_in_devman(int hc, device_t *parent,
     185    usb_address_t address, devman_handle_t *child_handle)
    186186{
     187        device_t *child = NULL;
     188        char *child_name = NULL;
     189        int rc;
     190
     191        child = create_device();
     192        if (child == NULL) {
     193                rc = ENOMEM;
     194                goto failure;
     195        }
     196
     197        /*
     198         * TODO: some better child naming
     199         */
     200        rc = asprintf(&child_name, "usb%p", child);
     201        if (rc < 0) {
     202                goto failure;
     203        }
     204        child->name = child_name;
     205       
     206        rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
     207        if (rc != EOK) {
     208                goto failure;
     209        }
     210
     211        rc = child_device_register(child, parent);
     212        if (rc != EOK) {
     213                goto failure;
     214        }
     215
     216        if (child_handle != NULL) {
     217                *child_handle = child->handle;
     218        }
     219       
     220        return EOK;
     221
     222failure:
     223        if (child != NULL) {
     224                child->name = NULL;
     225                /* This takes care of match_id deallocation as well. */
     226                delete_device(child);
     227        }
     228        if (child_name != NULL) {
     229                free(child_name);
     230        }
     231
     232        return rc;
    187233
    188234}
    189 #endif
     235
    190236
    191237/**
Note: See TracChangeset for help on using the changeset viewer.