Changeset 81685dd9 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2017-10-20T07:18:57Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
feab36ae
Parents:
04efacc
Message:

Add devctl unload-drv subcommand to manually unload a driver that is not in use.

Location:
uspace/srv/devman
Files:
3 edited

Legend:

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

    r04efacc r81685dd9  
    726726}
    727727
     728/** Unload a driver by user request. */
     729static void devman_driver_unload(ipc_callid_t iid, ipc_call_t *icall)
     730{
     731        driver_t *drv;
     732        int rc;
     733       
     734        drv = driver_find(&drivers_list, IPC_GET_ARG1(*icall));
     735        if (drv == NULL) {
     736                async_answer_0(iid, ENOENT);
     737                return;
     738        }
     739       
     740        fibril_mutex_lock(&drv->driver_mutex);
     741        rc = stop_driver(drv);
     742        fibril_mutex_unlock(&drv->driver_mutex);
     743
     744        async_answer_0(iid, rc);
     745}
     746
    728747/** Function for handling connections from a client to the device manager. */
    729748void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     
    794813                        devman_driver_load(callid, &call);
    795814                        break;
     815                case DEVMAN_DRIVER_UNLOAD:
     816                        devman_driver_unload(callid, &call);
     817                        break;
    796818                default:
    797819                        async_answer_0(callid, ENOENT);
  • uspace/srv/devman/driver.c

    r04efacc r81685dd9  
    298298        drv->state = DRIVER_STARTING;
    299299        return true;
     300}
     301
     302/** Stop a driver
     303 *
     304 * @param drv           The driver's structure.
     305 * @return              True if the driver's task is successfully spawned, false
     306 *                      otherwise.
     307 */
     308int stop_driver(driver_t *drv)
     309{
     310        async_exch_t *exch;
     311        sysarg_t retval;
     312       
     313        log_msg(LOG_DEFAULT, LVL_DEBUG, "stop_driver(drv=\"%s\")", drv->name);
     314
     315        exch = async_exchange_begin(drv->sess);
     316        retval = async_req_0_0(exch, DRIVER_STOP);
     317        loc_exchange_end(exch);
     318       
     319        if (retval != EOK)
     320                return retval;
     321       
     322        drv->state = DRIVER_NOT_STARTED;
     323        async_hangup(drv->sess);
     324        drv->sess = NULL;
     325        return EOK;
    300326}
    301327
  • uspace/srv/devman/driver.h

    r04efacc r81685dd9  
    5050extern void detach_driver(dev_tree_t *, dev_node_t *);
    5151extern bool start_driver(driver_t *);
     52extern int stop_driver(driver_t *);
    5253extern void add_device(driver_t *, dev_node_t *, dev_tree_t *);
    5354extern int driver_dev_remove(dev_tree_t *, dev_node_t *);
Note: See TracChangeset for help on using the changeset viewer.