Page MenuHomeFreeBSD

Refactor PCIOCGETCONF for improved readability.
ClosedPublic

Authored by brooks on Apr 5 2018, 6:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 17 2024, 5:03 PM
Unknown Object (File)
Dec 22 2023, 9:45 PM
Unknown Object (File)
Dec 12 2023, 2:48 PM
Unknown Object (File)
Nov 11 2023, 7:19 PM
Unknown Object (File)
Nov 6 2023, 5:04 PM
Unknown Object (File)
Nov 4 2023, 9:59 PM
Unknown Object (File)
Oct 8 2023, 6:15 PM
Unknown Object (File)
Oct 5 2023, 4:05 PM
Subscribers

Details

Summary

The code now has a single, consistant flow for all three ioctl
variants. ifdefs and for pre-FreeBSD-7 compatability are moved to
functions and macros. So the flow is alwasy the same, we impose
the cost of allocating, copying to, updating from, and freeing a
copy of struct pci_conf_io on all paths.

This change will allow PCIOCGETCONF32 support currently in
sys/compat/freebsd32/freebsd32_ioctl.c to be moved here.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

  • Correct a leftover from a botched substitution.
  • tab's after #define
  • Be a little more consistant with #ifdefs

I think this is ready for review now.

This revision is now accepted and ready to land.Apr 6 2018, 12:00 PM

One other possibility is to define a helper struct that contains the structure sizes and has function pointer callbacks (kevent and aio took this approach), but this is probably fine.

sys/dev/pci/pci_user.c
418 ↗(On Diff #41161)

While I appreciate the desire to reduce duplication, this feels a bit squishy to me, especially given it's only used twice. I think the expanded version in the two places might be less total lines than this set of helper macros. I don't think we use this pattern anywhere else in the tree.

As far as the ops structures, I found the structure in aio frustrating when I needed to change its interface due to having to (e.g.) add N new functions and add the right ones to N+2 or so ops struct instances.

sys/dev/pci/pci_user.c
418 ↗(On Diff #41161)

If makes more sense as the number of entries grows. I've got a patch which adds another case for PCIOCGETCONF32 (moving it out of sys/compat/freebsd32). On CheriBSD I've got yet another PCIOCGETCONF_C. I don't feel strongly about this case, but the virtue of this is that pci_ioctl() now contains no references to compat defines.

sys/dev/pci/pci_user.c
418 ↗(On Diff #41161)

I suppose static analysis expands macros so wouldn't be confused, but I wonder if things like clang-format or auto-indenting in emacs/vim handles this syntax ok? Maybe the trailing colon is good enough for that to not break?

  • Expand CASE_PCIOCGETCONF inplace and remove the defintion.
This revision now requires review to proceed.Apr 8 2018, 4:30 PM
This revision is now accepted and ready to land.Apr 9 2018, 10:27 PM
This revision was automatically updated to reflect the committed changes.