mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
device core: add device_is_bound()
Adds a function that tells whether a device is already bound to a driver. This is needed to warn when there is an attempt to change the PM domain of a device that has finished probing already. The reason why we want to enforce that is because in the general case that can cause problems and also that we can simplify code quite a bit if we can always assume that. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
c4e4d631fe
commit
6b9cb42752
2 changed files with 18 additions and 2 deletions
|
@ -223,9 +223,23 @@ static int deferred_probe_initcall(void)
|
||||||
}
|
}
|
||||||
late_initcall(deferred_probe_initcall);
|
late_initcall(deferred_probe_initcall);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_is_bound() - Check if device is bound to a driver
|
||||||
|
* @dev: device to check
|
||||||
|
*
|
||||||
|
* Returns true if passed device has already finished probing successfully
|
||||||
|
* against a driver.
|
||||||
|
*
|
||||||
|
* This function must be called with the device lock held.
|
||||||
|
*/
|
||||||
|
bool device_is_bound(struct device *dev)
|
||||||
|
{
|
||||||
|
return klist_node_attached(&dev->p->knode_driver);
|
||||||
|
}
|
||||||
|
|
||||||
static void driver_bound(struct device *dev)
|
static void driver_bound(struct device *dev)
|
||||||
{
|
{
|
||||||
if (klist_node_attached(&dev->p->knode_driver)) {
|
if (device_is_bound(dev)) {
|
||||||
printk(KERN_WARNING "%s: device %s already bound\n",
|
printk(KERN_WARNING "%s: device %s already bound\n",
|
||||||
__func__, kobject_name(&dev->kobj));
|
__func__, kobject_name(&dev->kobj));
|
||||||
return;
|
return;
|
||||||
|
@ -601,7 +615,7 @@ static int __device_attach(struct device *dev, bool allow_async)
|
||||||
|
|
||||||
device_lock(dev);
|
device_lock(dev);
|
||||||
if (dev->driver) {
|
if (dev->driver) {
|
||||||
if (klist_node_attached(&dev->p->knode_driver)) {
|
if (device_is_bound(dev)) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1044,6 +1044,8 @@ extern int __must_check driver_attach(struct device_driver *drv);
|
||||||
extern void device_initial_probe(struct device *dev);
|
extern void device_initial_probe(struct device *dev);
|
||||||
extern int __must_check device_reprobe(struct device *dev);
|
extern int __must_check device_reprobe(struct device *dev);
|
||||||
|
|
||||||
|
extern bool device_is_bound(struct device *dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Easy functions for dynamically creating devices on the fly
|
* Easy functions for dynamically creating devices on the fly
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue