Ignore:
File:
1 edited

Legend:

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

    rcc574511 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         char *svc_name;
     124        const char *pathname = mdev->dev_path;
    120125       
    121         if (asprintf(&svc_name, "devname%" PRIun, mdev->service_id) > 0)
    122                 svc_name = (char *) "unknown";
     126        int fd = open(pathname, O_RDWR);
     127        if (fd < 0)
     128                return -1;
    123129       
    124         async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
    125             mdev->service_id, 0);
     130        async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
    126131        if (sess == NULL) {
    127                 printf("%s: Failed starting session with '%s'\n", NAME, svc_name);
     132                printf("%s: Failed starting session with '%s'\n", NAME, pathname);
     133                close(fd);
    128134                return -1;
    129135        }
     
    132138        if (mousedev == NULL) {
    133139                printf("%s: Failed allocating device structure for '%s'.\n",
    134                     NAME, svc_name);
     140                    NAME, pathname);
    135141                return -1;
    136142        }
    137143       
     144        mousedev->fd = fd;
    138145        mousedev->sess = sess;
    139146       
    140147        async_exch_t *exch = async_exchange_begin(sess);
    141148        if (exch == NULL) {
    142                 printf("%s: Failed starting exchange with '%s'.\n", NAME,
    143                     svc_name);
     149                printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
    144150                mousedev_destroy(mousedev);
    145151                return -1;
     
    151157        if (rc != EOK) {
    152158                printf("%s: Failed creating callback connection from '%s'.\n",
    153                     NAME, svc_name);
     159                    NAME, pathname);
    154160                mousedev_destroy(mousedev);
    155161                return -1;
Note: See TracChangeset for help on using the changeset viewer.