@@ -201,10 +201,7 @@ com_detach(struct device *self, int flags)
201201
202202 sc -> sc_swflags |= COM_SW_DEAD ;
203203
204- /* Locate the major number. */
205- for (maj = 0 ; maj < nchrdev ; maj ++ )
206- if (cdevsw [maj ].d_open == comopen )
207- break ;
204+ maj = findchrmajor (comopen );
208205
209206 /* Nuke the vnodes for any open instances. */
210207 mn = self -> dv_unit ;
@@ -1422,10 +1419,7 @@ comcnprobe(struct consdev *cp)
14221419 if (!found )
14231420 return ;
14241421
1425- /* Locate the major number. */
1426- for (commajor = 0 ; commajor < nchrdev ; commajor ++ )
1427- if (cdevsw [commajor ].d_open == comopen )
1428- break ;
1422+ commajor = findchrmajor (comopen );
14291423
14301424 /* Initialize required fields. */
14311425 cp -> cn_dev = makedev (commajor , comconsunit );
@@ -1807,12 +1801,9 @@ com_attach_subr(struct com_softc *sc)
18071801 if (ISSET (sc -> sc_hwflags , COM_HW_CONSOLE )) {
18081802 int maj ;
18091803
1810- /* locate the major number */
1811- for (maj = 0 ; maj < nchrdev ; maj ++ )
1812- if (cdevsw [maj ].d_open == comopen )
1813- break ;
1804+ maj = findchrmajor (comopen );
18141805
1815- if (maj < nchrdev && cn_tab -> cn_dev == NODEV )
1806+ if (maj != -1 && cn_tab -> cn_dev == NODEV )
18161807 cn_tab -> cn_dev = makedev (maj , sc -> sc_dev .dv_unit );
18171808
18181809 printf ("%s: console\n" , sc -> sc_dev .dv_xname );
0 commit comments