Changeset ca4730a5 in mainline


Ignore:
Timestamp:
2013-07-05T08:33:40Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b2010e2
Parents:
882bc4b
Message:

Remove evil macros.

Location:
uspace/drv/char/i8042
Files:
2 edited

Legend:

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

    r882bc4b rca4730a5  
    6363#define i8042_AUX_DISABLE    0x20
    6464#define i8042_KBD_TRANSLATE  0x40  /* Use this to switch to XT scancodes */
    65 
    66 #define CHECK_RET_DESTROY(ret, msg...) \
    67         do { \
    68                 if (ret != EOK) { \
    69                         ddf_msg(LVL_ERROR, msg); \
    70                         if (dev->kbd_fun) { \
    71                                 dev->kbd_fun->driver_data = NULL; \
    72                                 ddf_fun_destroy(dev->kbd_fun); \
    73                         } \
    74                         if (dev->aux_fun) { \
    75                                 dev->aux_fun->driver_data = NULL; \
    76                                 ddf_fun_destroy(dev->aux_fun); \
    77                         } \
    78                 } \
    79         } while (0)
    80 
    81 #define CHECK_RET_UNBIND_DESTROY(ret, msg...) \
    82         do { \
    83                 if (ret != EOK) { \
    84                         ddf_msg(LVL_ERROR, msg); \
    85                         if (dev->kbd_fun) { \
    86                                 ddf_fun_unbind(dev->kbd_fun); \
    87                                 dev->kbd_fun->driver_data = NULL; \
    88                                 ddf_fun_destroy(dev->kbd_fun); \
    89                         } \
    90                         if (dev->aux_fun) { \
    91                                 ddf_fun_unbind(dev->aux_fun); \
    92                                 dev->aux_fun->driver_data = NULL; \
    93                                 ddf_fun_destroy(dev->aux_fun); \
    94                         } \
    95                 } \
    96         } while (0)
    9765
    9866void default_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
  • uspace/drv/char/i8042/main.c

    r882bc4b rca4730a5  
    4545#include <async.h>
    4646#include "i8042.h"
    47 
    48 #define CHECK_RET_RETURN(ret, message...) \
    49         do { \
    50                 if (ret != EOK) { \
    51                         ddf_msg(LVL_ERROR, message); \
    52                         return ret; \
    53                 } \
    54         } while (0)
    5547
    5648/** Get address of I/O registers.
     
    112104static int i8042_dev_add(ddf_dev_t *device)
    113105{
    114         if (!device)
    115                 return EINVAL;
    116        
    117106        uintptr_t io_regs = 0;
    118107        size_t io_size = 0;
    119108        int kbd = 0;
    120109        int mouse = 0;
     110        int rc;
    121111       
    122         int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
    123         CHECK_RET_RETURN(ret, "Failed to get registers: %s.",
    124             str_error(ret));
     112        if (!device)
     113                return EINVAL;
     114       
     115        rc = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
     116        if (rc != EOK) {
     117                ddf_msg(LVL_ERROR, "Failed to get registers: %s.",
     118                    str_error(rc));
     119                return rc;
     120        }
     121       
    125122        ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
    126123            (void *) io_regs, io_size, kbd, mouse);
    127124       
    128125        i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t));
    129         ret = (i8042 == NULL) ? ENOMEM : EOK;
    130         CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance.");
     126        if (i8042 == NULL) {
     127                ddf_msg(LVL_ERROR, "Out of memory.");
     128                return ENOMEM;
     129        }
    131130       
    132         ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);
    133         CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.",
    134             str_error(ret));
     131        rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);
     132        if (rc != EOK) {
     133                ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.",
     134                    str_error(rc));
     135                return rc;
     136        }
    135137       
    136138        ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
Note: See TracChangeset for help on using the changeset viewer.