Ignore:
File:
1 edited

Legend:

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

    rebcb05a raf6b5157  
    3535#include <str_error.h>
    3636#include <ddf/driver.h>
    37 #include <ddf/log.h>
    3837
    3938#include "test1.h"
     
    5958 */
    6059static int register_fun_verbose(ddf_dev_t *parent, const char *message,
    61     const char *name, const char *match_id, int match_score,
    62     int expected_rc)
     60    const char *name, const char *match_id, int match_score)
    6361{
    64         ddf_fun_t *fun = NULL;
     62        ddf_fun_t *fun;
    6563        int rc;
    6664
    67         ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
     65        printf(NAME ": registering function `%s': %s.\n", name, message);
    6866
    6967        fun = ddf_fun_create(parent, fun_inner, name);
    7068        if (fun == NULL) {
    71                 ddf_msg(LVL_ERROR, "Failed creating function %s", name);
    72                 rc = ENOMEM;
    73                 goto leave;
     69                printf(NAME ": error creating function %s\n", name);
     70                return ENOMEM;
    7471        }
    7572
    76         rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
     73        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7774        if (rc != EOK) {
    78                 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
    79                     name);
    80                 goto leave;
     75                printf(NAME ": error adding match IDs to function %s\n", name);
     76                ddf_fun_destroy(fun);
     77                return rc;
    8178        }
    8279
    8380        rc = ddf_fun_bind(fun);
    8481        if (rc != EOK) {
    85                 ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
     82                printf(NAME ": error binding function %s: %s\n", name,
    8683                    str_error(rc));
    87                 goto leave;
     84                ddf_fun_destroy(fun);
     85                return rc;
    8886        }
    8987
    90         ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
    91         rc = EOK;
    92 
    93 leave:
    94         if (rc != expected_rc) {
    95                 fprintf(stderr,
    96                     NAME ": Unexpected error registering function `%s'.\n"
    97                     NAME ":     Expected \"%s\" but got \"%s\".\n",
    98                     name, str_error(expected_rc), str_error(rc));
    99         }
    100 
    101         if ((rc != EOK) && (fun != NULL)) {
    102                 ddf_fun_destroy(fun);
    103         }
    104 
    105         return rc;
     88        printf(NAME ": registered child device `%s'\n", name);
     89        return EOK;
    10690}
    10791
     
    128112        int rc;
    129113
    130         ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)",
     114        printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
    131115            dev->name, (int) dev->handle);
    132116
    133117        fun_a = ddf_fun_create(dev, fun_exposed, "a");
    134118        if (fun_a == NULL) {
    135                 ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
     119                printf(NAME ": error creating function 'a'.\n");
    136120                return ENOMEM;
    137121        }
     
    139123        rc = ddf_fun_bind(fun_a);
    140124        if (rc != EOK) {
    141                 ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
     125                printf(NAME ": error binding function 'a'.\n");
    142126                return rc;
    143127        }
     
    149133                ddf_fun_add_to_class(fun_a, "virt-null");
    150134        } else if (str_cmp(dev->name, "test1") == 0) {
    151                 (void) register_fun_verbose(dev,
    152                     "cloning myself ;-)", "clone",
    153                     "virtual&test1", 10, EOK);
    154                 (void) register_fun_verbose(dev,
    155                     "cloning myself twice ;-)", "clone",
    156                     "virtual&test1", 10, EEXISTS);
     135                (void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
     136                    "virtual&test1", 10);
    157137        } else if (str_cmp(dev->name, "clone") == 0) {
    158                 (void) register_fun_verbose(dev,
    159                     "run by the same task", "child",
    160                     "virtual&test1&child", 10, EOK);
     138                (void) register_fun_verbose(dev, "run by the same task", "child",
     139                    "virtual&test1&child", 10);
    161140        }
    162141
    163         ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev->name);
     142        printf(NAME ": device `%s' accepted.\n", dev->name);
    164143
    165144        return EOK;
     
    169148{
    170149        printf(NAME ": HelenOS test1 virtual device driver\n");
    171         ddf_log_init(NAME, LVL_ERROR);
    172150        return ddf_driver_main(&test1_driver);
    173151}
Note: See TracChangeset for help on using the changeset viewer.