From 22ea1ec051c15659944bf3922c33ec4025d010ea Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 24 Jul 2024 22:22:48 -0600 Subject: newbus: introduce DEVICE_UNIT_ANY Right now we pass a bare -1 for situations where any unit number will do. Instead, introduce a DEVICE_UNIT_ANY to use instead of the bare constant. Update documentation and examples where -1 is currently used, though additional doc updates may be needed. Sponsored by: Netflix --- share/man/man9/DEVICE_IDENTIFY.9 | 2 +- share/man/man9/devclass.9 | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/man/man9/DEVICE_IDENTIFY.9 b/share/man/man9/DEVICE_IDENTIFY.9 index 4892e66eb214..d75c1a91ce4a 100644 --- a/share/man/man9/DEVICE_IDENTIFY.9 +++ b/share/man/man9/DEVICE_IDENTIFY.9 @@ -73,7 +73,7 @@ foo_identify(driver_t *driver, device_t parent) retrieve_device_information; if (devices matches one of your supported devices && not already in device tree) { - child = BUS_ADD_CHILD(parent, 0, "foo", -1); + child = BUS_ADD_CHILD(parent, 0, "foo", DEVICE_UNIT_ANY); bus_set_resource(child, SYS_RES_IOPORT, 0, FOO_IOADDR, 1); } } diff --git a/share/man/man9/devclass.9 b/share/man/man9/devclass.9 index d3c83133ae17..cbf81f3b0fa3 100644 --- a/share/man/man9/devclass.9 +++ b/share/man/man9/devclass.9 @@ -46,10 +46,11 @@ Each has a name and there cannot be two devclasses with the same name. This ensures that unique unit numbers are allocated to device instances. +All instances with the same name are treated as being the same. .Pp -Beware that this means -.Vt devclass -must be the same for different bus attachments of the same device driver. +When no specific unit number is needed, +.Vt DEVICE_UNIT_ANY +is used. .Sh SEE ALSO .Xr devclass_add_driver 9 , .Xr devclass_delete_driver 9 , -- cgit v1.2.3