Changeset 38b3baf in mainline for uspace/srv/devman/match.c
- Timestamp:
- 2010-10-23T07:16:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e66a5ec
- Parents:
- 032e0bb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/match.c
r032e0bb r38b3baf 30 30 * @{ 31 31 */ 32 33 32 34 33 #include <str.h> 35 34 36 35 #include "devman.h" 37 36 38 39 37 int get_match_score(driver_t *drv, node_t *dev) 40 { 41 link_t * drv_head = &drv->match_ids.ids;42 link_t *dev_head = &dev->match_ids.ids;38 { 39 link_t *drv_head = &drv->match_ids.ids; 40 link_t *dev_head = &dev->match_ids.ids; 43 41 44 if (list_empty(drv_head) || list_empty(dev_head)) {42 if (list_empty(drv_head) || list_empty(dev_head)) 45 43 return 0; 46 }47 44 48 link_t *drv_link = drv->match_ids.ids.next;49 link_t *dev_link = dev->match_ids.ids.next;45 link_t *drv_link = drv->match_ids.ids.next; 46 link_t *dev_link = dev->match_ids.ids.next; 50 47 51 48 match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link); … … 56 53 57 54 do { 58 if (0 == str_cmp(drv_id->id, dev_id->id)) { // we found a match 59 // return the score of the match 55 match_id_t *tmp_ma_id; 56 57 if (0 == str_cmp(drv_id->id, dev_id->id)) { 58 /* 59 * We found a match. 60 * Return the score of the match. 61 */ 60 62 return drv_id->score * dev_id->score; 61 63 } 62 64 63 // compute the next score we get, if we advance in the driver's list of match ids 65 /* 66 * Compute the next score we get, if we advance in the driver's 67 * list of match ids. 68 */ 64 69 if (drv_head != drv_link->next) { 65 score_next_drv = dev_id->score * list_get_instance(drv_link->next, match_id_t, link)->score; 70 tmp_ma_id = list_get_instance(drv_link->next, 71 match_id_t, link); 72 score_next_drv = dev_id->score * tmp_ma_id->score; 66 73 } else { 67 74 score_next_drv = 0; 68 75 } 69 76 70 // compute the next score we get, if we advance in the device's list of match ids 77 /* 78 * Compute the next score we get, if we advance in the device's 79 * list of match ids. 80 */ 71 81 if (dev_head != dev_link->next) { 72 score_next_dev = drv_id->score * list_get_instance(dev_link->next, match_id_t, link)->score; 82 tmp_ma_id = list_get_instance(dev_link->next, 83 match_id_t, link); 84 score_next_dev = drv_id->score * tmp_ma_id->score; 73 85 } else { 74 86 score_next_dev = 0; 75 87 } 76 88 77 // advance in one of the two lists, so we get the next highest score 89 /* 90 * Advance in one of the two lists, so we get the next highest 91 * score. 92 */ 78 93 if (score_next_drv > score_next_dev) { 79 94 drv_link = drv_link->next; … … 89 104 } 90 105 91 92 106 /** @} 107 */
Note:
See TracChangeset
for help on using the changeset viewer.