This is my variation of D4067.
Details
Watched the /dev/cuau0{,.init.,lock} states.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Hi,
Do you plan to add convenience wrappers/macros for the most common make device calls?
--HPS
I did not thought that something is needed. Do you mean some facility similar to your MAKE_DEV_ARGS() macro ?
I think we should settle on either this diff, or D4067 first, and then do some initial conversion of around 10 make_dev() consumers to see whether inline initialization of the structure is so big pain. In fact, if we select this rev, I volunteer to do the convertion of any ten drivers you list, as a start.
I did not thought that something is needed. Do you mean some facility similar to your MAKE_DEV_ARGS() macro ?
I think we should settle on either this diff, or D4067 first, and then do some initial conversion of around 10 make_dev() consumers to see whether inline initialization of the structure is so big pain. In fact, if we select this rev, I volunteer to do the convertion of any ten drivers you list, as a start.
Hi,
I'm fine with both. I think your version solves the problem just as much as mine.
--HPS
sys/kern/kern_conf.c | ||
---|---|---|
843 | How about making this function and other convenience wrappers static inline? |
So what drivers to convert first ?
sys/kern/kern_conf.c | ||
---|---|---|
843 | I want to keep the KBI for drivers both (a) compact (b) controlled. Making the wrappers inline means that e.g. make_dev_sv() is exposed by KBI while not used by the drivers directly. This contradicts both goals. If the planned converion to use make_dev_s() went uneventful, I want to remove all other compat functions for 12. |
So what drivers to convert first ?
All make_dev's in "sys/dev/usb" ?
sys/kern/kern_conf.c | ||
---|---|---|
843 | OK |
So what drivers to convert first ?
Possibly also TTY's makedev, and cleanup the sleep/wakeup cruft with regard to the waiting for si_drv2.
In general I think this looks good. The cleanup of the tty drivers is nice.
share/man/man9/make_dev.9 | ||
---|---|---|
76 | So make_dev_alias() is legacy because make_dev_alias_p() should be used instead? It is not somehow implemented via make_dev_s()? | |
113 | Nit: s/that the/that/ | |
114 | Stray apostrophe after driver here? | |
230 | This section is good, but I think you need to add a note of how make_dev_credf() is implemented. Ideally only one of make_dev_p() or make_dev_credf() would need a full example using the args, but right now make_dev_cred() and make_dev() are defined in terms of make_dev_credf() and it isn't clear that make_dev_credf() is a wrapper for make_dev_s(). | |
324 | s/later/latter/ I would also say "the driver should handle" instead of "driver should handle" | |
417 | Maybe list both functions here since the return values of other legacy routines are also described, so: If successful, .Fn make_dev_p and .Fn make_dev_s will return 0, otherwise they will return an error. Other manpages that deal with legacy wrapper interfaces still enumerate all of the wrappers when describing return values (wait(2) is one example that comes to mind). | |
sys/cam/scsi/scsi_pass.c | ||
552 | Bruce would sort 'error' before 'no_tags' I think? | |
674 | Does this leak a reference on the periph in the old code? | |
sys/kern/kern_conf.c | ||
843 | You could perhaps use wrapper macros instead of static inlines if you really wanted. This would avoid exposing make_dev_sv(). I don't think you need/want to do this though, and since the old KBI has these as functions you want to keep them as functions for now. Presumably the current version is something we can MFC to older branches since it just expands the API which is nice for permitting drivers to be portable across branches. |
share/man/man9/make_dev.9 | ||
---|---|---|
76 | Both make_dev_alias() and make_dev_alias_p() are implemented by make_dev_alias_v(). The KPI is getting out of control, and I want to trim it. The aliases are not created with make_dev_s(). | |
sys/cam/scsi/scsi_pass.c | ||
552 | Bruce would never touch computer keyboard after looking at the scsi_pass.c, I think. | |
674 | I do not quite follow the question. The code acquires a ref for each object which gives a handle to the periph. Old code does not suppose that make_dev(9) could fail, and unconditionally moved further. Since make_dev_s() can legitimately fail, I drop the reference for cdev, but do not touch other references. If the acquire of the reference for alias failed, then I assumed that a reference for successfully created cdev must stay, this is how both old and new code are structured. Did you mean something else, perhaps ? | |
sys/kern/kern_conf.c | ||
843 | I do not expose make_dev_sv(). Yes, the whole patch is MFCable. Some day I want to finish convertion, this probably must be done before 11 is branched. In 12- time, I may consider removing all functions I declared legacy. |
Update manpage according to Johm' comments. Reorder locals declarations in passregister().
sys/cam/scsi/scsi_pass.c | ||
---|---|---|
674 | I had missed that the old code wasn't checking for failure but assumed success. | |
sys/kern/kern_conf.c | ||
843 | Re: exposing make_dev_sv() I meant you could use wrapper macros without exposing it, something like: #define make_dev(....) ({ \ struct cdev *__dev; \ \ /* initialize args and call make_dev_s() using __VA_ARGS__ for format name */ \ __dev; }) This would provide the old API without exposing make_dev_sv(). However, I think using function wrappers as you do is fine and is required when merging to old branches to preserve exsiting KBI anyway. |