Ignore:
Timestamp:
2011-10-15T14:29:34Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c5fd7a
Parents:
a8c4e871
Message:

usbhid: multimedia; unite init and create_function functions.

File:
1 edited

Legend:

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

    ra8c4e871 rce2a1c2  
    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}
Note: See TracChangeset for help on using the changeset viewer.