Merge tag 'fbdev-v5.2' of git://github.com/bzolnier/linux
[sfrench/cifs-2.6.git] / include / linux / device.h
index 4e6987e11f688bc12001cc4d030e8a3a99faa514..e85264fb66161408aee2815001d8d5159ab04ac1 100644 (file)
@@ -976,18 +976,14 @@ struct dev_links_info {
  * a higher-level representation of the device.
  */
 struct device {
+       struct kobject kobj;
        struct device           *parent;
 
        struct device_private   *p;
 
-       struct kobject kobj;
        const char              *init_name; /* initial name of the device */
        const struct device_type *type;
 
-       struct mutex            mutex;  /* mutex to synchronize calls to
-                                        * its driver.
-                                        */
-
        struct bus_type *bus;           /* type of bus device is on */
        struct device_driver *driver;   /* which driver has allocated this
                                           device */
@@ -995,6 +991,10 @@ struct device {
                                           core doesn't touch it */
        void            *driver_data;   /* Driver data, set and get with
                                           dev_set_drvdata/dev_get_drvdata */
+       struct mutex            mutex;  /* mutex to synchronize calls to
+                                        * its driver.
+                                        */
+
        struct dev_links_info   links;
        struct dev_pm_info      power;
        struct dev_pm_domain    *pm_domain;
@@ -1009,9 +1009,6 @@ struct device {
        struct list_head        msi_list;
 #endif
 
-#ifdef CONFIG_NUMA
-       int             numa_node;      /* NUMA node this device is close to */
-#endif
        const struct dma_map_ops *dma_ops;
        u64             *dma_mask;      /* dma mask (if dma'able device) */
        u64             coherent_dma_mask;/* Like dma_mask, but for
@@ -1040,6 +1037,9 @@ struct device {
        struct device_node      *of_node; /* associated device tree node */
        struct fwnode_handle    *fwnode; /* firmware device node */
 
+#ifdef CONFIG_NUMA
+       int             numa_node;      /* NUMA node this device is close to */
+#endif
        dev_t                   devt;   /* dev_t, creates the sysfs "dev" */
        u32                     id;     /* device instance */
 
@@ -1229,7 +1229,7 @@ static inline void device_lock_assert(struct device *dev)
 
 static inline struct device_node *dev_of_node(struct device *dev)
 {
-       if (!IS_ENABLED(CONFIG_OF))
+       if (!IS_ENABLED(CONFIG_OF) || !dev)
                return NULL;
        return dev->of_node;
 }