Ignore:
File:
1 edited

Legend:

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

    r9b415c9 rebcb05a  
    148148
    149149        log_msg(LVL_NOTE, "Driver `%s' was added to the list of available "
    150             "drivers.\n", drv->name);
     150            "drivers.", drv->name);
    151151}
    152152
     
    238238bool read_match_ids(const char *conf_path, match_id_list_t *ids)
    239239{
    240         log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")\n", conf_path);
     240        log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path);
    241241       
    242242        bool suc = false;
     
    248248        fd = open(conf_path, O_RDONLY);
    249249        if (fd < 0) {
    250                 log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.\n",
     250                log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.",
    251251                    conf_path, str_error(fd));
    252252                goto cleanup;
     
    257257        lseek(fd, 0, SEEK_SET);
    258258        if (len == 0) {
    259                 log_msg(LVL_ERROR, "Configuration file '%s' is empty.\n",
     259                log_msg(LVL_ERROR, "Configuration file '%s' is empty.",
    260260                    conf_path);
    261261                goto cleanup;
     
    265265        if (buf == NULL) {
    266266                log_msg(LVL_ERROR, "Memory allocation failed when parsing file "
    267                     "'%s'.\n", conf_path);
     267                    "'%s'.", conf_path);
    268268                goto cleanup;
    269269        }
     
    271271        ssize_t read_bytes = safe_read(fd, buf, len);
    272272        if (read_bytes <= 0) {
    273                 log_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path);
     273                log_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
    274274                goto cleanup;
    275275        }
     
    309309bool get_driver_info(const char *base_path, const char *name, driver_t *drv)
    310310{
    311         log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")\n",
     311        log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")",
    312312            base_path, name);
    313313       
     
    369369int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
    370370{
    371         log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")\n", dir_path);
     371        log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")", dir_path);
    372372       
    373373        int drv_cnt = 0;
     
    403403        dev_node_t *dev;
    404404       
    405         log_msg(LVL_DEBUG, "create_root_nodes()\n");
     405        log_msg(LVL_DEBUG, "create_root_nodes()");
    406406       
    407407        fibril_rwlock_write_lock(&tree->rwlock);
     
    488488void attach_driver(dev_node_t *dev, driver_t *drv)
    489489{
    490         log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")\n",
     490        log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")",
    491491            dev->pfun->pathname, drv->name);
    492492       
     
    511511        assert(fibril_mutex_is_locked(&drv->driver_mutex));
    512512       
    513         log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")\n", drv->name);
     513        log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
    514514       
    515515        rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
    516516        if (rc != EOK) {
    517                 log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.\n",
     517                log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
    518518                    drv->name, drv->binary_path, str_error(rc));
    519519                return false;
     
    578578        int phone;
    579579
    580         log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")\n",
     580        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
    581581            driver->name);
    582582
     
    646646         * immediately and possibly started here as well.
    647647         */
    648         log_msg(LVL_DEBUG, "Driver `%s' enters running state.\n", driver->name);
     648        log_msg(LVL_DEBUG, "Driver `%s' enters running state.", driver->name);
    649649        driver->state = DRIVER_RUNNING;
    650650
     
    663663void initialize_running_driver(driver_t *driver, dev_tree_t *tree)
    664664{
    665         log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")\n",
     665        log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")",
    666666            driver->name);
    667667       
     
    754754         * access any structures that would affect driver_t.
    755755         */
    756         log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")\n",
     756        log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")",
    757757            drv->name, dev->pfun->name);
    758758       
     
    816816        driver_t *drv = find_best_match_driver(drivers_list, dev);
    817817        if (drv == NULL) {
    818                 log_msg(LVL_ERROR, "No driver found for device `%s'.\n",
     818                log_msg(LVL_ERROR, "No driver found for device `%s'.",
    819819                    dev->pfun->pathname);
    820820                return false;
     
    854854bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list)
    855855{
    856         log_msg(LVL_DEBUG, "init_device_tree()\n");
     856        log_msg(LVL_DEBUG, "init_device_tree()");
    857857       
    858858        tree->current_handle = 0;
     
    10331033        fun->pathname = (char *) malloc(pathsize);
    10341034        if (fun->pathname == NULL) {
    1035                 log_msg(LVL_ERROR, "Failed to allocate device path.\n");
     1035                log_msg(LVL_ERROR, "Failed to allocate device path.");
    10361036                return false;
    10371037        }
     
    10641064        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    10651065       
    1066         log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])\n",
     1066        log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])",
    10671067            dev, pfun, pfun->pathname);
    10681068
     
    11731173}
    11741174
     1175/** Find function with a specified name belonging to given device.
     1176 *
     1177 * Device tree rwlock should be held at least for reading.
     1178 *
     1179 * @param dev Device the function belongs to.
     1180 * @param name Function name (not path).
     1181 * @return Function node.
     1182 * @retval NULL No function with given name.
     1183 */
     1184fun_node_t *find_fun_node_in_device(dev_node_t *dev, const char *name)
     1185{
     1186        assert(dev != NULL);
     1187        assert(name != NULL);
     1188
     1189        fun_node_t *fun;
     1190        link_t *link;
     1191
     1192        for (link = dev->functions.next;
     1193            link != &dev->functions;
     1194            link = link->next) {
     1195                fun = list_get_instance(link, fun_node_t, dev_functions);
     1196
     1197                if (str_cmp(name, fun->name) == 0)
     1198                        return fun;
     1199        }
     1200
     1201        return NULL;
     1202}
     1203
     1204/** Find function node by its class name and index. */
     1205fun_node_t *find_fun_node_by_class(class_list_t *class_list,
     1206    const char *class_name, const char *dev_name)
     1207{
     1208        assert(class_list != NULL);
     1209        assert(class_name != NULL);
     1210        assert(dev_name != NULL);
     1211
     1212        fibril_rwlock_read_lock(&class_list->rwlock);
     1213
     1214        dev_class_t *cl = find_dev_class_no_lock(class_list, class_name);
     1215        if (cl == NULL) {
     1216                fibril_rwlock_read_unlock(&class_list->rwlock);
     1217                return NULL;
     1218        }
     1219
     1220        dev_class_info_t *dev = find_dev_in_class(cl, dev_name);
     1221        if (dev == NULL) {
     1222                fibril_rwlock_read_unlock(&class_list->rwlock);
     1223                return NULL;
     1224        }
     1225
     1226        fun_node_t *fun = dev->fun;
     1227
     1228        fibril_rwlock_read_unlock(&class_list->rwlock);
     1229
     1230        return fun;
     1231}
     1232
     1233
    11751234/** Find child function node with a specified name.
    11761235 *
     
    11831242fun_node_t *find_node_child(fun_node_t *pfun, const char *name)
    11841243{
    1185         fun_node_t *fun;
    1186         link_t *link;
    1187        
    1188         link = pfun->child->functions.next;
    1189        
    1190         while (link != &pfun->child->functions) {
    1191                 fun = list_get_instance(link, fun_node_t, dev_functions);
    1192                
    1193                 if (str_cmp(name, fun->name) == 0)
    1194                         return fun;
    1195                
    1196                 link = link->next;
    1197         }
    1198        
    1199         return NULL;
     1244        return find_fun_node_in_device(pfun->child, name);
    12001245}
    12011246
     
    13591404}
    13601405
     1406dev_class_info_t *find_dev_in_class(dev_class_t *dev_class, const char *dev_name)
     1407{
     1408        assert(dev_class != NULL);
     1409        assert(dev_name != NULL);
     1410
     1411        link_t *link;
     1412        for (link = dev_class->devices.next;
     1413            link != &dev_class->devices;
     1414            link = link->next) {
     1415                dev_class_info_t *dev = list_get_instance(link,
     1416                    dev_class_info_t, link);
     1417
     1418                if (str_cmp(dev->dev_name, dev_name) == 0) {
     1419                        return dev;
     1420                }
     1421        }
     1422
     1423        return NULL;
     1424}
     1425
    13611426void init_class_list(class_list_t *class_list)
    13621427{
Note: See TracChangeset for help on using the changeset viewer.