Ignore:
File:
1 edited

Legend:

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

    r77ad86c r9d58539  
    3333 * Functions for recognition of attached devices.
    3434 */
    35 
    3635#include <sys/types.h>
    3736#include <fibril_synch.h>
     
    312311 *      will be written.
    313312 * @return Error code.
    314  *
    315313 */
    316314int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
     
    320318        if (child_fun == NULL || ctrl_pipe == NULL)
    321319                return EINVAL;
    322        
     320
    323321        if (!dev_ops && dev_data) {
    324322                usb_log_warning("Using standard fun ops with arbitrary "
    325323                    "driver data. This does not have to work.\n");
    326324        }
    327        
     325
    328326        /** Index to append after device name for uniqueness. */
    329327        static atomic_t device_name_index = {0};
    330328        const size_t this_device_name_index =
    331329            (size_t) atomic_preinc(&device_name_index);
    332        
     330
    333331        ddf_fun_t *child = NULL;
    334332        int rc;
    335        
     333
    336334        /*
    337335         * TODO: Once the device driver framework support persistent
    338336         * naming etc., something more descriptive could be created.
    339337         */
    340         char child_name[12];  /* The format is: "usbAB_aXYZ", length 11 */
     338        char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */
    341339        rc = snprintf(child_name, sizeof(child_name),
    342340            "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address);
     
    344342                goto failure;
    345343        }
    346        
     344
    347345        child = ddf_fun_create(parent, fun_inner, child_name);
    348346        if (child == NULL) {
     
    350348                goto failure;
    351349        }
    352        
    353         if (dev_ops != NULL)
     350
     351        if (dev_ops != NULL) {
    354352                child->ops = dev_ops;
    355         else
     353        } else {
    356354                child->ops = &child_ops;
    357        
     355        }
     356
    358357        child->driver_data = dev_data;
    359         /*
    360          * Store the attached device in fun
    361          * driver data if there is no other data
    362          */
     358        /* Store the attached device in fun driver data if there is no
     359         * other data */
    363360        if (!dev_data) {
    364361                usb_hub_attached_device_t *new_device = ddf_fun_data_alloc(
     
    368365                        goto failure;
    369366                }
    370                
    371367                new_device->address = ctrl_pipe->wire->address;
    372368                new_device->fun = child;
    373369        }
    374        
     370
     371
    375372        rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
    376         if (rc != EOK)
     373        if (rc != EOK) {
    377374                goto failure;
    378        
     375        }
     376
    379377        rc = ddf_fun_bind(child);
    380         if (rc != EOK)
     378        if (rc != EOK) {
    381379                goto failure;
    382        
     380        }
     381
    383382        *child_fun = child;
    384383        return EOK;
    385        
     384
    386385failure:
    387386        if (child != NULL) {
    388387                /* We know nothing about the data if it came from outside. */
    389                 if (dev_data)
     388                if (dev_data) {
    390389                        child->driver_data = NULL;
    391                
     390                }
    392391                /* This takes care of match_id deallocation as well. */
    393392                ddf_fun_destroy(child);
    394393        }
    395        
     394
    396395        return rc;
    397396}
    398397
     398
    399399/**
    400400 * @}
Note: See TracChangeset for help on using the changeset viewer.