qcacmn: Add support to parse a string into uint16 array

Currently there is no api to parse a string to uint16 array.

Write an api to parse a string to uint16 array.

Change-Id: Idbde9d70c64bc131813f5789c0453c9b3736228b
CRs-Fixed: 2478267
This commit is contained in:
Ashish Kumar Dhanotiya
2019-06-19 21:32:41 +05:30
committed by nshrivas
부모 aa3385d78d
커밋 e2ff8ee254
2개의 변경된 파일66개의 추가작업 그리고 1개의 파일을 삭제

파일 보기

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2019 The Linux Foundation. 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
@@ -612,6 +612,55 @@ QDF_STATUS qdf_ipv6_parse(const char *ipv6_str, struct qdf_ipv6_addr *out_addr)
}
qdf_export_symbol(qdf_ipv6_parse);
QDF_STATUS qdf_uint16_array_parse(const char *in_str, uint16_t *out_array,
qdf_size_t array_size, qdf_size_t *out_size)
{
QDF_STATUS status;
bool negate;
qdf_size_t size = 0;
uint64_t value;
QDF_BUG(in_str);
if (!in_str)
return QDF_STATUS_E_INVAL;
QDF_BUG(out_array);
if (!out_array)
return QDF_STATUS_E_INVAL;
QDF_BUG(out_size);
if (!out_size)
return QDF_STATUS_E_INVAL;
while (size < array_size) {
status = __qdf_int_parse_lazy(&in_str, &value, &negate);
if (QDF_IS_STATUS_ERROR(status))
return status;
if ((uint16_t)value != value || negate)
return QDF_STATUS_E_RANGE;
in_str = qdf_str_left_trim(in_str);
switch (in_str[0]) {
case ',':
out_array[size++] = value;
in_str++;
break;
case '\0':
out_array[size++] = value;
*out_size = size;
return QDF_STATUS_SUCCESS;
default:
return QDF_STATUS_E_FAILURE;
}
}
return QDF_STATUS_E_FAILURE;
}
qdf_export_symbol(qdf_uint16_array_parse);
QDF_STATUS qdf_uint8_array_parse(const char *in_str, uint8_t *out_array,
qdf_size_t array_size, qdf_size_t *out_size)
{