Changeset 983e135 in mainline


Ignore:
Timestamp:
2011-09-19T13:31:23Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5b6f8dd
Parents:
d46b13d
Message:

usbhub: Further codestyle changes

Location:
uspace/drv/bus/usb/usbhub
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/ports.c

    rd46b13d r983e135  
    9595 * @param port port number, starting from 1
    9696 */
    97 void usb_hub_process_port_interrupt(usb_hub_info_t *hub,
    98     uint16_t port) {
     97void usb_hub_process_port_interrupt(usb_hub_info_t *hub, uint16_t port)
     98{
    9999        usb_log_debug("Interrupt at port %zu\n", (size_t) port);
    100100        //determine type of change
  • uspace/drv/bus/usb/usbhub/ports.h

    rd46b13d r983e135  
    7070
    7171
    72 void usb_hub_process_port_interrupt(usb_hub_info_t *hub,
    73         uint16_t port);
     72void usb_hub_process_port_interrupt(usb_hub_info_t *hub, uint16_t port);
    7473
    7574
  • uspace/drv/bus/usb/usbhub/usbhub.c

    rd46b13d r983e135  
    160160 */
    161161bool hub_port_changes_callback(usb_device_t *dev,
    162     uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
     162    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg)
     163{
    163164        usb_log_debug("hub_port_changes_callback\n");
    164         usb_hub_info_t *hub = (usb_hub_info_t *) arg;
     165        usb_hub_info_t *hub = arg;
    165166
    166167        /* FIXME: check that we received enough bytes. */
     
    169170        }
    170171
    171         bool change;
    172         change = ((uint8_t*) change_bitmap)[0] & 1;
     172        /* Lowest bit indicates global change */
     173        const bool change = change_bitmap[0] & 1;
    173174        if (change) {
    174175                usb_hub_process_global_interrupt(hub);
    175176        }
    176177
    177         size_t port;
    178         for (port = 1; port < hub->port_count + 1; port++) {
    179                 bool change = (change_bitmap[port / 8] >> (port % 8)) % 2;
     178        /* N + 1 bit indicates change on port N */
     179        size_t port = 1;
     180        for (; port < hub->port_count + 1; port++) {
     181                const bool change = (change_bitmap[port / 8] >> (port % 8)) & 1;
    180182                if (change) {
    181183                        usb_hub_process_port_interrupt(hub, port);
     
    184186leave:
    185187        /* FIXME: proper interval. */
     188        // TODO Interval should be handled by USB HC scheduler not here
    186189        async_usleep(1000 * 250);
    187190
     
    205208static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev)
    206209{
    207         usb_hub_info_t *result = malloc(sizeof (usb_hub_info_t));
     210        assert(usb_dev);
     211        usb_hub_info_t *result = malloc(sizeof(usb_hub_info_t));
    208212        if (!result)
    209213            return NULL;
     
    215219
    216220        result->ports = NULL;
    217         result->port_count = (size_t) - 1;
     221        result->port_count = -1;
    218222        fibril_mutex_initialize(&result->port_mutex);
    219 
    220223        fibril_mutex_initialize(&result->pending_ops_mutex);
    221224        fibril_condvar_initialize(&result->pending_ops_cv);
     
    315318 * @return error code
    316319 */
    317 static int usb_hub_set_configuration(usb_hub_info_t *hub_info) {
     320static int usb_hub_set_configuration(usb_hub_info_t *hub_info)
     321{
    318322        //device descriptor
    319         usb_standard_device_descriptor_t *std_descriptor
     323        const usb_standard_device_descriptor_t *std_descriptor
    320324            = &hub_info->usb_device->descriptors.device;
    321325        usb_log_debug("Hub has %d configurations\n",
    322326            std_descriptor->configuration_count);
     327
    323328        if (std_descriptor->configuration_count < 1) {
    324329                usb_log_error("There are no configurations available\n");
  • uspace/drv/bus/usb/usbhub/usbhub.h

    rd46b13d r983e135  
    7777         * searched again and again for the 'right pipe'.
    7878         */
    79         usb_pipe_t * status_change_pipe;
     79        usb_pipe_t *status_change_pipe;
    8080
    81         /** convenience pointer to control pipe
     81        /** Convenience pointer to control pipe
    8282         *
    8383         * Control pipe is initialized in usb_device structure. This is
    84          * pointer into this structure, so that it does not have to be
    85          * searched again and again for the 'right pipe'.
     84         * pointer into that structure, so that we don't not have to
     85         * search again and again for the 'right pipe'.
    8686         */
    87         usb_pipe_t * control_pipe;
     87        usb_pipe_t *control_pipe;
    8888
    89         /** generic usb device data*/
    90         usb_device_t * usb_device;
     89        /** Generic usb device data*/
     90        usb_device_t *usb_device;
    9191
    9292        /** Number of pending operations on the mutex to prevent shooting
     
    101101        /** Condition variable for pending_ops_count. */
    102102        fibril_condvar_t pending_ops_cv;
    103 
    104103};
    105104
Note: See TracChangeset for help on using the changeset viewer.