driver core: remove private pointer from struct bus_type
[linux-2.6-microblaze.git] / include / linux / device / bus.h
index d8b29cc..22bf634 100644 (file)
@@ -66,8 +66,6 @@ struct fwnode_handle;
  * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
  *              driver implementations to a bus and allow the driver to do
  *              bus-specific setup
- * @p:         The private data of the driver core, only the driver core can
- *             touch this.
  * @lock_key:  Lock class key for use by the lock validator
  * @need_parent_lock:  When probing or removing a device on this bus, the
  *                     device core should lock the device's parent.
@@ -90,7 +88,7 @@ struct bus_type {
        const struct attribute_group **drv_groups;
 
        int (*match)(struct device *dev, struct device_driver *drv);
-       int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
+       int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
        int (*probe)(struct device *dev);
        void (*sync_state)(struct device *dev);
        void (*remove)(struct device *dev);
@@ -111,9 +109,6 @@ struct bus_type {
 
        const struct iommu_ops *iommu_ops;
 
-       struct subsys_private *p;
-       struct lock_class_key lock_key;
-
        bool need_parent_lock;
 };
 
@@ -136,9 +131,8 @@ struct bus_attribute {
 #define BUS_ATTR_WO(_name) \
        struct bus_attribute bus_attr_##_name = __ATTR_WO(_name)
 
-extern int __must_check bus_create_file(struct bus_type *,
-                                       struct bus_attribute *);
-extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
+int __must_check bus_create_file(const struct bus_type *bus, struct bus_attribute *attr);
+void bus_remove_file(const struct bus_type *bus, struct bus_attribute *attr);
 
 /* Generic device matching functions that all busses can use to match with */
 int device_match_name(struct device *dev, const void *name);
@@ -150,20 +144,9 @@ int device_match_acpi_handle(struct device *dev, const void *handle);
 int device_match_any(struct device *dev, const void *unused);
 
 /* iterator helpers for buses */
-struct subsys_dev_iter {
-       struct klist_iter               ki;
-       const struct device_type        *type;
-};
-void subsys_dev_iter_init(struct subsys_dev_iter *iter,
-                        struct bus_type *subsys,
-                        struct device *start,
-                        const struct device_type *type);
-struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
-void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
-
-int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
+int bus_for_each_dev(const struct bus_type *bus, struct device *start, void *data,
                     int (*fn)(struct device *dev, void *data));
-struct device *bus_find_device(struct bus_type *bus, struct device *start,
+struct device *bus_find_device(const struct bus_type *bus, struct device *start,
                               const void *data,
                               int (*match)(struct device *dev, const void *data));
 /**
@@ -173,7 +156,7 @@ struct device *bus_find_device(struct bus_type *bus, struct device *start,
  * @start: Device to begin with
  * @name: name of the device to match
  */
-static inline struct device *bus_find_device_by_name(struct bus_type *bus,
+static inline struct device *bus_find_device_by_name(const struct bus_type *bus,
                                                     struct device *start,
                                                     const char *name)
 {
@@ -187,7 +170,7 @@ static inline struct device *bus_find_device_by_name(struct bus_type *bus,
  * @np: of_node of the device to match.
  */
 static inline struct device *
-bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
+bus_find_device_by_of_node(const struct bus_type *bus, const struct device_node *np)
 {
        return bus_find_device(bus, NULL, np, device_match_of_node);
 }
@@ -199,7 +182,7 @@ bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
  * @fwnode: fwnode of the device to match.
  */
 static inline struct device *
-bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
+bus_find_device_by_fwnode(const struct bus_type *bus, const struct fwnode_handle *fwnode)
 {
        return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
 }
@@ -210,7 +193,7 @@ bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwno
  * @bus: bus type
  * @devt: device type of the device to match.
  */
-static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
+static inline struct device *bus_find_device_by_devt(const struct bus_type *bus,
                                                     dev_t devt)
 {
        return bus_find_device(bus, NULL, &devt, device_match_devt);
@@ -223,7 +206,7 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
  * @cur: device to begin the search with.
  */
 static inline struct device *
-bus_find_next_device(struct bus_type *bus,struct device *cur)
+bus_find_next_device(const struct bus_type *bus,struct device *cur)
 {
        return bus_find_device(bus, cur, NULL, device_match_any);
 }
@@ -238,21 +221,19 @@ struct acpi_device;
  * @adev: ACPI COMPANION device to match.
  */
 static inline struct device *
-bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev)
+bus_find_device_by_acpi_dev(const struct bus_type *bus, const struct acpi_device *adev)
 {
        return bus_find_device(bus, NULL, adev, device_match_acpi_dev);
 }
 #else
 static inline struct device *
-bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
+bus_find_device_by_acpi_dev(const struct bus_type *bus, const void *adev)
 {
        return NULL;
 }
 #endif
 
-struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
-                                       struct device *hint);
-int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
+int bus_for_each_drv(const struct bus_type *bus, struct device_driver *start,
                     void *data, int (*fn)(struct device_driver *, void *));
 void bus_sort_breadthfirst(struct bus_type *bus,
                           int (*compare)(const struct device *a,
@@ -270,23 +251,36 @@ extern int bus_register_notifier(struct bus_type *bus,
 extern int bus_unregister_notifier(struct bus_type *bus,
                                   struct notifier_block *nb);
 
-/* All 4 notifers below get called with the target struct device *
- * as an argument. Note that those functions are likely to be called
- * with the device lock held in the core, so be careful.
+/**
+ * enum bus_notifier_event - Bus Notifier events that have happened
+ * @BUS_NOTIFY_ADD_DEVICE: device is added to this bus
+ * @BUS_NOTIFY_DEL_DEVICE: device is about to be removed from this bus
+ * @BUS_NOTIFY_REMOVED_DEVICE: device is successfully removed from this bus
+ * @BUS_NOTIFY_BIND_DRIVER: a driver is about to be bound to this device on this bus
+ * @BUS_NOTIFY_BOUND_DRIVER: a driver is successfully bound to this device on this bus
+ * @BUS_NOTIFY_UNBIND_DRIVER: a driver is about to be unbound from this device on this bus
+ * @BUS_NOTIFY_UNBOUND_DRIVER: a driver is successfully unbound from this device on this bus
+ * @BUS_NOTIFY_DRIVER_NOT_BOUND: a driver failed to be bound to this device on this bus
+ *
+ * These are the value passed to a bus notifier when a specific event happens.
+ *
+ * Note that bus notifiers are likely to be called with the device lock already
+ * held by the driver core, so be careful in any notifier callback as to what
+ * you do with the device structure.
+ *
+ * All bus notifiers are called with the target struct device * as an argument.
  */
-#define BUS_NOTIFY_ADD_DEVICE          0x00000001 /* device added */
-#define BUS_NOTIFY_DEL_DEVICE          0x00000002 /* device to be removed */
-#define BUS_NOTIFY_REMOVED_DEVICE      0x00000003 /* device removed */
-#define BUS_NOTIFY_BIND_DRIVER         0x00000004 /* driver about to be
-                                                     bound */
-#define BUS_NOTIFY_BOUND_DRIVER                0x00000005 /* driver bound to device */
-#define BUS_NOTIFY_UNBIND_DRIVER       0x00000006 /* driver about to be
-                                                     unbound */
-#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000007 /* driver is unbound
-                                                     from the device */
-#define BUS_NOTIFY_DRIVER_NOT_BOUND    0x00000008 /* driver fails to be bound */
+enum bus_notifier_event {
+       BUS_NOTIFY_ADD_DEVICE,
+       BUS_NOTIFY_DEL_DEVICE,
+       BUS_NOTIFY_REMOVED_DEVICE,
+       BUS_NOTIFY_BIND_DRIVER,
+       BUS_NOTIFY_BOUND_DRIVER,
+       BUS_NOTIFY_UNBIND_DRIVER,
+       BUS_NOTIFY_UNBOUND_DRIVER,
+       BUS_NOTIFY_DRIVER_NOT_BOUND,
+};
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
-extern struct klist *bus_get_device_klist(struct bus_type *bus);
 
 #endif