Ignore:
Timestamp:
2011-09-09T18:22:33Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40a2af3
Parents:
980671e7 (diff), 5da7199 (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/kbd/kbddev.c

    r980671e7 r3781092  
    4343#include <ipc/kbdev.h>
    4444#include <async.h>
    45 #include <async_obsolete.h>
    4645#include <fibril.h>
    4746#include <fibril_synch.h>
     
    7069
    7170#include "../usbhid.h"
    72 
    73 // FIXME: remove this header
    74 #include <abi/ipc/methods.h>
    7571
    7672/*----------------------------------------------------------------------------*/
     
    167163 *
    168164 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
    169  * assumes the caller is the console and thus it stores IPC phone to it for
     165 * assumes the caller is the console and thus it stores IPC session to it for
    170166 * later use by the driver to notify about key events.
    171167 *
     
    178174{
    179175        sysarg_t method = IPC_GET_IMETHOD(*icall);
    180         int callback;
    181        
    182         usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
     176       
     177        usb_kbd_t *kbd_dev = (usb_kbd_t *) fun->driver_data;
    183178        if (kbd_dev == NULL) {
    184179                usb_log_debug("default_connection_handler: "
     
    187182                return;
    188183        }
    189 
    190         switch (method) {
    191         case IPC_M_CONNECT_TO_ME:
    192                 callback = IPC_GET_ARG5(*icall);
    193 
    194                 if (kbd_dev->console_phone != -1) {
     184       
     185        async_sess_t *sess =
     186            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     187        if (sess != NULL) {
     188                if (kbd_dev->console_sess == NULL) {
     189                        kbd_dev->console_sess = sess;
     190                        usb_log_debug("default_connection_handler: OK\n");
     191                        async_answer_0(icallid, EOK);
     192                } else {
    195193                        usb_log_debug("default_connection_handler: "
    196                             "console phone already set\n");
     194                            "console session already set\n");
    197195                        async_answer_0(icallid, ELIMIT);
    198                         return;
    199                 }
    200 
    201                 kbd_dev->console_phone = callback;
    202                
    203                 usb_log_debug("default_connection_handler: OK\n");
    204                 async_answer_0(icallid, EOK);
    205                 break;
    206         case KBDEV_SET_IND:
    207                 kbd_dev->mods = IPC_GET_ARG1(*icall);
    208                 usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev);
    209                 async_answer_0(icallid, EOK);
    210                 break;
    211         default:
    212                 usb_log_debug("default_connection_handler: Wrong function.\n");
    213                 async_answer_0(icallid, EINVAL);
    214                 break;
     196                }
     197        } else {
     198                switch (method) {
     199                case KBDEV_SET_IND:
     200                        kbd_dev->mods = IPC_GET_ARG1(*icall);
     201                        usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev);
     202                        async_answer_0(icallid, EOK);
     203                        break;
     204                default:
     205                        usb_log_debug("default_connection_handler: Wrong function.\n");
     206                        async_answer_0(icallid, EINVAL);
     207                        break;
     208                }
    215209        }
    216210}
     
    301295{
    302296        usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key);
    303         if (kbd_dev->console_phone < 0) {
     297        if (kbd_dev->console_sess == NULL) {
    304298                usb_log_warning(
    305299                    "Connection to console not ready, key discarded.\n");
     
    307301        }
    308302       
    309         async_obsolete_msg_2(kbd_dev->console_phone, KBDEV_EVENT, type, key);
     303        async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess);
     304        async_msg_2(exch, KBDEV_EVENT, type, key);
     305        async_exchange_end(exch);
    310306}
    311307
     
    510506        }
    511507       
    512         kbd_dev->console_phone = -1;
     508        kbd_dev->console_sess = NULL;
    513509        kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
    514510       
     
    785781        }
    786782       
    787         // hangup phone to the console
    788         async_obsolete_hangup(kbd_dev->console_phone);
     783        // hangup session to the console
     784        async_hangup(kbd_dev->console_sess);
    789785       
    790786        if (kbd_dev->repeat_mtx != NULL) {
Note: See TracChangeset for help on using the changeset viewer.