Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/ps2mouse/ps2mouse.c

    r9d58539 r56fd7cf  
    3535#include <bool.h>
    3636#include <errno.h>
    37 #include <devman.h>
    3837#include <ddf/log.h>
    3938#include <io/keycode.h>
     
    114113int ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
    115114{
    116         assert(mouse);
    117         assert(dev);
    118115        mouse->client_sess = NULL;
    119         mouse->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
    120             dev->handle, IPC_FLAG_BLOCKING);
     116        mouse->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
    121117        if (!mouse->parent_sess)
    122118                return ENOMEM;
     
    124120        mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse");
    125121        if (!mouse->mouse_fun) {
    126                 async_hangup(mouse->parent_sess);
    127                 return ENOMEM;
    128         }
    129         mouse->mouse_fun->ops = &mouse_ops;
    130         mouse->mouse_fun->driver_data = mouse;
     122                return ENOMEM;
     123        }
     124        ddf_fun_set_ops(mouse->mouse_fun, &mouse_ops);
    131125
    132126        int ret = ddf_fun_bind(mouse->mouse_fun);
    133127        if (ret != EOK) {
    134                 async_hangup(mouse->parent_sess);
    135                 mouse->mouse_fun->driver_data = NULL;
    136128                ddf_fun_destroy(mouse->mouse_fun);
    137129                return ENOMEM;
     
    140132        ret = ddf_fun_add_to_category(mouse->mouse_fun, "mouse");
    141133        if (ret != EOK) {
    142                 async_hangup(mouse->parent_sess);
    143134                ddf_fun_unbind(mouse->mouse_fun);
    144                 mouse->mouse_fun->driver_data = NULL;
    145135                ddf_fun_destroy(mouse->mouse_fun);
    146136                return ENOMEM;
     
    161151                ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
    162152                async_exchange_end(exch);
    163                 async_hangup(mouse->parent_sess);
    164153                ddf_fun_unbind(mouse->mouse_fun);
    165                 mouse->mouse_fun->driver_data = NULL;
    166154                ddf_fun_destroy(mouse->mouse_fun);
    167155                return EIO;
     
    173161                ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.",
    174162                    report);
    175                 async_hangup(mouse->parent_sess);
    176163                ddf_fun_unbind(mouse->mouse_fun);
    177                 mouse->mouse_fun->driver_data = NULL;
    178164                ddf_fun_destroy(mouse->mouse_fun);
    179165                return EIO;
     
    182168        mouse->polling_fibril = fibril_create(polling_f, mouse);
    183169        if (!mouse->polling_fibril) {
    184                 async_hangup(mouse->parent_sess);
    185170                ddf_fun_unbind(mouse->mouse_fun);
    186                 mouse->mouse_fun->driver_data = NULL;
    187171                ddf_fun_destroy(mouse->mouse_fun);
    188172                return ENOMEM;
     
    368352    ipc_callid_t icallid, ipc_call_t *icall)
    369353{
    370         if (fun == NULL || fun->driver_data == NULL) {
    371                 ddf_msg(LVL_ERROR, "%s: Missing parameter.", __FUNCTION__);
    372                 async_answer_0(icallid, EINVAL);
    373                 return;
    374         }
    375 
    376354        const sysarg_t method = IPC_GET_IMETHOD(*icall);
    377         ps2_mouse_t *mouse = fun->driver_data;
     355        ps2_mouse_t *mouse = ddf_dev_data_get(ddf_fun_get_dev(fun));
    378356
    379357        switch (method) {
Note: See TracChangeset for help on using the changeset viewer.