Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/ctl/kbdev.c

    r854eddd6 rcce8a83  
    4848#include <kbd_ctl.h>
    4949#include <kbd_port.h>
     50#include <loc.h>
    5051#include <stdlib.h>
    5152#include <vfs/vfs_sess.h>
    52 
     53#include <sys/typefmt.h>
    5354
    5455static int kbdev_ctl_init(kbd_dev_t *);
    55 static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned);
     56static void kbdev_ctl_set_ind(kbd_dev_t *, unsigned int);
    5657
    5758static void kbdev_callback_conn(ipc_callid_t, ipc_call_t *, void *arg);
    5859
    5960kbd_ctl_ops_t kbdev_ctl = {
    60         .parse_scancode = NULL,
     61        .parse = NULL,
    6162        .init = kbdev_ctl_init,
    6263        .set_ind = kbdev_ctl_set_ind
     
    7071        /** Session with kbdev device */
    7172        async_sess_t *sess;
    72 
    73         /** File descriptor of open kbdev device */
    74         int fd;
    7573} kbdev_t;
    7674
     
    8482
    8583        kbdev->kbd_dev = kdev;
    86         kbdev->fd = -1;
    8784
    8885        return kbdev;
     
    9390        if (kbdev->sess != NULL)
    9491                async_hangup(kbdev->sess);
    95         if (kbdev->fd >= 0)
    96                 close(kbdev->fd);
    9792        free(kbdev);
    9893}
     
    10095static int kbdev_ctl_init(kbd_dev_t *kdev)
    10196{
    102         const char *pathname;
    10397        async_sess_t *sess;
    10498        async_exch_t *exch;
    10599        kbdev_t *kbdev;
    106         int fd;
    107100        int rc;
    108101
    109         pathname = kdev->dev_path;
    110 
    111         fd = open(pathname, O_RDWR);
    112         if (fd < 0) {
    113                 return -1;
    114         }
    115 
    116         sess = fd_session(EXCHANGE_SERIALIZE, fd);
     102        sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
    117103        if (sess == NULL) {
    118                 printf(NAME ": Failed starting session with '%s'\n", pathname);
    119                 close(fd);
     104                printf("%s: Failed starting session with '%s.'\n", NAME,
     105                    kdev->svc_name);
    120106                return -1;
    121107        }
     
    123109        kbdev = kbdev_new(kdev);
    124110        if (kbdev == NULL) {
    125                 printf(NAME ": Failed allocating device structure for '%s'.\n",
    126                     pathname);
     111                printf("%s: Failed allocating device structure for '%s'.\n",
     112                    NAME, kdev->svc_name);
    127113                return -1;
    128114        }
    129115
    130         kbdev->fd = fd;
    131116        kbdev->sess = sess;
    132117
    133118        exch = async_exchange_begin(sess);
    134119        if (exch == NULL) {
    135                 printf(NAME ": Failed starting exchange with '%s'.\n", pathname);
     120                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     121                    kdev->svc_name);
    136122                kbdev_destroy(kbdev);
    137123                return -1;
     
    140126        rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
    141127        if (rc != EOK) {
    142                 printf(NAME ": Failed creating callback connection from '%s'.\n",
    143                     pathname);
     128                printf("%s: Failed creating callback connection from '%s'.\n",
     129                    NAME, kdev->svc_name);
    144130                async_exchange_end(exch);
    145131                kbdev_destroy(kbdev);
     
    193179                        type = IPC_GET_ARG1(call);
    194180                        key = IPC_GET_ARG2(call);
    195                         kbd_push_ev(kbdev->kbd_dev, type, key);
     181                        kbd_push_event(kbdev->kbd_dev, type, key);
    196182                        break;
    197183                default:
Note: See TracChangeset for help on using the changeset viewer.