diff mbox series

[JAMMY,SRU,3/4] UBUNTU: SAUCE: Backport ZSTD-compressed firmware files to old ZSTD API

Message ID 20230725211507.47385-4-dimitri.ledkov@canonical.com
State New
Headers show
Series Backport support to tolerate ZSTD compressed firmware files | expand

Commit Message

Dimitri John Ledkov July 25, 2023, 9:15 p.m. UTC
This fixes "firmware: Add the support for ZSTD-compressed firmware
files" cherry-pick to use the old ZSTD APIs as present in the v5.15
kernel, instead of v5.19+ in-kernel API..

The zstd in-kernel API was introduced in v5.19 kernels by commit
cf30f6a5f0 ("lib: zstd: Add kernel-specific API").

BugLink: https://bugs.launchpad.net/bugs/2028550
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
---
 drivers/base/firmware_loader/main.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 227f6b3dff..701b7ee469 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -374,16 +374,16 @@  static int fw_decompress_zstd(struct device *dev, struct fw_priv *fw_priv,
 {
 	size_t len, out_size, workspace_size;
 	void *workspace, *out_buf;
-	zstd_dctx *ctx;
+	ZSTD_DCtx *ctx;
 	int err;
 
 	if (fw_priv->allocated_size) {
 		out_size = fw_priv->allocated_size;
 		out_buf = fw_priv->data;
 	} else {
-		zstd_frame_header params;
+		ZSTD_frameParams params;
 
-		if (zstd_get_frame_header(&params, in_buffer, in_size) ||
+		if (ZSTD_getFrameParams(&params, in_buffer, in_size) ||
 		    params.frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN) {
 			dev_dbg(dev, "%s: invalid zstd header\n", __func__);
 			return -EINVAL;
@@ -394,24 +394,24 @@  static int fw_decompress_zstd(struct device *dev, struct fw_priv *fw_priv,
 			return -ENOMEM;
 	}
 
-	workspace_size = zstd_dctx_workspace_bound();
+	workspace_size = ZSTD_DCtxWorkspaceBound();
 	workspace = kvzalloc(workspace_size, GFP_KERNEL);
 	if (!workspace) {
 		err = -ENOMEM;
 		goto error;
 	}
 
-	ctx = zstd_init_dctx(workspace, workspace_size);
+	ctx = ZSTD_initDCtx(workspace, workspace_size);
 	if (!ctx) {
 		dev_dbg(dev, "%s: failed to initialize context\n", __func__);
 		err = -EINVAL;
 		goto error;
 	}
 
-	len = zstd_decompress_dctx(ctx, out_buf, out_size, in_buffer, in_size);
-	if (zstd_is_error(len)) {
+	len = ZSTD_decompressDCtx(ctx, out_buf, out_size, in_buffer, in_size);
+	if (ZSTD_isError(len)) {
 		dev_dbg(dev, "%s: failed to decompress: %d\n", __func__,
-			zstd_get_error_code(len));
+			ZSTD_getErrorCode(len));
 		err = -EINVAL;
 		goto error;
 	}