Пример #1
0
static int
i915drm_modcmd(modcmd_t cmd, void *arg)
{
	int err;

	switch (cmd) {
	case MODULE_CMD_INIT:
		err = config_cfdriver_attach(&i915drm_cd);
		if (err)
			return err;
		err = config_cfattach_attach("i915drm", &i915drm_ca);
		if (err) {
			config_cfdriver_detach(&i915drm_cd);
			return err;
		}
		err = config_cfdata_attach(i915drm_cfdata, 1);
		if (err) {
			config_cfattach_detach("i915drm", &i915drm_ca);
			config_cfdriver_detach(&i915drm_cd);
			return err;
		}
		return 0;
	case MODULE_CMD_FINI:
		err = config_cfdata_detach(i915drm_cfdata);
		if (err)
			return err;
		config_cfattach_detach("i915drm", &i915drm_ca);
		config_cfdriver_detach(&i915drm_cd);
		return 0;
	default:
		return ENOTTY;
	}
}
Пример #2
0
static int
cgd_modcmd(modcmd_t cmd, void *arg)
{
	int error = 0;

#ifdef _MODULE
	devmajor_t bmajor = -1, cmajor = -1;
#endif

	switch (cmd) {
	case MODULE_CMD_INIT:
#ifdef _MODULE
		error = config_cfdriver_attach(&cgd_cd);
		if (error)
			break;

		error = config_cfattach_attach(cgd_cd.cd_name, &cgd_ca);
	        if (error) {
			config_cfdriver_detach(&cgd_cd);
			aprint_error("%s: unable to register cfattach\n",
			    cgd_cd.cd_name);
			break;
		}

		error = devsw_attach("cgd", &cgd_bdevsw, &bmajor,
		    &cgd_cdevsw, &cmajor);
		if (error) {
			config_cfattach_detach(cgd_cd.cd_name, &cgd_ca);
			config_cfdriver_detach(&cgd_cd);
			break;
		}
#endif
		break;

	case MODULE_CMD_FINI:
#ifdef _MODULE
		error = config_cfattach_detach(cgd_cd.cd_name, &cgd_ca);
		if (error)
			break;
		config_cfdriver_detach(&cgd_cd);
		devsw_detach(&cgd_bdevsw, &cgd_cdevsw);
#endif
		break;

	case MODULE_CMD_STAT:
		return ENOTTY;

	default:
		return ENOTTY;
	}

	return error;
}
Пример #3
0
static int
fss_modcmd(modcmd_t cmd, void *arg)
{
	devmajor_t bmajor = -1, cmajor = -1;
	int error = 0;

	switch (cmd) {
	case MODULE_CMD_INIT:
		mutex_init(&fss_device_lock, MUTEX_DEFAULT, IPL_NONE);
		error = config_cfdriver_attach(&fss_cd);
		if (error) {
			mutex_destroy(&fss_device_lock);
			break;
		}
		error = config_cfattach_attach(fss_cd.cd_name, &fss_ca);
		if (error) {
			config_cfdriver_detach(&fss_cd);
			mutex_destroy(&fss_device_lock);
			break;
		}
		error = devsw_attach(fss_cd.cd_name,
		    &fss_bdevsw, &bmajor, &fss_cdevsw, &cmajor);
		if (error == EEXIST)
			error = 0;
		if (error) {
			config_cfattach_detach(fss_cd.cd_name, &fss_ca);
			config_cfdriver_detach(&fss_cd);
			mutex_destroy(&fss_device_lock);
			break;
		}
		break;

	case MODULE_CMD_FINI:
		error = config_cfattach_detach(fss_cd.cd_name, &fss_ca);
		if (error)
			break;
		config_cfdriver_detach(&fss_cd);
		devsw_detach(&fss_bdevsw, &fss_cdevsw);
		mutex_destroy(&fss_device_lock);
		break;

	default:
		error = ENOTTY;
		break;
	}

	return error;
}
Пример #4
0
static int
vnd_modcmd(modcmd_t cmd, void *arg)
{
	int bmajor = -1, cmajor = -1,  error = 0;
	
	switch (cmd) {
	case MODULE_CMD_INIT:
		error = config_cfdriver_attach(&vnd_cd);
		if (error)
			break;

		error = config_cfattach_attach(vnd_cd.cd_name, &vnd_ca);
	        if (error) {
			config_cfdriver_detach(&vnd_cd);
			aprint_error("%s: unable to register cfattach\n",
			    vnd_cd.cd_name);
			break;
		}
		
		error = devsw_attach("vnd", &vnd_bdevsw, &bmajor,
		    &vnd_cdevsw, &cmajor);
		if (error) {
			config_cfattach_detach(vnd_cd.cd_name, &vnd_ca);
			config_cfdriver_detach(&vnd_cd);
			break;
		}
		
		break;

	case MODULE_CMD_FINI:
		error = config_cfattach_detach(vnd_cd.cd_name, &vnd_ca);
		if (error)
			break;
		config_cfdriver_detach(&vnd_cd);
		devsw_detach(&vnd_bdevsw, &vnd_cdevsw);
		break;

	case MODULE_CMD_STAT:
		return ENOTTY;

	default:
		return ENOTTY;
	}

	return error;
}
Пример #5
0
/* Destroy routine */
static int
dmdestroy(void)
{
	int error;

	error = config_cfattach_detach(dm_cd.cd_name, &dm_ca);
	if (error)
		return error;
	
	dm_dev_destroy();
	dm_pdev_destroy();
	dm_target_destroy();

	return 0;
}
Пример #6
0
static int
tapdetach(void)
{
	int error = 0;

	if (tap_count != 0)
		return EBUSY;

#ifdef _MODULE
	if (error == 0)
		error = devsw_detach(NULL, &tap_cdevsw);
#endif
	if (error == 0)
		sysctl_teardown(&tap_sysctl_clog);
	if (error == 0)
		if_clone_detach(&tap_cloners);

	if (error == 0)
		error = config_cfattach_detach(tap_cd.cd_name, &tap_ca);

	return error;
}
Пример #7
0
static int
vnd_lkm(struct lkm_table *lkmtp, int cmd)
{
	int error = 0, i;
	device_t dev;

	if (cmd == LKM_E_LOAD) {
		error = config_cfdriver_attach(&vnd_cd);
		if (error) {
			aprint_error("%s: unable to register cfdriver\n",
			    vnd_cd.cd_name);
			return error;
		}
		
		vndattach(0);
	} else if (cmd == LKM_E_UNLOAD) {
		for (i = 0; i < vnd_cd.cd_ndevs; i++) {
			dev = device_lookup(&vnd_cd, i);
			if (dev != NULL &&
			    (error = vnd_destroy(dev)) != 0)
				return 0;
		}

		if ((error = config_cfattach_detach(vnd_cd.cd_name,
		    &vnd_ca)) != 0) {
			aprint_error("%s: unable to deregister cfattach\n",
			    vnd_cd.cd_name);
			return error;
		}

		if ((error = config_cfdriver_detach(&vnd_cd)) != 0) {
			aprint_error("%s: unable to deregister cfdriver\n",
			    vnd_cd.cd_name);
			return error;
		}
	}
	return (error);
}
Пример #8
0
static int
iscsi_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
	devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
	int error;
#endif

	switch (cmd) {
	case MODULE_CMD_INIT:
#ifdef _MODULE
		error = config_cfdriver_attach(&iscsi_cd);
		if (error) {
			return error;
		}

		error = config_cfattach_attach(iscsi_cd.cd_name, &iscsi_ca);
		if (error) {
			config_cfdriver_detach(&iscsi_cd);
			aprint_error("%s: unable to register cfattach\n",
				iscsi_cd.cd_name);
			return error;
		}

		error = config_cfdata_attach(iscsi_cfdata, 1);
		if (error) {
			aprint_error("%s: unable to attach cfdata\n",
				iscsi_cd.cd_name);
			config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca);
			config_cfdriver_detach(&iscsi_cd);
			return error;
		}

		error = devsw_attach(iscsi_cd.cd_name, NULL, &bmajor,
			&iscsi_cdevsw, &cmajor);
		if (error) {
			aprint_error("%s: unable to register devsw\n",
				iscsi_cd.cd_name);
			config_cfdata_detach(iscsi_cfdata);
			config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca);
			config_cfdriver_detach(&iscsi_cd);
			return error;
		}

		if (config_attach_pseudo(iscsi_cfdata) == NULL) {
			aprint_error("%s: config_attach_pseudo failed\n",
				iscsi_cd.cd_name);
			config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca);
			config_cfdriver_detach(&iscsi_cd);
			return ENXIO;
		}
#endif
		return 0;
		break;

	case MODULE_CMD_FINI:
#ifdef _MODULE
		error = config_cfdata_detach(iscsi_cfdata);
		if (error)
			return error;

		config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca);
		config_cfdriver_detach(&iscsi_cd);
		devsw_detach(NULL, &iscsi_cdevsw);
#endif
		return 0;
		break;

	case MODULE_CMD_AUTOUNLOAD:
		return EBUSY;
		break;

	default:
		return ENOTTY;
		break;
	}
}
Пример #9
0
/* New module handle routine */
static int
dm_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
	int error, bmajor, cmajor;

	error = 0;
	bmajor = -1;
	cmajor = -1;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = config_cfdriver_attach(&dm_cd);
		if (error)
			break;

		error = config_cfattach_attach(dm_cd.cd_name, &dm_ca);
		if (error) {
			aprint_error("%s: unable to register cfattach\n",
			    dm_cd.cd_name);
			return error;
		}

		error = devsw_attach(dm_cd.cd_name, &dm_bdevsw, &bmajor,
		    &dm_cdevsw, &cmajor);
		if (error == EEXIST)
			error = 0;
		if (error) {
			config_cfattach_detach(dm_cd.cd_name, &dm_ca);
			config_cfdriver_detach(&dm_cd);
			break;
		}

		dm_doinit();

		break;

	case MODULE_CMD_FINI:
		/*
		 * Disable unloading of dm module if there are any devices
		 * defined in driver. This is probably too strong we need
		 * to disable auto-unload only if there is mounted dm device
		 * present.
		 */ 
		if (dm_dev_counter > 0)
			return EBUSY;

		error = dmdestroy();
		if (error)
			break;

		config_cfdriver_detach(&dm_cd);

		devsw_detach(&dm_bdevsw, &dm_cdevsw);
		break;
	case MODULE_CMD_STAT:
		return ENOTTY;

	default:
		return ENOTTY;
	}

	return error;
#else
	return ENOTTY;
#endif
}