git: 0b377a49fa59 - main - FB_INSTALL_CDEV: Remove this option and related code.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 21 Apr 2022 17:30:17 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=0b377a49fa59ddf63a45c9434c447d25f4f3a354

commit 0b377a49fa59ddf63a45c9434c447d25f4f3a354
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-21 17:29:14 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-04-21 17:29:14 +0000

    FB_INSTALL_CDEV: Remove this option and related code.
    
    This option was never enabled in GENERIC and does not appear to work
    (the cdevsw is stored in a global array but never passed to make_dev
    to be associated with a character device).
    
    Reviewed by:    emaste
    Differential Revision:  https://reviews.freebsd.org/D35008
---
 sys/amd64/conf/NOTES |   2 -
 sys/conf/options     |   1 -
 sys/dev/fb/fb.c      | 243 ---------------------------------------------------
 sys/dev/fb/fbreg.h   |  31 -------
 sys/dev/fb/vga.c     |  49 -----------
 sys/dev/fb/vgareg.h  |  16 ----
 sys/i386/conf/NOTES  |   2 -
 sys/isa/vga_isa.c    |  75 ----------------
 8 files changed, 419 deletions(-)

diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 5e486978781d..7ee1b45e6ba6 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -639,8 +639,6 @@ options 	PV_STATS
 # More undocumented options for linting.
 # Note that documenting these are not considered an affront.
 
-options 	FB_INSTALL_CDEV		# install a CDEV entry in /dev
-
 options 	KBDIO_DEBUG=2
 options 	KBD_MAXRETRY=4
 options 	KBD_MAXWAIT=6
diff --git a/sys/conf/options b/sys/conf/options
index 0c10801637c2..fda513ee484a 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -586,7 +586,6 @@ IFMEDIA_DEBUG		opt_ifmedia.h
 
 # Fb options
 FB_DEBUG		opt_fb.h
-FB_INSTALL_CDEV		opt_fb.h
 
 # ppbus related options
 PERIPH_1284		opt_ppb_1284.h
diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c
index 95b7a30391cf..5c8e354290be 100644
--- a/sys/dev/fb/fb.c
+++ b/sys/dev/fb/fb.c
@@ -66,11 +66,6 @@ static video_adapter_t	**adapter = &adp_ini;
 static video_switch_t	*vidsw_ini;
        video_switch_t	**vidsw = &vidsw_ini;
 
-#ifdef FB_INSTALL_CDEV
-static struct cdevsw	*vidcdevsw_ini;
-static struct cdevsw	**vidcdevsw = &vidcdevsw_ini;
-#endif
-
 #define ARRAY_DELTA	4
 
 static int
@@ -78,9 +73,6 @@ vid_realloc_array(void)
 {
 	video_adapter_t **new_adp;
 	video_switch_t **new_vidsw;
-#ifdef FB_INSTALL_CDEV
-	struct cdevsw **new_cdevsw;
-#endif
 	int newsize;
 	int s;
 
@@ -92,27 +84,14 @@ vid_realloc_array(void)
 	new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK | M_ZERO);
 	new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF,
 	    M_WAITOK | M_ZERO);
-#ifdef FB_INSTALL_CDEV
-	new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF,
-	    M_WAITOK | M_ZERO);
-#endif
 	bcopy(adapter, new_adp, sizeof(*adapter)*adapters);
 	bcopy(vidsw, new_vidsw, sizeof(*vidsw)*adapters);
-#ifdef FB_INSTALL_CDEV
-	bcopy(vidcdevsw, new_cdevsw, sizeof(*vidcdevsw)*adapters);
-#endif
 	if (adapters > 1) {
 		free(adapter, M_DEVBUF);
 		free(vidsw, M_DEVBUF);
-#ifdef FB_INSTALL_CDEV
-		free(vidcdevsw, M_DEVBUF);
-#endif
 	}
 	adapter = new_adp;
 	vidsw = new_vidsw;
-#ifdef FB_INSTALL_CDEV
-	vidcdevsw = new_cdevsw;
-#endif
 	adapters = newsize;
 	splx(s);
 
@@ -296,230 +275,8 @@ vid_configure(int flags)
 	return 0;
 }
 
-/*
- * Virtual frame buffer cdev driver functions
- * The virtual frame buffer driver dispatches driver functions to
- * appropriate subdrivers.
- */
-
 #define FB_DRIVER_NAME	"fb"
 
-#ifdef FB_INSTALL_CDEV
-
-#if 0 /* experimental */
-
-static devclass_t	fb_devclass;
-
-static int		fbprobe(device_t dev);
-static int		fbattach(device_t dev);
-
-static device_method_t fb_methods[] = {
-	DEVMETHOD(device_probe,		fbprobe),
-	DEVMETHOD(device_attach,	fbattach),
-
-	DEVMETHOD_END
-};
-
-static driver_t fb_driver = {
-	FB_DRIVER_NAME,
-	fb_methods,
-	0,
-};
-
-static int
-fbprobe(device_t dev)
-{
-	int unit;
-
-	unit = device_get_unit(dev);
-	if (unit >= adapters)
-		return ENXIO;
-	if (adapter[unit] == NULL)
-		return ENXIO;
-
-	device_set_desc(dev, "generic frame buffer");
-	return 0;
-}
-
-static int
-fbattach(device_t dev)
-{
-	printf("fbattach: about to attach children\n");
-	bus_generic_attach(dev);
-	return 0;
-}
-
-#endif
-
-#define FB_UNIT(dev)	dev2unit(dev)
-#define FB_MKMINOR(unit) (u)
-
-#if 0 /* experimental */
-static d_open_t		fbopen;
-static d_close_t	fbclose;
-static d_read_t		fbread;
-static d_write_t	fbwrite;
-static d_ioctl_t	fbioctl;
-static d_mmap_t		fbmmap;
-
-
-static struct cdevsw fb_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	fbopen,
-	.d_close =	fbclose,
-	.d_read =	fbread,
-	.d_write =	fbwrite,
-	.d_ioctl =	fbioctl,
-	.d_mmap =	fbmmap,
-	.d_name =	FB_DRIVER_NAME,
-};
-#endif
-
-
-static int
-fb_modevent(module_t mod, int type, void *data) 
-{ 
-
-	switch (type) { 
-	case MOD_LOAD: 
-		break; 
-	case MOD_UNLOAD: 
-		printf("fb module unload - not possible for this module type\n"); 
-		return EINVAL; 
-	default:
-		return EOPNOTSUPP;
-	} 
-	return 0; 
-} 
-
-static moduledata_t fb_mod = { 
-	"fb", 
-	fb_modevent, 
-	NULL
-}; 
-
-DECLARE_MODULE(fb, fb_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
-
-int
-fb_attach(int unit, video_adapter_t *adp, struct cdevsw *cdevsw)
-{
-	int s;
-
-	if (adp->va_index >= adapters)
-		return EINVAL;
-	if (adapter[adp->va_index] != adp)
-		return EINVAL;
-
-	s = spltty();
-	adp->va_minor = unit;
-	vidcdevsw[adp->va_index] = cdevsw;
-	splx(s);
-
-	printf("fb%d at %s%d\n", adp->va_index, adp->va_name, adp->va_unit);
-	return 0;
-}
-
-int
-fb_detach(int unit, video_adapter_t *adp, struct cdevsw *cdevsw)
-{
-	int s;
-
-	if (adp->va_index >= adapters)
-		return EINVAL;
-	if (adapter[adp->va_index] != adp)
-		return EINVAL;
-	if (vidcdevsw[adp->va_index] != cdevsw)
-		return EINVAL;
-
-	s = spltty();
-	vidcdevsw[adp->va_index] = NULL;
-	splx(s);
-	return 0;
-}
-
-/*
- * Generic frame buffer cdev driver functions
- * Frame buffer subdrivers may call these functions to implement common
- * driver functions.
- */
-
-int genfbopen(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
-	      struct thread *td)
-{
-	int s;
-
-	s = spltty();
-	if (!(sc->gfb_flags & FB_OPEN))
-		sc->gfb_flags |= FB_OPEN;
-	splx(s);
-	return 0;
-}
-
-int genfbclose(genfb_softc_t *sc, video_adapter_t *adp, int flag, int mode,
-	       struct thread *td)
-{
-	int s;
-
-	s = spltty();
-	sc->gfb_flags &= ~FB_OPEN;
-	splx(s);
-	return 0;
-}
-
-int genfbread(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
-	      int flag)
-{
-	int size;
-	int offset;
-	int error;
-	int len;
-
-	error = 0;
-	size = adp->va_buffer_size/adp->va_info.vi_planes;
-	while (uio->uio_resid > 0) {
-		if (uio->uio_offset >= size)
-			break;
-		offset = uio->uio_offset%adp->va_window_size;
-		len = imin(uio->uio_resid, size - uio->uio_offset);
-		len = imin(len, adp->va_window_size - offset);
-		if (len <= 0)
-			break;
-		vidd_set_win_org(adp, uio->uio_offset);
-		error = uiomove((caddr_t)(adp->va_window + offset), len, uio);
-		if (error)
-			break;
-	}
-	return error;
-}
-
-int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp, struct uio *uio,
-	       int flag)
-{
-	return ENODEV;
-}
-
-int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd,
-	       caddr_t arg, int flag, struct thread *td)
-{
-	int error;
-
-	if (adp == NULL)	/* XXX */
-		return ENXIO;
-	error = vidd_ioctl(adp, cmd, arg);
-	if (error == ENOIOCTL)
-		error = ENODEV;
-	return error;
-}
-
-int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_ooffset_t offset,
-	      vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
-{
-	return vidd_mmap(adp, offset, paddr, prot, memattr);
-}
-
-#endif /* FB_INSTALL_CDEV */
-
 static char
 *adapter_name(int type)
 {
diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h
index 7637f06a86b4..944243d4e687 100644
--- a/sys/dev/fb/fbreg.h
+++ b/sys/dev/fb/fbreg.h
@@ -294,37 +294,6 @@ video_adapter_t	*vid_get_adapter(int index);
 int		vid_configure(int flags);
 #define VIO_PROBE_ONLY	(1 << 0)	/* probe only, don't initialize */
 
-#ifdef FB_INSTALL_CDEV
-
-/* virtual frame buffer driver functions */
-int		fb_attach(int unit, video_adapter_t *adp,
-			  struct cdevsw *cdevsw);
-int		fb_detach(int unit, video_adapter_t *adp,
-			  struct cdevsw *cdevsw);
-
-/* generic frame buffer cdev driver functions */
-
-typedef struct genfb_softc {
-	int		gfb_flags;	/* flag/status bits */
-#define FB_OPEN		(1 << 0)
-} genfb_softc_t;
-
-int		genfbopen(genfb_softc_t *sc, video_adapter_t *adp,
-			  int flag, int mode, struct thread *td);
-int		genfbclose(genfb_softc_t *sc, video_adapter_t *adp,
-			   int flag, int mode, struct thread *td);
-int		genfbread(genfb_softc_t *sc, video_adapter_t *adp,
-			  struct uio *uio, int flag);
-int		genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
-			   struct uio *uio, int flag);
-int		genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
-			   u_long cmd, caddr_t arg, int flag, struct thread *td);
-int		genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
-			  vm_ooffset_t offset, vm_paddr_t *paddr,
-			  int prot, vm_memattr_t *memattr);
-
-#endif /* FB_INSTALL_CDEV */
-
 /* generic low-level driver functions */
 
 void		fb_dump_adp_info(char *driver, video_adapter_t *adp, int level);
diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c
index 88ce75b922e1..d8fc19369ea7 100644
--- a/sys/dev/fb/vga.c
+++ b/sys/dev/fb/vga.c
@@ -105,55 +105,6 @@ vga_attach_unit(int unit, vga_softc_t *sc, int flags)
 	return (*sw->init)(unit, sc->adp, flags);
 }
 
-/* cdev driver functions */
-
-#ifdef FB_INSTALL_CDEV
-
-int
-vga_open(struct cdev *dev, vga_softc_t *sc, int flag, int mode, struct thread *td)
-{
-	if (sc == NULL)
-		return ENXIO;
-	if (mode & (O_CREAT | O_APPEND | O_TRUNC))
-		return ENODEV;
-
-	return genfbopen(&sc->gensc, sc->adp, flag, mode, td);
-}
-
-int
-vga_close(struct cdev *dev, vga_softc_t *sc, int flag, int mode, struct thread *td)
-{
-	return genfbclose(&sc->gensc, sc->adp, flag, mode, td);
-}
-
-int
-vga_read(struct cdev *dev, vga_softc_t *sc, struct uio *uio, int flag)
-{
-	return genfbread(&sc->gensc, sc->adp, uio, flag);
-}
-
-int
-vga_write(struct cdev *dev, vga_softc_t *sc, struct uio *uio, int flag)
-{
-	return genfbread(&sc->gensc, sc->adp, uio, flag);
-}
-
-int
-vga_ioctl(struct cdev *dev, vga_softc_t *sc, u_long cmd, caddr_t arg, int flag,
-	  struct thread *td)
-{
-	return genfbioctl(&sc->gensc, sc->adp, cmd, arg, flag, td);
-}
-
-int
-vga_mmap(struct cdev *dev, vga_softc_t *sc, vm_ooffset_t offset,
-    vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
-{
-	return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot, memattr);
-}
-
-#endif /* FB_INSTALL_CDEV */
-
 /* LOW-LEVEL */
 
 #include <isa/rtc.h>
diff --git a/sys/dev/fb/vgareg.h b/sys/dev/fb/vgareg.h
index b2c148a4dd3b..370888e6d167 100644
--- a/sys/dev/fb/vgareg.h
+++ b/sys/dev/fb/vgareg.h
@@ -73,27 +73,11 @@ typedef struct vga_softc {
 	struct video_adapter	*adp;
 	void			*state_buf;
 	void			*pal_buf;
-#ifdef FB_INSTALL_CDEV
-	genfb_softc_t		gensc;
-#endif
 } vga_softc_t;
 
 int		vga_probe_unit(int unit, struct video_adapter *adp, int flags);
 int		vga_attach_unit(int unit, vga_softc_t *sc, int flags);
 
-#ifdef FB_INSTALL_CDEV
-int		vga_open(struct cdev *dev, vga_softc_t *sc, int flag, int mode,
-			 struct thread *td);
-int		vga_close(struct cdev *dev, vga_softc_t *sc, int flag, int mode,
-			  struct thread *td);
-int		vga_read(struct cdev *dev, vga_softc_t *sc, struct uio *uio, int flag);
-int		vga_write(struct cdev *dev, vga_softc_t *sc, struct uio *uio, int flag);
-int		vga_ioctl(struct cdev *dev, vga_softc_t *sc, u_long cmd, caddr_t arg,
-			  int flag, struct thread *td);
-int		vga_mmap(struct cdev *dev, vga_softc_t *sc, vm_ooffset_t offset,
-			 vm_paddr_t *paddr, int prot, vm_memattr_t *memattr);
-#endif
-
 extern int	(*vga_sub_configure)(int flags);
 
 #endif /* _KERNEL */
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index 1cf8a34a8ebc..42aafcecd97b 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -877,8 +877,6 @@ options 	PV_STATS
 # More undocumented options for linting.
 # Note that documenting these are not considered an affront.
 
-options 	FB_INSTALL_CDEV		# install a CDEV entry in /dev
-
 options 	KBDIO_DEBUG=2
 options 	KBD_MAXRETRY=4
 options 	KBD_MAXWAIT=6
diff --git a/sys/isa/vga_isa.c b/sys/isa/vga_isa.c
index 0d1f042fa78f..b5660a1f70d3 100644
--- a/sys/isa/vga_isa.c
+++ b/sys/isa/vga_isa.c
@@ -131,34 +131,8 @@ vga_resume(device_t dev)
 	}
 }
 
-#define VGA_SOFTC(unit)		\
-	((vga_softc_t *)devclass_get_softc(isavga_devclass, unit))
-
 static devclass_t	isavga_devclass;
 
-#ifdef FB_INSTALL_CDEV
-
-static d_open_t		isavga_open;
-static d_close_t	isavga_close;
-static d_read_t		isavga_read;
-static d_write_t	isavga_write;
-static d_ioctl_t	isavga_ioctl;
-static d_mmap_t		isavga_mmap;
-
-static struct cdevsw isavga_cdevsw = {
-	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
-	.d_open =	isavga_open,
-	.d_close =	isavga_close,
-	.d_read =	isavga_read,
-	.d_write =	isavga_write,
-	.d_ioctl =	isavga_ioctl,
-	.d_mmap =	isavga_mmap,
-	.d_name =	VGA_DRIVER_NAME,
-};
-
-#endif /* FB_INSTALL_CDEV */
-
 static void
 isavga_identify(driver_t *driver, device_t parent)
 {
@@ -216,13 +190,6 @@ isavga_attach(device_t dev)
 	if (error)
 		return (error);
 
-#ifdef FB_INSTALL_CDEV
-	/* attach a virtual frame buffer device */
-	error = fb_attach(VGA_MKMINOR(unit), sc->adp, &isavga_cdevsw);
-	if (error)
-		return (error);
-#endif /* FB_INSTALL_CDEV */
-
 	if (0 && bootverbose)
 		vidd_diag(sc->adp, bootverbose);
 
@@ -256,48 +223,6 @@ isavga_resume(device_t dev)
 	return (bus_generic_resume(dev));
 }
 
-#ifdef FB_INSTALL_CDEV
-
-static int
-isavga_open(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	return (vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td));
-}
-
-static int
-isavga_close(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	return (vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td));
-}
-
-static int
-isavga_read(struct cdev *dev, struct uio *uio, int flag)
-{
-	return (vga_read(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag));
-}
-
-static int
-isavga_write(struct cdev *dev, struct uio *uio, int flag)
-{
-	return (vga_write(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag));
-}
-
-static int
-isavga_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
-{
-	return (vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, td));
-}
-
-static int
-isavga_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
-    int prot, vm_memattr_t *memattr)
-{
-	return (vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, paddr, prot,
-	    memattr));
-}
-
-#endif /* FB_INSTALL_CDEV */
-
 static device_method_t isavga_methods[] = {
 	DEVMETHOD(device_identify,	isavga_identify),
 	DEVMETHOD(device_probe,		isavga_probe),