Changeset d0dd7b5 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2011-08-18T20:10:47Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef7052ec
Parents:
763e0cd
Message:

Work on device removal:

  • properly track service memberships in categories
  • implement loc_service_unregister()
  • ddf_fun_unbind() (limited to exposed functions for now)
Location:
uspace/srv/devman
Files:
3 edited

Legend:

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

    r763e0cd rd0dd7b5  
    11001100}
    11011101
     1102/** Remove function from device tree.
     1103 *
     1104 * @param tree          Device tree
     1105 * @param node          Function node to remove
     1106 */
     1107void remove_fun_node(dev_tree_t *tree, fun_node_t *fun)
     1108{
     1109        assert(tree != NULL);
     1110        assert(fun != NULL);
     1111        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
     1112       
     1113        /* Remove the node from the handle-to-node map. */
     1114        unsigned long key = fun->handle;
     1115        hash_table_remove(&tree->devman_functions, &key, 1);
     1116       
     1117        /* Remove the node from the list of its parent's children. */
     1118        if (fun->dev != NULL)
     1119                list_remove(&fun->dev_functions);
     1120}
     1121
    11021122/** Find function node with a specified path in the device tree.
    11031123 *
  • uspace/srv/devman/devman.h

    r763e0cd rd0dd7b5  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    154155        /** Name of the function, assigned by the device driver */
    155156        char *name;
     157        /** Function type */
     158        fun_type_t ftype;
    156159       
    157160        /** Full path and name of the device in device hierarchy */
     
    265268extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
    266269extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
     270extern void remove_fun_node(dev_tree_t *, fun_node_t *);
    267271
    268272/* Loc services */
  • uspace/srv/devman/main.c

    r763e0cd rd0dd7b5  
    278278                return;
    279279        }
    280 
     280       
    281281        fun_node_t *fun = create_fun_node();
     282        fun->ftype = ftype;
     283       
    282284        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
    283285                fibril_rwlock_write_unlock(&tree->rwlock);
     
    367369}
    368370
     371/** Remove function. */
     372static void devman_remove_function(ipc_callid_t callid, ipc_call_t *call)
     373{
     374        devman_handle_t fun_handle = IPC_GET_ARG1(*call);
     375        dev_tree_t *tree = &device_tree;
     376        int rc;
     377       
     378        fibril_rwlock_write_lock(&tree->rwlock);
     379       
     380        fun_node_t *fun = find_fun_node_no_lock(&device_tree, fun_handle);
     381        if (fun == NULL) {
     382                fibril_rwlock_write_unlock(&tree->rwlock);
     383                async_answer_0(callid, ENOENT);
     384                return;
     385        }
     386       
     387        log_msg(LVL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname);
     388       
     389        if (fun->ftype == fun_inner) {
     390                /* Handle possible descendants */
     391                /* TODO */
     392                log_msg(LVL_WARN, "devman_remove_function(): not handling "
     393                    "descendants\n");
     394        } else {
     395                /* Unregister from location service */
     396                rc = loc_service_unregister(fun->service_id);
     397                if (rc != EOK) {
     398                        log_msg(LVL_ERROR, "Failed unregistering tree service.");
     399                        fibril_rwlock_write_unlock(&tree->rwlock);
     400                        async_answer_0(callid, EIO);
     401                        return;
     402                }
     403        }
     404       
     405        remove_fun_node(&device_tree, fun);
     406        fibril_rwlock_write_unlock(&tree->rwlock);
     407        delete_fun_node(fun);
     408       
     409        log_msg(LVL_DEBUG, "devman_remove_function() succeeded.");
     410        async_answer_0(callid, EOK);
     411}
     412
    369413/** Initialize driver which has registered itself as running and ready.
    370414 *
     
    418462                case DEVMAN_ADD_DEVICE_TO_CATEGORY:
    419463                        devman_add_function_to_cat(callid, &call);
     464                        break;
     465                case DEVMAN_REMOVE_FUNCTION:
     466                        devman_remove_function(callid, &call);
    420467                        break;
    421468                default:
Note: See TracChangeset for help on using the changeset viewer.