Changes in uspace/drv/ns8250/ns8250.c [af6b5157:ebcb05a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ns8250/ns8250.c
raf6b5157 rebcb05a 55 55 #include <ddf/driver.h> 56 56 #include <ddf/interrupt.h> 57 #include <ddf/log.h> 57 58 #include <ops/char_dev.h> 58 59 … … 275 276 static bool ns8250_pio_enable(ns8250_t *ns) 276 277 { 277 printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);278 ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s", ns->dev->name); 278 279 279 280 /* Gain control over port's registers. */ 280 281 if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT, 281 282 (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); 284 285 return false; 285 286 } … … 295 296 static bool ns8250_dev_probe(ns8250_t *ns) 296 297 { 297 printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);298 ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name); 298 299 299 300 ioport8_t *port_addr = ns->port; … … 313 314 pio_write_8(port_addr + 4, olddata); 314 315 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 } 317 320 318 321 return res; … … 326 329 static int ns8250_dev_initialize(ns8250_t *ns) 327 330 { 328 printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);331 ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ns->dev->name); 329 332 330 333 int ret = EOK; … … 337 340 IPC_FLAG_BLOCKING); 338 341 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); 341 344 ret = ns->dev->parent_phone; 342 345 goto failed; … … 346 349 ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources); 347 350 if (ret != EOK) { 348 printf(NAME ": failed to get hw resources for thedevice "349 "%s. \n", ns->dev->name);351 ddf_msg(LVL_ERROR, "Failed to get HW resources for device " 352 "%s.", ns->dev->name); 350 353 goto failed; 351 354 } … … 362 365 ns->irq = res->res.interrupt.irq; 363 366 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.", 365 368 ns->dev->name, ns->irq); 366 369 break; … … 369 372 ns->io_addr = res->res.io_range.address; 370 373 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); 373 376 ret = ELIMIT; 374 377 goto failed; 375 378 } 376 379 ioport = true; 377 printf(NAME ": the %s device was asigned i/oaddress = "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; 380 383 381 384 default: … … 385 388 386 389 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.", 388 391 ns->dev->name); 389 392 ret = ENOENT; … … 470 473 471 474 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); 474 477 return EINVAL; 475 478 } … … 654 657 if (ns->client_connected) { 655 658 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); 658 661 } 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.", 661 664 val, ns->dev->name); 662 665 } … … 714 717 int rc; 715 718 716 printf(NAME ": ns8250_add_device %s (handle = %d)\n",719 ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)", 717 720 dev->name, (int) dev->handle); 718 721 … … 749 752 /* Register interrupt handler. */ 750 753 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."); 752 755 rc = EADDRNOTAVAIL; 753 756 goto fail; … … 757 760 rc = ns8250_interrupt_enable(ns); 758 761 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); 761 764 goto fail; 762 765 } … … 764 767 fun = ddf_fun_create(dev, fun_exposed, "a"); 765 768 if (fun == NULL) { 766 printf(NAME ": error creating function.\n");769 ddf_msg(LVL_ERROR, "Failed creating function."); 767 770 goto fail; 768 771 } … … 772 775 rc = ddf_fun_bind(fun); 773 776 if (rc != EOK) { 774 printf(NAME ": error binding function.\n");777 ddf_msg(LVL_ERROR, "Failed binding function."); 775 778 goto fail; 776 779 } … … 780 783 ddf_fun_add_to_class(fun, "serial"); 781 784 782 printf(NAME ": the %s device has been successfully initialized.\n",785 ddf_msg(LVL_NOTE, "Device %s successfully initialized.", 783 786 dev->name); 784 787 … … 862 865 fibril_mutex_unlock(&data->mutex); 863 866 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, 866 869 *stop_bits); 867 870 } … … 879 882 unsigned int parity, unsigned int word_length, unsigned int stop_bits) 880 883 { 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, 883 886 stop_bits); 884 887 … … 940 943 static void ns8250_init(void) 941 944 { 945 ddf_log_init(NAME, LVL_ERROR); 946 942 947 ns8250_dev_ops.open = &ns8250_open; 943 948 ns8250_dev_ops.close = &ns8250_close;
Note:
See TracChangeset
for help on using the changeset viewer.