Changeset 3b5d1535 in mainline for uspace/drv/test1/test1.c
- Timestamp:
- 2011-02-23T10:28:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eb48f61
- Parents:
- e936e8e (diff), eb1a2f4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/test1/test1.c
re936e8e r3b5d1535 34 34 #include <errno.h> 35 35 #include <str_error.h> 36 #include <ddf/driver.h> 37 36 38 #include "test1.h" 37 39 38 static int add_device(device_t *dev);40 static int test1_add_device(ddf_dev_t *dev); 39 41 40 42 static driver_ops_t driver_ops = { 41 .add_device = & add_device43 .add_device = &test1_add_device 42 44 }; 43 45 44 static driver_t t he_driver = {46 static driver_t test1_driver = { 45 47 .name = NAME, 46 48 .driver_ops = &driver_ops … … 55 57 * @param score Device match score. 56 58 */ 57 static void register_child_verbose(device_t *parent, const char *message,59 static int register_fun_verbose(ddf_dev_t *parent, const char *message, 58 60 const char *name, const char *match_id, int match_score) 59 61 { 60 printf(NAME ": registering child device `%s': %s.\n",61 name, message);62 ddf_fun_t *fun; 63 int rc; 62 64 63 int rc = child_device_register_wrapper(parent, name, 64 match_id, match_score, NULL); 65 printf(NAME ": registering function `%s': %s.\n", name, message); 65 66 66 if (rc == EOK) { 67 printf(NAME ": registered child device `%s'.\n", name); 68 } else { 69 printf(NAME ": failed to register child `%s' (%s).\n", 70 name, str_error(rc)); 67 fun = ddf_fun_create(parent, fun_inner, name); 68 if (fun == NULL) { 69 printf(NAME ": error creating function %s\n", name); 70 return ENOMEM; 71 71 } 72 73 rc = ddf_fun_add_match_id(fun, match_id, match_score); 74 if (rc != EOK) { 75 printf(NAME ": error adding match IDs to function %s\n", name); 76 ddf_fun_destroy(fun); 77 return rc; 78 } 79 80 rc = ddf_fun_bind(fun); 81 if (rc != EOK) { 82 printf(NAME ": error binding function %s: %s\n", name, 83 str_error(rc)); 84 ddf_fun_destroy(fun); 85 return rc; 86 } 87 88 printf(NAME ": registered child device `%s'\n", name); 89 return EOK; 72 90 } 73 91 … … 89 107 * @return Error code reporting success of the operation. 90 108 */ 91 static int add_device(device_t *dev)109 static int test1_add_device(ddf_dev_t *dev) 92 110 { 111 ddf_fun_t *fun_a; 112 int rc; 113 93 114 printf(NAME ": add_device(name=\"%s\", handle=%d)\n", 94 115 dev->name, (int) dev->handle); 95 116 96 add_device_to_class(dev, "virtual"); 117 fun_a = ddf_fun_create(dev, fun_exposed, "a"); 118 if (fun_a == NULL) { 119 printf(NAME ": error creating function 'a'.\n"); 120 return ENOMEM; 121 } 122 123 rc = ddf_fun_bind(fun_a); 124 if (rc != EOK) { 125 printf(NAME ": error binding function 'a'.\n"); 126 return rc; 127 } 128 129 ddf_fun_add_to_class(fun_a, "virtual"); 97 130 98 131 if (str_cmp(dev->name, "null") == 0) { 99 dev->ops = &char_device_ops;100 add_device_to_class(dev, "virt-null");101 } else if ( dev->parent == NULL) {102 register_child_verbose(dev, "cloning myself ;-)", "clone",132 fun_a->ops = &char_device_ops; 133 ddf_fun_add_to_class(fun_a, "virt-null"); 134 } else if (str_cmp(dev->name, "test1") == 0) { 135 (void) register_fun_verbose(dev, "cloning myself ;-)", "clone", 103 136 "virtual&test1", 10); 104 137 } else if (str_cmp(dev->name, "clone") == 0) { 105 register_child_verbose(dev, "run by the same task", "child",138 (void) register_fun_verbose(dev, "run by the same task", "child", 106 139 "virtual&test1&child", 10); 107 140 } … … 115 148 { 116 149 printf(NAME ": HelenOS test1 virtual device driver\n"); 117 return d river_main(&the_driver);150 return ddf_driver_main(&test1_driver); 118 151 } 119 152
Note:
See TracChangeset
for help on using the changeset viewer.