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

Changeset e1e4192 in mainline for uspace/lib/usbdev/src/recognise.c


Ignore:
Timestamp:
2012-06-03T20:45:58Z (10 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
90478727
Parents:
f7e69f5 (diff), 3123d2a (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

File:
1 edited

Legend:

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

    rf7e69f5 re1e4192  
    3333 * Functions for recognition of attached devices.
    3434 */
     35
    3536#include <sys/types.h>
    3637#include <fibril_synch.h>
     
    311312 *      will be written.
    312313 * @return Error code.
     314 *
    313315 */
    314316int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
     
    318320        if (child_fun == NULL || ctrl_pipe == NULL)
    319321                return EINVAL;
    320 
     322       
    321323        if (!dev_ops && dev_data) {
    322324                usb_log_warning("Using standard fun ops with arbitrary "
    323325                    "driver data. This does not have to work.\n");
    324326        }
    325 
     327       
    326328        /** Index to append after device name for uniqueness. */
    327329        static atomic_t device_name_index = {0};
    328330        const size_t this_device_name_index =
    329331            (size_t) atomic_preinc(&device_name_index);
    330 
     332       
    331333        ddf_fun_t *child = NULL;
    332334        int rc;
    333 
     335       
    334336        /*
    335337         * TODO: Once the device driver framework support persistent
    336338         * naming etc., something more descriptive could be created.
    337339         */
    338         char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */
     340        char child_name[12];  /* The format is: "usbAB_aXYZ", length 11 */
    339341        rc = snprintf(child_name, sizeof(child_name),
    340342            "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address);
     
    342344                goto failure;
    343345        }
    344 
     346       
    345347        child = ddf_fun_create(parent, fun_inner, child_name);
    346348        if (child == NULL) {
     
    348350                goto failure;
    349351        }
    350 
    351         if (dev_ops != NULL) {
     352       
     353        if (dev_ops != NULL)
    352354                child->ops = dev_ops;
    353         } else {
     355        else
    354356                child->ops = &child_ops;
    355         }
    356 
     357       
    357358        child->driver_data = dev_data;
    358         /* Store the attached device in fun driver data if there is no
    359          * other data */
     359        /*
     360         * Store the attached device in fun
     361         * driver data if there is no other data
     362         */
    360363        if (!dev_data) {
    361364                usb_hub_attached_device_t *new_device = ddf_fun_data_alloc(
     
    365368                        goto failure;
    366369                }
     370               
    367371                new_device->address = ctrl_pipe->wire->address;
    368372                new_device->fun = child;
    369373        }
    370 
    371 
     374       
    372375        rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
    373         if (rc != EOK) {
     376        if (rc != EOK)
    374377                goto failure;
    375         }
    376 
     378       
    377379        rc = ddf_fun_bind(child);
    378         if (rc != EOK) {
     380        if (rc != EOK)
    379381                goto failure;
    380         }
    381 
     382       
    382383        *child_fun = child;
    383384        return EOK;
    384 
     385       
    385386failure:
    386387        if (child != NULL) {
    387388                /* We know nothing about the data if it came from outside. */
    388                 if (dev_data) {
     389                if (dev_data)
    389390                        child->driver_data = NULL;
    390                 }
     391               
    391392                /* This takes care of match_id deallocation as well. */
    392393                ddf_fun_destroy(child);
    393394        }
    394 
     395       
    395396        return rc;
    396397}
    397398
    398 
    399399/**
    400400 * @}
Note: See TracChangeset for help on using the changeset viewer.