Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157254060
D12557.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D12557.id.diff
View Options
Index: head/sys/kern/subr_bus.c
===================================================================
--- head/sys/kern/subr_bus.c
+++ head/sys/kern/subr_bus.c
@@ -2936,6 +2936,7 @@
else
dev->state = DS_ATTACHED;
dev->flags &= ~DF_DONENOMATCH;
+ EVENTHANDLER_INVOKE(device_attach, dev);
devadded(dev);
return (0);
}
@@ -2969,8 +2970,13 @@
if (dev->state != DS_ATTACHED)
return (0);
- if ((error = DEVICE_DETACH(dev)) != 0)
+ EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN);
+ if ((error = DEVICE_DETACH(dev)) != 0) {
+ EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_FAILED);
return (error);
+ } else {
+ EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_COMPLETE);
+ }
devremoved(dev);
if (!device_is_quiet(dev))
device_printf(dev, "detached\n");
Index: head/sys/sys/eventhandler.h
===================================================================
--- head/sys/sys/eventhandler.h
+++ head/sys/sys/eventhandler.h
@@ -293,4 +293,15 @@
EVENTHANDLER_DECLARE(swapon, swapon_fn);
EVENTHANDLER_DECLARE(swapoff, swapoff_fn);
+/* newbus device events */
+enum evhdev_detach {
+ EVHDEV_DETACH_BEGIN, /* Before detach() is called */
+ EVHDEV_DETACH_COMPLETE, /* After detach() returns 0 */
+ EVHDEV_DETACH_FAILED /* After detach() returns err */
+};
+typedef void (*device_attach_fn)(void *, device_t);
+typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach);
+EVENTHANDLER_DECLARE(device_attach, device_attach_fn);
+EVENTHANDLER_DECLARE(device_detach, device_detach_fn);
+
#endif /* _SYS_EVENTHANDLER_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 20, 6:12 PM (2 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33326564
Default Alt Text
D12557.id.diff (1 KB)
Attached To
Mode
D12557: Add eventhandler notifications for newbus device attach/detach.
Attached
Detach File
Event Timeline
Log In to Comment