Changeset 1affcdf3 in mainline for uspace/srv/hid/kbd/port/adb.c


Ignore:
Timestamp:
2011-06-10T19:33:41Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1878386
Parents:
13ecdac9 (diff), 79a141a (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/srv/hid/kbd/port/adb.c

    r13ecdac9 r1affcdf3  
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief ADB keyboard port driver.
     
    3737#include <ipc/adb.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
     
    4243#include <fcntl.h>
    4344#include <errno.h>
     45#include <devmap.h>
     46#include <devmap_obsolete.h>
    4447
    4548static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     
    5255int kbd_port_init(void)
    5356{
    54         const char *input = "/dev/adb/kbd";
    55         int input_fd;
    56 
    57         printf(NAME ": open %s\n", input);
    58 
    59         input_fd = open(input, O_RDONLY);
    60         if (input_fd < 0) {
    61                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    62                 return false;
     57        const char *dev = "adb/kbd";
     58        devmap_handle_t handle;
     59       
     60        int rc = devmap_device_get_handle(dev, &handle, 0);
     61        if (rc == EOK) {
     62                dev_phone = devmap_obsolete_device_connect(handle, 0);
     63                if (dev_phone < 0) {
     64                        printf("%s: Failed to connect to device\n", NAME);
     65                        return dev_phone;
     66                }
     67        } else
     68                return rc;
     69       
     70        /* NB: The callback connection is slotted for removal */
     71        rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events);
     72        if (rc != EOK) {
     73                printf(NAME ": Failed to create callback from device\n");
     74                return rc;
    6375        }
    64 
    65         dev_phone = fd_phone(input_fd);
    66         if (dev_phone < 0) {
    67                 printf(NAME ": Failed to connect to device\n");
    68                 return false;
    69         }
    70 
    71         /* NB: The callback connection is slotted for removal */
    72         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    73                 printf(NAME ": Failed to create callback from device\n");
    74                 return false;
    75         }
    76 
    77         return 0;
     76       
     77        return EOK;
    7878}
    7979
     
    100100
    101101                int retval;
    102 
    103                 switch (IPC_GET_IMETHOD(call)) {
    104                 case IPC_M_PHONE_HUNGUP:
     102               
     103                if (!IPC_GET_IMETHOD(call)) {
    105104                        /* TODO: Handle hangup */
    106105                        return;
     106                }
     107               
     108                switch (IPC_GET_IMETHOD(call)) {
    107109                case ADB_REG_NOTIF:
    108110                        adb_kbd_reg0_data(IPC_GET_ARG1(call));
Note: See TracChangeset for help on using the changeset viewer.