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


Ignore:
Timestamp:
2011-03-31T17:37:25Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3acb285
Parents:
9b415c9
Message:

Add logging for device drivers.

File:
1 edited

Legend:

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

    r9b415c9 rfc51296  
    3535#include <str_error.h>
    3636#include <ddf/driver.h>
     37#include <ddf/log.h>
    3738
    3839#include "test1.h"
     
    6364        int rc;
    6465
    65         printf(NAME ": registering function `%s': %s.\n", name, message);
     66        ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message);
    6667
    6768        fun = ddf_fun_create(parent, fun_inner, name);
    6869        if (fun == NULL) {
    69                 printf(NAME ": error creating function %s\n", name);
     70                ddf_msg(LVL_ERROR, "Failed creating function %s\n", name);
    7071                return ENOMEM;
    7172        }
     
    7374        rc = ddf_fun_add_match_id(fun, match_id, match_score);
    7475        if (rc != EOK) {
    75                 printf(NAME ": error adding match IDs to function %s\n", name);
     76                ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n",
     77                    name);
    7678                ddf_fun_destroy(fun);
    7779                return rc;
     
    8082        rc = ddf_fun_bind(fun);
    8183        if (rc != EOK) {
    82                 printf(NAME ": error binding function %s: %s\n", name,
     84                ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name,
    8385                    str_error(rc));
    8486                ddf_fun_destroy(fun);
     
    8688        }
    8789
    88         printf(NAME ": registered child device `%s'\n", name);
     90        ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name);
    8991        return EOK;
    9092}
     
    112114        int rc;
    113115
    114         printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
     116        ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)\n",
    115117            dev->name, (int) dev->handle);
    116118
    117119        fun_a = ddf_fun_create(dev, fun_exposed, "a");
    118120        if (fun_a == NULL) {
    119                 printf(NAME ": error creating function 'a'.\n");
     121                ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n");
    120122                return ENOMEM;
    121123        }
     
    123125        rc = ddf_fun_bind(fun_a);
    124126        if (rc != EOK) {
    125                 printf(NAME ": error binding function 'a'.\n");
     127                ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n");
    126128                return rc;
    127129        }
     
    140142        }
    141143
    142         printf(NAME ": device `%s' accepted.\n", dev->name);
     144        ddf_msg(LVL_DEBUG, "Device `%s' accepted.\n", dev->name);
    143145
    144146        return EOK;
     
    148150{
    149151        printf(NAME ": HelenOS test1 virtual device driver\n");
     152        ddf_log_init(NAME, LVL_ERROR);
    150153        return ddf_driver_main(&test1_driver);
    151154}
Note: See TracChangeset for help on using the changeset viewer.