Add function cdevsw_remove, the opposite of cdevsw_add: remove an

entry in cdevsw (and bdevsw if appropriate).

Reviewed-by: phk
This commit is contained in:
Greg Lehey 1999-06-25 07:49:01 +00:00
parent 0b60724004
commit 9a9eb2b92b
3 changed files with 26 additions and 3 deletions

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_conf.c,v 1.42 1999/06/01 18:56:24 phk Exp $
* $Id: kern_conf.c,v 1.43 1999/06/01 20:41:26 dt Exp $
*/
#include <sys/param.h>
@ -120,6 +120,27 @@ cdevsw_add(struct cdevsw *newentry)
return 0;
}
/*
* Remove a cdevsw entry
*/
int
cdevsw_remove(struct cdevsw *oldentry)
{
if (oldentry->d_maj < 0 || oldentry->d_maj >= NUMCDEVSW) {
printf("%s: ERROR: driver has bogus cdevsw->d_maj = %d\n",
oldentry->d_name, oldentry->d_maj);
return EINVAL;
}
cdevsw[oldentry->d_maj] = NULL;
if (oldentry->d_bmaj >= 0 && oldentry->d_bmaj < NUMCDEVSW)
bmaj2cmaj[oldentry->d_bmaj] = NULL;
return 0;
}
int
devsw_module_handler(module_t mod, int what, void* arg)
{

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.58 1999/05/31 11:29:08 phk Exp $
* $Id: conf.h,v 1.59 1999/06/01 18:56:26 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -221,6 +221,7 @@ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj)
struct cdevsw *bdevsw __P((dev_t dev));
int cdevsw_add __P((struct cdevsw *new));
int cdevsw_remove __P((struct cdevsw *old));
dev_t chrtoblk __P((dev_t dev));
struct cdevsw *devsw __P((dev_t dev));
int devsw_module_handler __P((struct module *mod, int what, void *arg));

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.58 1999/05/31 11:29:08 phk Exp $
* $Id: conf.h,v 1.59 1999/06/01 18:56:26 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -221,6 +221,7 @@ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj)
struct cdevsw *bdevsw __P((dev_t dev));
int cdevsw_add __P((struct cdevsw *new));
int cdevsw_remove __P((struct cdevsw *old));
dev_t chrtoblk __P((dev_t dev));
struct cdevsw *devsw __P((dev_t dev));
int devsw_module_handler __P((struct module *mod, int what, void *arg));