Ignore:
File:
1 edited

Legend:

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

    r56fd7cf r9d58539  
    3535#include <bool.h>
    3636#include <errno.h>
     37#include <devman.h>
    3738#include <ddf/log.h>
    3839#include <io/keycode.h>
     
    113114int ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
    114115{
     116        assert(mouse);
     117        assert(dev);
    115118        mouse->client_sess = NULL;
    116         mouse->parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE);
     119        mouse->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
     120            dev->handle, IPC_FLAG_BLOCKING);
    117121        if (!mouse->parent_sess)
    118122                return ENOMEM;
     
    120124        mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse");
    121125        if (!mouse->mouse_fun) {
     126                async_hangup(mouse->parent_sess);
    122127                return ENOMEM;
    123128        }
    124         ddf_fun_set_ops(mouse->mouse_fun, &mouse_ops);
     129        mouse->mouse_fun->ops = &mouse_ops;
     130        mouse->mouse_fun->driver_data = mouse;
    125131
    126132        int ret = ddf_fun_bind(mouse->mouse_fun);
    127133        if (ret != EOK) {
     134                async_hangup(mouse->parent_sess);
     135                mouse->mouse_fun->driver_data = NULL;
    128136                ddf_fun_destroy(mouse->mouse_fun);
    129137                return ENOMEM;
     
    132140        ret = ddf_fun_add_to_category(mouse->mouse_fun, "mouse");
    133141        if (ret != EOK) {
     142                async_hangup(mouse->parent_sess);
    134143                ddf_fun_unbind(mouse->mouse_fun);
     144                mouse->mouse_fun->driver_data = NULL;
    135145                ddf_fun_destroy(mouse->mouse_fun);
    136146                return ENOMEM;
     
    151161                ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
    152162                async_exchange_end(exch);
     163                async_hangup(mouse->parent_sess);
    153164                ddf_fun_unbind(mouse->mouse_fun);
     165                mouse->mouse_fun->driver_data = NULL;
    154166                ddf_fun_destroy(mouse->mouse_fun);
    155167                return EIO;
     
    161173                ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.",
    162174                    report);
     175                async_hangup(mouse->parent_sess);
    163176                ddf_fun_unbind(mouse->mouse_fun);
     177                mouse->mouse_fun->driver_data = NULL;
    164178                ddf_fun_destroy(mouse->mouse_fun);
    165179                return EIO;
     
    168182        mouse->polling_fibril = fibril_create(polling_f, mouse);
    169183        if (!mouse->polling_fibril) {
     184                async_hangup(mouse->parent_sess);
    170185                ddf_fun_unbind(mouse->mouse_fun);
     186                mouse->mouse_fun->driver_data = NULL;
    171187                ddf_fun_destroy(mouse->mouse_fun);
    172188                return ENOMEM;
     
    352368    ipc_callid_t icallid, ipc_call_t *icall)
    353369{
     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
    354376        const sysarg_t method = IPC_GET_IMETHOD(*icall);
    355         ps2_mouse_t *mouse = ddf_dev_data_get(ddf_fun_get_dev(fun));
     377        ps2_mouse_t *mouse = fun->driver_data;
    356378
    357379        switch (method) {
Note: See TracChangeset for help on using the changeset viewer.