Driver core: Add BUS_NOTIFY_BIND_DRIVER
[firefly-linux-kernel-4.4.55.git] / include / linux / device.h
index 0713e10571dd61eb0abf1388e0c415ba6d143b6d..0ca24e93304fc1dcc3f410950dbba5562337563a 100644 (file)
@@ -84,9 +84,8 @@ struct device *bus_find_device_by_name(struct bus_type *bus,
                                       struct device *start,
                                       const char *name);
 
-int __must_check bus_for_each_drv(struct bus_type *bus,
-                                 struct device_driver *start, void *data,
-                                 int (*fn)(struct device_driver *, void *));
+int bus_for_each_drv(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,
@@ -110,10 +109,12 @@ extern int bus_unregister_notifier(struct bus_type *bus,
  */
 #define BUS_NOTIFY_ADD_DEVICE          0x00000001 /* device added */
 #define BUS_NOTIFY_DEL_DEVICE          0x00000002 /* device removed */
-#define BUS_NOTIFY_BOUND_DRIVER                0x00000003 /* driver bound to device */
-#define BUS_NOTIFY_UNBIND_DRIVER       0x00000004 /* driver about to be
+#define BUS_NOTIFY_BIND_DRIVER         0x00000003 /* driver about to be
+                                                     bound */
+#define BUS_NOTIFY_BOUND_DRIVER                0x00000004 /* driver bound to device */
+#define BUS_NOTIFY_UNBIND_DRIVER       0x00000005 /* driver about to be
                                                      unbound */
-#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000005 /* driver is unbound
+#define BUS_NOTIFY_UNBOUND_DRIVER      0x00000006 /* driver is unbound
                                                      from the device */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
@@ -638,43 +639,103 @@ extern void sysdev_shutdown(void);
 
 /* debugging and troubleshooting/diagnostic helpers. */
 extern const char *dev_driver_string(const struct device *dev);
-#define dev_printk(level, dev, format, arg...) \
-       printk(level "%s %s: " format , dev_driver_string(dev) , \
-              dev_name(dev) , ## arg)
-
-#define dev_emerg(dev, format, arg...)         \
-       dev_printk(KERN_EMERG , dev , format , ## arg)
-#define dev_alert(dev, format, arg...)         \
-       dev_printk(KERN_ALERT , dev , format , ## arg)
-#define dev_crit(dev, format, arg...)          \
-       dev_printk(KERN_CRIT , dev , format , ## arg)
-#define dev_err(dev, format, arg...)           \
-       dev_printk(KERN_ERR , dev , format , ## arg)
-#define dev_warn(dev, format, arg...)          \
-       dev_printk(KERN_WARNING , dev , format , ## arg)
-#define dev_notice(dev, format, arg...)                \
-       dev_printk(KERN_NOTICE , dev , format , ## arg)
-#define dev_info(dev, format, arg...)          \
-       dev_printk(KERN_INFO , dev , format , ## arg)
+
+
+#ifdef CONFIG_PRINTK
+
+extern int dev_printk(const char *level, const struct device *dev,
+                     const char *fmt, ...)
+       __attribute__ ((format (printf, 3, 4)));
+extern int dev_emerg(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int dev_alert(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int dev_crit(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int dev_err(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int dev_warn(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int dev_notice(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int _dev_info(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+
+#else
+
+static inline int dev_printk(const char *level, const struct device *dev,
+                     const char *fmt, ...)
+       __attribute__ ((format (printf, 3, 4)));
+static inline int dev_printk(const char *level, const struct device *dev,
+                     const char *fmt, ...)
+        { return 0; }
+
+static inline int dev_emerg(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_emerg(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int dev_crit(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_crit(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int dev_alert(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_alert(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int dev_err(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_err(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int dev_warn(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_warn(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int dev_notice(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int dev_notice(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+static inline int _dev_info(const struct device *dev, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));
+static inline int _dev_info(const struct device *dev, const char *fmt, ...)
+       { return 0; }
+
+#endif
+
+/*
+ * Stupid hackaround for existing uses of non-printk uses dev_info
+ *
+ * Note that the definition of dev_info below is actually _dev_info
+ * and a macro is used to avoid redefining dev_info
+ */
+
+#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
 
 #if defined(DEBUG)
 #define dev_dbg(dev, format, arg...)           \
-       dev_printk(KERN_DEBUG , dev , format , ## arg)
+       dev_printk(KERN_DEBUG, dev, format, ##arg)
 #elif defined(CONFIG_DYNAMIC_DEBUG)
-#define dev_dbg(dev, format, ...) do { \
+#define dev_dbg(dev, format, ...)                   \
+do {                                                \
        dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
-       } while (0)
+} while (0)
 #else
-#define dev_dbg(dev, format, arg...)           \
-       ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
+#define dev_dbg(dev, format, arg...)                           \
+({                                                             \
+       if (0)                                                  \
+               dev_printk(KERN_DEBUG, dev, format, ##arg);     \
+       0;                                                      \
+})
 #endif
 
 #ifdef VERBOSE_DEBUG
 #define dev_vdbg       dev_dbg
 #else
-
-#define dev_vdbg(dev, format, arg...)          \
-       ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
+#define dev_vdbg(dev, format, arg...)                          \
+({                                                             \
+       if (0)                                                  \
+               dev_printk(KERN_DEBUG, dev, format, ##arg);     \
+       0;                                                      \
+})
 #endif
 
 /*