瀏覽代碼

qcacmn: Fix cfg_in_range for non-ini values

Currently, the macro type and the "is an ini" value information are
clubbed to together in the cfg component. This lead to not being able to
use the macro type with non-ini configuration values. Split macro type
and "is an ini" value information in the cfg component so that
cfg_in_range can be used with non-ini configuration values.

Change-Id: If63f222cf21a45f0d7d3809f1be845ecc2b2cd65
CRs-Fixed: 2278656
Dustin Brown 6 年之前
父節點
當前提交
46a32752de
共有 4 個文件被更改,包括 67 次插入50 次删除
  1. 32 24
      cfg/inc/cfg_define.h
  2. 16 8
      cfg/inc/cfg_ucfg_api.h
  3. 10 9
      cfg/inc/i_cfg.h
  4. 9 9
      cfg/src/cfg.c

+ 32 - 24
cfg/inc/cfg_define.h

@@ -29,52 +29,60 @@ enum cfg_fallback_behavior {
 };
 
 #define rm_parens(...) __VA_ARGS__
-#define __CFG(id, mtype, args...) __CFG_##mtype(id, mtype, args)
+#define __CFG(id, is_ini, mtype, args...) \
+	__CFG_##is_ini##_##mtype(id, mtype, args)
 #define _CFG(id, args) __CFG(id, args)
 #define CFG(id) _CFG(__##id, rm_parens id)
 
-#define __CFG_INT(args...) __CFG_ANY(args)
-#define __CFG_UINT(args...) __CFG_ANY(args)
-#define __CFG_BOOL(args...) __CFG_ANY(args)
-#define __CFG_STRING(args...) __CFG_ANY(args)
-#define __CFG_MAC(args...) __CFG_ANY(args)
-#define __CFG_IPV4(args...) __CFG_ANY(args)
-#define __CFG_IPV6(args...) __CFG_ANY(args)
+#define __CFG_INI_INT(args...) __CFG_INI(args)
+#define __CFG_INI_UINT(args...) __CFG_INI(args)
+#define __CFG_INI_BOOL(args...) __CFG_INI(args)
+#define __CFG_INI_STRING(args...) __CFG_INI(args)
+#define __CFG_INI_MAC(args...) __CFG_INI(args)
+#define __CFG_INI_IPV4(args...) __CFG_INI(args)
+#define __CFG_INI_IPV6(args...) __CFG_INI(args)
+#define __CFG_INI(args...) (args)
 
-#define __CFG_ANY(args...) (args)
-#define __CFG_NONE(args...)
+#define __CFG_NON_INI_INT(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_UINT(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_BOOL(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_STRING(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_MAC(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_IPV4(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI_IPV6(args...) __CFG_NON_INI(args)
+#define __CFG_NON_INI(args...)
 
 /* configuration available in ini */
 #define CFG_INI_INT(name, min, max, def, fallback, desc) \
-	(INT, int32_t, name, min, max, fallback, desc, def)
+	(INI, INT, int32_t, name, min, max, fallback, desc, def)
 #define CFG_INI_UINT(name, min, max, def, fallback, desc) \
-	(UINT, uint32_t, name, min, max, fallback, desc, def)
+	(INI, UINT, uint32_t, name, min, max, fallback, desc, def)
 #define CFG_INI_BOOL(name, def, desc) \
-	(BOOL, bool, name, -1, -1, -1, desc, def)
+	(INI, BOOL, bool, name, -1, -1, -1, desc, def)
 #define CFG_INI_STRING(name, min_len, max_len, def, desc) \
-	(STRING, char *, name, min_len, max_len, -1, desc, def)
+	(INI, STRING, char *, name, min_len, max_len, -1, desc, def)
 #define CFG_INI_MAC(name, def, desc) \
-	(MAC, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
+	(INI, MAC, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
 #define CFG_INI_IPV4(name, def, desc) \
-	(IPV4, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
+	(INI, IPV4, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
 #define CFG_INI_IPV6(name, def, desc) \
-	(IPV6, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
+	(INI, IPV6, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
 
 /* configuration *not* available in ini */
 #define CFG_INT(name, min, max, def, fallback, desc) \
-	(NONE, int32_t, name, min, max, fallback, desc, def)
+	(NON_INI, INT, int32_t, name, min, max, fallback, desc, def)
 #define CFG_UINT(name, min, max, def, fallback, desc) \
-	(NONE, uint32_t, name, min, max, fallback, desc, def)
+	(NON_INI, UINT, uint32_t, name, min, max, fallback, desc, def)
 #define CFG_BOOL(name, def, desc) \
-	(NONE, bool, name, -1, -1, -1, desc, def)
+	(NON_INI, BOOL, bool, name, -1, -1, -1, desc, def)
 #define CFG_STRING(name, min_len, max_len, def, desc) \
-	(NONE, char *, name, min_len, max_len, -1, desc, def)
+	(NON_INI, STRING, char *, name, min_len, max_len, -1, desc, def)
 #define CFG_MAC(name, def, desc) \
-	(NONE, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
+	(NON_INI, MAC, struct qdf_mac_addr, name, -1, -1, -1, desc, def)
 #define CFG_IPV4(name, def, desc) \
-	(NONE, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
+	(NON_INI, IPV4, struct qdf_ipv4_addr, name, -1, -1, -1, desc, def)
 #define CFG_IPV6(name, def, desc) \
-	(NONE, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
+	(NON_INI, IPV6, struct qdf_ipv6_addr, name, -1, -1, -1, desc, def)
 
 /* utility macros/functions */
 #ifdef MCL

+ 16 - 8
cfg/inc/cfg_ucfg_api.h

@@ -174,28 +174,36 @@ QDF_STATUS cfg_psoc_parse(struct wlan_objmgr_psoc *psoc, const char *path);
 
 #define cfg_id(id) #id
 
-#define __cfg_mtype(mtype, ctype, name, min, max, fallback, desc, def...) mtype
+#define __cfg_mtype(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	mtype
 #define cfg_mtype(id) do_call(__cfg_mtype, id)
 
-#define __cfg_type(mtype, ctype, name, min, max, fallback, desc, def...) ctype
+#define __cfg_type(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	ctype
 #define cfg_type(id) do_call(__cfg_type, id)
 
-#define __cfg_name(mtype, ctype, name, min, max, fallback, desc, def...) name
+#define __cfg_name(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	name
 #define cfg_name(id) do_call(__cfg_name, id)
 
-#define __cfg_min(mtype, ctype, name, min, max, fallback, desc, def...) min
+#define __cfg_min(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	min
 #define cfg_min(id) do_call(__cfg_min, id)
 
-#define __cfg_max(mtype, ctype, name, min, max, fallback, desc, def...) max
+#define __cfg_max(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	max
 #define cfg_max(id) do_call(__cfg_max, id)
 
-#define __cfg_fb(mtype, ctype, name, min, max, fallback, desc, def...) fallback
+#define __cfg_fb(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	fallback
 #define cfg_fallback(id) do_call(__cfg_fb, id)
 
-#define __cfg_desc(mtype, ctype, name, min, max, fallback, desc, def...) desc
+#define __cfg_desc(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	desc
 #define cfg_description(id) do_call(__cfg_desc, id)
 
-#define __cfg_def(mtype, ctype, name, min, max, fallback, desc, def...) def
+#define __cfg_def(ini, mtype, ctype, name, min, max, fallback, desc, def...) \
+	def
 #define cfg_default(id) do_call(__cfg_def, id)
 
 #define __cfg_str(id...) #id

+ 10 - 9
cfg/inc/i_cfg.h

@@ -38,11 +38,12 @@
 
 /* define global config values structure */
 
-#undef __CFG_STRING
-#define __CFG_STRING(id, mtype, ctype, name, min, max, fallback, desc, def...) \
-	const char id##_internal[max + 1];
-#undef __CFG_ANY
-#define __CFG_ANY(id, mtype, ctype, name, min, max, fallback, desc, def...) \
+#undef __CFG_INI_STRING
+#define __CFG_INI_STRING(id, mtype, ctype, name, min, max, fallback, desc, \
+			 def...) \
+	const char id##_internal[(max) + 1];
+#undef __CFG_INI
+#define __CFG_INI(id, mtype, ctype, name, min, max, fallback, desc, def...) \
 	const ctype id##_internal;
 
 struct cfg_values {
@@ -50,10 +51,10 @@ struct cfg_values {
 	CFG_ALL
 };
 
-#undef __CFG_STRING
-#define __CFG_STRING(args...) __CFG_ANY(args)
-#undef __CFG_ANY
-#define __CFG_ANY(args...) (args)
+#undef __CFG_INI_STRING
+#define __CFG_INI_STRING(args...) __CFG_INI(args)
+#undef __CFG_INI
+#define __CFG_INI(args...) (args)
 
 struct cfg_values *cfg_psoc_get_values(struct wlan_objmgr_psoc *psoc);
 

+ 9 - 9
cfg/src/cfg.c

@@ -273,8 +273,8 @@ cfg_ipv6_item_handler(struct cfg_value_store *store,
 }
 
 /* populate metadata lookup table */
-#undef __CFG_ANY
-#define __CFG_ANY(_id, _mtype, _ctype, _name, _min, _max, _fallback, ...) \
+#undef __CFG_INI
+#define __CFG_INI(_id, _mtype, _ctype, _name, _min, _max, _fallback, ...) \
 { \
 	.name = _name, \
 	.field_offset = qdf_offsetof(struct cfg_values, _id##_internal), \
@@ -300,17 +300,17 @@ static const struct cfg_meta cfg_meta_lookup_table[] = {
 
 static void cfg_store_set_defaults(struct cfg_value_store *store)
 {
-#undef __CFG_ANY
-#define __CFG_ANY(id, mtype, ctype, name, min, max, fallback, desc, def...) \
+#undef __CFG_INI
+#define __CFG_INI(id, mtype, ctype, name, min, max, fallback, desc, def...) \
 	ctype id = def;
 
 	CFG_ALL
 
-#undef __CFG_STRING
-#define __CFG_STRING(id, mtype, ctype, name, min_len, max_len, ...) \
-	qdf_str_lcopy((char *)&store->values.id##_internal, id, max_len + 1);
-#undef __CFG_ANY
-#define __CFG_ANY(id, mtype, ctype, name, min, max, fallback, desc, def...) \
+#undef __CFG_INI_STRING
+#define __CFG_INI_STRING(id, mtype, ctype, name, min_len, max_len, ...) \
+	qdf_str_lcopy((char *)&store->values.id##_internal, id, (max_len) + 1);
+#undef __CFG_INI
+#define __CFG_INI(id, mtype, ctype, name, min, max, fallback, desc, def...) \
 	*(ctype *)&store->values.id##_internal = id;
 
 	CFG_ALL