Changeset cd50486 in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-02-06T22:03:55Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25971d2
Parents:
1110ebd (diff), 960ff451 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge development/ changes

Location:
uspace/lib/usb/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/addrkeep.c

    r1110ebd rcd50486  
    149149                        &addresses->default_condvar_guard);
    150150        }
     151        addresses->default_available = false;
    151152        fibril_mutex_unlock(&addresses->default_condvar_guard);
    152153}
  • uspace/lib/usb/src/debug.c

    r1110ebd rcd50486  
    6767/** Serialization mutex for logging functions. */
    6868static FIBRIL_MUTEX_INITIALIZE(log_serializer);
     69static FILE *log_stream = NULL;
    6970
    7071/** Find or create new tag with given name.
     
    171172        log_prefix = message_prefix;
    172173        log_level = level;
     174        if (log_stream == NULL) {
     175                char *fname;
     176                int rc = asprintf(&fname, "/log/%s", message_prefix);
     177                if (rc > 0) {
     178                        log_stream = fopen(fname, "w");
     179                        free(fname);
     180                }
     181        }
    173182}
    174183
     
    197206void usb_log_printf(usb_log_level_t level, const char *format, ...)
    198207{
    199         if (level > log_level) {
    200                 return;
    201         }
    202 
    203         FILE *stream = NULL;
     208        FILE *screen_stream = NULL;
    204209        switch (level) {
    205210                case USB_LOG_LEVEL_FATAL:
    206211                case USB_LOG_LEVEL_ERROR:
    207                         stream = stderr;
     212                        screen_stream = stderr;
    208213                        break;
    209214                default:
    210                         stream = stdout;
     215                        screen_stream = stdout;
    211216                        break;
    212217        }
    213         assert(stream != NULL);
     218        assert(screen_stream != NULL);
    214219
    215220        va_list args;
    216         va_start(args, format);
    217 
     221
     222        /*
     223         * Serialize access to log files.
     224         * Always print to log file, to screen print only when the enabled
     225         * log level is high enough.
     226         */
    218227        fibril_mutex_lock(&log_serializer);
    219         fprintf(stream, "[%s]%s: ", log_prefix, log_level_name(level));
    220         vfprintf(stream, format, args);
     228
     229        const char *level_name = log_level_name(level);
     230
     231        if (log_stream != NULL) {
     232                va_start(args, format);
     233
     234                fprintf(log_stream, "[%s]%s: ", log_prefix, level_name);
     235                vfprintf(log_stream, format, args);
     236                fflush(log_stream);
     237
     238                va_end(args);
     239        }
     240
     241        if (level <= log_level) {
     242                va_start(args, format);
     243
     244                fprintf(screen_stream, "[%s]%s: ", log_prefix, level_name);
     245                vfprintf(screen_stream, format, args);
     246                fflush(screen_stream);
     247
     248                va_end(args);
     249        }
     250
    221251        fibril_mutex_unlock(&log_serializer);
    222 
    223         va_end(args);
    224252}
    225253
  • uspace/lib/usb/src/pipes.c

    r1110ebd rcd50486  
    9090
    9191leave:
    92         ipc_hangup(hc_phone);
     92        async_hangup(hc_phone);
    9393        return rc;
    9494}
     
    211211        }
    212212
    213         int rc = ipc_hangup(pipe->hc_phone);
     213        int rc = async_hangup(pipe->hc_phone);
    214214        if (rc != EOK) {
    215215                return rc;
  • uspace/lib/usb/src/recognise.c

    r1110ebd rcd50486  
    3333 * @brief Functions for recognising kind of attached devices.
    3434 */
     35#include <sys/types.h>
    3536#include <usb_iface.h>
    3637#include <usb/usbdrv.h>
     
    359360{
    360361        static size_t device_name_index = 0;
     362        static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
     363
     364        size_t this_device_name_index;
     365
     366        fibril_mutex_lock(&device_name_index_mutex);
     367        this_device_name_index = device_name_index;
     368        device_name_index++;
     369        fibril_mutex_unlock(&device_name_index_mutex);
     370
    361371
    362372        device_t *child = NULL;
     
    374384         * naming etc., something more descriptive could be created.
    375385         */
    376         rc = asprintf(&child_name, "usbdev%02zu", device_name_index);
     386        rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index);
    377387        if (rc < 0) {
    378388                goto failure;
     
    396406        }
    397407       
    398         device_name_index++;
    399 
    400408        return EOK;
    401409
  • uspace/lib/usb/src/usbdrv.c

    r1110ebd rcd50486  
    8080            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    8181
    82         ipc_hangup(parent_phone);
     82        async_hangup(parent_phone);
    8383
    8484        if (rc != EOK) {
  • uspace/lib/usb/src/usbmem.c

    r1110ebd rcd50486  
    11/*
    2  * Copyright (c) 2010 Matus Dekanek
     2 * Copyright (c) 2011 Matus Dekanek
    33 * All rights reserved.
    44 *
     
    6969}
    7070
    71 static void addr_remove_callback(link_t *item)
     71static void addr_remove_callback(link_t * item)
    7272{
    7373        //delete item
Note: See TracChangeset for help on using the changeset viewer.