Date: Sat, 17 Apr 2004 22:06:26 -0700 (PDT) From: Nate Lawson <nate@root.org> To: current@freebsd.org Subject: refcounting for devclass_get_devices() Message-ID: <20040417220208.D10434@root.org>
next in thread | raw e-mail | index | archive | help
I am doing some locking work and ran across a tough case. It's useful to
use devclass_get_devices() when iterating across a whole set of softcs.
However, I didn't want to implement my own refcount for the returned
pointer. Are there any plans to deal with this interface? As a driver,
how can I know when a device is going away or keep it refed because I hold
a pointer to its softc? Since it mallocs data, I can't hold a device lock
across calling it and by the next instruction, one of the devices in the
array may have been destroyed.
The code is usually:
devclass_get_devices(acpi_cmbat_devclass, &acpi_cmbat_devs,
&acpi_cmbat_units);
for (i = 0; i < acpi_cmbat_units; i++)
sc = device_get_softc(acpi_cmbat_devs[i]);
...
Thanks,
Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040417220208.D10434>
