Changes in uspace/drv/root/root.c [7e752b2:6f9e7fea] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/root.c
r7e752b2 r6f9e7fea 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2010 Vojtech Horky 3 4 * All rights reserved. 4 5 * … … 45 46 #include <ctype.h> 46 47 #include <macros.h> 47 #include <inttypes.h>48 48 49 49 #include <driver.h> … … 52 52 53 53 #define NAME "root" 54 55 #define PLATFORM_DEVICE_NAME "hw" 56 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH) 57 #define PLATFORM_DEVICE_MATCH_SCORE 100 58 59 #define VIRTUAL_DEVICE_NAME "virt" 60 #define VIRTUAL_DEVICE_MATCH_ID "rootvirt" 61 #define VIRTUAL_DEVICE_MATCH_SCORE 100 54 62 55 63 static int root_add_device(device_t *dev); … … 66 74 }; 67 75 76 /** Create the device which represents the root of virtual device tree. 77 * 78 * @param parent Parent of the newly created device. 79 * @return Error code. 80 */ 81 static int add_virtual_root_child(device_t *parent) 82 { 83 printf(NAME ": adding new child for virtual devices.\n"); 84 printf(NAME ": device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME, 85 VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID); 86 87 int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME, 88 VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE); 89 90 return res; 91 } 92 68 93 /** Create the device which represents the root of HW device tree. 69 94 * … … 74 99 { 75 100 printf(NAME ": adding new child for platform device.\n"); 101 printf(NAME ": device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME, 102 PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID); 76 103 77 int res = EOK; 78 device_t *platform = NULL; 79 match_id_t *match_id = NULL; 80 81 /* Create new device. */ 82 platform = create_device(); 83 if (NULL == platform) { 84 res = ENOMEM; 85 goto failure; 86 } 87 88 platform->name = "hw"; 89 printf(NAME ": the new device's name is %s.\n", platform->name); 90 91 /* Initialize match id list. */ 92 match_id = create_match_id(); 93 if (NULL == match_id) { 94 res = ENOMEM; 95 goto failure; 96 } 97 98 /* TODO - replace this with some better solution (sysinfo ?) */ 99 match_id->id = STRING(UARCH); 100 match_id->score = 100; 101 add_match_id(&platform->match_ids, match_id); 102 103 /* Register child device. */ 104 res = child_device_register(platform, parent); 105 if (EOK != res) 106 goto failure; 107 108 return res; 109 110 failure: 111 if (NULL != match_id) 112 match_id->id = NULL; 113 114 if (NULL != platform) { 115 platform->name = NULL; 116 delete_device(platform); 117 } 118 104 int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME, 105 PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE); 106 119 107 return res; 120 108 } … … 127 115 static int root_add_device(device_t *dev) 128 116 { 129 printf(NAME ": root_add_device, device handle=%" PRIun "\n", 130 dev->handle); 117 printf(NAME ": root_add_device, device handle = %d\n", dev->handle); 131 118 119 /* 120 * Register virtual devices root. 121 * We ignore error occurrence because virtual devices shall not be 122 * vital for the system. 123 */ 124 add_virtual_root_child(dev); 125 132 126 /* Register root device's children. */ 133 127 int res = add_platform_child(dev);
Note:
See TracChangeset
for help on using the changeset viewer.