Changeset df747b9c in mainline for uspace/lib/libdrv
- Timestamp:
- 2010-04-23T11:30:25Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5af21c5
- Parents:
- a78fa2a
- Location:
- uspace/lib/libdrv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libdrv/generic/driver.c
ra78fa2a rdf747b9c 103 103 static void driver_add_device(ipc_callid_t iid, ipc_call_t *icall) 104 104 { 105 // TODO device state - the driver may detect the device is not actually present 106 // (old non PnP devices) or is not working properly. 107 // We should send such information to device manager. 108 109 ipcarg_t ret; 105 char *dev_name = NULL; 106 int res = EOK; 107 110 108 device_handle_t dev_handle = IPC_GET_ARG1(*icall); 111 109 device_t *dev = driver_create_device(); 112 110 dev->handle = dev_handle; 113 async_string_receive(&dev->name, 0, NULL); 114 add_to_devices_list(dev); 115 if (driver->driver_ops->add_device(dev)) { 111 112 async_string_receive(&dev_name, 0, NULL); 113 dev->name = dev_name; 114 115 add_to_devices_list(dev); 116 res = driver->driver_ops->add_device(dev); 117 if (0 == res) { 116 118 printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle); 117 ret = 1;118 119 } else { 119 printf("%s: failed to add a new device with handle = % x.\n", driver->name, dev_handle);120 printf("%s: failed to add a new device with handle = %d.\n", driver->name, dev_handle); 120 121 remove_from_devices_list(dev); 121 // TODO delete device122 ret = 0;123 }124 ipc_answer_0(iid, EOK);122 delete_device(dev); 123 } 124 125 ipc_answer_0(iid, res); 125 126 } 126 127 … … 270 271 } 271 272 272 boolchild_device_register(device_t *child, device_t *parent)273 int child_device_register(device_t *child, device_t *parent) 273 274 { 274 275 // printf("%s: child_device_register\n", driver->name); … … 276 277 assert(NULL != child->name); 277 278 279 int res; 280 278 281 add_to_devices_list(child); 279 if (EOK == devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) {280 return true;282 if (EOK == (res = devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle))) { 283 return res; 281 284 } 282 285 remove_from_devices_list(child); 283 return false;286 return res; 284 287 } 285 288 -
uspace/lib/libdrv/include/driver.h
ra78fa2a rdf747b9c 109 109 typedef struct driver_ops { 110 110 /** Callback method for passing a new device to the device driver.*/ 111 bool(*add_device)(device_t *dev);111 int (*add_device)(device_t *dev); 112 112 // TODO add other generic driver operations 113 113 } driver_ops_t; … … 161 161 } 162 162 163 boolchild_device_register(device_t *child, device_t *parent);163 int child_device_register(device_t *child, device_t *parent); 164 164 165 165
Note:
See TracChangeset
for help on using the changeset viewer.