Changeset 97adec8 in mainline


Ignore:
Timestamp:
2011-01-09T20:27:48Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5fdd7c3
Parents:
36f2b3e
Message:

More cstyle cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/driver.h

    r36f2b3e r97adec8  
    5050typedef struct device device_t;
    5151
    52 /* device interface */
     52/*
     53 * Device interface
     54 */
    5355
    5456/*
     
    7375static inline bool is_valid_iface_idx(int idx)
    7476{
    75         return 0 <= idx && idx < DEV_IFACE_MAX;
     77        return (0 <= idx) && (idx < DEV_IFACE_MAX);
    7678}
    7779
     
    8082
    8183
    82 /* device class */
    83 
    84 /** Devices operations. */
     84/*
     85 * Device class
     86 */
     87
     88/** Devices operations */
    8589typedef struct device_ops {
    8690        /**
     
    108112
    109113
    110 /* device */
    111 
    112 /** The device. */
     114/*
     115 * Device
     116 */
     117
     118/** Device structure */
    113119struct device {
    114120        /**
     
    119125       
    120126        /**
    121          * The phone to the parent device driver (if it is different from this
    122          * driver).
     127         * Phone to the parent device driver (if it is different from this
     128         * driver)
    123129         */
    124130        int parent_phone;
    125131       
    126         /** Parent device if handled by this driver, NULL otherwise. */
     132        /** Parent device if handled by this driver, NULL otherwise */
    127133        device_t *parent;
    128         /** The device's name. */
     134        /** Device name */
    129135        const char *name;
    130         /** The list of device ids for device-to-driver matching. */
     136        /** List of device ids for device-to-driver matching */
    131137        match_id_list_t match_ids;
    132         /** The device driver's data associated with this device. */
     138        /** Driver-specific data associated with this device */
    133139        void *driver_data;
    134         /** The implementation of operations provided by this device. */
     140        /** The implementation of operations provided by this device */
    135141        device_ops_t *ops;
    136142       
    137         /**
    138          * Pointer to the previous and next device in the list of devices
    139          * handled by the driver.
    140          */
     143        /** Link in the list of devices handled by the driver */
    141144        link_t link;
    142145};
    143146
    144147
    145 /* driver */
    146 
    147 /** Generic device driver operations. */
     148/*
     149 * Driver
     150 */
     151
     152/** Generic device driver operations */
    148153typedef struct driver_ops {
    149         /** Callback method for passing a new device to the device driver.*/
     154        /** Callback method for passing a new device to the device driver */
    150155        int (*add_device)(device_t *dev);
    151         /* TODO add other generic driver operations */
     156        /* TODO: add other generic driver operations */
    152157} driver_ops_t;
    153158
    154 /** The driver structure.*/
     159/** Driver structure */
    155160typedef struct driver {
    156         /** The name of the device driver. */
     161        /** Name of the device driver */
    157162        const char *name;
    158         /** Generic device driver operations. */
     163        /** Generic device driver operations */
    159164        driver_ops_t *driver_ops;
    160165} driver_t;
     
    169174{
    170175        device_t *dev = malloc(sizeof(device_t));
    171         if (NULL != dev) {
     176
     177        if (dev != NULL) {
    172178                memset(dev, 0, sizeof(device_t));
    173179                init_match_ids(&dev->match_ids);
    174         }       
     180        }
     181
    175182        return dev;
    176183}
     
    183190{
    184191        clean_match_ids(&dev->match_ids);
    185         if (NULL != dev->name)
     192        if (dev->name != NULL)
    186193                free(dev->name);
    187194        free(dev);
     
    199206int child_device_register_wrapper(device_t *, const char *, const char *, int);
    200207
    201 
    202 /* interrupts */
     208/*
     209 * Interrupts
     210 */
    203211
    204212typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
     
    223231       
    224232        ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
    225         if (NULL != ctx)
     233        if (ctx != NULL)
    226234                memset(ctx, 0, sizeof(interrupt_context_t));
    227235       
     
    231239static inline void delete_interrupt_context(interrupt_context_t *ctx)
    232240{
    233         if (NULL != ctx)
     241        if (ctx != NULL)
    234242                free(ctx);
    235243}
     
    270278        while (link != &list->contexts) {
    271279                ctx = list_get_instance(link, interrupt_context_t, link);
    272                 if (id == ctx->id) {
     280                if (ctx->id == id) {
    273281                        fibril_mutex_unlock(&list->mutex);
    274282                        return ctx;
     
    291299        while (link != &list->contexts) {
    292300                ctx = list_get_instance(link, interrupt_context_t, link);
    293                 if (irq == ctx->irq && dev == ctx->dev) {
     301                if (ctx->irq == irq && ctx->dev == dev) {
    294302                        fibril_mutex_unlock(&list->mutex);
    295303                        return ctx;
     
    307315
    308316
    309 /* default handler for client requests */
    310 
     317/** Get default handler for client requests */
    311318static inline remote_handler_t *device_get_default_handler(device_t *dev)
    312319{
    313         if (NULL == dev->ops)
     320        if (dev->ops == NULL)
    314321                return NULL;
    315322        return dev->ops->default_handler;
Note: See TracChangeset for help on using the changeset viewer.