Changeset 84439d7 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2010-12-05T09:34:46Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75732da
Parents:
56b962d (diff), 35537a7 (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 with development/

Location:
uspace/srv/devman
Files:
3 edited

Legend:

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

    r56b962d r84439d7  
    651651       
    652652        /* Send the device to the driver. */
    653         aid_t req = async_send_1(phone, DRIVER_ADD_DEVICE, node->handle,
    654             &answer);
     653        devman_handle_t parent_handle;
     654        if (node->parent) {
     655                parent_handle = node->parent->handle;
     656        } else {
     657                parent_handle = 0;
     658        }
     659        aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle,
     660            parent_handle, &answer);
    655661       
    656662        /* Send the device's name to the driver. */
     
    10221028       
    10231029        size_t idx = get_new_class_dev_idx(cl);
    1024         asprintf(&dev_name, "%s%d", base_name, idx);
     1030        asprintf(&dev_name, "%s%zu", base_name, idx);
    10251031       
    10261032        return dev_name;
  • uspace/srv/devman/main.c

    r56b962d r84439d7  
    3636 */
    3737
     38#include <inttypes.h>
    3839#include <assert.h>
    3940#include <ipc/services.h>
     
    405406                        break;
    406407                default:
    407                         if (!(callid & IPC_CALLID_NOTIFICATION))
    408                                 ipc_answer_0(callid, ENOENT);
     408                        ipc_answer_0(callid, ENOENT);
    409409                }
    410410        }
     
    418418        node_t *dev = find_dev_node(&device_tree, handle);
    419419        if (dev == NULL) {
    420                 printf(NAME ": devman_forward error - no device with handle %x "
    421                     "was found.\n", handle);
     420                printf(NAME ": devman_forward error - no device with handle %" PRIun
     421                    " was found.\n", handle);
    422422                ipc_answer_0(iid, ENOENT);
    423423                return;
     
    435435       
    436436        if (driver == NULL) {
    437                 printf(NAME ": devman_forward error - the device is not in "
    438                     "usable state.\n", handle);
     437                printf(NAME ": devman_forward error - the device is not in %" PRIun
     438                    " usable state.\n", handle);
    439439                ipc_answer_0(iid, ENOENT);
    440440                return;
     
    450450                printf(NAME ": devman_forward: cound not forward to driver %s ",
    451451                    driver->name);
    452                 printf("the driver's phone is %x).\n", driver->phone);
     452                printf("the driver's phone is %" PRIun ").\n", driver->phone);
    453453                ipc_answer_0(iid, EINVAL);
    454454                return;
  • uspace/srv/devman/match.c

    r56b962d r84439d7  
    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.