Merge "qcacmn: Add API qdf_file_read_bytes to read a file from host"

Este commit está contenido en:
Linux Build Service Account
2023-04-21 09:15:16 -07:00
cometido por Gerrit - the friendly Code Review server
Se han modificado 2 ficheros con 53 adiciones y 1 borrados

Ver fichero

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -40,11 +41,30 @@
*/
QDF_STATUS qdf_file_read(const char *path, char **out_buf);
/**
* qdf_file_read_bytes() - read the entire contents of a file and return the
* size read along with the content
* @path: the full path of the file to read
* @out_buf: double pointer for referring to the file contents buffer
* @out_buff_size: size of the contents read
*
* This API allocates a new, null-terminated buffer containing the contents of
* the file at @path. On success, @out_buf points to this new buffer, otherwise
* @out_buf is set to NULL.
*
* Consumers must free the allocated buffer by calling qdf_file_buf_free().
*
* Return: QDF_STATUS
*/
QDF_STATUS qdf_file_read_bytes(const char *path, char **out_buf,
unsigned int *out_buff_size);
/**
* qdf_file_buf_free() - free a previously allocated file buffer
* @file_buf: pointer to the file buffer to free
*
* This API is used in conjunction with qdf_file_read().
* This API is used in conjunction with qdf_file_read() and
* qdf_file_read_bytes().
*
* Return: None
*/

Ver fichero

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -121,3 +122,34 @@ void qdf_module_param_file_free(char *file_buf)
qdf_untracked_mem_free(file_buf);
}
#endif
QDF_STATUS qdf_file_read_bytes(const char *path, char **out_buf,
unsigned int *out_buff_size)
{
int errno;
const struct firmware *fw;
char *buf;
*out_buf = NULL;
errno = qdf_firmware_request_nowarn(&fw, path, NULL);
if (errno) {
qdf_err("Failed to read file %s", path);
return QDF_STATUS_E_FAILURE;
}
buf = qdf_mem_malloc(fw->size);
if (!buf) {
release_firmware(fw);
return QDF_STATUS_E_NOMEM;
}
qdf_mem_copy(buf, fw->data, fw->size);
*out_buff_size = fw->size;
*out_buf = buf;
release_firmware(fw);
return QDF_STATUS_SUCCESS;
}
qdf_export_symbol(qdf_file_read_bytes);