From 360ad1d34f68f3ba51c781af6d65b707dbe4e999 Mon Sep 17 00:00:00 2001 From: Sathyanarayanan Esakkiappan Date: Thu, 2 Aug 2018 14:04:07 +0530 Subject: [PATCH] qcacmn: Wrapper API for memset_io and memcpy_toio Inclusion of Wrapper API for memset_io and memcpy_toio Change-Id: I89b94e201f043d37b782e855f198dbc00b89ac15 --- qdf/inc/qdf_mem.h | 5 +++++ qdf/linux/src/qdf_mem.c | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/qdf/inc/qdf_mem.h b/qdf/inc/qdf_mem.h index 26534910c1..9c81257040 100644 --- a/qdf/inc/qdf_mem.h +++ b/qdf/inc/qdf_mem.h @@ -224,6 +224,11 @@ void qdf_mem_free_consistent(qdf_device_t osdev, void *dev, void *qdf_mem_alloc_outline(qdf_device_t osdev, qdf_size_t size); +void qdf_mem_set_io(void *ptr, uint32_t num_bytes, uint32_t value); + +void qdf_mem_copy_toio(void *dst_addr, const void *src_addr, + uint32_t num_bytes); + void qdf_mem_set(void *ptr, uint32_t num_bytes, uint32_t value); void qdf_mem_zero(void *ptr, uint32_t num_bytes); diff --git a/qdf/linux/src/qdf_mem.c b/qdf/linux/src/qdf_mem.c index 718d50df0f..82d8119555 100644 --- a/qdf/linux/src/qdf_mem.c +++ b/qdf/linux/src/qdf_mem.c @@ -1510,6 +1510,52 @@ void qdf_mem_zero(void *ptr, uint32_t num_bytes) } qdf_export_symbol(qdf_mem_zero); +/** + * qdf_mem_copy_toio() - copy memory + * @dst_addr: Pointer to destination memory location (to copy to) + * @src_addr: Pointer to source memory location (to copy from) + * @num_bytes: Number of bytes to copy. + * + * Return: none + */ +void qdf_mem_copy_toio(void *dst_addr, const void *src_addr, uint32_t num_bytes) +{ + if (0 == num_bytes) { + /* special case where dst_addr or src_addr can be NULL */ + return; + } + + if ((!dst_addr) || (!src_addr)) { + QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, + "%s called with NULL parameter, source:%pK destination:%pK", + __func__, src_addr, dst_addr); + QDF_ASSERT(0); + return; + } + memcpy_toio(dst_addr, src_addr, num_bytes); +} + +qdf_export_symbol(qdf_mem_copy_toio); + +/** + * qdf_mem_set_io() - set (fill) memory with a specified byte value. + * @ptr: Pointer to memory that will be set + * @value: Byte set in memory + * @num_bytes: Number of bytes to be set + * + * Return: None + */ +void qdf_mem_set_io(void *ptr, uint32_t num_bytes, uint32_t value) +{ + if (!ptr) { + qdf_print("%s called with NULL parameter ptr", __func__); + return; + } + memset_io(ptr, value, num_bytes); +} + +qdf_export_symbol(qdf_mem_set_io); + /** * qdf_mem_set() - set (fill) memory with a specified byte value. * @ptr: Pointer to memory that will be set