Changeset b910455 in mainline for uspace/drv/ns8250/ns8250.c


Ignore:
Timestamp:
2011-04-07T09:46:11Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6639ae1
Parents:
f6bffee (diff), 8e80d3f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    rf6bffee rb910455  
    5555#include <ddf/driver.h>
    5656#include <ddf/interrupt.h>
     57#include <ddf/log.h>
    5758#include <ops/char_dev.h>
    5859
     
    275276static bool ns8250_pio_enable(ns8250_t *ns)
    276277{
    277         printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);
     278        ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s", ns->dev->name);
    278279       
    279280        /* Gain control over port's registers. */
    280281        if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT,
    281282            (void **) &ns->port)) {
    282                 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
    283                     "%s.\n", ns->io_addr, ns->dev->name);
     283                ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32
     284                    " for device %s.", ns->io_addr, ns->dev->name);
    284285                return false;
    285286        }
     
    295296static bool ns8250_dev_probe(ns8250_t *ns)
    296297{
    297         printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);
     298        ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name);
    298299       
    299300        ioport8_t *port_addr = ns->port;
     
    313314        pio_write_8(port_addr + 4, olddata);
    314315       
    315         if (!res)
    316                 printf(NAME ": device %s is not present.\n", ns->dev->name);
     316        if (!res) {
     317                ddf_msg(LVL_DEBUG, "Device %s is not present.",
     318                    ns->dev->name);
     319        }
    317320       
    318321        return res;
     
    326329static int ns8250_dev_initialize(ns8250_t *ns)
    327330{
    328         printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);
     331        ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ns->dev->name);
    329332       
    330333        int ret = EOK;
     
    337340            IPC_FLAG_BLOCKING);
    338341        if (ns->dev->parent_phone < 0) {
    339                 printf(NAME ": failed to connect to the parent driver of the "
    340                     "device %s.\n", ns->dev->name);
     342                ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
     343                    "device %s.", ns->dev->name);
    341344                ret = ns->dev->parent_phone;
    342345                goto failed;
     
    346349        ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
    347350        if (ret != EOK) {
    348                 printf(NAME ": failed to get hw resources for the device "
    349                     "%s.\n", ns->dev->name);
     351                ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
     352                    "%s.", ns->dev->name);
    350353                goto failed;
    351354        }
     
    362365                        ns->irq = res->res.interrupt.irq;
    363366                        irq = true;
    364                         printf(NAME ": the %s device was asigned irq = 0x%x.\n",
     367                        ddf_msg(LVL_NOTE, "Device %s was asigned irq = 0x%x.",
    365368                            ns->dev->name, ns->irq);
    366369                        break;
     
    369372                        ns->io_addr = res->res.io_range.address;
    370373                        if (res->res.io_range.size < REG_COUNT) {
    371                                 printf(NAME ": i/o range assigned to the device "
    372                                     "%s is too small.\n", ns->dev->name);
     374                                ddf_msg(LVL_ERROR, "I/O range assigned to "
     375                                    "device %s is too small.", ns->dev->name);
    373376                                ret = ELIMIT;
    374377                                goto failed;
    375378                        }
    376379                        ioport = true;
    377                         printf(NAME ": the %s device was asigned i/o address = "
    378                             "0x%x.\n", ns->dev->name, ns->io_addr);
    379                         break;
     380                        ddf_msg(LVL_NOTE, "Device %s was asigned I/O address = "
     381                            "0x%x.", ns->dev->name, ns->io_addr);
     382                        break;
    380383                       
    381384                default:
     
    385388       
    386389        if (!irq || !ioport) {
    387                 printf(NAME ": missing hw resource(s) for the device %s.\n",
     390                ddf_msg(LVL_ERROR, "Missing HW resource(s) for device %s.",
    388391                    ns->dev->name);
    389392                ret = ENOENT;
     
    470473       
    471474        if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {
    472                 printf(NAME ": error - somebody tried to set invalid baud rate "
    473                     "%d\n", baud_rate);
     475                ddf_msg(LVL_ERROR, "Invalid baud rate %d requested.",
     476                    baud_rate);
    474477                return EINVAL;
    475478        }
     
    654657                        if (ns->client_connected) {
    655658                                if (!buf_push_back(&ns->input_buffer, val)) {
    656                                         printf(NAME ": buffer overflow on "
    657                                             "%s.\n", ns->dev->name);
     659                                        ddf_msg(LVL_WARN, "Buffer overflow on "
     660                                            "%s.", ns->dev->name);
    658661                                } else {
    659                                         printf(NAME ": the character %c saved "
    660                                             "to the buffer of %s.\n",
     662                                        ddf_msg(LVL_DEBUG2, "Character %c saved "
     663                                            "to the buffer of %s.",
    661664                                            val, ns->dev->name);
    662665                                }
     
    714717        int rc;
    715718       
    716         printf(NAME ": ns8250_add_device %s (handle = %d)\n",
     719        ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)",
    717720            dev->name, (int) dev->handle);
    718721       
     
    749752        /* Register interrupt handler. */
    750753        if (ns8250_register_interrupt_handler(ns) != EOK) {
    751                 printf(NAME ": failed to register interrupt handler.\n");
     754                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
    752755                rc = EADDRNOTAVAIL;
    753756                goto fail;
     
    757760        rc = ns8250_interrupt_enable(ns);
    758761        if (rc != EOK) {
    759                 printf(NAME ": failed to enable the interrupt. Error code = "
    760                     "%d.\n", rc);
     762                ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = "
     763                    "%d.", rc);
    761764                goto fail;
    762765        }
     
    764767        fun = ddf_fun_create(dev, fun_exposed, "a");
    765768        if (fun == NULL) {
    766                 printf(NAME ": error creating function.\n");
     769                ddf_msg(LVL_ERROR, "Failed creating function.");
    767770                goto fail;
    768771        }
     
    772775        rc = ddf_fun_bind(fun);
    773776        if (rc != EOK) {
    774                 printf(NAME ": error binding function.\n");
     777                ddf_msg(LVL_ERROR, "Failed binding function.");
    775778                goto fail;
    776779        }
     
    780783        ddf_fun_add_to_class(fun, "serial");
    781784       
    782         printf(NAME ": the %s device has been successfully initialized.\n",
     785        ddf_msg(LVL_NOTE, "Device %s successfully initialized.",
    783786            dev->name);
    784787       
     
    862865        fibril_mutex_unlock(&data->mutex);
    863866       
    864         printf(NAME ": ns8250_get_props: baud rate %d, parity 0x%x, word "
    865             "length %d, stop bits %d\n", *baud_rate, *parity, *word_length,
     867        ddf_msg(LVL_DEBUG, "ns8250_get_props: baud rate %d, parity 0x%x, word "
     868            "length %d, stop bits %d", *baud_rate, *parity, *word_length,
    866869            *stop_bits);
    867870}
     
    879882    unsigned int parity, unsigned int word_length, unsigned int stop_bits)
    880883{
    881         printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word "
    882             "length %d, stop bits %d\n", baud_rate, parity, word_length,
     884        ddf_msg(LVL_DEBUG, "ns8250_set_props: baud rate %d, parity 0x%x, word "
     885            "length %d, stop bits %d", baud_rate, parity, word_length,
    883886            stop_bits);
    884887       
     
    940943static void ns8250_init(void)
    941944{
     945        ddf_log_init(NAME, LVL_ERROR);
     946       
    942947        ns8250_dev_ops.open = &ns8250_open;
    943948        ns8250_dev_ops.close = &ns8250_close;
Note: See TracChangeset for help on using the changeset viewer.