]> Pileus Git - ~andy/linux/blobdiff - drivers/base/base.h
driver core: move knode_driver into private structure
[~andy/linux] / drivers / base / base.h
index 9f50f1b545dc49de323135663628da1566797175..4fc5fd3984cca8e7851b7656c47bc0e75805ba96 100644 (file)
@@ -63,6 +63,28 @@ struct class_private {
 #define to_class(obj)  \
        container_of(obj, struct class_private, class_subsys.kobj)
 
+/**
+ * struct device_private - structure to hold the private to the driver core portions of the device structure.
+ *
+ * @klist_children - klist containing all children of this device
+ * @knode_parent - node in sibling list
+ * @knode_driver - node in driver list
+ * @device - pointer back to the struct class that this structure is
+ * associated with.
+ *
+ * Nothing outside of the driver core should ever touch these fields.
+ */
+struct device_private {
+       struct klist klist_children;
+       struct klist_node knode_parent;
+       struct klist_node knode_driver;
+       struct device *device;
+};
+#define to_device_private_parent(obj)  \
+       container_of(obj, struct device_private, knode_parent)
+#define to_device_private_driver(obj)  \
+       container_of(obj, struct device_private, knode_driver)
+
 /* initialisation functions */
 extern int devices_init(void);
 extern int buses_init(void);
@@ -86,6 +108,11 @@ extern void bus_remove_driver(struct device_driver *drv);
 
 extern void driver_detach(struct device_driver *drv);
 extern int driver_probe_device(struct device_driver *drv, struct device *dev);
+static inline int driver_match_device(struct device_driver *drv,
+                                     struct device *dev)
+{
+       return drv->bus->match && drv->bus->match(dev, drv);
+}
 
 extern void sysdev_shutdown(void);