summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Knudsen <mk@cvs.openbsd.org>2006-05-28 01:33:51 +0000
committerMichael Knudsen <mk@cvs.openbsd.org>2006-05-28 01:33:51 +0000
commitc2a515d420306ea8e24621710865c86c172efa40 (patch)
treebeb8007ae363f16ce7c78ef57fc345a38bccf6ac
parent558df10eb9ad635023ca959cde1a13cafde9959f (diff)
Include device id in hotplug events. This will be used by ntpd to check
sensors on attach/detach. hotplugd changes following in a minute. ok henning.
-rw-r--r--sys/dev/hotplug.c8
-rw-r--r--sys/kern/kern_sensors.c6
-rw-r--r--sys/kern/subr_autoconf.c13
-rw-r--r--sys/sys/hotplug.h7
4 files changed, 19 insertions, 15 deletions
diff --git a/sys/dev/hotplug.c b/sys/dev/hotplug.c
index b463370010e..e41aa87f1f2 100644
--- a/sys/dev/hotplug.c
+++ b/sys/dev/hotplug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplug.c,v 1.6 2004/10/08 18:57:38 drahn Exp $ */
+/* $OpenBSD: hotplug.c,v 1.7 2006/05/28 01:33:50 mk Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -60,10 +60,11 @@ hotplugattach(int count)
}
void
-hotplug_device_attach(enum devclass class, char *name)
+hotplug_device_attach(enum devclass class, char *name, int id)
{
struct hotplug_event he;
+ he.he_devid = id;
he.he_type = HOTPLUG_DEVAT;
he.he_devclass = class;
strlcpy(he.he_devname, name, sizeof(he.he_devname));
@@ -71,10 +72,11 @@ hotplug_device_attach(enum devclass class, char *name)
}
void
-hotplug_device_detach(enum devclass class, char *name)
+hotplug_device_detach(enum devclass class, char *name, int id)
{
struct hotplug_event he;
+ he.he_devid = id;
he.he_type = HOTPLUG_DEVDT;
he.he_devclass = class;
strlcpy(he.he_devname, name, sizeof(he.he_devname));
diff --git a/sys/kern/kern_sensors.c b/sys/kern/kern_sensors.c
index 9e78e263186..c8951d9154a 100644
--- a/sys/kern/kern_sensors.c
+++ b/sys/kern/kern_sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sensors.c,v 1.10 2006/05/28 00:24:00 henning Exp $ */
+/* $OpenBSD: kern_sensors.c,v 1.11 2006/05/28 01:33:50 mk Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -70,7 +70,7 @@ sensor_add(struct sensor *sens)
splx(s);
#if NHOTPLUG > 0
- hotplug_device_attach(DV_SENSOR, sens->device);
+ hotplug_device_attach(DV_SENSOR, sens->device, sens->num);
#endif
}
@@ -85,7 +85,7 @@ sensor_del(struct sensor *sens)
splx(s);
#if NHOTPLUG > 0
- hotplug_device_detach(DV_SENSOR, sens->device);
+ hotplug_device_detach(DV_SENSOR, sens->device, sens->num);
#endif
}
diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c
index 94fa73cf057..13c8acedbc1 100644
--- a/sys/kern/subr_autoconf.c
+++ b/sys/kern/subr_autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_autoconf.c,v 1.46 2006/05/17 23:56:03 krw Exp $ */
+/* $OpenBSD: subr_autoconf.c,v 1.47 2006/05/28 01:33:50 mk Exp $ */
/* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */
/*
@@ -397,7 +397,7 @@ config_attach(struct device *parent, void *match, void *aux, cfprint_t print)
config_process_deferred_children(dev);
#if NHOTPLUG > 0
if (!cold)
- hotplug_device_attach(cd->cd_class, dev->dv_xname);
+ hotplug_device_attach(cd->cd_class, dev->dv_xname, dev->dv_unit);
#endif
return (dev);
}
@@ -495,6 +495,7 @@ config_detach(struct device *dev, int flags)
int rv = 0, i;
#if NHOTPLUG > 0
char devname[16];
+ int devnum = dev->dv_unit;
strlcpy(devname, dev->dv_xname, sizeof(devname));
#endif
@@ -561,10 +562,10 @@ config_detach(struct device *dev, int flags)
for (cf = cfdata; cf->cf_driver; cf++) {
if (cf->cf_driver == cd) {
if (cf->cf_fstate == FSTATE_FOUND &&
- cf->cf_unit == dev->dv_unit)
+ cf->cf_unit == devnum)
cf->cf_fstate = FSTATE_NOTFOUND;
if (cf->cf_fstate == FSTATE_STAR &&
- cf->cf_unit == dev->dv_unit + 1)
+ cf->cf_unit == devnum + 1)
cf->cf_unit--;
}
}
@@ -578,7 +579,7 @@ config_detach(struct device *dev, int flags)
/*
* Remove from cfdriver's array, tell the world, and free softc.
*/
- cd->cd_devs[dev->dv_unit] = NULL;
+ cd->cd_devs[devnum] = NULL;
if ((flags & DETACH_QUIET) == 0)
printf("%s detached\n", dev->dv_xname);
@@ -598,7 +599,7 @@ config_detach(struct device *dev, int flags)
#if NHOTPLUG > 0
if (!cold)
- hotplug_device_detach(cd->cd_class, devname);
+ hotplug_device_detach(cd->cd_class, devname, devnum);
#endif
/*
diff --git a/sys/sys/hotplug.h b/sys/sys/hotplug.h
index 20147c20d87..23275067084 100644
--- a/sys/sys/hotplug.h
+++ b/sys/sys/hotplug.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplug.h,v 1.1 2004/05/30 08:11:27 grange Exp $ */
+/* $OpenBSD: hotplug.h,v 1.2 2006/05/28 01:33:50 mk Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -27,14 +27,15 @@
#define HOTPLUG_DEVDT 0x02 /* device detached */
struct hotplug_event {
+ int he_devid; /* device id */
int he_type; /* event type */
enum devclass he_devclass; /* device class */
char he_devname[16]; /* device name */
};
#ifdef _KERNEL
-void hotplug_device_attach(enum devclass, char *);
-void hotplug_device_detach(enum devclass, char *);
+void hotplug_device_attach(enum devclass, char *, int);
+void hotplug_device_detach(enum devclass, char *, int);
#endif
#endif /* _SYS_HOTPLUG_H_ */