[v2,21/37] net/mvpp2: move common functions to common location

Message ID 20210122191925.24308-22-lironh@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series net/mvpp2: misc updates |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Liron Himi Jan. 22, 2021, 7:19 p.m. UTC
  From: Liron Himi <lironh@marvell.com>

Move common functions to common location

Signed-off-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.h | 41 +++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_qos.c    | 24 -------------------
 2 files changed, 41 insertions(+), 24 deletions(-)
  

Patch

diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h
index da026e606..8be7603d4 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.h
+++ b/drivers/net/mvpp2/mrvl_ethdev.h
@@ -195,4 +195,45 @@  extern int mrvl_logtype;
 	rte_log(RTE_LOG_ ## level, mrvl_logtype, "%s(): " fmt "\n", \
 		__func__, ##args)
 
+/**
+ * Convert string to uint32_t with extra checks for result correctness.
+ *
+ * @param string String to convert.
+ * @param val Conversion result.
+ * @returns 0 in case of success, negative value otherwise.
+ */
+static int
+get_val_securely(const char *string, uint32_t *val)
+{
+	char *endptr;
+	size_t len = strlen(string);
+
+	if (len == 0)
+		return -1;
+
+	errno = 0;
+	*val = strtoul(string, &endptr, 0);
+	if (errno != 0 || RTE_PTR_DIFF(endptr, string) != len)
+		return -2;
+
+	return 0;
+}
+
+static int
+get_val_securely8(const char *string, uint32_t base, uint8_t *val)
+{
+	char *endptr;
+	size_t len = strlen(string);
+
+	if (len == 0)
+		return -1;
+
+	errno = 0;
+	*val = (uint8_t)strtoul(string, &endptr, base);
+	if (errno != 0 || RTE_PTR_DIFF(endptr, string) != len)
+		return -2;
+
+	return 0;
+}
+
 #endif /* _MRVL_ETHDEV_H_ */
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 18cf470dd..d3ad7cc5a 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -74,30 +74,6 @@ 
 /** Global configuration. */
 struct mrvl_cfg *mrvl_cfg;
 
-/**
- * Convert string to uint32_t with extra checks for result correctness.
- *
- * @param string String to convert.
- * @param val Conversion result.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-get_val_securely(const char *string, uint32_t *val)
-{
-	char *endptr;
-	size_t len = strlen(string);
-
-	if (len == 0)
-		return -1;
-
-	errno = 0;
-	*val = strtoul(string, &endptr, 0);
-	if (errno != 0 || RTE_PTR_DIFF(endptr, string) != len)
-		return -2;
-
-	return 0;
-}
-
 /**
  * Read out-queue configuration from file.
  *