aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-04-12 13:32:30 +0000
committerMark Johnston <markj@FreeBSD.org>2021-04-12 13:32:30 +0000
commitdfff37765ce4ea4fd7db4d293b459dc84008f411 (patch)
treed87e095b485161d7dc2351bd4a3820a55dc4b48b /sys/kern/subr_bus.c
parent3f322b22e02d6aae147e9948ab50ca1bee9a9dd4 (diff)
downloadsrc-dfff37765ce4ea4fd7db4d293b459dc84008f411.tar.gz
src-dfff37765ce4ea4fd7db4d293b459dc84008f411.zip
Rename struct device to struct _device
types.h defines device_t as a typedef of struct device *. struct device is defined in subr_bus.c and almost all of the kernel uses device_t. The LinuxKPI also defines a struct device, so type confusion can occur. This causes bugs and ambiguity for debugging tools. Rename the FreeBSD struct device to struct _device. Reviewed by: gbe (man pages) Reviewed by: rpokala, imp, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29676
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 2a8cf00b5700..08f1cb5886d2 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -95,7 +95,7 @@ struct driverlink {
*/
typedef TAILQ_HEAD(devclass_list, devclass) devclass_list_t;
typedef TAILQ_HEAD(driver_list, driverlink) driver_list_t;
-typedef TAILQ_HEAD(device_list, device) device_list_t;
+typedef TAILQ_HEAD(device_list, _device) device_list_t;
struct devclass {
TAILQ_ENTRY(devclass) link;
@@ -112,9 +112,12 @@ struct devclass {
};
/**
- * @brief Implementation of device.
+ * @brief Implementation of _device.
+ *
+ * The structure is named "_device" instead of "device" to avoid type confusion
+ * caused by other subsystems defining a (struct device).
*/
-struct device {
+struct _device {
/*
* A device is a kernel object. The first field must be the
* current ops table for the object.
@@ -124,8 +127,8 @@ struct device {
/*
* Device hierarchy.
*/
- TAILQ_ENTRY(device) link; /**< list of devices in parent */
- TAILQ_ENTRY(device) devlink; /**< global device list membership */
+ TAILQ_ENTRY(_device) link; /**< list of devices in parent */
+ TAILQ_ENTRY(_device) devlink; /**< global device list membership */
device_t parent; /**< parent of this device */
device_list_t children; /**< list of child devices */
@@ -853,7 +856,7 @@ devctl_safe_quote_sb(struct sbuf *sb, const char *src)
/* End of /dev/devctl code */
-static TAILQ_HEAD(,device) bus_data_devices;
+static struct device_list bus_data_devices;
static int bus_data_generation = 1;
static kobj_method_t null_methods[] = {