Ignore:
Timestamp:
2012-11-06T21:03:44Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
338810f
Parents:
de73242 (diff), 94795812 (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/drv/bus/usb/usbhid/multimedia/multimedia.c

    rde73242 refdfebc  
    5454#define NAME  "multimedia-keys"
    5555
    56 /*----------------------------------------------------------------------------*/
     56
    5757/**
    5858 * Logitech UltraX device type.
     
    7070
    7171
    72 /*----------------------------------------------------------------------------*/
     72
    7373/**
    7474 * Default handler for IPC methods not handled by DDF.
     
    8686{
    8787        usb_log_debug(NAME " default_connection_handler()\n");
    88         if (fun == NULL || fun->driver_data == NULL) {
    89                 async_answer_0(icallid, EINVAL);
    90                 return;
    91         }
    92 
    93         usb_multimedia_t *multim_dev = fun->driver_data;
     88
     89        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
    9490
    9591        async_sess_t *sess =
     
    106102                async_answer_0(icallid, EINVAL);
    107103}
    108 /*----------------------------------------------------------------------------*/
     104
    109105static ddf_dev_ops_t multimedia_ops = {
    110106        .default_handler = default_connection_handler
    111107};
    112 /*----------------------------------------------------------------------------*/
     108
    113109/**
    114110 * Processes key events.
     
    155151        }
    156152}
    157 /*----------------------------------------------------------------------------*/
     153
    158154int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data)
    159155{
     
    172168        }
    173169
    174         fun->ops = &multimedia_ops;
     170        ddf_fun_set_ops(fun, &multimedia_ops);
    175171
    176172        usb_multimedia_t *multim_dev =
     
    194190
    195191        usb_log_debug(NAME " function created (handle: %" PRIun ").\n",
    196             fun->handle);
     192            ddf_fun_get_handle(fun));
    197193
    198194        rc = ddf_fun_add_to_category(fun, "keyboard");
     
    203199                if (ddf_fun_unbind(fun) != EOK) {
    204200                        usb_log_error("Failed to unbind %s, won't destroy.\n",
    205                             fun->name);
     201                            ddf_fun_get_name(fun));
    206202                } else {
    207203                        ddf_fun_destroy(fun);
     
    216212        return EOK;
    217213}
    218 /*----------------------------------------------------------------------------*/
     214
    219215void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data)
    220216{
    221217        ddf_fun_t *fun = data;
    222         if (fun != NULL && fun->driver_data != NULL) {
    223                 usb_multimedia_t *multim_dev = fun->driver_data;
    224                 /* Hangup session to the console */
    225                 if (multim_dev->console_sess)
    226                         async_hangup(multim_dev->console_sess);
    227                 if (ddf_fun_unbind(fun) != EOK) {
    228                         usb_log_error("Failed to unbind %s, won't destroy.\n",
    229                             fun->name);
    230                 } else {
    231                         usb_log_debug2("%s unbound.\n", fun->name);
    232                         /* This frees multim_dev too as it was stored in
    233                          * fun->data */
    234                         ddf_fun_destroy(fun);
    235                 }
     218
     219        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
     220
     221        /* Hangup session to the console */
     222        if (multim_dev->console_sess)
     223                async_hangup(multim_dev->console_sess);
     224        if (ddf_fun_unbind(fun) != EOK) {
     225                usb_log_error("Failed to unbind %s, won't destroy.\n",
     226                    ddf_fun_get_name(fun));
    236227        } else {
    237                 usb_log_error(
    238                     "Failed to deinit multimedia subdriver, data missing.\n");
    239         }
    240 }
    241 /*----------------------------------------------------------------------------*/
     228                usb_log_debug2("%s unbound.\n", ddf_fun_get_name(fun));
     229                /* This frees multim_dev too as it was stored in
     230                 * fun->data */
     231                ddf_fun_destroy(fun);
     232        }
     233}
     234
    242235bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data)
    243236{
    244237        // TODO: checks
    245238        ddf_fun_t *fun = data;
    246         if (hid_dev == NULL || fun == NULL || fun->driver_data == NULL) {
     239        if (hid_dev == NULL) {
    247240                return false;
    248241        }
    249242
    250         usb_multimedia_t *multim_dev = fun->driver_data;
     243        usb_multimedia_t *multim_dev = ddf_fun_data_get(fun);
    251244
    252245        usb_hid_report_path_t *path = usb_hid_report_path();
Note: See TracChangeset for help on using the changeset viewer.