question on cdevsw_add mask/match
chuck_tuffli at agilent.com
Tue Mar 22 17:16:54 PST 2005
Matthew Dillon wrote:
Well, psm generates a mask other then -1 because it needs to break
the minor device space down for multiple devices per unit, whereas
e.g. agp/agp.c only needs one unit so the match mask can be -1 (match
all bits against the specified unit number). -1 is the most restrictive
mask that can be used, the unit number must *exactly* match the minor
device number for the system to recognize the (major,minor) as belonging
to the device.
Thanks for the great explanation - this is starting to make sense.
By specifying -1, isn't destroy_all_dev() (kern_conf.c:354) matching
against both the major and minor/unit numbers? It looks like
dev->si_udev is (major number << 8) | minor number (via makeudev()
kern_conf.c:216). match is the minor/unit number which gets compared
against all of si_udev because mask is 0xffffffff. Thus the conditional
on line 366 will never be equal because the mask includes the major
number in the comparison.
The question is how to specify mask/match for drivers wanting
/dev/driver%d like devices. If I'm understanding this, two possible
approaches would be
1) continue to use the unit number for match but set mask to 0xff
2) continue to use -1 for the mask but make the match value be a
shift/OR or the major and unit numbers
Is one of these preferable to the other or is there something else that
needs to be taken into account? Both options make an assumption about
the underlying representation, but maybe that's ok.
More information about the Kernel