Changeset 5fdd7c3 in mainline for uspace/lib/drv/include/driver.h


Ignore:
Timestamp:
2011-01-09T20:41:07Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
22027b6e
Parents:
97adec8
Message:

Say no to static functions.

File:
1 edited

Legend:

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

    r97adec8 r5fdd7c3  
    7272} iface_dipatch_table_t;
    7373
    74 
    75 static inline bool is_valid_iface_idx(int idx)
    76 {
    77         return (0 <= idx) && (idx < DEV_IFACE_MAX);
    78 }
    79 
    80 remote_iface_t *get_remote_iface(int);
    81 remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
    82 
     74extern remote_iface_t *get_remote_iface(int);
     75extern remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
    8376
    8477/*
     
    171164 * @return              The device structure.
    172165 */
    173 static inline device_t *create_device(void)
    174 {
    175         device_t *dev = malloc(sizeof(device_t));
    176 
    177         if (dev != NULL) {
    178                 memset(dev, 0, sizeof(device_t));
    179                 init_match_ids(&dev->match_ids);
    180         }
    181 
    182         return dev;
    183 }
    184 
    185 /** Delete device structure.
    186  *
    187  * @param dev           The device structure.
    188  */
    189 static inline void delete_device(device_t *dev)
    190 {
    191         clean_match_ids(&dev->match_ids);
    192         if (dev->name != NULL)
    193                 free(dev->name);
    194         free(dev);
    195 }
    196 
    197 static inline void *device_get_ops(device_t *dev, dev_inferface_idx_t idx)
    198 {
    199         assert(is_valid_iface_idx(idx));
    200         if (dev->ops == NULL)
    201                 return NULL;
    202         return dev->ops->interfaces[idx];
    203 }
    204 
    205 int child_device_register(device_t *, device_t *);
    206 int child_device_register_wrapper(device_t *, const char *, const char *, int);
     166extern device_t *create_device(void);
     167extern void delete_device(device_t *);
     168extern void *device_get_ops(device_t *, dev_inferface_idx_t);
     169
     170extern int child_device_register(device_t *, device_t *);
     171extern int child_device_register_wrapper(device_t *, const char *, const char *,
     172    int);
    207173
    208174/*
     
    226192} interrupt_context_list_t;
    227193
    228 static inline interrupt_context_t *create_interrupt_context(void)
    229 {
    230         interrupt_context_t *ctx;
    231        
    232         ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
    233         if (ctx != NULL)
    234                 memset(ctx, 0, sizeof(interrupt_context_t));
    235        
    236         return ctx;
    237 }
    238 
    239 static inline void delete_interrupt_context(interrupt_context_t *ctx)
    240 {
    241         if (ctx != NULL)
    242                 free(ctx);
    243 }
    244 
    245 static inline void init_interrupt_context_list(interrupt_context_list_t *list)
    246 {
    247         memset(list, 0, sizeof(interrupt_context_list_t));
    248         fibril_mutex_initialize(&list->mutex);
    249         list_initialize(&list->contexts);
    250 }
    251 
    252 static inline void
    253 add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
    254 {
    255         fibril_mutex_lock(&list->mutex);
    256         ctx->id = list->curr_id++;
    257         list_append(&ctx->link, &list->contexts);
    258         fibril_mutex_unlock(&list->mutex);
    259 }
    260 
    261 static inline void
    262 remove_interrupt_context(interrupt_context_list_t *list,
    263     interrupt_context_t *ctx)
    264 {
    265         fibril_mutex_lock(&list->mutex);
    266         list_remove(&ctx->link);
    267         fibril_mutex_unlock(&list->mutex);
    268 }
    269 
    270 static inline interrupt_context_t *
    271 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)
    272 {
    273         fibril_mutex_lock(&list->mutex);
    274        
    275         link_t *link = list->contexts.next;
    276         interrupt_context_t *ctx;
    277        
    278         while (link != &list->contexts) {
    279                 ctx = list_get_instance(link, interrupt_context_t, link);
    280                 if (ctx->id == id) {
    281                         fibril_mutex_unlock(&list->mutex);
    282                         return ctx;
    283                 }
    284                 link = link->next;
    285         }
    286        
    287         fibril_mutex_unlock(&list->mutex);
    288         return NULL;
    289 }
    290 
    291 static inline interrupt_context_t *
    292 find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq)
    293 {
    294         fibril_mutex_lock(&list->mutex);
    295        
    296         link_t *link = list->contexts.next;
    297         interrupt_context_t *ctx;
    298        
    299         while (link != &list->contexts) {
    300                 ctx = list_get_instance(link, interrupt_context_t, link);
    301                 if (ctx->irq == irq && ctx->dev == dev) {
    302                         fibril_mutex_unlock(&list->mutex);
    303                         return ctx;
    304                 }
    305                 link = link->next;
    306         }
    307        
    308         fibril_mutex_unlock(&list->mutex);
    309         return NULL;
    310 }
    311 
    312 int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
     194extern interrupt_context_t *create_interrupt_context(void);
     195extern void delete_interrupt_context(interrupt_context_t *);
     196extern void init_interrupt_context_list(interrupt_context_list_t *);
     197extern void add_interrupt_context(interrupt_context_list_t *,
     198    interrupt_context_t *);
     199extern void remove_interrupt_context(interrupt_context_list_t *,
     200    interrupt_context_t *);
     201extern interrupt_context_t *find_interrupt_context_by_id(
     202    interrupt_context_list_t *, int);
     203extern interrupt_context_t *find_interrupt_context(
     204    interrupt_context_list_t *, device_t *, int);
     205
     206extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
    313207    irq_code_t *);
    314 int unregister_interrupt_handler(device_t *, int);
    315 
    316 
    317 /** Get default handler for client requests */
    318 static inline remote_handler_t *device_get_default_handler(device_t *dev)
    319 {
    320         if (dev->ops == NULL)
    321                 return NULL;
    322         return dev->ops->default_handler;
    323 }
    324 
    325 static inline int add_device_to_class(device_t *dev, const char *class_name)
    326 {
    327         return devman_add_device_to_class(dev->handle, class_name);
    328 }
     208extern int unregister_interrupt_handler(device_t *, int);
     209
     210extern remote_handler_t *device_get_default_handler(device_t *);
     211extern int add_device_to_class(device_t *, const char *);
    329212
    330213#endif
Note: See TracChangeset for help on using the changeset viewer.