xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_vfs.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
1 /*
2  * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: qdf_vfs
21  * QCA driver framework (QDF) virtual filesystem management APIs
22  */
23 
24 #if !defined(__I_QDF_VFS_H)
25 #define __I_QDF_VFS_H
26 
27 /* Include Files */
28 #include <qdf_types.h>
29 
30 struct qdf_vfs_attr;
31 struct qdf_vf_bin_attr;
32 struct qdf_dev_obj;
33 
34 /**
35  * __qdf_vfs_set_file_attributes() - set file attributes
36  * @devobj: Device object
37  * @attr: File attribute
38  *
39  * This function will set the attributes of a file
40  *
41  * Return: QDF_STATUS_SUCCESS on success
42  */
43 static inline QDF_STATUS
44 __qdf_vfs_set_file_attributes(struct qdf_dev_obj *devobj,
45 			      struct qdf_vfs_attr *attr)
46 {
47 	int ret;
48 
49 	ret = sysfs_create_group((struct kobject *)devobj,
50 				 (struct attribute_group *)attr);
51 
52 	return qdf_status_from_os_return(ret);
53 }
54 
55 /**
56  * __qdf_vfs_clear_file_attributes() - clear file attributes
57  * @devobj: Device object
58  * @attr: File attribute
59  *
60  * This function will clear the attributes of a file
61  *
62  * Return: QDF_STATUS_SUCCESS on success
63  */
64 static inline QDF_STATUS
65 __qdf_vfs_clear_file_attributes(struct qdf_dev_obj *devobj,
66 				struct qdf_vfs_attr *attr)
67 {
68 	sysfs_remove_group((struct kobject *)devobj,
69 			   (struct attribute_group *)attr);
70 
71 	return QDF_STATUS_SUCCESS;
72 }
73 
74 /**
75  * __qdf_vfs_create_binfile() - create binfile
76  * @devobj: Device object
77  * @attr: File attribute
78  *
79  * This function will create a binary file
80  *
81  * Return: QDF_STATUS_SUCCESS on success
82  */
83 static inline QDF_STATUS
84 __qdf_vfs_create_binfile(struct qdf_dev_obj *devobj,
85 			 struct qdf_vf_bin_attr *attr)
86 {
87 	int ret;
88 
89 	ret = sysfs_create_bin_file((struct kobject *)devobj,
90 				    (struct bin_attribute *)attr);
91 
92 	return qdf_status_from_os_return(ret);
93 }
94 
95 /**
96  * __qdf_vfs_delete_binfile() - delete binfile
97  * @devobj: Device object
98  * @attr: File attribute
99  *
100  * This function will delete a binary file
101  *
102  * Return: QDF_STATUS_SUCCESS on success
103  */
104 static inline QDF_STATUS
105 __qdf_vfs_delete_binfile(struct qdf_dev_obj *devobj,
106 			 struct qdf_vf_bin_attr *attr)
107 {
108 	sysfs_remove_bin_file((struct kobject *)devobj,
109 			      (struct bin_attribute *)attr);
110 
111 	return QDF_STATUS_SUCCESS;
112 }
113 #endif /* __I_QDF_VFS_H */
114