Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3123d2a in mainline for uspace/srv/hid/input/ctl/kbdev.c


Ignore:
Timestamp:
2012-06-01T19:26:32Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
520acaf, 85a4350, c573e0f, e1e4192
Parents:
2f90b46
Message:

trivial changes (error code reporting, messages)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/ctl/kbdev.c

    r2f90b46 r3123d2a  
    6868        /** Link to generic keyboard device */
    6969        kbd_dev_t *kbd_dev;
    70 
     70       
    7171        /** Session with kbdev device */
    7272        async_sess_t *sess;
     
    7575static kbdev_t *kbdev_new(kbd_dev_t *kdev)
    7676{
    77         kbdev_t *kbdev;
    78 
    79         kbdev = calloc(1, sizeof(kbdev_t));
     77        kbdev_t *kbdev = calloc(1, sizeof(kbdev_t));
    8078        if (kbdev == NULL)
    8179                return NULL;
    82 
     80       
    8381        kbdev->kbd_dev = kdev;
    8482
     
    9088        if (kbdev->sess != NULL)
    9189                async_hangup(kbdev->sess);
     90       
    9291        free(kbdev);
    9392}
     
    9594static int kbdev_ctl_init(kbd_dev_t *kdev)
    9695{
    97         async_sess_t *sess;
    98         async_exch_t *exch;
    99         kbdev_t *kbdev;
    100         int rc;
    101 
    102         sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
     96        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
     97            kdev->svc_id, 0);
    10398        if (sess == NULL) {
    10499                printf("%s: Failed starting session with '%s.'\n", NAME,
    105100                    kdev->svc_name);
    106                 return -1;
     101                return ENOENT;
    107102        }
    108 
    109         kbdev = kbdev_new(kdev);
     103       
     104        kbdev_t *kbdev = kbdev_new(kdev);
    110105        if (kbdev == NULL) {
    111106                printf("%s: Failed allocating device structure for '%s'.\n",
    112107                    NAME, kdev->svc_name);
    113108                async_hangup(sess);
    114                 return -1;
     109                return ENOMEM;
    115110        }
    116 
     111       
    117112        kbdev->sess = sess;
    118 
    119         exch = async_exchange_begin(sess);
     113       
     114        async_exch_t *exch = async_exchange_begin(sess);
    120115        if (exch == NULL) {
    121116                printf("%s: Failed starting exchange with '%s'.\n", NAME,
    122117                    kdev->svc_name);
    123118                kbdev_destroy(kbdev);
    124                 return -1;
     119                return ENOENT;
    125120        }
    126 
    127         rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
     121       
     122        int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);
    128123        if (rc != EOK) {
    129124                printf("%s: Failed creating callback connection from '%s'.\n",
     
    131126                async_exchange_end(exch);
    132127                kbdev_destroy(kbdev);
    133                 return -1;
     128                return rc;
    134129        }
    135 
     130       
    136131        async_exchange_end(exch);
    137 
     132       
    138133        kdev->ctl_private = (void *) kbdev;
    139134        return 0;
     
    142137static void kbdev_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    143138{
    144         async_sess_t *sess;
    145         async_exch_t *exch;
    146 
    147         sess = ((kbdev_t *) kdev->ctl_private)->sess;
    148 
    149         exch = async_exchange_begin(sess);
     139        async_sess_t *sess = ((kbdev_t *) kdev->ctl_private)->sess;
     140        async_exch_t *exch = async_exchange_begin(sess);
    150141        if (!exch)
    151142                return;
    152 
     143       
    153144        async_msg_1(exch, KBDEV_SET_IND, mods);
    154145        async_exchange_end(exch);
Note: See TracChangeset for help on using the changeset viewer.