Changes in uspace/drv/char/ns8250/ns8250.c [38d150e:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/ns8250/ns8250.c
r38d150e rb7fd2a0 40 40 #include <stdio.h> 41 41 #include <errno.h> 42 #include <str_error.h> 42 43 #include <stdbool.h> 43 44 #include <fibril_synch.h> … … 250 251 * @return EOK on success or non-zero error code 251 252 */ 252 static int ns8250_read(chardev_srv_t *srv, void *buf, size_t count, size_t *nread)253 static errno_t ns8250_read(chardev_srv_t *srv, void *buf, size_t count, size_t *nread) 253 254 { 254 255 ns8250_t *ns = srv_ns8250(srv); … … 294 295 * @return EOK on success or non-zero error code 295 296 */ 296 static int ns8250_write(chardev_srv_t *srv, const void *buf, size_t count,297 static errno_t ns8250_write(chardev_srv_t *srv, const void *buf, size_t count, 297 298 size_t *nwritten) 298 299 { … … 308 309 } 309 310 310 static int ns8250_open(chardev_srvs_t *, chardev_srv_t *);311 static int ns8250_close(chardev_srv_t *);311 static errno_t ns8250_open(chardev_srvs_t *, chardev_srv_t *); 312 static errno_t ns8250_close(chardev_srv_t *); 312 313 static void ns8250_default_handler(chardev_srv_t *, ipc_callid_t, ipc_call_t *); 313 314 … … 323 324 static void ns8250_char_conn(ipc_callid_t, ipc_call_t *, void *); 324 325 325 static int ns8250_dev_add(ddf_dev_t *dev);326 static int ns8250_dev_remove(ddf_dev_t *dev);326 static errno_t ns8250_dev_add(ddf_dev_t *dev); 327 static errno_t ns8250_dev_remove(ddf_dev_t *dev); 327 328 328 329 /** The serial port device driver's standard operations. */ … … 404 405 * 405 406 * @param ns Serial port device 406 * @return Zero on success, negativeerror number otherwise407 */ 408 static int ns8250_dev_initialize(ns8250_t *ns)409 { 410 int ret = EOK;407 * @return Zero on success, error number otherwise 408 */ 409 static errno_t ns8250_dev_initialize(ns8250_t *ns) 410 { 411 errno_t ret = EOK; 411 412 412 413 ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ddf_dev_get_name(ns->dev)); … … 498 499 * 499 500 * @param ns Serial port device 500 * @return Zero on success, negativeerror number otherwise501 */ 502 static int ns8250_interrupt_enable(ns8250_t *ns)501 * @return Zero on success, error number otherwise 502 */ 503 static errno_t ns8250_interrupt_enable(ns8250_t *ns) 503 504 { 504 505 /* 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); 506 507 if (rc != EOK) 507 508 return EIO; … … 543 544 * @param port The base address of the serial port device's ports. 544 545 * @param baud_rate The baud rate to be used by the device. 545 * @return Zero on success, negativeerror number otherwise (EINVAL546 * @return Zero on success, error number otherwise (EINVAL 546 547 * if the specified baud_rate is not valid). 547 548 */ 548 static int ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate)549 static errno_t ns8250_port_set_baud_rate(ns8250_regs_t *regs, unsigned int baud_rate) 549 550 { 550 551 uint16_t divisor; … … 645 646 * is invalid. 646 647 */ 647 static int ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity,648 static errno_t ns8250_port_set_com_props(ns8250_regs_t *regs, unsigned int parity, 648 649 unsigned int word_length, unsigned int stop_bits) 649 650 { … … 802 803 * @param ns Serial port device 803 804 */ 804 static inline int ns8250_register_interrupt_handler(ns8250_t *ns) 805 static inline errno_t ns8250_register_interrupt_handler(ns8250_t *ns, 806 cap_handle_t *handle) 805 807 { 806 808 return register_interrupt_handler(ns->dev, ns->irq, 807 ns8250_interrupt_handler, NULL );809 ns8250_interrupt_handler, NULL, handle); 808 810 } 809 811 … … 812 814 * @param ns Serial port device 813 815 */ 814 static inline int ns8250_unregister_interrupt_handler(ns8250_t *ns)816 static inline errno_t ns8250_unregister_interrupt_handler(ns8250_t *ns) 815 817 { 816 818 return unregister_interrupt_handler(ns->dev, ns->irq_cap); … … 823 825 * @param dev The serial port device. 824 826 */ 825 static int ns8250_dev_add(ddf_dev_t *dev)827 static errno_t ns8250_dev_add(ddf_dev_t *dev) 826 828 { 827 829 ns8250_t *ns = NULL; … … 829 831 bool need_cleanup = false; 830 832 bool need_unreg_intr_handler = false; 831 int rc;833 errno_t rc; 832 834 833 835 ddf_msg(LVL_DEBUG, "ns8250_dev_add %s (handle = %d)", … … 874 876 875 877 /* 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) { 878 880 ddf_msg(LVL_ERROR, "Failed to register interrupt handler."); 879 881 rc = EADDRNOTAVAIL; … … 886 888 if (rc != EOK) { 887 889 ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = " 888 "% d.", rc);890 "%s.", str_error_name(rc)); 889 891 goto fail; 890 892 } … … 926 928 } 927 929 928 static int ns8250_dev_remove(ddf_dev_t *dev)930 static errno_t ns8250_dev_remove(ddf_dev_t *dev) 929 931 { 930 932 ns8250_t *ns = dev_ns8250(dev); 931 int rc;933 errno_t rc; 932 934 933 935 fibril_mutex_lock(&ns->mutex); … … 961 963 * @param srv Server-side connection structure 962 964 */ 963 static int ns8250_open(chardev_srvs_t *srvs, chardev_srv_t *srv)965 static errno_t ns8250_open(chardev_srvs_t *srvs, chardev_srv_t *srv) 964 966 { 965 967 ns8250_t *ns = srv_ns8250(srv); 966 int res;968 errno_t res; 967 969 968 970 fibril_mutex_lock(&ns->mutex); … … 985 987 * @param srv Server-side connection structure 986 988 */ 987 static int ns8250_close(chardev_srv_t *srv)989 static errno_t ns8250_close(chardev_srv_t *srv) 988 990 { 989 991 ns8250_t *data = srv_ns8250(srv); … … 1038 1040 * @param stop_bits The number of stop bits to be used. 1039 1041 */ 1040 static int ns8250_set_props(ddf_dev_t *dev, unsigned int baud_rate,1042 static errno_t ns8250_set_props(ddf_dev_t *dev, unsigned int baud_rate, 1041 1043 unsigned int parity, unsigned int word_length, unsigned int stop_bits) 1042 1044 { … … 1047 1049 ns8250_t *data = dev_ns8250(dev); 1048 1050 ns8250_regs_t *regs = data->regs; 1049 int ret;1051 errno_t ret; 1050 1052 1051 1053 fibril_mutex_lock(&data->mutex); … … 1070 1072 ns8250_t *ns8250 = srv_ns8250(srv); 1071 1073 sysarg_t method = IPC_GET_IMETHOD(*call); 1072 int ret;1074 errno_t ret; 1073 1075 unsigned int baud_rate, parity, word_length, stop_bits; 1074 1076
Note:
See TracChangeset
for help on using the changeset viewer.