Unconfuse DEV_MODULE() and DEV_DRIVER_MODULE() about the difference between

a major number for a dev_t.
This commit is contained in:
Poul-Henning Kamp 1999-05-09 13:00:50 +00:00
parent e3a3d09cb9
commit 52400704e9
18 changed files with 52 additions and 39 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: zs_tlsb.c,v 1.9 1999/05/07 10:09:38 phk Exp $
* $Id: zs_tlsb.c,v 1.10 1999/05/08 21:58:54 dfr Exp $
*/
/*
* This driver is a hopeless hack to get the SimOS console working. A real
@ -375,7 +375,7 @@ zsdevtotty(dev_t dev)
}
DEV_DRIVER_MODULE(zs, zsc, zs_driver, zs_devclass,
CDEV_MAJOR, NODEV, zs_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, zs_cdevsw, 0, 0);
/*
* The zsc bus holds two zs devices, one for channel A, one for channel B.

View File

@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: psm.c,v 1.7 1999/05/08 21:59:29 dfr Exp $
* $Id: psm.c,v 1.8 1999/05/09 04:58:35 yokota Exp $
*/
/*
@ -2277,6 +2277,6 @@ psmresume(void *dummy)
#endif /* PSM_HOOKAPM */
DEV_DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass,
CDEV_MAJOR, NODEV, psm_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, psm_cdevsw, 0, 0);
#endif /* NPSM > 0 */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: iic.c,v 1.8 1999/05/07 10:09:46 phk Exp $
* $Id: iic.c,v 1.9 1999/05/08 21:59:03 dfr Exp $
*
*/
#include <sys/param.h>
@ -277,6 +277,6 @@ iic_drvinit(void *unused)
}
DEV_DRIVER_MODULE(iic, iicbus, iic_driver, iic_devclass, CDEV_MAJOR,
NODEV, iic_cdevsw, 0, 0);
NOMAJ, iic_cdevsw, 0, 0);
SYSINIT(iicdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,iic_drvinit,NULL)

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.235 1999/05/09 10:28:50 phk Exp $
* $Id: sio.c,v 1.236 1999/05/09 10:51:13 phk Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.234
*/
@ -3176,4 +3176,4 @@ siopnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
#endif
DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass,
CDEV_MAJOR, NODEV, sio_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, sio_cdevsw, 0, 0);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: smb.c,v 1.9 1999/05/07 10:09:50 phk Exp $
* $Id: smb.c,v 1.10 1999/05/08 21:59:08 dfr Exp $
*
*/
#include <sys/param.h>
@ -269,7 +269,7 @@ smb_drvinit(void *unused)
}
}
DEV_DRIVER_MODULE(smb, smbus, smb_driver, smb_devclass, CDEV_MAJOR, NODEV,
DEV_DRIVER_MODULE(smb, smbus, smb_driver, smb_devclass, CDEV_MAJOR, NOMAJ,
smb_cdevsw, 0, 0);
SYSINIT(smbdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,smb_drvinit,NULL)

View File

@ -998,5 +998,5 @@ ugen_detach(device_t self)
}
DEV_DRIVER_MODULE(ugen, uhub, ugen_driver, ugen_devclass,
UGEN_CDEV_MAJOR, NODEV, ugen_cdevsw, usbd_driver_load, 0);
UGEN_CDEV_MAJOR, NOMAJ, ugen_cdevsw, usbd_driver_load, 0);
#endif

View File

@ -443,5 +443,5 @@ ulpt_detach(device_t self)
}
DEV_DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass,
ULPT_CDEV_MAJOR, NODEV, ulpt_cdevsw, usbd_driver_load, 0);
ULPT_CDEV_MAJOR, NOMAJ, ulpt_cdevsw, usbd_driver_load, 0);
#endif

View File

@ -796,5 +796,5 @@ ums_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
#if defined(__FreeBSD__)
DEV_DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass,
UMS_CDEV_MAJOR, NODEV, ums_cdevsw, usbd_driver_load, 0);
UMS_CDEV_MAJOR, NOMAJ, ums_cdevsw, usbd_driver_load, 0);
#endif

View File

@ -15,7 +15,7 @@
*
* Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
*
* $Id: apm.c,v 1.83 1999/05/08 21:59:13 dfr Exp $
* $Id: apm.c,v 1.84 1999/05/09 04:58:13 yokota Exp $
*/
#include "opt_devfs.h"
@ -1065,4 +1065,4 @@ static driver_t apm_driver = {
static devclass_t apm_devclass;
DEV_DRIVER_MODULE(apm, nexus, apm_driver, apm_devclass,
CDEV_MAJOR, NODEV, apm_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, apm_cdevsw, 0, 0);

View File

@ -15,7 +15,7 @@
*
* Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
*
* $Id: apm.c,v 1.83 1999/05/08 21:59:13 dfr Exp $
* $Id: apm.c,v 1.84 1999/05/09 04:58:13 yokota Exp $
*/
#include "opt_devfs.h"
@ -1065,4 +1065,4 @@ static driver_t apm_driver = {
static devclass_t apm_devclass;
DEV_DRIVER_MODULE(apm, nexus, apm_driver, apm_devclass,
CDEV_MAJOR, NODEV, apm_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, apm_cdevsw, 0, 0);

View File

@ -20,7 +20,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: psm.c,v 1.7 1999/05/08 21:59:29 dfr Exp $
* $Id: psm.c,v 1.8 1999/05/09 04:58:35 yokota Exp $
*/
/*
@ -2277,6 +2277,6 @@ psmresume(void *dummy)
#endif /* PSM_HOOKAPM */
DEV_DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass,
CDEV_MAJOR, NODEV, psm_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, psm_cdevsw, 0, 0);
#endif /* NPSM > 0 */

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.235 1999/05/09 10:28:50 phk Exp $
* $Id: sio.c,v 1.236 1999/05/09 10:51:13 phk Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.234
*/
@ -3176,4 +3176,4 @@ siopnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
#endif
DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass,
CDEV_MAJOR, NODEV, sio_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, sio_cdevsw, 0, 0);

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.34 1999/05/09 08:10:17 peter Exp $
* $Id: kern_conf.c,v 1.35 1999/05/09 08:18:12 phk Exp $
*/
#include <sys/param.h>
@ -123,12 +123,21 @@ devsw_module_handler(module_t mod, int what, void* arg)
struct devsw_module_data* data = (struct devsw_module_data*) arg;
int error;
if (data->cmaj == NOMAJ)
data->cdev = NODEV;
else
data->cdev = makedev(data->cmaj, 0);
switch (what) {
case MOD_LOAD:
error = cdevsw_add(&data->cdev, data->cdevsw, NULL);
if (!error && data->cdevsw->d_strategy != nostrategy) {
if (data->bdev == NODEV)
if (data->bmaj == NOMAJ) {
data->bdev = data->cdev;
data->bmaj = data->cmaj;
} else {
data->bdev = makedev(data->bmaj, 0);
}
data->cdevsw->d_maj = data->bmaj;
bmaj2cmaj[major(data->bdev)] = major(data->cdev);
}
if (!error && data->chainevh)

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.91 1999/05/07 10:11:17 phk Exp $
* $Id: sio.c,v 1.92 1999/05/09 05:00:54 kato Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.234
*/
@ -4477,7 +4477,7 @@ siopnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
#endif
DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass,
CDEV_MAJOR, NODEV, sio_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, sio_cdevsw, 0, 0);
#ifdef PC98
/*

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.91 1999/05/07 10:11:17 phk Exp $
* $Id: sio.c,v 1.92 1999/05/09 05:00:54 kato Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.234
*/
@ -4477,7 +4477,7 @@ siopnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
#endif
DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass,
CDEV_MAJOR, NODEV, sio_cdevsw, 0, 0);
CDEV_MAJOR, NOMAJ, sio_cdevsw, 0, 0);
#ifdef PC98
/*

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bus.h,v 1.13 1999/05/08 18:07:37 peter Exp $
* $Id: bus.h,v 1.14 1999/05/08 21:59:43 dfr Exp $
*/
#ifndef _SYS_BUS_H_
@ -283,7 +283,7 @@ DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \
cmajor, bmajor, devsw, evh, arg) \
\
static struct devsw_module_data name##_##busname##_devsw_mod = { \
evh, arg, makedev(bmajor, 0), makedev(cmajor, 0), &devsw \
evh, arg, bmajor, cmajor, &devsw \
}; \
\
DRIVER_MODULE(name, busname, driver, devclass, \

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.52 1999/05/08 06:40:12 phk Exp $
* $Id: conf.h,v 1.53 1999/05/09 08:58:44 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -228,15 +228,17 @@ struct module;
struct devsw_module_data {
int (*chainevh)(struct module *, int, void *); /* next handler */
void *chainarg; /* arg for next event handler */
dev_t bdev; /* device major to use */
dev_t cdev; /* device major to use */
int bmaj; /* device major to use */
int cmaj; /* device major to use */
struct cdevsw *cdevsw; /* device functions */
/* Do not initialize fields hereafter */
dev_t bdev;
dev_t cdev;
};
#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg) \
static struct devsw_module_data name##_devsw_mod = { \
evh, arg, bmaj == NOMAJ ? NODEV : makedev(bmaj, 0), \
cmaj == NOMAJ ? NODEV : makedev(cmaj, 0), &devsw \
evh, arg, bmaj, cmaj, &devsw \
}; \
\
static moduledata_t name##_mod = { \

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.52 1999/05/08 06:40:12 phk Exp $
* $Id: conf.h,v 1.53 1999/05/09 08:58:44 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -228,15 +228,17 @@ struct module;
struct devsw_module_data {
int (*chainevh)(struct module *, int, void *); /* next handler */
void *chainarg; /* arg for next event handler */
dev_t bdev; /* device major to use */
dev_t cdev; /* device major to use */
int bmaj; /* device major to use */
int cmaj; /* device major to use */
struct cdevsw *cdevsw; /* device functions */
/* Do not initialize fields hereafter */
dev_t bdev;
dev_t cdev;
};
#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg) \
static struct devsw_module_data name##_devsw_mod = { \
evh, arg, bmaj == NOMAJ ? NODEV : makedev(bmaj, 0), \
cmaj == NOMAJ ? NODEV : makedev(cmaj, 0), &devsw \
evh, arg, bmaj, cmaj, &devsw \
}; \
\
static moduledata_t name##_mod = { \