diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2015-12-16 01:33:22 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-01-04 16:12:42 -0500 |
commit | e0f03e87fc6f27a8af9896f430f2945b3b1664c0 (patch) | |
tree | 609518455b06bfb95b74f7dcf1336244820f92b1 /drivers/pnp | |
parent | a77060f07ffc6ac978e280e738302f3e5572a99e (diff) |
PNP: respect PNP_DRIVER_RES_DO_NOT_CHANGE when detaching
I have a device (Nuvoton 6779D Super-IO IR RC with nuvoton-cir driver)
which works after initial boot but not any longer if I unload and
re-load the driver module.
Digging into the issue I found that unloading the driver calls
pnp_disable_dev although the driver has flag PNP_DRIVER_RES_DO_NOT_CHANGE
set. IMHO this is not right.
Let's have a look at the call chain when probing a device:
pnp_device_probe
1. attaches the device
2. if it's not active and PNP_DRIVER_RES_DO_NOT_CHANGE is not set
it gets activated
3. probes driver
I think pnp_device_remove should do it in reverse order and also
respect PNP_DRIVER_RES_DO_NOT_CHANGE. Therefore:
1. call drivers remove callback
2. if device is active and PNP_DRIVER_RES_DO_NOT_CHANGE is not set
disable it
3. detach device
The change works for me and sounds logical to me.
However I don't know the pnp driver in detail so I might be wrong.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r-- | drivers/pnp/driver.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 153a493b5413..63452f20e3e9 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -74,7 +74,6 @@ void pnp_device_detach(struct pnp_dev *pnp_dev) | |||
74 | if (pnp_dev->status == PNP_ATTACHED) | 74 | if (pnp_dev->status == PNP_ATTACHED) |
75 | pnp_dev->status = PNP_READY; | 75 | pnp_dev->status = PNP_READY; |
76 | mutex_unlock(&pnp_lock); | 76 | mutex_unlock(&pnp_lock); |
77 | pnp_disable_dev(pnp_dev); | ||
78 | } | 77 | } |
79 | 78 | ||
80 | static int pnp_device_probe(struct device *dev) | 79 | static int pnp_device_probe(struct device *dev) |
@@ -131,6 +130,11 @@ static int pnp_device_remove(struct device *dev) | |||
131 | drv->remove(pnp_dev); | 130 | drv->remove(pnp_dev); |
132 | pnp_dev->driver = NULL; | 131 | pnp_dev->driver = NULL; |
133 | } | 132 | } |
133 | |||
134 | if (pnp_dev->active && | ||
135 | (!drv || !(drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE))) | ||
136 | pnp_disable_dev(pnp_dev); | ||
137 | |||
134 | pnp_device_detach(pnp_dev); | 138 | pnp_device_detach(pnp_dev); |
135 | return 0; | 139 | return 0; |
136 | } | 140 | } |