qcacld-3.0: Add sysfs print api
Current code does not have a way to abstract printing to sysfs file resulting in duplicate code when wanting to add sysfs output to existing functionalities. Fix this by creating API which allows for easy printing to a sysfs file and is compatible with qdf_abstract_print. Change-Id: Ide71dc1e5f869f03ce66500eed50bb55781dc228 CRs-Fixed: 3426189
This commit is contained in:

committed by
Madan Koyyalamudi

parent
475329074b
commit
05ddf01c24
@@ -20,6 +20,18 @@
|
|||||||
#ifndef _WLAN_HDD_SYSFS_H_
|
#ifndef _WLAN_HDD_SYSFS_H_
|
||||||
#define _WLAN_HDD_SYSFS_H_
|
#define _WLAN_HDD_SYSFS_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct hdd_sysfs_print_ctx - keeps track of sysfs buffer printing
|
||||||
|
* @buf: pointer to sysfs char buffer
|
||||||
|
* @idx: current position in char buffer
|
||||||
|
* @new_line: if set true, newline will be added at end of each print
|
||||||
|
*/
|
||||||
|
struct hdd_sysfs_print_ctx {
|
||||||
|
char *buf;
|
||||||
|
int idx;
|
||||||
|
bool new_line;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef WLAN_SYSFS
|
#ifdef WLAN_SYSFS
|
||||||
|
|
||||||
#define MAX_SYSFS_USER_COMMAND_SIZE_LENGTH (32)
|
#define MAX_SYSFS_USER_COMMAND_SIZE_LENGTH (32)
|
||||||
@@ -100,6 +112,24 @@ void hdd_sysfs_create_wifi_root_obj(void);
|
|||||||
*/
|
*/
|
||||||
void hdd_sysfs_destroy_wifi_root_obj(void);
|
void hdd_sysfs_destroy_wifi_root_obj(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hdd_sysfs_print() - print to sysfs char buffer
|
||||||
|
* @ctx: pointer to struct hdd_sysfs_print_ctx
|
||||||
|
* @fmt: string format
|
||||||
|
*
|
||||||
|
* To use this function, create a hdd_sysfs_print_ctx variable, set
|
||||||
|
* idx to 0, set buf to the outbuffer and set new_line to true or false.
|
||||||
|
* Pass this context struct to every function call.
|
||||||
|
* Using this function will then write the data to the outbuffer and
|
||||||
|
* increment the counter.
|
||||||
|
*
|
||||||
|
* The context pointer is void to be compatible with qdf_abstract_print,
|
||||||
|
* to allow for abstract printing.
|
||||||
|
*
|
||||||
|
* Return: Number of characters written
|
||||||
|
*/
|
||||||
|
int hdd_sysfs_print(void *ctx, const char *fmt, ...);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static inline int
|
static inline int
|
||||||
hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
|
hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
|
||||||
@@ -139,6 +169,7 @@ static inline void hdd_sysfs_create_wifi_root_obj(void)
|
|||||||
static inline void hdd_sysfs_destroy_wifi_root_obj(void)
|
static inline void hdd_sysfs_destroy_wifi_root_obj(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* End of WLAN SYSFS*/
|
#endif /* End of WLAN SYSFS*/
|
||||||
|
|
||||||
#endif /* End of _WLAN_HDD_SYSFS_H_ */
|
#endif /* End of _WLAN_HDD_SYSFS_H_ */
|
||||||
|
@@ -735,6 +735,30 @@ void hdd_destroy_wifi_feature_interface_sysfs_file(void)
|
|||||||
hdd_sysfs_destroy_wifi_feature_interface(wifi_kobject);
|
hdd_sysfs_destroy_wifi_feature_interface(wifi_kobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hdd_sysfs_print(void *ctx, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int ret = -1;
|
||||||
|
struct hdd_sysfs_print_ctx *p_ctx = ctx;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
if (ctx) {
|
||||||
|
ret = vscnprintf(p_ctx->buf + p_ctx->idx,
|
||||||
|
PAGE_SIZE - p_ctx->idx, fmt, args);
|
||||||
|
p_ctx->idx += ret;
|
||||||
|
if (p_ctx->new_line) {
|
||||||
|
ret += scnprintf(p_ctx->buf + p_ctx->idx,
|
||||||
|
PAGE_SIZE - p_ctx->idx,
|
||||||
|
"\n");
|
||||||
|
p_ctx->idx += ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
|
#ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
|
||||||
static int hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter
|
static int hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter
|
||||||
*adapter)
|
*adapter)
|
||||||
|
Reference in New Issue
Block a user