Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_bus.c
Show First 20 Lines • Show All 991 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
device_detach(device_t dev) | device_detach(device_t dev) | ||||
{ | { | ||||
int error; | int error; | ||||
GIANT_REQUIRED; | GIANT_REQUIRED; | ||||
PDEBUG(("%s", DEVICENAME(dev))); | PDEBUG(("%s", DEVICENAME(dev))); | ||||
if (dev->state == DS_BUSY) | if (dev->state == DS_BUSY || dev->state == DS_ATTACHING) | ||||
imp: Please add a comment that this is a horrific hack designed to cope with busses that aren't… | |||||
emasteUnsubmitted Not Done Inline ActionsWarner is it worth going a little further than a comment, and emitting a warning upon DS_ATTACHING? emaste: Warner is it worth going a little further than a comment, and emitting a warning upon… | |||||
mwUnsubmitted Not Done Inline ActionsHow about following then: if (dev->state == DS_BUSY) return (EBUSY); if (dev->state == DS_ATTACHING) { device_printf(dev, "device in attaching state! Deferring detach.\n"); return (EBUSY); } mw: How about following then:
```
if (dev->state == DS_BUSY)
return (EBUSY);
if (dev->state… | |||||
emasteUnsubmitted Not Done Inline ActionsThat LGTM but I'll defer to @imp emaste: That LGTM but I'll defer to @imp | |||||
impUnsubmitted Not Done Inline ActionsThis makes me happier since we warn about the problem, even if the root cause is well beyond the scope of this review to fix. imp: This makes me happier since we warn about the problem, even if the root cause is well beyond… | |||||
mwUnsubmitted Not Done Inline ActionsI also added mentioning the work-around character of the patch in the commit log (r344676.) Thanks, mw: I also added mentioning the work-around character of the patch in the commit log (r344676.)… | |||||
return (EBUSY); | return (EBUSY); | ||||
if (dev->state != DS_ATTACHED) | if (dev->state != DS_ATTACHED) | ||||
return (0); | return (0); | ||||
EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); | EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); | ||||
if ((error = DEVICE_DETACH(dev)) != 0) { | if ((error = DEVICE_DETACH(dev)) != 0) { | ||||
EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, | EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, | ||||
EVHDEV_DETACH_FAILED); | EVHDEV_DETACH_FAILED); | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |
Please add a comment that this is a horrific hack designed to cope with busses that aren't properly locked that allow entry into both attach and detach.
Sadly, most busses are like this in the tree, and it's one of the big issues with my work trying to properly lock newbus.