Changes in uspace/drv/isa/isa.c [af6b5157:28a3e74] in mainline


Ignore:
File:
1 edited

Legend:

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

    raf6b5157 r28a3e74  
    5353
    5454#include <ddf/driver.h>
     55#include <ddf/log.h>
    5556#include <ops/hw_res.h>
    5657
     
    8283static bool isa_enable_fun_interrupt(ddf_fun_t *fnode)
    8384{
    84         // TODO
     85        /* TODO */
    8586
    8687        return false;
     
    134135        fd = open(conf_path, O_RDONLY);
    135136        if (fd < 0) {
    136                 printf(NAME ": unable to open %s\n", conf_path);
     137                ddf_msg(LVL_ERROR, "Unable to open %s", conf_path);
    137138                goto cleanup;
    138139        }
     
    141142
    142143        len = lseek(fd, 0, SEEK_END);
    143         lseek(fd, 0, SEEK_SET); 
     144        lseek(fd, 0, SEEK_SET);
    144145        if (len == 0) {
    145                 printf(NAME ": fun_conf_read error: configuration file '%s' "
    146                     "is empty.\n", conf_path);
     146                ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
     147                    conf_path);
    147148                goto cleanup;
    148149        }
     
    150151        buf = malloc(len + 1);
    151152        if (buf == NULL) {
    152                 printf(NAME ": fun_conf_read error: memory allocation failed.\n");
     153                ddf_msg(LVL_ERROR, "Memory allocation failed.");
    153154                goto cleanup;
    154155        }
    155156
    156157        if (0 >= read(fd, buf, len)) {
    157                 printf(NAME ": fun_conf_read error: unable to read file '%s'.\n",
    158                     conf_path);
     158                ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
    159159                goto cleanup;
    160160        }
     
    252252                fun->hw_resources.count++;
    253253
    254                 printf(NAME ": added irq 0x%x to function %s\n", irq,
     254                ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq,
    255255                    fun->fnode->name);
    256256        }
     
    270270                fun->hw_resources.count++;
    271271
    272                 printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
    273                     "function %s\n", (unsigned int) addr, (unsigned int) len,
     272                ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
     273                    "function %s", (unsigned int) addr, (unsigned int) len,
    274274                    fun->fnode->name);
    275275        }
     
    331331        score = (int)strtol(val, &end, 10);
    332332        if (val == end) {
    333                 printf(NAME " : error - could not read match score for "
    334                     "function %s.\n", fun->fnode->name);
     333                ddf_msg(LVL_ERROR, "Cannot read match score for function "
     334                    "%s.", fun->fnode->name);
    335335                return;
    336336        }
     
    339339        get_match_id(&id, val);
    340340        if (id == NULL) {
    341                 printf(NAME " : error - could not read match id for "
    342                     "function %s.\n", fun->fnode->name);
     341                ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.",
     342                    fun->fnode->name);
    343343                return;
    344344        }
    345345
    346         printf(NAME ": adding match id '%s' with score %d to function %s\n", id,
    347             score, fun->fnode->name);
     346        ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
     347            "function %s", id, score, fun->fnode->name);
    348348
    349349        rc = ddf_fun_add_match_id(fun->fnode, id, score);
    350         if (rc != EOK)
    351                 printf(NAME ": error adding match ID: %s\n", str_error(rc));
     350        if (rc != EOK) {
     351                ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
     352                    str_error(rc));
     353        }
    352354}
    353355
     
    375377        if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
    376378            !prop_parse(fun, line, "irq", &fun_parse_irq) &&
    377             !prop_parse(fun, line, "match", &fun_parse_match_id))
    378         {
    379             printf(NAME " error undefined device property at line '%s'\n",
    380                 line);
     379            !prop_parse(fun, line, "match", &fun_parse_match_id)) {
     380
     381                ddf_msg(LVL_ERROR, "Undefined device property at line '%s'",
     382                    line);
    381383        }
    382384}
     
    439441        fun->fnode->ops = &isa_fun_ops;
    440442
    441         printf(NAME ": Binding function %s.\n", fun->fnode->name);
     443        ddf_msg(LVL_DEBUG, "Binding function %s.", fun->fnode->name);
    442444
    443445        /* XXX Handle error */
     
    467469static int isa_add_device(ddf_dev_t *dev)
    468470{
    469         printf(NAME ": isa_add_device, device handle = %d\n",
     471        ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d",
    470472            (int) dev->handle);
    471473
    472474        /* Make the bus device more visible. Does not do anything. */
    473         printf(NAME ": adding a 'ctl' function\n");
     475        ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
    474476
    475477        ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl");
    476478        if (ctl == NULL) {
    477                 printf(NAME ": Error creating control function.\n");
     479                ddf_msg(LVL_ERROR, "Failed creating control function.");
    478480                return EXDEV;
    479481        }
    480482
    481483        if (ddf_fun_bind(ctl) != EOK) {
    482                 printf(NAME ": Error binding control function.\n");
     484                ddf_msg(LVL_ERROR, "Failed binding control function.");
    483485                return EXDEV;
    484486        }
     
    486488        /* Add functions as specified in the configuration file. */
    487489        isa_functions_add(dev);
    488         printf(NAME ": finished the enumeration of legacy functions\n");
     490        ddf_msg(LVL_NOTE, "Finished enumerating legacy functions");
    489491
    490492        return EOK;
     
    493495static void isa_init()
    494496{
     497        ddf_log_init(NAME, LVL_ERROR);
    495498        isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
    496499}
Note: See TracChangeset for help on using the changeset viewer.