Changeset 68414f4a in mainline for uspace/drv/root/root.c
- Timestamp:
- 2011-02-13T20:03:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bab6388
- Parents:
- 8b1e15ac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/root.c
r8b1e15ac r68414f4a 2 2 * Copyright (c) 2010 Lenka Trochtova 3 3 * Copyright (c) 2010 Vojtech Horky 4 * Copyright (c) 2011 Jiri Svoboda 4 5 * All rights reserved. 5 6 * … … 55 56 #define NAME "root" 56 57 57 #define PLATFORM_ DEVICE_NAME "hw"58 #define PLATFORM_ DEVICE_MATCH_ID_FMT "platform/%s"59 #define PLATFORM_ DEVICE_MATCH_SCORE 10058 #define PLATFORM_FUN_NAME "hw" 59 #define PLATFORM_FUN_MATCH_ID_FMT "platform/%s" 60 #define PLATFORM_FUN_MATCH_SCORE 100 60 61 61 #define VIRTUAL_ DEVICE_NAME "virt"62 #define VIRTUAL_ DEVICE_MATCH_ID "rootvirt"63 #define VIRTUAL_ DEVICE_MATCH_SCORE 10062 #define VIRTUAL_FUN_NAME "virt" 63 #define VIRTUAL_FUN_MATCH_ID "rootvirt" 64 #define VIRTUAL_FUN_MATCH_SCORE 100 64 65 65 66 static int root_add_device(device_t *dev); … … 76 77 }; 77 78 78 /** Create the devicewhich represents the root of virtual device tree.79 /** Create the function which represents the root of virtual device tree. 79 80 * 80 * @param parent Parent of the newly created device.81 * @return Error code.81 * @param dev Device 82 * @return EOK on success or negative error code 82 83 */ 83 static int add_virtual_root_ child(device_t *parent)84 static int add_virtual_root_fun(device_t *dev) 84 85 { 85 printf(NAME ": adding new childfor virtual devices.\n");86 printf(NAME ": device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,87 VIRTUAL_ DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);86 printf(NAME ": adding new function for virtual devices.\n"); 87 printf(NAME ": function node is `%s' (%d %s)\n", VIRTUAL_FUN_NAME, 88 VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID); 88 89 89 int res = register_function_wrapper( parent, VIRTUAL_DEVICE_NAME,90 VIRTUAL_ DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE);90 int res = register_function_wrapper(dev, VIRTUAL_FUN_NAME, 91 VIRTUAL_FUN_MATCH_ID, VIRTUAL_FUN_MATCH_SCORE); 91 92 92 93 return res; 93 94 } 94 95 95 /** Create the devicewhich represents the root of HW device tree.96 /** Create the function which represents the root of HW device tree. 96 97 * 97 * @param parent Parent of the newly created device.98 * @return 0 on success, negative error number otherwise.98 * @param dev Device 99 * @return EOK on success or negative error code 99 100 */ 100 static int add_platform_ child(device_t *parent)101 static int add_platform_fun(device_t *dev) 101 102 { 102 103 char *match_id; … … 106 107 107 108 /* Get platform name from sysinfo. */ 108 109 109 platform = sysinfo_get_data("platform", &platform_size); 110 110 if (platform == NULL) { … … 123 123 124 124 /* Construct match ID. */ 125 126 if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) { 125 if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) { 127 126 printf(NAME ": Memory allocation failed.\n"); 128 127 return ENOMEM; 129 128 } 130 129 131 /* Add child. */ 130 /* Add function. */ 131 printf(NAME ": adding platform function\n"); 132 printf(NAME ": function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME, 133 PLATFORM_FUN_MATCH_SCORE, match_id); 132 134 133 printf(NAME ": adding new child for platform device.\n"); 134 printf(NAME ": device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME, 135 PLATFORM_DEVICE_MATCH_SCORE, match_id); 136 137 res = register_function_wrapper(parent, PLATFORM_DEVICE_NAME, 138 match_id, PLATFORM_DEVICE_MATCH_SCORE); 135 res = register_function_wrapper(dev, PLATFORM_FUN_NAME, 136 match_id, PLATFORM_FUN_MATCH_SCORE); 139 137 140 138 return res; … … 156 154 * vital for the system. 157 155 */ 158 add_virtual_root_ child(dev);156 add_virtual_root_fun(dev); 159 157 160 158 /* Register root device's children. */ 161 int res = add_platform_ child(dev);159 int res = add_platform_fun(dev); 162 160 if (EOK != res) 163 161 printf(NAME ": failed to add child device for platform.\n");
Note:
See TracChangeset
for help on using the changeset viewer.