Ignore:
Timestamp:
2011-10-16T19:38:53Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
22ceff3a, e5291e0
Parents:
98fb010 (diff), 93d2684 (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:

Minor USB changes.

Add more const qualifiers where possible.
Do not limit the number possible usbhid subdrivers.
This should not break anything. If it does feel free to revert this merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    r98fb010 r1f131fb9  
    161161/*----------------------------------------------------------------------------*/
    162162
    163 static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev,
    164     usb_multimedia_t *multim_dev)
    165 {
     163int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
     164{
     165        if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
     166                return EINVAL; /*! @todo Other return code? */
     167        }
     168
     169        usb_log_debug(NAME " Initializing HID/multimedia structure...\n");
     170
    166171        /* Create the exposed function. */
    167         ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
    168             NAME);
     172        ddf_fun_t *fun = ddf_fun_create(
     173            hid_dev->usb_dev->ddf_dev, fun_exposed, NAME);
    169174        if (fun == NULL) {
    170175                usb_log_error("Could not create DDF function node.\n");
     
    173178
    174179        fun->ops = &multimedia_ops;
    175         fun->driver_data = multim_dev;   // TODO: maybe change to hid_dev->data
     180
     181        usb_multimedia_t *multim_dev =
     182            ddf_fun_data_alloc(fun, sizeof(usb_multimedia_t));
     183        if (multim_dev == NULL) {
     184                ddf_fun_destroy(fun);
     185                return ENOMEM;
     186        }
     187
     188        multim_dev->console_sess = NULL;
     189        multim_dev->fun = fun;
     190
     191        //todo Autorepeat?
    176192
    177193        int rc = ddf_fun_bind(fun);
     
    194210                return rc;
    195211        }
    196         multim_dev->fun = fun;
    197 
    198         return EOK;
    199 }
    200 
    201 /*----------------------------------------------------------------------------*/
    202 
    203 int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
    204 {
    205         if (hid_dev == NULL || hid_dev->usb_dev == NULL) {
    206                 return EINVAL; /*! @todo Other return code? */
    207         }
    208 
    209         usb_log_debug(NAME " Initializing HID/multimedia structure...\n");
    210 
    211         usb_multimedia_t *multim_dev = (usb_multimedia_t *)malloc(
    212             sizeof(usb_multimedia_t));
    213         if (multim_dev == NULL) {
    214                 return ENOMEM;
    215         }
    216 
    217         multim_dev->console_sess = NULL;
    218 
    219         /*! @todo Autorepeat */
    220 
    221         // save the KBD device structure into the HID device structure
     212
     213        /* Save the KBD device structure into the HID device structure. */
    222214        *data = multim_dev;
    223215
    224         usb_log_debug(NAME " HID/multimedia device structure initialized.\n");
    225 
    226         int rc = usb_multimedia_create_function(hid_dev, multim_dev);
    227         if (rc != EOK)
    228                 return rc;
    229 
    230216        usb_log_debug(NAME " HID/multimedia structure initialized.\n");
    231 
    232217        return EOK;
    233218}
     
    272257
    273258        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    274             hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
    275             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
     259            &hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
     260            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    276261            USB_HID_REPORT_TYPE_INPUT);
    277262
     
    293278
    294279                field = usb_hid_report_get_sibling(
    295                     hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     280                    &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
    296281                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    297282                    USB_HID_REPORT_TYPE_INPUT);
Note: See TracChangeset for help on using the changeset viewer.