Changeset cd0684d in mainline for uspace/drv/test1/test1.c


Ignore:
Timestamp:
2011-02-14T22:14:52Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
659ca07
Parents:
97a62fe
Message:

Remove register_function_wrapper() since it became practically useless.
Provide ddf_fun_add_match_id() instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/test1/test1.c

    r97a62fe rcd0684d  
    5555 * @param score Device match score.
    5656 */
    57 static void register_fun_verbose(device_t *parent, const char *message,
     57static int register_fun_verbose(device_t *parent, const char *message,
    5858    const char *name, const char *match_id, int match_score)
    5959{
    60         printf(NAME ": registering child device `%s': %s.\n",
    61            name, message);
     60        function_t *fun;
     61        int rc;
    6262
    63         int rc = register_function_wrapper(parent, name,
    64             match_id, match_score);
     63        printf(NAME ": registering function `%s': %s.\n", name, message);
    6564
    66         if (rc == EOK) {
    67                 printf(NAME ": registered function `%s'.\n", name);
    68         } else {
    69                 printf(NAME ": failed to register function `%s' (%s).\n",
    70                     name, str_error(rc));
     65        fun = ddf_fun_create(parent, fun_inner, name);
     66        if (fun == NULL) {
     67                printf(NAME ": error creating function %s\n", name);
     68                return ENOMEM;
    7169        }
     70
     71        rc = ddf_fun_add_match_id(fun, match_id, match_score);
     72        if (rc != EOK) {
     73                printf(NAME ": error adding match IDs to function %s\n", name);
     74                ddf_fun_destroy(fun);
     75                return rc;
     76        }
     77
     78        rc = ddf_fun_bind(fun);
     79        if (rc != EOK) {
     80                printf(NAME ": error binding function %s: %s\n", name,
     81                    str_error(rc));
     82                ddf_fun_destroy(fun);
     83                return rc;
     84        }
     85
     86        printf(NAME ": registered child device `%s'\n", name);
     87        return EOK;
    7288}
    7389
     
    115131                add_function_to_class(fun_a, "virt-null");
    116132        } else if (str_cmp(dev->name, "test1") == 0) {
    117                 register_fun_verbose(dev, "cloning myself ;-)", "clone",
     133                (void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
    118134                    "virtual&test1", 10);
    119135        } else if (str_cmp(dev->name, "clone") == 0) {
    120                 register_fun_verbose(dev, "run by the same task", "child",
     136                (void) register_fun_verbose(dev, "run by the same task", "child",
    121137                    "virtual&test1&child", 10);
    122138        }
Note: See TracChangeset for help on using the changeset viewer.