Re: question on cdevsw_add mask/match

看板DFBSD_kernel作者時間21年前 (2005/03/23 09:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/6 (看更多)
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. Matt - 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. -- Chuck Tuffli Agilent Technologies
文章代碼(AID): #12GCSU00 (DFBSD_kernel)
文章代碼(AID): #12GCSU00 (DFBSD_kernel)