Changeset 97adec8 in mainline
- Timestamp:
- 2011-01-09T20:27:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5fdd7c3
- Parents:
- 36f2b3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/include/driver.h
r36f2b3e r97adec8 50 50 typedef struct device device_t; 51 51 52 /* device interface */ 52 /* 53 * Device interface 54 */ 53 55 54 56 /* … … 73 75 static inline bool is_valid_iface_idx(int idx) 74 76 { 75 return 0 <= idx && idx < DEV_IFACE_MAX;77 return (0 <= idx) && (idx < DEV_IFACE_MAX); 76 78 } 77 79 … … 80 82 81 83 82 /* device class */ 83 84 /** Devices operations. */ 84 /* 85 * Device class 86 */ 87 88 /** Devices operations */ 85 89 typedef struct device_ops { 86 90 /** … … 108 112 109 113 110 /* device */ 111 112 /** The device. */ 114 /* 115 * Device 116 */ 117 118 /** Device structure */ 113 119 struct device { 114 120 /** … … 119 125 120 126 /** 121 * The phone to the parent device driver (if it is different from this122 * driver) .127 * Phone to the parent device driver (if it is different from this 128 * driver) 123 129 */ 124 130 int parent_phone; 125 131 126 /** Parent device if handled by this driver, NULL otherwise .*/132 /** Parent device if handled by this driver, NULL otherwise */ 127 133 device_t *parent; 128 /** The device's name.*/134 /** Device name */ 129 135 const char *name; 130 /** The list of device ids for device-to-driver matching.*/136 /** List of device ids for device-to-driver matching */ 131 137 match_id_list_t match_ids; 132 /** The device driver's data associated with this device.*/138 /** Driver-specific data associated with this device */ 133 139 void *driver_data; 134 /** The implementation of operations provided by this device .*/140 /** The implementation of operations provided by this device */ 135 141 device_ops_t *ops; 136 142 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 */ 141 144 link_t link; 142 145 }; 143 146 144 147 145 /* driver */ 146 147 /** Generic device driver operations. */ 148 /* 149 * Driver 150 */ 151 152 /** Generic device driver operations */ 148 153 typedef 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 */ 150 155 int (*add_device)(device_t *dev); 151 /* TODO add other generic driver operations */156 /* TODO: add other generic driver operations */ 152 157 } driver_ops_t; 153 158 154 /** The driver structure.*/159 /** Driver structure */ 155 160 typedef struct driver { 156 /** The name of the device driver.*/161 /** Name of the device driver */ 157 162 const char *name; 158 /** Generic device driver operations .*/163 /** Generic device driver operations */ 159 164 driver_ops_t *driver_ops; 160 165 } driver_t; … … 169 174 { 170 175 device_t *dev = malloc(sizeof(device_t)); 171 if (NULL != dev) { 176 177 if (dev != NULL) { 172 178 memset(dev, 0, sizeof(device_t)); 173 179 init_match_ids(&dev->match_ids); 174 } 180 } 181 175 182 return dev; 176 183 } … … 183 190 { 184 191 clean_match_ids(&dev->match_ids); 185 if ( NULL != dev->name)192 if (dev->name != NULL) 186 193 free(dev->name); 187 194 free(dev); … … 199 206 int child_device_register_wrapper(device_t *, const char *, const char *, int); 200 207 201 202 /* interrupts */ 208 /* 209 * Interrupts 210 */ 203 211 204 212 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *); … … 223 231 224 232 ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t)); 225 if ( NULL != ctx)233 if (ctx != NULL) 226 234 memset(ctx, 0, sizeof(interrupt_context_t)); 227 235 … … 231 239 static inline void delete_interrupt_context(interrupt_context_t *ctx) 232 240 { 233 if ( NULL != ctx)241 if (ctx != NULL) 234 242 free(ctx); 235 243 } … … 270 278 while (link != &list->contexts) { 271 279 ctx = list_get_instance(link, interrupt_context_t, link); 272 if ( id == ctx->id) {280 if (ctx->id == id) { 273 281 fibril_mutex_unlock(&list->mutex); 274 282 return ctx; … … 291 299 while (link != &list->contexts) { 292 300 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) { 294 302 fibril_mutex_unlock(&list->mutex); 295 303 return ctx; … … 307 315 308 316 309 /* default handler for client requests */ 310 317 /** Get default handler for client requests */ 311 318 static inline remote_handler_t *device_get_default_handler(device_t *dev) 312 319 { 313 if ( NULL == dev->ops)320 if (dev->ops == NULL) 314 321 return NULL; 315 322 return dev->ops->default_handler;
Note:
See TracChangeset
for help on using the changeset viewer.