Changeset 5fe1c32 in mainline for uspace/srv/drivers/isa/isa.c


Ignore:
Timestamp:
2010-04-21T22:01:54Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f928a8a
Parents:
5dc9622
Message:

backup (unstable)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/drivers/isa/isa.c

    r5dc9622 r5fe1c32  
    312312        char *end = val;
    313313       
    314         while (isspace(*end)) {
     314        while (!isspace(*end)) {
    315315                end++;
    316316        }       
     
    330330        val = skip_spaces(val);
    331331       
    332         score = (int)strtol(val, &end, 0x10);
     332        score = (int)strtol(val, &end, 10);
    333333        if (val == end) {
     334                printf(NAME " : error - could not read match score for device %s.\n", dev->name);
    334335                return;
    335336        }
     
    337338        match_id_t *match_id = create_match_id();
    338339        if (NULL == match_id) {
     340                printf(NAME " : failed to allocate match id for device %s.\n", dev->name);
    339341                return;
    340342        }
     
    343345        get_match_id(&id, val);
    344346        if (NULL == id) {
     347                printf(NAME " : error - could not read match id for device %s.\n", dev->name);
    345348                delete_match_id(match_id);
    346349                return;
     
    350353        match_id->score = score;
    351354       
     355        printf(NAME ": adding match id %s with score %d to device %s\n", id, score, dev->name);
    352356        add_match_id(&dev->match_ids, match_id);
    353357}
    354358
     359static bool read_dev_prop(
     360        device_t *dev, char *line, const char *prop, void (* read_fn)(device_t *, char *))
     361{
     362        size_t proplen = str_size(prop);
     363        if (0 == str_lcmp(line, prop, proplen)) {
     364                line += proplen;
     365                line = skip_spaces(line);
     366                (*read_fn)(dev, line);
     367                return true;
     368        }
     369        return false;           
     370}
     371
    355372static void get_dev_prop(device_t *dev, char *line)
    356373{
     374        printf(NAME " get_dev_prop from line '%s'\n", line);
    357375        // skip leading spaces
    358376        line = skip_spaces(line);
    359377       
    360         // value of the property
    361         char *val;
    362        
    363         if (NULL != (val = strtok(line, "io_range"))) {         
    364                 get_dev_io_range(dev, val);
    365         } else if (NULL != (val = strtok(line, "irq"))) {
    366                 get_dev_irq(dev, val);         
    367         } else if (NULL != (val = strtok(line, "match"))) {
    368                 get_dev_match_id(dev, val);
     378        if (!read_dev_prop(dev, line, "io_range", &get_dev_io_range) &&
     379                !read_dev_prop(dev, line, "irq", &get_dev_irq) &&
     380                !read_dev_prop(dev, line, "match", &get_dev_match_id)
     381        ) {             
     382                printf(NAME " error undefined device property at line %s\n", line);
    369383        }       
    370384}
     
    397411        }
    398412       
     413        printf(NAME ": next line ='%s'\n", dev_conf);
     414        printf(NAME ": current line ='%s'\n", line);
     415       
    399416        // get device name
    400417        dev_name = get_device_name(line);
     
    424441                // get the device's property from the configuration line and store it in the device structure
    425442                get_dev_prop(dev, line);
     443               
     444                printf(NAME ": next line ='%s'\n", dev_conf);
     445                printf(NAME ": current line ='%s'\n", line);           
    426446        }
    427447       
     
    429449        dev->class = &isa_child_class;
    430450       
    431         child_device_register(dev, parent);
     451        child_device_register(dev, parent);     
    432452       
    433453        return dev_conf;       
     
    456476        // add child devices   
    457477        add_legacy_children(dev);
     478        printf(NAME ": finished the enumeration of legacy devices\n", dev->handle);
    458479       
    459480        return true;
Note: See TracChangeset for help on using the changeset viewer.