Changeset b7fd2a0 in mainline for uspace/lib/usbhost/src/hcd.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/lib/usbhost/src/hcd.c

    r36f0738 rb7fd2a0  
    4949 * @return Error code.
    5050 */
    51 static int register_helper(endpoint_t *ep, void *arg)
     51static errno_t register_helper(endpoint_t *ep, void *arg)
    5252{
    5353        hcd_t *hcd = arg;
     
    102102}
    103103
    104 int hcd_request_address(hcd_t *hcd, usb_speed_t speed, usb_address_t *address)
     104errno_t hcd_request_address(hcd_t *hcd, usb_speed_t speed, usb_address_t *address)
    105105{
    106106        assert(hcd);
     
    108108}
    109109
    110 int hcd_release_address(hcd_t *hcd, usb_address_t address)
     110errno_t hcd_release_address(hcd_t *hcd, usb_address_t address)
    111111{
    112112        assert(hcd);
     
    115115}
    116116
    117 int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed)
     117errno_t hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed)
    118118{
    119119        assert(hcd);
     
    122122}
    123123
    124 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
     124errno_t hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    125125    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
    126126    size_t size, usb_address_t tt_address, unsigned tt_port)
     
    132132}
    133133
    134 int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir)
     134errno_t hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir)
    135135{
    136136        assert(hcd);
     
    147147} toggle_t;
    148148
    149 static void toggle_reset_callback(int retval, void *arg)
     149static void toggle_reset_callback(errno_t retval, void *arg)
    150150{
    151151        assert(arg);
     
    172172 * @return Error code.
    173173 */
    174 int hcd_send_batch(
     174errno_t hcd_send_batch(
    175175    hcd_t *hcd, usb_target_t target, usb_direction_t direction,
    176176    void *data, size_t size, uint64_t setup_data,
     
    232232        }
    233233
    234         const int ret = hcd->ops.schedule(hcd, batch);
     234        const errno_t ret = hcd->ops.schedule(hcd, batch);
    235235        if (ret != EOK)
    236236                usb_transfer_batch_destroy(batch);
     
    244244typedef struct {
    245245        volatile unsigned done;
    246         int ret;
     246        errno_t ret;
    247247        size_t size;
    248248} sync_data_t;
    249249
    250 static void transfer_in_cb(int ret, size_t size, void* data)
     250static void transfer_in_cb(errno_t ret, size_t size, void* data)
    251251{
    252252        sync_data_t *d = data;
     
    257257}
    258258
    259 static void transfer_out_cb(int ret, void* data)
     259static void transfer_out_cb(errno_t ret, void* data)
    260260{
    261261        sync_data_t *d = data;
     
    266266
    267267/** this is really ugly version of sync usb communication */
    268 int hcd_send_batch_sync(
     268errno_t hcd_send_batch_sync(
    269269    hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    270270    void *data, size_t size, uint64_t setup_data, const char* name, size_t *out_size)
     
    273273        sync_data_t sd = { .done = 0, .ret = EBUSY, .size = size };
    274274
    275         const int ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
     275        const errno_t ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
    276276            dir == USB_DIRECTION_IN ? transfer_in_cb : NULL,
    277277            dir == USB_DIRECTION_OUT ? transfer_out_cb : NULL, &sd, name);
Note: See TracChangeset for help on using the changeset viewer.