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