tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: introduce device_is_attached()

Along these same lines, it might be nice if there were a way to determine if _any_ instances of a device were attached. This is particularly useful for device-driver modules, which should prevent themselves from being unloaded if there are active instances.

A quick check of some device-driver modules show that they simply call config_fini_component() which updates autoconfig tables, but doesn't seem to check if a driver instance exists...

On Mon, 16 Apr 2012, Christoph Egger wrote:


I want to introduce a new function to sys/devices.h:

bool device_is_attached(device_t parent, cfdata_t cf);

The purpose is for bus drivers who wants to attach children
and ensure that only one instance of it will attach.

'parent' is the bus driver and 'cf' is the child device
as passed to the submatch callback via config_search_loc().

The return value is true if the child is already attached.

I implemented a reference usage of it in amdnb_misc.c to ensure
that amdtemp only attaches once on rescan.

Any comments to the patch?



| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at |
| Kernel Developer |                          | pgoyette at  |

Home | Main Index | Thread Index | Old Index