Browse Source

[DM/FIXUP] remove OFW switch macros

The drivers will support OFW and name probe both.
We should make build OK when OFW is disable.

Signed-off-by: GuEe-GUI <2991707448@qq.com>
GuEe-GUI 6 months ago
parent
commit
b6f67285e9
2 changed files with 11 additions and 14 deletions
  1. 11 5
      components/drivers/core/platform.c
  2. 0 9
      components/drivers/include/drivers/platform.h

+ 11 - 5
components/drivers/core/platform.c

@@ -78,21 +78,21 @@ static rt_bool_t platform_match(rt_driver_t drv, rt_device_t dev)
 {
 {
     struct rt_platform_driver *pdrv = rt_container_of(drv, struct rt_platform_driver, parent);
     struct rt_platform_driver *pdrv = rt_container_of(drv, struct rt_platform_driver, parent);
     struct rt_platform_device *pdev = rt_container_of(dev, struct rt_platform_device, parent);
     struct rt_platform_device *pdev = rt_container_of(dev, struct rt_platform_device, parent);
-
-#ifdef RT_USING_OFW
     struct rt_ofw_node *np = dev->ofw_node;
     struct rt_ofw_node *np = dev->ofw_node;
 
 
     /* 1、match with ofw node */
     /* 1、match with ofw node */
     if (np)
     if (np)
     {
     {
+    #ifdef RT_USING_OFW
         pdev->id = rt_ofw_node_match(np, pdrv->ids);
         pdev->id = rt_ofw_node_match(np, pdrv->ids);
-
+    #else
+        pdev->id = RT_NULL;
+    #endif
         if (pdev->id)
         if (pdev->id)
         {
         {
             return RT_TRUE;
             return RT_TRUE;
         }
         }
     }
     }
-#endif
 
 
     /* 2、match with name */
     /* 2、match with name */
     if (pdev->name && pdrv->name)
     if (pdev->name && pdrv->name)
@@ -123,7 +123,13 @@ static rt_err_t platform_probe(rt_device_t dev)
 
 
     if (err && err != -RT_EEMPTY)
     if (err && err != -RT_EEMPTY)
     {
     {
-        LOG_E("Attach power domain error = %s in device %s", pdev->name, rt_strerror(err));
+        LOG_E("Attach power domain error = %s in device %s", rt_strerror(err),
+        #ifdef RT_USING_OFW
+            (pdev->name && pdev->name[0]) ? pdev->name : rt_ofw_node_full_name(np)
+        #else
+            pdev->name
+        #endif
+            );
 
 
         return err;
         return err;
     }
     }

+ 0 - 9
components/drivers/include/drivers/platform.h

@@ -12,10 +12,7 @@
 #ifndef __PLATFORM_H__
 #ifndef __PLATFORM_H__
 #define __PLATFORM_H__
 #define __PLATFORM_H__
 
 
-#ifdef RT_USING_OFW
 #include <drivers/ofw.h>
 #include <drivers/ofw.h>
-#endif
-
 #include <drivers/core/driver.h>
 #include <drivers/core/driver.h>
 
 
 struct rt_platform_device
 struct rt_platform_device
@@ -25,10 +22,7 @@ struct rt_platform_device
     int dev_id;
     int dev_id;
 
 
     const char *name;
     const char *name;
-
-#ifdef RT_USING_OFW
     const struct rt_ofw_node_id *id;
     const struct rt_ofw_node_id *id;
-#endif
 
 
     void *priv;
     void *priv;
 };
 };
@@ -38,10 +32,7 @@ struct rt_platform_driver
     struct rt_driver parent;
     struct rt_driver parent;
 
 
     const char *name;
     const char *name;
-
-#ifdef RT_USING_OFW
     const struct rt_ofw_node_id *ids;
     const struct rt_ofw_node_id *ids;
-#endif
 
 
     rt_err_t (*probe)(struct rt_platform_device *pdev);
     rt_err_t (*probe)(struct rt_platform_device *pdev);
     rt_err_t (*remove)(struct rt_platform_device *pdev);
     rt_err_t (*remove)(struct rt_platform_device *pdev);