Changeset 15d0046 in mainline for uspace/drv/char/xtkbd/xtkbd.c


Ignore:
Timestamp:
2014-09-12T13:22:33Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b20126
Parents:
8db09e4 (diff), 105d8d6 (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/char/xtkbd/xtkbd.c

    r8db09e4 r15d0046  
    3636#include <ddf/log.h>
    3737#include <io/keycode.h>
     38#include <io/chardev.h>
    3839#include <io/console.h>
    3940#include <ipc/kbdev.h>
    4041#include <abi/ipc/methods.h>
    4142
    42 #include "chardev.h"
    4343#include "xtkbd.h"
    4444
     
    159159static const int scanmap_e0[] = {
    160160        [0x38] = KC_RALT,
    161         [0x1d] = KC_RSHIFT,
     161        [0x1d] = KC_RCTRL,
    162162
    163163        [0x37] = KC_PRTSCR,
     
    199199 * @param dev DDF device structure.
    200200 *
    201  * Connects to parent, creates mouse function, starts polling fibril.
     201 * Connects to parent, creates keyboard function, starts polling fibril.
    202202 */
    203203int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev)
     
    207207        kbd->client_sess = NULL;
    208208        kbd->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
    209         if (!kbd->parent_sess)
    210                 return ENOMEM;
     209        if (!kbd->parent_sess) {
     210                ddf_msg(LVL_ERROR, "Failed creating parent session.");
     211                return EIO;
     212        }
    211213
    212214        kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
    213215        if (!kbd->kbd_fun) {
     216                ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
    214217                return ENOMEM;
    215218        }
     
    218221        int ret = ddf_fun_bind(kbd->kbd_fun);
    219222        if (ret != EOK) {
     223                ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
    220224                ddf_fun_destroy(kbd->kbd_fun);
    221                 return ENOMEM;
     225                return EEXIST;
    222226        }
    223227
    224228        ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
    225229        if (ret != EOK) {
     230                ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
     231                    "'keyboard'.");
    226232                ddf_fun_unbind(kbd->kbd_fun);
    227233                ddf_fun_destroy(kbd->kbd_fun);
     
    231237        kbd->polling_fibril = fibril_create(polling, kbd);
    232238        if (!kbd->polling_fibril) {
     239                ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
    233240                ddf_fun_unbind(kbd->kbd_fun);
    234241                ddf_fun_destroy(kbd->kbd_fun);
    235242                return ENOMEM;
    236243        }
     244
    237245        fibril_add_ready(kbd->polling_fibril);
    238246        return EOK;
     
    241249/** Get data and parse scancodes.
    242250 * @param arg Pointer to xt_kbd_t structure.
    243  * @return Never.
     251 * @return EIO on error.
    244252 */
    245253int polling(void *arg)
     
    259267                uint8_t code = 0;
    260268                ssize_t size = chardev_read(parent_exch, &code, 1);
     269                if (size != 1)
     270                        return EIO;
    261271
    262272                /** Ignore AT command reply */
     
    269279                        map_size = sizeof(scanmap_e0) / sizeof(int);
    270280                        size = chardev_read(parent_exch, &code, 1);
     281                        if (size != 1)
     282                                return EIO;
     283
    271284                        // TODO handle print screen
    272285                }
    273 
    274                 /* Invalid read. */
    275                 if (size != 1) {
    276                         continue;
    277                 }
    278 
    279286
    280287                /* Bit 7 indicates press/release */
Note: See TracChangeset for help on using the changeset viewer.