Changeset d35ac1d in mainline
- Timestamp:
- 2011-01-09T19:52:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36f2b3e
- Parents:
- 8871dba
- Location:
- uspace/lib/drv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r8871dba rd35ac1d 140 140 } 141 141 142 static device_t * 142 static device_t *driver_get_device(link_t *devices, devman_handle_t handle) 143 143 { 144 144 device_t *dev = NULL; … … 164 164 int res = EOK; 165 165 166 devman_handle_t dev_handle = 166 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 167 167 devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall); 168 168 169 169 device_t *dev = create_device(); 170 170 dev->handle = dev_handle; … … 177 177 178 178 res = driver->driver_ops->add_device(dev); 179 if ( 0 == res) {179 if (res == 0) { 180 180 printf("%s: new device with handle=%" PRIun " was added.\n", 181 181 driver->name, dev_handle); … … 246 246 ret = (*dev->ops->open)(dev); 247 247 248 ipc_answer_0(iid, ret); 248 ipc_answer_0(iid, ret); 249 249 if (EOK != ret) 250 250 return; … … 258 258 259 259 switch (method) { 260 case IPC_M_PHONE_HUNGUP: 260 case IPC_M_PHONE_HUNGUP: 261 261 /* close the device */ 262 262 if (NULL != dev->ops && NULL != dev->ops->close) … … 264 264 ipc_answer_0(callid, EOK); 265 265 return; 266 default: 266 default: 267 267 /* convert ipc interface id to interface index */ 268 268 … … 289 289 /* calling one of the device's interfaces */ 290 290 291 /* get the device interface structure*/292 void * iface = device_get_iface(dev, iface_idx);293 if ( NULL == iface) {291 /* Get the interface ops structure. */ 292 void *ops = device_get_ops(dev, iface_idx); 293 if (ops == NULL) { 294 294 printf("%s: driver_connection_gen error - ", 295 295 driver->name); … … 304 304 * handling ("remote interface"). 305 305 */ 306 remote_iface_t *rem_iface = get_remote_iface(iface_idx);306 remote_iface_t *rem_iface = get_remote_iface(iface_idx); 307 307 assert(NULL != rem_iface); 308 308 … … 325 325 * associated with the device by its driver. 326 326 */ 327 (*iface_method_ptr)(dev, iface, callid, &call);327 (*iface_method_ptr)(dev, ops, callid, &call); 328 328 break; 329 329 } … … 377 377 if (EOK == res) 378 378 return res; 379 remove_from_devices_list(child); 379 remove_from_devices_list(child); 380 380 return res; 381 381 } -
uspace/lib/drv/generic/remote_char_dev.c
r8871dba rd35ac1d 69 69 * 70 70 * @param dev The device from which the data are read. 71 * @param iface The local interfacestructure.71 * @param ops The local ops structure. 72 72 */ 73 73 static void 74 remote_char_read(device_t *dev, void * iface, ipc_callid_t callid,74 remote_char_read(device_t *dev, void *ops, ipc_callid_t callid, 75 75 ipc_call_t *call) 76 76 { 77 char_dev_ops_t *char_ iface = (char_dev_ops_t *) iface;77 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 78 78 ipc_callid_t cid; 79 79 … … 85 85 } 86 86 87 if (!char_ iface->read) {87 if (!char_dev_ops->read) { 88 88 async_data_read_finalize(cid, NULL, 0); 89 89 ipc_answer_0(callid, ENOTSUP); … … 95 95 96 96 char buf[MAX_CHAR_RW_COUNT]; 97 int ret = (*char_ iface->read)(dev, buf, len);97 int ret = (*char_dev_ops->read)(dev, buf, len); 98 98 99 99 if (ret < 0) { … … 116 116 * 117 117 * @param dev The device to which the data are written. 118 * @param iface The local interfacestructure.118 * @param ops The local ops structure. 119 119 */ 120 120 static void 121 remote_char_write(device_t *dev, void * iface, ipc_callid_t callid,121 remote_char_write(device_t *dev, void *ops, ipc_callid_t callid, 122 122 ipc_call_t *call) 123 123 { 124 char_dev_ops_t *char_ iface = (char_dev_ops_t *) iface;124 char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops; 125 125 ipc_callid_t cid; 126 126 size_t len; … … 132 132 } 133 133 134 if (!char_ iface->write) {134 if (!char_dev_ops->write) { 135 135 async_data_write_finalize(cid, NULL, 0); 136 136 ipc_answer_0(callid, ENOTSUP); … … 145 145 async_data_write_finalize(cid, buf, len); 146 146 147 int ret = (*char_ iface->write)(dev, buf, len);147 int ret = (*char_dev_ops->write)(dev, buf, len); 148 148 if (ret < 0) { 149 149 /* Some error occured. */ -
uspace/lib/drv/generic/remote_hw_res.c
r8871dba rd35ac1d 56 56 }; 57 57 58 static void remote_res_enable_interrupt(device_t *dev, void * iface,58 static void remote_res_enable_interrupt(device_t *dev, void *ops, 59 59 ipc_callid_t callid, ipc_call_t *call) 60 60 { 61 hw_res_ops_t * ires = (hw_res_ops_t *) iface;61 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 62 62 63 if ( NULL == ires->enable_interrupt)63 if (hw_res_ops->enable_interrupt == NULL) 64 64 ipc_answer_0(callid, ENOTSUP); 65 else if ( ires->enable_interrupt(dev))65 else if (hw_res_ops->enable_interrupt(dev)) 66 66 ipc_answer_0(callid, EOK); 67 67 else … … 69 69 } 70 70 71 static void remote_res_get_resource_list(device_t *dev, void * iface,71 static void remote_res_get_resource_list(device_t *dev, void *ops, 72 72 ipc_callid_t callid, ipc_call_t *call) 73 73 { 74 hw_res_ops_t *ires = (hw_res_ops_t *) iface; 75 if (NULL == ires->get_resource_list) { 74 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 75 76 if (hw_res_ops->get_resource_list == NULL) { 76 77 ipc_answer_0(callid, ENOTSUP); 77 78 return; 78 79 } 79 80 80 hw_resource_list_t *hw_resources = ires->get_resource_list(dev);81 hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev); 81 82 if (NULL == hw_resources){ 82 83 ipc_answer_0(callid, ENOENT); -
uspace/lib/drv/include/driver.h
r8871dba rd35ac1d 188 188 } 189 189 190 static inline void *device_get_ iface(device_t *dev, dev_inferface_idx_t idx)190 static inline void *device_get_ops(device_t *dev, dev_inferface_idx_t idx) 191 191 { 192 192 assert(is_valid_iface_idx(idx)); 193 if ( NULL == dev->ops)193 if (dev->ops == NULL) 194 194 return NULL; 195 195 return dev->ops->interfaces[idx];
Note:
See TracChangeset
for help on using the changeset viewer.