Changeset 0918382f in mainline for uspace/lib/drv


Ignore:
Timestamp:
2013-08-07T15:00:36Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
14dd4c9
Parents:
2757247
Message:

usb: Switch to using port number as device identifier.

Port number info will be needed for HS SPLIT transactions. Moreover,
it can be used to produce predictable, persistent device names.

Switch port_number from size_t to unsigned. There are max 256 ports so
even short would be enough.

Location:
uspace/lib/drv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usb.c

    r2757247 r0918382f  
    139139 * @return Error code.
    140140 */
    141 int usb_device_enumerate(async_exch_t *exch, usb_device_handle_t *handle)
    142 {
    143         if (!exch || !handle)
    144                 return EBADMEM;
    145         sysarg_t h;
    146         const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    147             IPC_M_USB_DEVICE_ENUMERATE, &h);
    148         if (ret == EOK)
    149                 *handle = (usb_device_handle_t)h;
     141int usb_device_enumerate(async_exch_t *exch, unsigned port)
     142{
     143        if (!exch)
     144                return EBADMEM;
     145        const int ret = async_req_2_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     146            IPC_M_USB_DEVICE_ENUMERATE, port);
    150147        return ret;
    151148}
     
    156153 * @return Error code.
    157154 */
    158 int usb_device_remove(async_exch_t *exch, usb_device_handle_t handle)
     155int usb_device_remove(async_exch_t *exch, unsigned port)
    159156{
    160157        if (!exch)
    161158                return EBADMEM;
    162159        return async_req_2_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    163             IPC_M_USB_DEVICE_REMOVE, handle);
     160            IPC_M_USB_DEVICE_REMOVE, port);
    164161}
    165162
     
    381378        }
    382379
    383         usb_device_handle_t handle = 0;
    384         const int ret = usb_iface->device_enumerate(fun, &handle);
    385         if (ret != EOK) {
    386                 async_answer_0(callid, ret);
    387         }
    388 
    389         async_answer_1(callid, EOK, (sysarg_t) handle);
     380        const unsigned port = DEV_IPC_GET_ARG1(*call);
     381        const int ret = usb_iface->device_enumerate(fun, port);
     382        async_answer_0(callid, ret);
    390383}
    391384
     
    400393        }
    401394
    402         usb_device_handle_t handle = DEV_IPC_GET_ARG1(*call);
    403         const int ret = usb_iface->device_remove(fun, handle);
     395        const unsigned port = DEV_IPC_GET_ARG1(*call);
     396        const int ret = usb_iface->device_remove(fun, port);
    404397        async_answer_0(callid, ret);
    405398}
  • uspace/lib/drv/include/usb_iface.h

    r2757247 r0918382f  
    4242#include <usb/usb.h>
    4343
    44 typedef intptr_t usb_device_handle_t;
    45 enum {
    46         USB_DEVICE_HANDLE_INVALID = -1
    47 };
    4844typedef async_sess_t usb_dev_session_t;
    4945
     
    5854int usb_release_default_address(async_exch_t *);
    5955
    60 int usb_device_enumerate(async_exch_t *, usb_device_handle_t *);
    61 int usb_device_remove(async_exch_t *, usb_device_handle_t);
     56int usb_device_enumerate(async_exch_t *, unsigned port);
     57int usb_device_remove(async_exch_t *, unsigned port);
    6258
    6359int usb_register_endpoint(async_exch_t *, usb_endpoint_t, usb_transfer_type_t,
     
    8177        int (*release_default_address)(ddf_fun_t *);
    8278
    83         int (*device_enumerate)(ddf_fun_t *, usb_device_handle_t *);
    84         int (*device_remove)(ddf_fun_t *, usb_device_handle_t);
     79        int (*device_enumerate)(ddf_fun_t *, unsigned);
     80        int (*device_remove)(ddf_fun_t *, unsigned);
    8581
    8682        int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t,
Note: See TracChangeset for help on using the changeset viewer.