Skip to content

Commit e0f03e8

Browse files
hkallweitrafaeljw
authored andcommitted
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a77060f commit e0f03e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/pnp/driver.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ void pnp_device_detach(struct pnp_dev *pnp_dev)
7474
if (pnp_dev->status == PNP_ATTACHED)
7575
pnp_dev->status = PNP_READY;
7676
mutex_unlock(&pnp_lock);
77-
pnp_disable_dev(pnp_dev);
7877
}
7978

8079
static int pnp_device_probe(struct device *dev)
@@ -131,6 +130,11 @@ static int pnp_device_remove(struct device *dev)
131130
drv->remove(pnp_dev);
132131
pnp_dev->driver = NULL;
133132
}
133+
134+
if (pnp_dev->active &&
135+
(!drv || !(drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)))
136+
pnp_disable_dev(pnp_dev);
137+
134138
pnp_device_detach(pnp_dev);
135139
return 0;
136140
}

0 commit comments

Comments
 (0)