qcacmn: Move existing qdf_str APIs to qdf_str

A set of files for string abstractions has recently been added to QDF.
Move any existing qdf_str_* APIs from qdf_mem to qdf_str.

Change-Id: I6e1e5d1edcdfae2af83a6497ebd872fba981cdec
CRs-Fixed: 2196098
This commit is contained in:
Dustin Brown
2018-02-26 11:50:23 -08:00
committed by snandini
父節點 68c9a549cb
當前提交 d5ff73ebc7
共有 5 個文件被更改,包括 66 次插入91 次删除

查看文件

@@ -34,6 +34,7 @@
#define __QDF_MEMORY_H #define __QDF_MEMORY_H
/* Include Files */ /* Include Files */
#include "qdf_str.h" /* TODO: update references and remove */
#include <qdf_types.h> #include <qdf_types.h>
#include <i_qdf_mem.h> #include <i_qdf_mem.h>
@@ -262,45 +263,6 @@ static inline int32_t qdf_mem_cmp(const void *memory1, const void *memory2,
return __qdf_mem_cmp(memory1, memory2, num_bytes); return __qdf_mem_cmp(memory1, memory2, num_bytes);
} }
/**
* qdf_str_cmp - Compare two strings
* @str1: First string
* @str2: Second string
* Return: =0 equal
* >0 not equal, if str1 sorts lexicographically after str2
* <0 not equal, if str1 sorts lexicographically before str2
*/
static inline int32_t qdf_str_cmp(const char *str1, const char *str2)
{
return __qdf_str_cmp(str1, str2);
}
/**
* qdf_str_eq - compare two null-terminated strings for equality
* @left: the string left of the equality
* @right: the string right of the equality
*
* This is a thin wrapper over `if (strcmp(left, right) == 0)` for clarity.
*
* Return: true if strings are equal
*/
static inline bool qdf_str_eq(const char *left, const char *right)
{
return qdf_str_cmp(left, right) == 0;
}
/**
* qdf_str_lcopy - Copy from one string to another
* @dest: destination string
* @src: source string
* @bytes: limit of num bytes to copy
* Return: =0 returns the initial value of dest
*/
static inline uint32_t qdf_str_lcopy(char *dest, const char *src, uint32_t bytes)
{
return __qdf_str_lcopy(dest, src, bytes);
}
/** /**
* qdf_mem_map_nbytes_single - Map memory for DMA * qdf_mem_map_nbytes_single - Map memory for DMA
* @osdev: pomter OS device context * @osdev: pomter OS device context
@@ -402,16 +364,6 @@ void qdf_mem_dma_sync_single_for_cpu(qdf_device_t osdev,
qdf_dma_addr_t bus_addr, qdf_dma_addr_t bus_addr,
qdf_size_t size, qdf_size_t size,
__dma_data_direction direction); __dma_data_direction direction);
/**
* qdf_str_len() - returns the length of a string
* @str: input string
* Return:
* length of string
*/
static inline int32_t qdf_str_len(const char *str)
{
return __qdf_str_len(str);
}
void qdf_mem_multi_pages_alloc(qdf_device_t osdev, void qdf_mem_multi_pages_alloc(qdf_device_t osdev,
struct qdf_mem_multi_page_t *pages, struct qdf_mem_multi_page_t *pages,

查看文件

@@ -40,6 +40,20 @@ static inline bool qdf_is_space(char c)
return __qdf_is_space(c); return __qdf_is_space(c);
} }
/**
* qdf_str_cmp - Compare two strings
* @str1: First string
* @str2: Second string
* Return:
* 0 - strings are equal
* <0 - str1 sorts lexicographically before str2
* >0 - str1 sorts lexicographically after str2
*/
static inline int32_t qdf_str_cmp(const char *str1, const char *str2)
{
return __qdf_str_cmp(str1, str2);
}
/** /**
* qdf_str_dup() - duplicate null-terminated string @src * qdf_str_dup() - duplicate null-terminated string @src
* @dest: double pointer to be populated * @dest: double pointer to be populated
@@ -51,6 +65,36 @@ static inline bool qdf_is_space(char c)
*/ */
QDF_STATUS qdf_str_dup(char **dest, const char *src); QDF_STATUS qdf_str_dup(char **dest, const char *src);
/**
* qdf_str_eq - compare two null-terminated strings for equality
* @left: the string left of the equality
* @right: the string right of the equality
*
* This is a thin wrapper over `if (strcmp(left, right) == 0)` for clarity.
*
* Return: true if strings are equal
*/
static inline bool qdf_str_eq(const char *left, const char *right)
{
return qdf_str_cmp(left, right) == 0;
}
/**
* qdf_str_lcopy - Bounded copy from one string to another
* @dest: destination string
* @src: source string
* @dest_size: max number of bytes to copy (incl. null terminator)
*
* If the return value is >= @dest_size, @dest has been truncated.
*
* Return: length of @src
*/
static inline qdf_size_t
qdf_str_lcopy(char *dest, const char *src, uint32_t dest_size)
{
return __qdf_str_lcopy(dest, src, dest_size);
}
/** /**
* qdf_str_left_trim() - Trim any leading whitespace from @str * qdf_str_left_trim() - Trim any leading whitespace from @str
* @str: the string to trim * @str: the string to trim
@@ -62,6 +106,17 @@ static inline const char *qdf_str_left_trim(const char *str)
return __qdf_str_left_trim(str); return __qdf_str_left_trim(str);
} }
/**
* qdf_str_len() - returns the length of a null-terminated string
* @str: input string
*
* Return: length of @str (without null terminator)
*/
static inline qdf_size_t qdf_str_len(const char *str)
{
return __qdf_str_len(str);
}
/** /**
* qdf_str_right_trim() - Trim any trailing whitespace from @str * qdf_str_right_trim() - Trim any trailing whitespace from @str
* @str: the string to trim * @str: the string to trim
@@ -92,9 +147,9 @@ static inline char *qdf_str_trim(char *str)
* @str: the string to get the length of * @str: the string to get the length of
* @limit: the maximum number of characters to check * @limit: the maximum number of characters to check
* *
* Return: length of @str, or @limit if the end is not found * Return: the less of @limit or the length of @str (without null terminator)
*/ */
static inline qdf_size_t qdf_str_nlen(const char *str, size_t limit) static inline qdf_size_t qdf_str_nlen(const char *str, qdf_size_t limit)
{ {
return __qdf_str_nlen(str, limit); return __qdf_str_nlen(str, limit);
} }

查看文件

@@ -24,8 +24,13 @@
#ifndef __I_QDF_STR_H #ifndef __I_QDF_STR_H
#define __I_QDF_STR_H #define __I_QDF_STR_H
#include "string.h"
#define __qdf_is_space(c) isspace(c) #define __qdf_is_space(c) isspace(c)
#define __qdf_str_cmp(left, right) strcmp(left, right)
#define __qdf_str_lcopy(dest, src, dest_size) strlcpy(dest, src, dest_size)
const char *__qdf_str_left_trim(const char *str); const char *__qdf_str_left_trim(const char *str);
#define __qdf_str_len(str) strlen(str)
char *__qdf_str_trim(char *str); char *__qdf_str_trim(char *str);
#define __qdf_str_nlen(str, limit) strnlen(str, limit) #define __qdf_str_nlen(str, limit) strnlen(str, limit)

查看文件

@@ -107,34 +107,6 @@ typedef struct __qdf_mempool_ctxt {
/* typedef for dma_data_direction */ /* typedef for dma_data_direction */
typedef enum dma_data_direction __dma_data_direction; typedef enum dma_data_direction __dma_data_direction;
/**
* __qdf_str_cmp() - Compare two strings
* @str1: First string
* @str2: Second string
*
* Return: =0 equal
* >0 not equal, if str1 sorts lexicographically after str2
* <0 not equal, if str1 sorts lexicographically before str2
*/
static inline int32_t __qdf_str_cmp(const char *str1, const char *str2)
{
return strcmp(str1, str2);
}
/**
* __qdf_str_lcopy() - Copy from one string to another
* @dest: destination string
* @src: source string
* @bytes: limit of num bytes to copy
*
* @return: 0 returns the initial value of dest
*/
static inline uint32_t __qdf_str_lcopy(char *dest, const char *src,
uint32_t bytes)
{
return strlcpy(dest, src, bytes);
}
/** /**
* __qdf_dma_dir_to_os() - Convert DMA data direction to OS specific enum * __qdf_dma_dir_to_os() - Convert DMA data direction to OS specific enum
* @dir: QDF DMA data direction * @dir: QDF DMA data direction
@@ -211,17 +183,6 @@ void __qdf_mempool_free(qdf_device_t osdev, __qdf_mempool_t pool, void *buf);
#define __qdf_mempool_elem_size(_pool) ((_pool)->elem_size) #define __qdf_mempool_elem_size(_pool) ((_pool)->elem_size)
#endif #endif
/**
* __qdf_str_len() - returns the length of a string
* @str: input string
* Return:
* length of string
*/
static inline int32_t __qdf_str_len(const char *str)
{
return strlen(str);
}
/** /**
* __qdf_mem_cmp() - memory compare * __qdf_mem_cmp() - memory compare
* @memory1: pointer to one location in memory to compare. * @memory1: pointer to one location in memory to compare.

查看文件

@@ -24,11 +24,13 @@
#ifndef __I_QDF_STR_H #ifndef __I_QDF_STR_H
#define __I_QDF_STR_H #define __I_QDF_STR_H
#include "linux/ctype.h"
#include "linux/string.h" #include "linux/string.h"
#define __qdf_is_space(c) isspace(c) #define __qdf_is_space(c) isspace(c)
#define __qdf_str_cmp(left, right) strcmp(left, right)
#define __qdf_str_lcopy(dest, src, dest_size) strlcpy(dest, src, dest_size)
#define __qdf_str_left_trim(str) skip_spaces(str) #define __qdf_str_left_trim(str) skip_spaces(str)
#define __qdf_str_len(str) strlen(str)
#define __qdf_str_trim(str) strim(str) #define __qdf_str_trim(str) strim(str)
#define __qdf_str_nlen(str, limit) strnlen(str, limit) #define __qdf_str_nlen(str, limit) strnlen(str, limit)