Ignore:
File:
1 edited

Legend:

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

    r38d150e rb7fd2a0  
    4040#include <stdio.h>
    4141#include <errno.h>
     42#include <str_error.h>
    4243#include <stdbool.h>
    4344#include <fibril_synch.h>
     
    250251 * @return              EOK on success or non-zero error code
    251252 */
    252 static int ns8250_read(chardev_srv_t *srv, void *buf, size_t count, size_t *nread)
     253static errno_t ns8250_read(chardev_srv_t *srv, void *buf, size_t count, size_t *nread)
    253254{
    254255        ns8250_t *ns = srv_ns8250(srv);
     
    294295 * @return              EOK on success or non-zero error code
    295296 */
    296 static int ns8250_write(chardev_srv_t *srv, const void *buf, size_t count,
     297static errno_t ns8250_write(chardev_srv_t *srv, const void *buf, size_t count,
    297298    size_t *nwritten)
    298299{
     
    308309}
    309310
    310 static int ns8250_open(chardev_srvs_t *, chardev_srv_t *);
    311 static int ns8250_close(chardev_srv_t *);
     311static errno_t ns8250_open(chardev_srvs_t *, chardev_srv_t *);
     312static errno_t ns8250_close(chardev_srv_t *);
    312313static void ns8250_default_handler(chardev_srv_t *, ipc_callid_t, ipc_call_t *);
    313314
     
    323324static void ns8250_char_conn(ipc_callid_t, ipc_call_t *, void *);
    324325
    325 static int ns8250_dev_add(ddf_dev_t *dev);
    326 static int ns8250_dev_remove(ddf_dev_t *dev);
     326static errno_t ns8250_dev_add(ddf_dev_t *dev);
     327static errno_t ns8250_dev_remove(ddf_dev_t *dev);
    327328
    328329/** The serial port device driver's standard operations. */
     
    404405 *
    405406 * @param ns            Serial port device
    406  * @return              Zero on success, negative error number otherwise
    407  */
    408 static int ns8250_dev_initialize(ns8250_t *ns)
    409 {
    410         int ret = EOK;
     407 * @return              Zero on success, error number otherwise
     408 */
     409static errno_t ns8250_dev_initialize(ns8250_t *ns)
     410{
     411        errno_t ret = EOK;
    411412       
    412413        ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ddf_dev_get_name(ns->dev));
     
    498499 *
    499500 * @param ns            Serial port device
    500  * @return              Zero on success, negative error number otherwise
    501  */
    502 static int ns8250_interrupt_enable(ns8250_t *ns)
     501 * @return              Zero on success, error number otherwise
     502 */
     503static errno_t ns8250_interrupt_enable(ns8250_t *ns)
    503504{
    504505        /* Enable interrupt using IRC service. */
    505         int rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq);
     506        errno_t rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq);
    506507        if (rc != EOK)
    507508                return EIO;
     
    543544 * @param port          The base address of the serial port device's ports.
    544545 * @param baud_rate     The baud rate to be used by the device.
    545  * @return              Zero on success, negative error number otherwise (EINVAL
     546 * @return              Zero on success, error number otherwise (EINVAL
    546547 *                      if the specified baud_rate is not valid).
    547548 */
    548 static int ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate)
     549static errno_t ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate)
    549550{
    550551        uint16_t divisor;
     
    645646 *                      is invalid.
    646647 */
    647 static int ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity,
     648static errno_t ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity,
    648649    unsigned int word_length, unsigned int stop_bits)
    649650{
     
    802803 * @param ns            Serial port device
    803804 */
    804 static inline int ns8250_register_interrupt_handler(ns8250_t *ns)
     805static inline errno_t ns8250_register_interrupt_handler(ns8250_t *ns,
     806    cap_handle_t *handle)
    805807{
    806808        return register_interrupt_handler(ns->dev, ns->irq,
    807             ns8250_interrupt_handler, NULL);
     809            ns8250_interrupt_handler, NULL, handle);
    808810}
    809811
     
    812814 * @param ns            Serial port device
    813815 */
    814 static inline int ns8250_unregister_interrupt_handler(ns8250_t *ns)
     816static inline errno_t ns8250_unregister_interrupt_handler(ns8250_t *ns)
    815817{
    816818        return unregister_interrupt_handler(ns->dev, ns->irq_cap);
     
    823825 * @param dev           The serial port device.
    824826 */
    825 static int ns8250_dev_add(ddf_dev_t *dev)
     827static errno_t ns8250_dev_add(ddf_dev_t *dev)
    826828{
    827829        ns8250_t *ns = NULL;
     
    829831        bool need_cleanup = false;
    830832        bool need_unreg_intr_handler = false;
    831         int rc;
     833        errno_t rc;
    832834       
    833835        ddf_msg(LVL_DEBUG, "ns8250_dev_add %s (handle = %d)",
     
    874876       
    875877        /* Register interrupt handler. */
    876         ns->irq_cap = ns8250_register_interrupt_handler(ns);
    877         if (ns->irq_cap < 0) {
     878        rc = ns8250_register_interrupt_handler(ns, &ns->irq_cap);
     879        if (rc != EOK) {
    878880                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
    879881                rc = EADDRNOTAVAIL;
     
    886888        if (rc != EOK) {
    887889                ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = "
    888                     "%d.", rc);
     890                    "%s.", str_error_name(rc));
    889891                goto fail;
    890892        }
     
    926928}
    927929
    928 static int ns8250_dev_remove(ddf_dev_t *dev)
     930static errno_t ns8250_dev_remove(ddf_dev_t *dev)
    929931{
    930932        ns8250_t *ns = dev_ns8250(dev);
    931         int rc;
     933        errno_t rc;
    932934       
    933935        fibril_mutex_lock(&ns->mutex);
     
    961963 * @param srv           Server-side connection structure
    962964 */
    963 static int ns8250_open(chardev_srvs_t *srvs, chardev_srv_t *srv)
     965static errno_t ns8250_open(chardev_srvs_t *srvs, chardev_srv_t *srv)
    964966{
    965967        ns8250_t *ns = srv_ns8250(srv);
    966         int res;
     968        errno_t res;
    967969       
    968970        fibril_mutex_lock(&ns->mutex);
     
    985987 * @param srv           Server-side connection structure
    986988 */
    987 static int ns8250_close(chardev_srv_t *srv)
     989static errno_t ns8250_close(chardev_srv_t *srv)
    988990{
    989991        ns8250_t *data = srv_ns8250(srv);
     
    10381040 * @param stop_bits     The number of stop bits to be used.
    10391041 */
    1040 static int ns8250_set_props(ddf_dev_t *dev, unsigned int baud_rate,
     1042static errno_t ns8250_set_props(ddf_dev_t *dev, unsigned int baud_rate,
    10411043    unsigned int parity, unsigned int word_length, unsigned int stop_bits)
    10421044{
     
    10471049        ns8250_t *data = dev_ns8250(dev);
    10481050        ns8250_regs_t *regs = data->regs;
    1049         int ret;
     1051        errno_t ret;
    10501052       
    10511053        fibril_mutex_lock(&data->mutex);
     
    10701072        ns8250_t *ns8250 = srv_ns8250(srv);
    10711073        sysarg_t method = IPC_GET_IMETHOD(*call);
    1072         int ret;
     1074        errno_t ret;
    10731075        unsigned int baud_rate, parity, word_length, stop_bits;
    10741076       
Note: See TracChangeset for help on using the changeset viewer.