Changeset e280857 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2011-08-18T12:35:59Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99ac5cf
Parents:
12f9f0d0
Message:

Remove class infrastructure from devman.

File:
1 edited

Legend:

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

    r12f9f0d0 re280857  
    6464static driver_list_t drivers_list;
    6565static dev_tree_t device_tree;
    66 static class_list_t class_list;
    6766
    6867/** Register running driver. */
     
    333332}
    334333
    335 static void loc_register_class_dev(dev_class_info_t *cli)
    336 {
    337         /* Create loc path and name for the service. */
    338         char *loc_pathname = NULL;
    339 
    340         asprintf(&loc_pathname, "%s/%s%c%s", LOC_CLASS_NAMESPACE,
    341             cli->dev_class->name, LOC_SEPARATOR, cli->dev_name);
    342         if (loc_pathname == NULL)
    343                 return;
    344        
    345         /*
    346          * Register the device with location service and remember its
    347          * service ID.
    348          */
    349         loc_service_register_with_iface(loc_pathname,
    350             &cli->service_id, DEVMAN_CONNECT_FROM_LOC);
    351        
    352         /*
    353          * Add device to the hash map of class devices registered with
    354          * location service.
    355          */
    356         class_add_loc_function(&class_list, cli);
    357        
    358         free(loc_pathname);
    359 }
    360 
    361334static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call)
    362335{
     
    380353        }
    381354       
    382         dev_class_t *cl = get_dev_class(&class_list, class_name);
    383         dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
    384        
    385         /* Register the device's class alias with location service. */
    386         loc_register_class_dev(class_info);
    387        
    388355        rc = loc_category_get_id(class_name, &cat_id, IPC_FLAG_BLOCKING);
    389356        if (rc == EOK) {
     
    394361        }
    395362       
    396         log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",
    397             fun->pathname, class_name, class_info->dev_name);
     363        log_msg(LVL_NOTE, "Function `%s' added to class `%s'.",
     364            fun->pathname, class_name);
    398365
    399366        async_answer_0(callid, EOK);
     
    483450}
    484451
    485 /** Find handle for the device instance identified by device class name. */
    486 static void devman_function_get_handle_by_class(ipc_callid_t iid,
    487     ipc_call_t *icall)
    488 {
    489         char *classname;
    490         char *devname;
    491 
    492         int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);
    493         if (rc != EOK) {
    494                 async_answer_0(iid, rc);
    495                 return;
    496         }
    497         rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);
    498         if (rc != EOK) {
    499                 free(classname);
    500                 async_answer_0(iid, rc);
    501                 return;
    502         }
    503 
    504 
    505         fun_node_t *fun = find_fun_node_by_class(&class_list,
    506             classname, devname);
    507 
    508         free(classname);
    509         free(devname);
    510 
    511         if (fun == NULL) {
    512                 async_answer_0(iid, ENOENT);
    513                 return;
    514         }
    515 
    516         async_answer_1(iid, EOK, fun->handle);
    517 }
    518 
    519452/** Find device path by its handle. */
    520453static void devman_get_device_path_by_handle(ipc_callid_t iid,
     
    554487}
    555488
     489/** Find handle for the function instance identified by its service ID. */
     490static void devman_fun_sid_to_handle(ipc_callid_t iid, ipc_call_t *icall)
     491{
     492        fun_node_t *fun;
     493
     494        fun = find_loc_tree_function(&device_tree, IPC_GET_ARG1(*icall));
     495       
     496        if (fun == NULL) {
     497                async_answer_0(iid, ENOENT);
     498                return;
     499        }
     500
     501        async_answer_1(iid, EOK, fun->handle);
     502}
    556503
    557504/** Function for handling connections from a client to the device manager. */
     
    572519                        devman_function_get_handle(callid, &call);
    573520                        break;
    574                 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:
    575                         devman_function_get_handle_by_class(callid, &call);
    576                         break;
    577521                case DEVMAN_DEVICE_GET_DEVICE_PATH:
    578522                        devman_get_device_path_by_handle(callid, &call);
     523                        break;
     524                case DEVMAN_FUN_SID_TO_HANDLE:
     525                        devman_fun_sid_to_handle(callid, &call);
    579526                        break;
    580527                default:
     
    678625
    679626        fun = find_loc_tree_function(&device_tree, service_id);
    680         if (fun == NULL)
    681                 fun = find_loc_class_function(&class_list, service_id);
    682627       
    683628        if (fun == NULL || fun->dev->drv == NULL) {
     
    750695        }
    751696
    752         init_class_list(&class_list);
    753        
    754697        /*
    755698         * !!! devman_connection ... as the device manager is not a real loc
Note: See TracChangeset for help on using the changeset viewer.