Page MenuHomeFreeBSD

make_dev_s()
ClosedPublic

Authored by kib on Dec 31 2015, 3:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 2:37 AM
Unknown Object (File)
Nov 18 2024, 8:54 AM
Unknown Object (File)
Nov 6 2024, 3:44 AM
Unknown Object (File)
Oct 18 2024, 6:34 AM
Unknown Object (File)
Oct 11 2024, 10:00 PM
Unknown Object (File)
Oct 1 2024, 4:13 PM
Unknown Object (File)
Sep 27 2024, 1:54 AM
Unknown Object (File)
Sep 20 2024, 7:25 PM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib retitled this revision from to make_dev_s().
kib updated this object.
kib edited the test plan for this revision. (Show Details)
kib added reviewers: hselasky, jhb.
kib set the repository for this revision to rS FreeBSD src repository - subversion.

Hi,

Do you plan to add convenience wrappers/macros for the most common make device calls?

--HPS

Do you plan to add convenience wrappers/macros for the most common make device calls?

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?

This revision is now accepted and ready to land.Jan 3 2016, 12:33 PM

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.

kib edited the test plan for this revision. (Show Details)
kib edited edge metadata.

Convert kern/tty.c to use new KPI.

This revision now requires review to proceed.Jan 3 2016, 1:43 PM
kib added a reviewer: manpages.

Man page update.

kib edited edge metadata.

Fix mda_si_drv0/mda_unit discrepancy (remove si_drv0).

kib edited edge metadata.

Fix thinko in the make_dev_args_init_impl(). Convert sys/cam.

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.

kib marked 6 inline comments as done.Jan 5 2016, 12:09 PM
kib added inline comments.
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.

kib edited edge metadata.
kib marked an inline comment as done.

Update manpage according to Johm' comments. Reorder locals declarations in passregister().

This revision is now accepted and ready to land.Jan 6 2016, 9:25 AM
jhb edited edge metadata.
jhb added inline comments.
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.

This revision was automatically updated to reflect the committed changes.