Changeset 5291411 in mainline
- Timestamp:
- 2010-10-23T13:01:34Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b9ccc46
- Parents:
- 663f41c4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/root.c
r663f41c4 r5291411 54 54 static int root_add_device(device_t *dev); 55 55 56 /** The root device driver's standard operations. 57 */ 56 /** The root device driver's standard operations. */ 58 57 static driver_ops_t root_ops = { 59 58 .add_device = &root_add_device 60 59 }; 61 60 62 /** The root device driver structure. 63 */ 61 /** The root device driver structure. */ 64 62 static driver_t root_driver = { 65 63 .name = NAME, … … 68 66 69 67 /** Create the device which represents the root of HW device tree. 70 * 71 * @param parent parent of the newly created device.68 * 69 * @param parent Parent of the newly created device. 72 70 * @return 0 on success, negative error number otherwise. 73 71 */ 74 static int add_platform_child(device_t *parent) { 72 static int add_platform_child(device_t *parent) 73 { 75 74 printf(NAME ": adding new child for platform device.\n"); 76 75 77 76 int res = EOK; 78 77 device_t *platform = NULL; 79 match_id_t *match_id = NULL; 78 match_id_t *match_id = NULL; 80 79 81 // create new device 82 if (NULL == (platform = create_device())) { 80 /* Create new device. */ 81 platform = create_device(); 82 if (NULL == platform) { 83 83 res = ENOMEM; 84 84 goto failure; … … 88 88 printf(NAME ": the new device's name is %s.\n", platform->name); 89 89 90 // initialize match id list 91 if (NULL == (match_id = create_match_id())) { 90 /* Initialize match id list. */ 91 match_id = create_match_id(); 92 if (NULL == match_id) { 92 93 res = ENOMEM; 93 94 goto failure; 94 95 } 95 96 96 / / TODO - replace this with some better solution (sysinfo ?)97 /* TODO - replace this with some better solution (sysinfo ?) */ 97 98 match_id->id = STRING(UARCH); 98 99 match_id->score = 100; 99 add_match_id(&platform->match_ids, match_id); 100 add_match_id(&platform->match_ids, match_id); 100 101 101 / / register child device102 /* Register child device. */ 102 103 res = child_device_register(platform, parent); 103 if (EOK != res) {104 if (EOK != res) 104 105 goto failure; 105 }106 106 107 107 return res; 108 108 109 109 failure: 110 if (NULL != match_id) {110 if (NULL != match_id) 111 111 match_id->id = NULL; 112 }113 112 114 113 if (NULL != platform) { 115 114 platform->name = NULL; 116 delete_device(platform); 115 delete_device(platform); 117 116 } 118 117 119 return res; 118 return res; 120 119 } 121 120 122 121 /** Get the root device. 123 * @param dev the device which is root of the whole device tree (both of HW and pseudo devices). 122 * 123 * @param dev The device which is root of the whole device tree (both 124 * of HW and pseudo devices). 124 125 */ 125 static int root_add_device(device_t *dev) 126 static int root_add_device(device_t *dev) 126 127 { 127 128 printf(NAME ": root_add_device, device handle = %d\n", dev->handle); 128 129 129 / / register root device's children130 int res = add_platform_child(dev); 131 if (EOK != res) {130 /* Register root device's children. */ 131 int res = add_platform_child(dev); 132 if (EOK != res) 132 133 printf(NAME ": failed to add child device for platform.\n"); 133 }134 134 135 135 return res; … … 138 138 int main(int argc, char *argv[]) 139 139 { 140 printf(NAME ": HelenOS root device driver\n"); 140 printf(NAME ": HelenOS root device driver\n"); 141 141 return driver_main(&root_driver); 142 142 } … … 145 145 * @} 146 146 */ 147 147
Note:
See TracChangeset
for help on using the changeset viewer.