Ignore:
Timestamp:
2011-08-16T12:37:58Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
16dc887
Parents:
86ffa27f
Message:

Basic category support in location service. Devman adds device services
to categories. Switch over input server device discovery from using
/dev/class to loc categories.

File:
1 edited

Legend:

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

    r86ffa27f rcc574511  
    4444#include <ipc/mouseev.h>
    4545#include <input.h>
     46#include <loc.h>
    4647#include <mouse.h>
    4748#include <mouse_port.h>
    4849#include <mouse_proto.h>
     50#include <sys/typefmt.h>
    4951
    5052/** Mousedev softstate */
     
    5557        /** Session to mouse device */
    5658        async_sess_t *sess;
    57        
    58         /** File descriptor of open mousedev device */
    59         int fd;
    6059} mousedev_t;
    6160
     
    6766       
    6867        mousedev->mouse_dev = mdev;
    69         mousedev->fd = -1;
    7068       
    7169        return mousedev;
     
    7674        if (mousedev->sess != NULL)
    7775                async_hangup(mousedev->sess);
    78        
    79         if (mousedev->fd >= 0)
    80                 close(mousedev->fd);
    8176       
    8277        free(mousedev);
     
    122117static int mousedev_proto_init(mouse_dev_t *mdev)
    123118{
    124         const char *pathname = mdev->dev_path;
     119        char *svc_name;
    125120       
    126         int fd = open(pathname, O_RDWR);
    127         if (fd < 0)
    128                 return -1;
     121        if (asprintf(&svc_name, "devname%" PRIun, mdev->service_id) > 0)
     122                svc_name = (char *) "unknown";
    129123       
    130         async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
     124        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
     125            mdev->service_id, 0);
    131126        if (sess == NULL) {
    132                 printf("%s: Failed starting session with '%s'\n", NAME, pathname);
    133                 close(fd);
     127                printf("%s: Failed starting session with '%s'\n", NAME, svc_name);
    134128                return -1;
    135129        }
     
    138132        if (mousedev == NULL) {
    139133                printf("%s: Failed allocating device structure for '%s'.\n",
    140                     NAME, pathname);
     134                    NAME, svc_name);
    141135                return -1;
    142136        }
    143137       
    144         mousedev->fd = fd;
    145138        mousedev->sess = sess;
    146139       
    147140        async_exch_t *exch = async_exchange_begin(sess);
    148141        if (exch == NULL) {
    149                 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
     142                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     143                    svc_name);
    150144                mousedev_destroy(mousedev);
    151145                return -1;
     
    157151        if (rc != EOK) {
    158152                printf("%s: Failed creating callback connection from '%s'.\n",
    159                     NAME, pathname);
     153                    NAME, svc_name);
    160154                mousedev_destroy(mousedev);
    161155                return -1;
Note: See TracChangeset for help on using the changeset viewer.