Changeset 08f747e in mainline for uspace/srv/devman/match.c


Ignore:
Timestamp:
2010-11-26T21:49:30Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e423a2d, dac43be
Parents:
e4dbfda (diff), da55d5b (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/match.c

    re4dbfda r08f747e  
    3535#include "devman.h"
    3636
     37/** Compute compound score of driver and device.
     38 *
     39 * @param driver Match id of the driver.
     40 * @param device Match id of the device.
     41 * @return Compound score.
     42 * @retval 0 No match at all.
     43 */
     44static int compute_match_score(match_id_t *driver, match_id_t *device)
     45{
     46        if (str_cmp(driver->id, device->id) == 0) {
     47                /*
     48                 * The strings matches, return their score multiplied.
     49                 */
     50                return driver->score * device->score;
     51        } else {
     52                /*
     53                 * Different strings, return zero.
     54                 */
     55                return 0;
     56        }
     57}
     58
    3759int get_match_score(driver_t *drv, node_t *dev)
    3860{
     
    4466       
    4567        /*
    46          * Find first matching pair.
     68         * Go through all pairs, return the highest score obtainetd.
    4769         */
     70        int highest_score = 0;
     71       
    4872        link_t *drv_link = drv->match_ids.ids.next;
    4973        while (drv_link != drv_head) {
    50                 link_t *dev_link = dev->match_ids.ids.next;
     74                link_t *dev_link = dev_head->next;
    5175                while (dev_link != dev_head) {
    5276                        match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
    5377                        match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link);
    54 
    55                         if (str_cmp(drv_id->id, dev_id->id) == 0) {
    56                                 /*
    57                                  * We found a match.
    58                                  * Return the score of the match.
    59                                  */
    60                                 return drv_id->score * dev_id->score;
     78                       
     79                        int score = compute_match_score(drv_id, dev_id);
     80                        if (score > highest_score) {
     81                                highest_score = score;
    6182                        }
    6283
    6384                        dev_link = dev_link->next;
    6485                }
     86               
    6587                drv_link = drv_link->next;
    6688        }
    6789       
    68         return 0;
     90        return highest_score;
    6991}
    7092
Note: See TracChangeset for help on using the changeset viewer.