Ignore:
File:
1 edited

Legend:

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

    rce2a1c2 r2a5b62b  
    161161/*----------------------------------------------------------------------------*/
    162162
    163 int 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 
     163static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev,
     164    usb_multimedia_t *multim_dev)
     165{
    171166        /* Create the exposed function. */
    172         ddf_fun_t *fun = ddf_fun_create(
    173             hid_dev->usb_dev->ddf_dev, fun_exposed, NAME);
     167        ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     168            NAME);
    174169        if (fun == NULL) {
    175170                usb_log_error("Could not create DDF function node.\n");
     
    178173
    179174        fun->ops = &multimedia_ops;
    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?
     175        fun->driver_data = multim_dev;   // TODO: maybe change to hid_dev->data
    192176
    193177        int rc = ddf_fun_bind(fun);
     
    210194                return rc;
    211195        }
    212 
    213         /* Save the KBD device structure into the HID device structure. */
     196        multim_dev->fun = fun;
     197
     198        return EOK;
     199}
     200
     201/*----------------------------------------------------------------------------*/
     202
     203int 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
    214222        *data = multim_dev;
    215223
     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
    216230        usb_log_debug(NAME " HID/multimedia structure initialized.\n");
     231
    217232        return EOK;
    218233}
     
    257272
    258273        usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    259             &hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
    260             | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
     274            hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END
     275            | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
    261276            USB_HID_REPORT_TYPE_INPUT);
    262277
     
    278293
    279294                field = usb_hid_report_get_sibling(
    280                     &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
     295                    hid_dev->report, field, path, USB_HID_PATH_COMPARE_END
    281296                    | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    282297                    USB_HID_REPORT_TYPE_INPUT);
Note: See TracChangeset for help on using the changeset viewer.