Changeset a81a1d09 in mainline for uspace/drv/usbhid/kbd/kbddev.c


Ignore:
Timestamp:
2011-05-11T16:49:28Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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 development/ changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/kbd/kbddev.c

    re1dbcbc ra81a1d09  
    255255       
    256256        if (hid_dev == NULL || hid_dev->data == NULL) {
     257                usb_log_debug("default_connection_handler: "
     258                    "Missing parameter.\n");
    257259                async_answer_0(icallid, EINVAL);
    258260                return;
     
    267269
    268270                if (kbd_dev->console_phone != -1) {
     271                        usb_log_debug("default_connection_handler: "
     272                            "console phone already set\n");
    269273                        async_answer_0(icallid, ELIMIT);
    270274                        return;
     
    272276
    273277                kbd_dev->console_phone = callback;
     278               
     279                usb_log_debug("default_connection_handler: OK\n");
    274280                async_answer_0(icallid, EOK);
    275281                return;
    276282        }
    277283       
     284        usb_log_debug("default_connection_handler: Wrong function.\n");
    278285        async_answer_0(icallid, EINVAL);
    279286}
     
    555562                        usb_log_debug2("Key pressed: %d (keycode: %d)\n", key,
    556563                            kbd_dev->keys[i]);
    557                         usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS, key);
    558564                        if (!usb_kbd_is_lock(key)) {
    559565                                usb_kbd_repeat_start(kbd_dev, key);
    560566                        }
     567                        usb_kbd_push_ev(hid_dev, kbd_dev, KEY_PRESS, key);
    561568                } else {
    562569                        // found, nothing happens
     
    766773
    767774/*----------------------------------------------------------------------------*/
     775
     776static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
     777{
     778        assert(hid_dev != NULL);
     779        assert(hid_dev->usb_dev != NULL);
     780       
     781        /* Create the function exposed under /dev/devices. */
     782        usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
     783        ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     784            HID_KBD_FUN_NAME);
     785        if (fun == NULL) {
     786                usb_log_error("Could not create DDF function node.\n");
     787                return ENOMEM;
     788        }
     789       
     790        /*
     791         * Store the initialized HID device and HID ops
     792         * to the DDF function.
     793         */
     794        fun->ops = &hid_dev->ops;
     795        fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     796
     797        int rc = ddf_fun_bind(fun);
     798        if (rc != EOK) {
     799                usb_log_error("Could not bind DDF function: %s.\n",
     800                    str_error(rc));
     801                ddf_fun_destroy(fun);
     802                return rc;
     803        }
     804       
     805        usb_log_debug("Adding DDF function to class %s...\n",
     806            HID_KBD_CLASS_NAME);
     807        rc = ddf_fun_add_to_class(fun, HID_KBD_CLASS_NAME);
     808        if (rc != EOK) {
     809                usb_log_error(
     810                    "Could not add DDF function to class %s: %s.\n",
     811                    HID_KBD_CLASS_NAME, str_error(rc));
     812                ddf_fun_destroy(fun);
     813                return rc;
     814        }
     815       
     816        return EOK;
     817}
     818
     819/*----------------------------------------------------------------------------*/
    768820/* API functions                                                              */
    769821/*----------------------------------------------------------------------------*/
     
    930982        usb_log_debug("HID/KBD device structure initialized.\n");
    931983       
     984        usb_log_debug("Creating KBD function...\n");
     985        int rc = usb_kbd_create_function(hid_dev);
     986        if (rc != EOK) {
     987                usb_kbd_free(&kbd_dev);
     988                return rc;
     989        }
     990       
    932991        return EOK;
    933992}
     
    9931052        if ((*kbd_dev)->led_data != NULL) {
    9941053                free((*kbd_dev)->led_data);
    995         }
    996         if ((*kbd_dev)->output_buffer != NULL) {
    997                 free((*kbd_dev)->output_buffer);
    9981054        }
    9991055        if ((*kbd_dev)->led_path != NULL) {
Note: See TracChangeset for help on using the changeset viewer.