Changeset 58563585 in mainline for uspace/lib/usbdev


Ignore:
Timestamp:
2016-08-31T11:15:39Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
10cb47e
Parents:
7a67416
Message:

code review and cstyle cleanup (no change in functionality)

Location:
uspace/lib/usbdev
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/poll.h

    r7a67416 r58563585  
    9494typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
    9595
    96 int usb_device_auto_polling(usb_device_t *, usb_endpoint_t,
     96extern int usb_device_auto_polling(usb_device_t *, usb_endpoint_t,
    9797    const usb_device_auto_polling_t *, size_t);
    9898
    99 int usb_device_auto_poll(usb_device_t *, usb_endpoint_t,
     99extern int usb_device_auto_poll(usb_device_t *, usb_endpoint_t,
    100100    usb_polling_callback_t, size_t, int, usb_polling_terminted_callback_t, void *);
    101101
    102 int usb_device_auto_polling_desc(usb_device_t *,
     102extern int usb_device_auto_polling_desc(usb_device_t *,
    103103    const usb_endpoint_description_t *, const usb_device_auto_polling_t *,
    104104    size_t);
    105105
    106 int usb_device_auto_poll_desc(usb_device_t *,
     106extern int usb_device_auto_poll_desc(usb_device_t *,
    107107    const usb_endpoint_description_t *, usb_polling_callback_t, size_t, int,
    108108    usb_polling_terminted_callback_t, void *);
  • uspace/lib/usbdev/include/usb/dev/recognise.h

    r7a67416 r58563585  
    5050
    5151extern int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
     52
    5253#endif
    5354
  • uspace/lib/usbdev/src/devdrv.c

    r7a67416 r58563585  
    2727 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828 */
     29
    2930/** @addtogroup libusbdev
    3031 * @{
     
    5556        /** Connection to device on USB bus */
    5657        usb_dev_session_t *bus_session;
     58       
    5759        /** devman handle */
    5860        devman_handle_t handle;
     61       
    5962        /** The default control pipe. */
    6063        usb_pipe_t ctrl_pipe;
    61 
     64       
    6265        /** Other endpoint pipes.
     66         *
    6367         * This is an array of other endpoint pipes in the same order as
    6468         * in usb_driver_t.
    6569         */
    6670        usb_endpoint_mapping_t *pipes;
     71       
    6772        /** Number of other endpoint pipes. */
    6873        size_t pipes_count;
     74       
    6975        /** Current interface.
     76         *
    7077         * Usually, drivers operate on single interface only.
    7178         * This item contains the value of the interface or -1 for any.
    7279         */
    7380        int interface_no;
     81       
    7482        /** Alternative interfaces. */
    7583        usb_alternate_interfaces_t alternate_interfaces;
     84       
    7685        /** Some useful descriptors for USB device. */
    7786        usb_device_descriptors_t descriptors;
     87       
    7888        /** Generic DDF device backing this one. DO NOT TOUCH! */
    7989        ddf_dev_t *ddf_dev;
     90       
    8091        /** Custom driver data.
     92         *
    8193         * Do not use the entry in generic device, that is already used
    8294         * by the framework.
    8395         */
    8496        void *driver_data;
    85 
    8697} usb_device_t;
    8798
     
    135146                return rc;
    136147        }
    137 
     148       
    138149        /* Change current alternative */
    139150        usb_dev->alternate_interfaces.current = alternate_setting;
     
    279290 *
    280291 * @param[in] usb_dev USB device.
     292 *
    281293 */
    282294void usb_device_destroy_pipes(usb_device_t *usb_dev)
     
    284296        assert(usb_dev);
    285297        assert(usb_dev->pipes || usb_dev->pipes_count == 0);
     298       
    286299        /* Destroy the pipes. */
    287300        for (size_t i = 0; i < usb_dev->pipes_count; ++i) {
     
    291304                        usb_pipe_unregister(&usb_dev->pipes[i].pipe);
    292305        }
     306       
    293307        free(usb_dev->pipes);
    294308        usb_dev->pipes = NULL;
     
    448462        assert(handle);
    449463        assert(iface_no);
     464       
    450465        async_exch_t *exch = async_exchange_begin(sess);
    451466        if (!exch)
    452467                return EPARTY;
     468       
    453469        int ret = usb_get_my_device_handle(exch, handle);
    454470        if (ret == EOK) {
     
    459475                }
    460476        }
     477       
    461478        async_exchange_end(exch);
    462479        return ret;
  • uspace/lib/usbdev/src/devpoll.c

    r7a67416 r58563585  
    3333 * USB device driver framework - automatic interrupt polling.
    3434 */
     35
    3536#include <usb/dev/device.h>
    3637#include <usb/dev/pipes.h>
     
    8586
    8687        if (params->debug > 0) {
    87                 const usb_endpoint_mapping_t *mapping
    88                     = data->polling_mapping;
     88                const usb_endpoint_mapping_t *mapping =
     89                    data->polling_mapping;
    8990                usb_log_debug("Poll (%p): started polling of `%s' - " \
    9091                    "interface %d (%s,%d,%d), %zuB/%zu.\n",
     
    154155
    155156                /* Take a rest before next request. */
    156                 //TODO: This is broken, the time is in ms not us.
     157               
     158                // FIXME TODO: This is broken, the time is in ms not us.
    157159                // but first we need to fix drivers to actually stop using this,
    158                 // since polling dealy should be implemented in HC schedule
     160                // since polling delay should be implemented in HC schedule
    159161                async_usleep(params->delay);
    160162        }
     
    213215        if (request_size == 0)
    214216                return EINVAL;
    215 
     217       
    216218        if (!epm || (epm->pipe.transfer_type != USB_TRANSFER_INTERRUPT) ||
    217219            (epm->pipe.direction != USB_DIRECTION_IN))
    218220                return EINVAL;
    219 
     221       
    220222
    221223        polling_data_t *polling_data = malloc(sizeof(polling_data_t));
  • uspace/lib/usbdev/src/pipes.c

    r7a67416 r58563585  
    9898        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    9999        size_t act_size = 0;
    100         const int rc = usb_read(exch,
    101             pipe->endpoint_no, setup_packet, buffer, buffer_size, &act_size);
     100        const int rc = usb_read(exch, pipe->endpoint_no, setup_packet, buffer,
     101            buffer_size, &act_size);
    102102        async_exchange_end(exch);
    103103
  • uspace/lib/usbdev/src/pipesinit.c

    r7a67416 r58563585  
    286286    usb_dev_session_t *bus_session)
    287287{
    288 
    289         if (config_descriptor == NULL) {
     288        if (config_descriptor == NULL)
    290289                return EBADMEM;
    291         }
    292         if (config_descriptor_size
    293             < sizeof(usb_standard_configuration_descriptor_t)) {
     290       
     291        if (config_descriptor_size <
     292            sizeof(usb_standard_configuration_descriptor_t)) {
    294293                return ERANGE;
    295294        }
  • uspace/lib/usbdev/src/recognise.c

    r7a67416 r58563585  
    234234                    (int) device_descriptor->product_id,
    235235                    BCD_ARGS(device_descriptor->device_version));
    236 
     236               
    237237                /* Next, without release number. */
    238238                ADD_MATCHID_OR_RETURN(matches, 90,
     
    245245        ADD_MATCHID_OR_RETURN(matches, 50, "usb&class=%s",
    246246            usb_str_class(device_descriptor->device_class));
    247 
     247       
    248248        /* As a last resort, try fallback driver. */
    249249        ADD_MATCHID_OR_RETURN(matches, 10, "usb&fallback");
  • uspace/lib/usbdev/src/request.c

    r7a67416 r58563585  
    5050 * @see usb_pipe_control_write
    5151 *
    52  * @param pipe Pipe used for the communication.
     52 * @param pipe         Pipe used for the communication.
    5353 * @param request_type Request type (standard/class/vendor).
    54  * @param recipient Request recipient (e.g. device or endpoint).
    55  * @param request Actual request (e.g. GET_DESCRIPTOR).
    56  * @param value Value of @c wValue field of setup packet
    57  *      (must be in USB endianness).
    58  * @param index Value of @c wIndex field of setup packet
    59  *      (must be in USB endianness).
    60  * @param data Data to be sent during DATA stage
    61  *      (expected to be in USB endianness).
    62  * @param data_size Size of the @p data buffer (in native endianness).
     54 * @param recipient    Request recipient (e.g. device or endpoint).
     55 * @param request      Actual request (e.g. GET_DESCRIPTOR).
     56 * @param value        Value of @c wValue field of setup packet
     57 *                     (must be in USB endianness).
     58 * @param index        Value of @c wIndex field of setup packet
     59 *                     (must be in USB endianness).
     60 * @param data         Data to be sent during DATA stage
     61 *                     (expected to be in USB endianness).
     62 * @param data_size     Size of the @p data buffer (in native endianness).
     63 *
    6364 * @return Error code.
    6465 * @retval EBADMEM @p pipe is NULL.
    6566 * @retval EBADMEM @p data is NULL and @p data_size is not zero.
    6667 * @retval ERANGE Data buffer too large.
     68 *
    6769 */
    6870int usb_control_request_set(usb_pipe_t *pipe,
     
    100102}
    101103
    102  /** Generic wrapper for GET requests using standard control request format.
    103   *
    104   * @see usb_pipe_control_read
    105   *
    106   * @param pipe Pipe used for the communication.
    107   * @param request_type Request type (standard/class/vendor).
    108   * @param recipient Request recipient (e.g. device or endpoint).
    109   * @param request Actual request (e.g. GET_DESCRIPTOR).
    110   * @param value Value of @c wValue field of setup packet
    111   *     (must be in USB endianness).
    112   * @param index Value of @c wIndex field of setup packet
    113   *     (must be in USB endianness).
    114   * @param data Buffer where to store data accepted during the DATA stage.
    115   *     (they will come in USB endianness).
    116   * @param data_size Size of the @p data buffer
    117   *     (in native endianness).
    118   * @param actual_data_size Actual size of transfered data
    119   *     (in native endianness).
    120   * @return Error code.
    121   * @retval EBADMEM @p pipe is NULL.
    122   * @retval EBADMEM @p data is NULL and @p data_size is not zero.
    123   * @retval ERANGE Data buffer too large.
    124   */
     104/** Generic wrapper for GET requests using standard control request format.
     105 *
     106 * @see usb_pipe_control_read
     107 *
     108 * @param pipe             Pipe used for the communication.
     109 * @param request_type     Request type (standard/class/vendor).
     110 * @param recipient        Request recipient (e.g. device or endpoint).
     111 * @param request          Actual request (e.g. GET_DESCRIPTOR).
     112 * @param value            Value of @c wValue field of setup packet
     113 *                         (must be in USB endianness).
     114 * @param index            Value of @c wIndex field of setup packet
     115 *                         (must be in USB endianness).
     116 * @param data             Buffer where to store data accepted during
     117 *                         the DATA stage (they will come in USB endianness).
     118 * @param data_size        Size of the @p data buffer
     119 *                         (in native endianness).
     120 * @param actual_data_size Actual size of transfered data
     121 *                         (in native endianness).
     122 *
     123 * @return Error code.
     124 * @retval EBADMEM @p pipe is NULL.
     125 * @retval EBADMEM @p data is NULL and @p data_size is not zero.
     126 * @retval ERANGE Data buffer too large.
     127 *
     128 */
    125129int usb_control_request_get(usb_pipe_t *pipe,
    126130    usb_request_type_t request_type, usb_request_recipient_t recipient,
     
    209213{
    210214        if (request_type == USB_REQUEST_TYPE_STANDARD) {
    211                 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0))
    212                 {
     215                if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) {
    213216                        return EINVAL;
    214217                }
     
    234237{
    235238        if (request_type == USB_REQUEST_TYPE_STANDARD) {
    236                 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0))
    237                 {
     239                if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) {
    238240                        return EINVAL;
    239241                }
     
    271273        }
    272274
    273         /* The wValue field specifies the descriptor type in the high byte
     275        /*
     276         * The wValue field specifies the descriptor type in the high byte
    274277         * and the descriptor index in the low byte. USB 1.1 spec p. 189
    275278         */
Note: See TracChangeset for help on using the changeset viewer.