Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/proto/mousedev.c

    rcce8a83 r1875a0c  
    4444#include <ipc/mouseev.h>
    4545#include <input.h>
    46 #include <loc.h>
    4746#include <mouse.h>
    4847#include <mouse_port.h>
    4948#include <mouse_proto.h>
    50 #include <sys/typefmt.h>
    5149
    5250/** Mousedev softstate */
     
    5755        /** Session to mouse device */
    5856        async_sess_t *sess;
     57       
     58        /** File descriptor of open mousedev device */
     59        int fd;
    5960} mousedev_t;
    6061
     
    6667       
    6768        mousedev->mouse_dev = mdev;
     69        mousedev->fd = -1;
    6870       
    6971        return mousedev;
     
    7476        if (mousedev->sess != NULL)
    7577                async_hangup(mousedev->sess);
     78       
     79        if (mousedev->fd >= 0)
     80                close(mousedev->fd);
    7681       
    7782        free(mousedev);
     
    117122static int mousedev_proto_init(mouse_dev_t *mdev)
    118123{
    119         async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
    120             mdev->svc_id, 0);
     124        const char *pathname = mdev->dev_path;
     125       
     126        int fd = open(pathname, O_RDWR);
     127        if (fd < 0)
     128                return -1;
     129       
     130        async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
    121131        if (sess == NULL) {
    122                 printf("%s: Failed starting session with '%s'\n", NAME,
    123                     mdev->svc_name);
     132                printf("%s: Failed starting session with '%s'\n", NAME, pathname);
     133                close(fd);
    124134                return -1;
    125135        }
     
    128138        if (mousedev == NULL) {
    129139                printf("%s: Failed allocating device structure for '%s'.\n",
    130                     NAME, mdev->svc_name);
     140                    NAME, pathname);
    131141                return -1;
    132142        }
    133143       
     144        mousedev->fd = fd;
    134145        mousedev->sess = sess;
    135146       
    136147        async_exch_t *exch = async_exchange_begin(sess);
    137148        if (exch == NULL) {
    138                 printf("%s: Failed starting exchange with '%s'.\n", NAME,
    139                     mdev->svc_name);
     149                printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
    140150                mousedev_destroy(mousedev);
    141151                return -1;
     
    147157        if (rc != EOK) {
    148158                printf("%s: Failed creating callback connection from '%s'.\n",
    149                     NAME, mdev->svc_name);
     159                    NAME, pathname);
    150160                mousedev_destroy(mousedev);
    151161                return -1;
Note: See TracChangeset for help on using the changeset viewer.