Changeset b7fd2a0 in mainline for uspace/drv/bus/usb/usbhub/port.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/bus/usb/usbhub/port.c

    r36f0738 rb7fd2a0  
    5454};
    5555
    56 static int usb_hub_port_device_gone(usb_hub_port_t *port, usb_hub_dev_t *hub);
     56static errno_t usb_hub_port_device_gone(usb_hub_port_t *port, usb_hub_dev_t *hub);
    5757static void usb_hub_port_reset_completed(usb_hub_port_t *port,
    5858    usb_hub_dev_t *hub, usb_port_status_t status);
    59 static int get_port_status(usb_hub_port_t *port, usb_port_status_t *status);
    60 static int add_device_phase1_worker_fibril(void *arg);
    61 static int create_add_device_fibril(usb_hub_port_t *port, usb_hub_dev_t *hub,
     59static errno_t get_port_status(usb_hub_port_t *port, usb_port_status_t *status);
     60static errno_t add_device_phase1_worker_fibril(void *arg);
     61static errno_t create_add_device_fibril(usb_hub_port_t *port, usb_hub_dev_t *hub,
    6262    usb_speed_t speed);
    6363
    64 int usb_hub_port_fini(usb_hub_port_t *port, usb_hub_dev_t *hub)
     64errno_t usb_hub_port_fini(usb_hub_port_t *port, usb_hub_dev_t *hub)
    6565{
    6666        assert(port);
     
    7777 * @return Operation result
    7878 */
    79 int usb_hub_port_clear_feature(
     79errno_t usb_hub_port_clear_feature(
    8080    usb_hub_port_t *port, usb_hub_class_feature_t feature)
    8181{
     
    9999 * @return Operation result
    100100 */
    101 int usb_hub_port_set_feature(
     101errno_t usb_hub_port_set_feature(
    102102    usb_hub_port_t *port, usb_hub_class_feature_t feature)
    103103{
     
    143143
    144144        usb_port_status_t status = 0;
    145         const int opResult = get_port_status(port, &status);
     145        const errno_t opResult = get_port_status(port, &status);
    146146        if (opResult != EOK) {
    147147                usb_log_error("(%p-%u): Failed to get port status: %s.\n", hub,
     
    158158
    159159                /* ACK the change */
    160                 const int opResult = usb_hub_port_clear_feature(port,
     160                const errno_t opResult = usb_hub_port_clear_feature(port,
    161161                    USB_HUB_FEATURE_C_PORT_CONNECTION);
    162162                if (opResult != EOK) {
     
    167167
    168168                if (connected) {
    169                         const int opResult = create_add_device_fibril(port, hub,
     169                        const errno_t opResult = create_add_device_fibril(port, hub,
    170170                            usb_port_speed(status));
    171171                        if (opResult != EOK) {
     
    191191                   port->port_number);
    192192                usb_hub_port_device_gone(port, hub);
    193                 const int rc = usb_hub_port_clear_feature(port,
     193                const errno_t rc = usb_hub_port_clear_feature(port,
    194194                        USB_HUB_FEATURE_C_PORT_ENABLE);
    195195                if (rc != EOK) {
     
    206206                    " NOT happen as we do not support suspend state!", hub,
    207207                    port->port_number);
    208                 const int rc = usb_hub_port_clear_feature(port,
     208                const errno_t rc = usb_hub_port_clear_feature(port,
    209209                        USB_HUB_FEATURE_C_PORT_SUSPEND);
    210210                if (rc != EOK) {
     
    224224                 * mode. USB system software is responsible for powering port
    225225                 * back on when the over-current condition is gone */
    226                 const int rc = usb_hub_port_clear_feature(port,
     226                const errno_t rc = usb_hub_port_clear_feature(port,
    227227                    USB_HUB_FEATURE_C_PORT_OVER_CURRENT);
    228228                if (rc != EOK) {
     
    232232                }
    233233                if (!(status & ~USB_HUB_PORT_STATUS_OC)) {
    234                         const int rc = usb_hub_port_set_feature(
     234                        const errno_t rc = usb_hub_port_set_feature(
    235235                            port, USB_HUB_FEATURE_PORT_POWER);
    236236                        if (rc != EOK) {
     
    260260 * @param hub hub representation
    261261 */
    262 int usb_hub_port_device_gone(usb_hub_port_t *port, usb_hub_dev_t *hub)
     262errno_t usb_hub_port_device_gone(usb_hub_port_t *port, usb_hub_dev_t *hub)
    263263{
    264264        assert(port);
     
    267267        if (!exch)
    268268                return ENOMEM;
    269         const int rc = usb_device_remove(exch, port->port_number);
     269        const errno_t rc = usb_device_remove(exch, port->port_number);
    270270        usb_device_bus_exchange_end(exch);
    271271        if (rc == EOK)
     
    304304
    305305        /* Clear the port reset change. */
    306         int rc = usb_hub_port_clear_feature(port, USB_HUB_FEATURE_C_PORT_RESET);
     306        errno_t rc = usb_hub_port_clear_feature(port, USB_HUB_FEATURE_C_PORT_RESET);
    307307        if (rc != EOK) {
    308308                usb_log_error("(%p-%u): Failed to clear port reset change: %s.",
     
    317317 * @return Error code.
    318318 */
    319 static int get_port_status(usb_hub_port_t *port, usb_port_status_t *status)
     319static errno_t get_port_status(usb_hub_port_t *port, usb_port_status_t *status)
    320320{
    321321        assert(port);
     
    333333        usb_port_status_t status_tmp;
    334334
    335         const int rc = usb_pipe_control_read(port->control_pipe,
     335        const errno_t rc = usb_pipe_control_read(port->control_pipe,
    336336            &request, sizeof(usb_device_request_setup_packet_t),
    337337            &status_tmp, sizeof(status_tmp), &recv_size);
     
    351351}
    352352
    353 static int port_enable(usb_hub_port_t *port, usb_hub_dev_t *hub, bool enable)
     353static errno_t port_enable(usb_hub_port_t *port, usb_hub_dev_t *hub, bool enable)
    354354{
    355355        if (enable) {
    356                 int rc =
     356                errno_t rc =
    357357                    usb_hub_port_set_feature(port, USB_HUB_FEATURE_PORT_RESET);
    358358                if (rc != EOK) {
     
    383383 * @return 0 Always.
    384384 */
    385 int add_device_phase1_worker_fibril(void *arg)
     385errno_t add_device_phase1_worker_fibril(void *arg)
    386386{
    387387        struct add_device_phase1 *params = arg;
    388388        assert(params);
    389389
    390         int ret = EOK;
     390        errno_t ret = EOK;
    391391        usb_hub_dev_t *hub = params->hub;
    392392        usb_hub_port_t *port = params->port;
     
    434434                usb_log_error("(%p-%u): Failed to enumerate device: %s", hub,
    435435                    port->port_number, str_error(ret));
    436                 const int ret = port_enable(port, hub, false);
     436                const errno_t ret = port_enable(port, hub, false);
    437437                if (ret != EOK) {
    438438                        usb_log_warning("(%p-%u)Failed to disable port (%s), "
     
    440440                            port->port_number, str_error(ret));
    441441                } else {
    442                         const int ret = usb_release_default_address(exch);
     442                        const errno_t ret = usb_release_default_address(exch);
    443443                        if (ret != EOK)
    444444                                usb_log_warning("(%p-%u): Failed to release "
     
    475475 * @return Error code.
    476476 */
    477 static int create_add_device_fibril(usb_hub_port_t *port, usb_hub_dev_t *hub,
     477static errno_t create_add_device_fibril(usb_hub_port_t *port, usb_hub_dev_t *hub,
    478478    usb_speed_t speed)
    479479{
Note: See TracChangeset for help on using the changeset viewer.