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


Ignore:
Timestamp:
2011-02-14T22:14:52Z (14 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/test2/test2.c

    r97a62fe rcd0684d  
    5757 * @param score Device match score.
    5858 */
    59 static void register_child_verbose(device_t *parent, const char *message,
     59static int register_fun_verbose(device_t *parent, const char *message,
    6060    const char *name, const char *match_id, int match_score)
    6161{
    62         printf(NAME ": registering child device `%s': %s.\n",
    63            name, message);
     62        function_t *fun;
     63        int rc;
    6464
    65         int rc = register_function_wrapper(parent, name,
    66             match_id, match_score);
     65        printf(NAME ": registering function `%s': %s.\n", name, message);
    6766
    68         if (rc == EOK) {
    69                 printf(NAME ": registered child device `%s'.\n", name);
    70         } else {
    71                 printf(NAME ": failed to register child `%s' (%s).\n",
    72                     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;
    7371        }
     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;
    7490}
    7591
     
    87103        async_usleep(1000);
    88104
    89         register_child_verbose(dev, "child driven by the same task",
     105        (void) register_fun_verbose(dev, "child driven by the same task",
    90106            "child", "virtual&test2", 10);
    91         register_child_verbose(dev, "child driven by test1",
     107        (void) register_fun_verbose(dev, "child driven by test1",
    92108            "test1", "virtual&test1", 10);
    93109
     
    122138                fibril_add_ready(postpone);
    123139        } else {
    124                 register_child_verbose(dev, "child without available driver",
     140                (void) register_fun_verbose(dev, "child without available driver",
    125141                    "ERROR", "non-existent.match.id", 10);
    126142        }
Note: See TracChangeset for help on using the changeset viewer.