Changeset b7fd2a0 in mainline for uspace/drv/char/ns8250/ns8250.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

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

    r36f0738 rb7fd2a0  
    251251 * @return              EOK on success or non-zero error code
    252252 */
    253 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)
    254254{
    255255        ns8250_t *ns = srv_ns8250(srv);
     
    295295 * @return              EOK on success or non-zero error code
    296296 */
    297 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,
    298298    size_t *nwritten)
    299299{
     
    309309}
    310310
    311 static int ns8250_open(chardev_srvs_t *, chardev_srv_t *);
    312 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 *);
    313313static void ns8250_default_handler(chardev_srv_t *, ipc_callid_t, ipc_call_t *);
    314314
     
    324324static void ns8250_char_conn(ipc_callid_t, ipc_call_t *, void *);
    325325
    326 static int ns8250_dev_add(ddf_dev_t *dev);
    327 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);
    328328
    329329/** The serial port device driver's standard operations. */
     
    407407 * @return              Zero on success, error number otherwise
    408408 */
    409 static int ns8250_dev_initialize(ns8250_t *ns)
    410 {
    411         int ret = EOK;
     409static errno_t ns8250_dev_initialize(ns8250_t *ns)
     410{
     411        errno_t ret = EOK;
    412412       
    413413        ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ddf_dev_get_name(ns->dev));
     
    501501 * @return              Zero on success, error number otherwise
    502502 */
    503 static int ns8250_interrupt_enable(ns8250_t *ns)
     503static errno_t ns8250_interrupt_enable(ns8250_t *ns)
    504504{
    505505        /* Enable interrupt using IRC service. */
    506         int rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq);
     506        errno_t rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq);
    507507        if (rc != EOK)
    508508                return EIO;
     
    547547 *                      if the specified baud_rate is not valid).
    548548 */
    549 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)
    550550{
    551551        uint16_t divisor;
     
    646646 *                      is invalid.
    647647 */
    648 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,
    649649    unsigned int word_length, unsigned int stop_bits)
    650650{
     
    803803 * @param ns            Serial port device
    804804 */
    805 static inline int ns8250_register_interrupt_handler(ns8250_t *ns,
     805static inline errno_t ns8250_register_interrupt_handler(ns8250_t *ns,
    806806    cap_handle_t *handle)
    807807{
     
    814814 * @param ns            Serial port device
    815815 */
    816 static inline int ns8250_unregister_interrupt_handler(ns8250_t *ns)
     816static inline errno_t ns8250_unregister_interrupt_handler(ns8250_t *ns)
    817817{
    818818        return unregister_interrupt_handler(ns->dev, ns->irq_cap);
     
    825825 * @param dev           The serial port device.
    826826 */
    827 static int ns8250_dev_add(ddf_dev_t *dev)
     827static errno_t ns8250_dev_add(ddf_dev_t *dev)
    828828{
    829829        ns8250_t *ns = NULL;
     
    831831        bool need_cleanup = false;
    832832        bool need_unreg_intr_handler = false;
    833         int rc;
     833        errno_t rc;
    834834       
    835835        ddf_msg(LVL_DEBUG, "ns8250_dev_add %s (handle = %d)",
     
    928928}
    929929
    930 static int ns8250_dev_remove(ddf_dev_t *dev)
     930static errno_t ns8250_dev_remove(ddf_dev_t *dev)
    931931{
    932932        ns8250_t *ns = dev_ns8250(dev);
    933         int rc;
     933        errno_t rc;
    934934       
    935935        fibril_mutex_lock(&ns->mutex);
     
    963963 * @param srv           Server-side connection structure
    964964 */
    965 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)
    966966{
    967967        ns8250_t *ns = srv_ns8250(srv);
    968         int res;
     968        errno_t res;
    969969       
    970970        fibril_mutex_lock(&ns->mutex);
     
    987987 * @param srv           Server-side connection structure
    988988 */
    989 static int ns8250_close(chardev_srv_t *srv)
     989static errno_t ns8250_close(chardev_srv_t *srv)
    990990{
    991991        ns8250_t *data = srv_ns8250(srv);
     
    10401040 * @param stop_bits     The number of stop bits to be used.
    10411041 */
    1042 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,
    10431043    unsigned int parity, unsigned int word_length, unsigned int stop_bits)
    10441044{
     
    10491049        ns8250_t *data = dev_ns8250(dev);
    10501050        ns8250_regs_t *regs = data->regs;
    1051         int ret;
     1051        errno_t ret;
    10521052       
    10531053        fibril_mutex_lock(&data->mutex);
     
    10721072        ns8250_t *ns8250 = srv_ns8250(srv);
    10731073        sysarg_t method = IPC_GET_IMETHOD(*call);
    1074         int ret;
     1074        errno_t ret;
    10751075        unsigned int baud_rate, parity, word_length, stop_bits;
    10761076       
Note: See TracChangeset for help on using the changeset viewer.