diff mbox series

[10/10] Relax dependencies for hw_compatibility

Message ID 20231009161827.422108-1-stefano.babic@swupdate.org
State Accepted
Delegated to: Stefano Babic
Headers show
Series None | expand

Commit Message

Stefano Babic Oct. 9, 2023, 4:18 p.m. UTC
Drop dependencies from swupdate configuration and just pass hardware
related structures.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 core/hw-compatibility.c    | 14 ++++++--------
 core/stream_interface.c    |  2 +-
 corelib/lua_interface.c    |  2 +-
 include/hw-compatibility.h | 13 +++++++++++--
 include/swupdate.h         |  9 +--------
 5 files changed, 20 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/core/hw-compatibility.c b/core/hw-compatibility.c
index 7c6cd253..34a27cb6 100644
--- a/core/hw-compatibility.c
+++ b/core/hw-compatibility.c
@@ -10,7 +10,6 @@ 
 #include <unistd.h>
 #include <errno.h>
 #include "util.h"
-#include "swupdate.h"
 #include "hw-compatibility.h"
 
 /*
@@ -18,19 +17,19 @@ 
  * in the sw-description file
  */
 #ifdef CONFIG_HW_COMPATIBILITY
-int check_hw_compatibility(struct swupdate_cfg *cfg)
+int check_hw_compatibility(struct hw_type *hwt, struct hwlist *hardware)
 {
 	struct hw_type *hw;
 	int ret;
 
-	ret = get_hw_revision(&cfg->hw);
+	ret = get_hw_revision(hwt);
 	if (ret < 0)
 		return -1;
 
-	TRACE("Hardware %s Revision: %s", cfg->hw.boardname, cfg->hw.revision);
-	LIST_FOREACH(hw, &cfg->hardware, next) {
+	TRACE("Hardware %s Revision: %s", hwt->boardname, hwt->revision);
+	LIST_FOREACH(hw, hardware, next) {
 		if (hw &&
-		    (!hwid_match(hw->revision, cfg->hw.revision))) {
+		    (!hwid_match(hw->revision, hwt->revision))) {
 			TRACE("Hardware compatibility verified");
 			return 0;
 		}
@@ -39,8 +38,7 @@  int check_hw_compatibility(struct swupdate_cfg *cfg)
 	return -1;
 }
 #else
-int check_hw_compatibility(struct swupdate_cfg
-		__attribute__ ((__unused__)) *cfg)
+int check_hw_compatibility(struct hw_type __attribute__ ((__unused__)) *hwt, struct hwlist __attribute__ ((__unused__)) *hardware)
 {
 	return 0;
 }
diff --git a/core/stream_interface.c b/core/stream_interface.c
index aa971d2c..d9afa4af 100644
--- a/core/stream_interface.c
+++ b/core/stream_interface.c
@@ -183,7 +183,7 @@  static int extract_files(int fd, struct swupdate_cfg *software)
 				return -1;
 			}
 
-			if (check_hw_compatibility(software)) {
+			if (check_hw_compatibility(&software->hw, &software->hardware)) {
 				ERROR("SW not compatible with hardware");
 				return -1;
 			}
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index ac2b82eb..0ef8f87a 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -23,7 +23,7 @@ 
 #include "bootloader.h"
 #include "progress.h"
 #include "swupdate_image.h"
-#include "hw-compatibility.h"
+#include "swupdate.h"
 
 #define LUA_TYPE_PEMBSCR 1
 #define LUA_TYPE_HANDLER 2
diff --git a/include/hw-compatibility.h b/include/hw-compatibility.h
index 21e73818..3c2dca82 100644
--- a/include/hw-compatibility.h
+++ b/include/hw-compatibility.h
@@ -8,9 +8,18 @@ 
 #ifndef _SWUPDATE_HW_COMPATIBILITY_H
 #define _SWUPDATE_HW_COMPATIBILITY_H
 
-#include "swupdate.h"
+#include "bsdqueue.h"
+#include "globals.h"
 
-int check_hw_compatibility(struct swupdate_cfg *cfg);
+struct hw_type {
+	char boardname[SWUPDATE_GENERAL_STRING_SIZE];
+	char revision[SWUPDATE_GENERAL_STRING_SIZE];
+	LIST_ENTRY(hw_type) next;
+};
+
+LIST_HEAD(hwlist, hw_type);
+
+int check_hw_compatibility(struct hw_type *hwt, struct hwlist *hardware);
 int get_hw_revision(struct hw_type *hw);
 
 #endif
diff --git a/include/swupdate.h b/include/swupdate.h
index e473e411..9e48d04a 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -15,6 +15,7 @@ 
 #include "mongoose_interface.h"
 #include "swupdate_dict.h"
 #include "swupdate_image.h"
+#include "hw-compatibility.h"
 
 /*
  * this is used to indicate if a file
@@ -27,14 +28,6 @@  typedef enum {
 	INSTALL_FROM_STREAM
 } swupdate_file_t;
 
-struct hw_type {
-	char boardname[SWUPDATE_GENERAL_STRING_SIZE];
-	char revision[SWUPDATE_GENERAL_STRING_SIZE];
-	LIST_ENTRY(hw_type) next;
-};
-
-LIST_HEAD(hwlist, hw_type);
-
 struct extproc {
 	char name[SWUPDATE_GENERAL_STRING_SIZE];
 	char exec[SWUPDATE_GENERAL_STRING_SIZE];