xref: /wlan-driver/qca-wifi-host-cmn/qdf/linux/src/qdf_vfs.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2018 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  * This file provides OS dependent virtual fiesystem APIs
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #include "qdf_vfs.h"
25*5113495bSYour Name #include "qdf_util.h"
26*5113495bSYour Name #include "qdf_module.h"
27*5113495bSYour Name #include <linux/string.h>
28*5113495bSYour Name #include <linux/kobject.h>
29*5113495bSYour Name 
30*5113495bSYour Name QDF_STATUS
qdf_vfs_set_file_attributes(struct qdf_dev_obj * devobj,struct qdf_vfs_attr * attr)31*5113495bSYour Name qdf_vfs_set_file_attributes(struct qdf_dev_obj *devobj,
32*5113495bSYour Name 			    struct qdf_vfs_attr *attr)
33*5113495bSYour Name {
34*5113495bSYour Name 	int ret;
35*5113495bSYour Name 
36*5113495bSYour Name 	if (!devobj || !attr)
37*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
38*5113495bSYour Name 
39*5113495bSYour Name 	ret = sysfs_create_group((struct kobject *)devobj,
40*5113495bSYour Name 				 (struct attribute_group *)attr);
41*5113495bSYour Name 
42*5113495bSYour Name 	return qdf_status_from_os_return(ret);
43*5113495bSYour Name }
44*5113495bSYour Name 
45*5113495bSYour Name qdf_export_symbol(qdf_vfs_set_file_attributes);
46*5113495bSYour Name 
47*5113495bSYour Name QDF_STATUS
qdf_vfs_clear_file_attributes(struct qdf_dev_obj * devobj,struct qdf_vfs_attr * attr)48*5113495bSYour Name qdf_vfs_clear_file_attributes(struct qdf_dev_obj *devobj,
49*5113495bSYour Name 			      struct qdf_vfs_attr *attr)
50*5113495bSYour Name {
51*5113495bSYour Name 	if (!devobj || !attr)
52*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
53*5113495bSYour Name 
54*5113495bSYour Name 	sysfs_remove_group((struct kobject *)devobj,
55*5113495bSYour Name 			   (struct attribute_group *)attr);
56*5113495bSYour Name 
57*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
58*5113495bSYour Name }
59*5113495bSYour Name 
60*5113495bSYour Name qdf_export_symbol(qdf_vfs_clear_file_attributes);
61*5113495bSYour Name 
62*5113495bSYour Name QDF_STATUS
qdf_vfs_create_binfile(struct qdf_dev_obj * devobj,struct qdf_vf_bin_attr * attr)63*5113495bSYour Name qdf_vfs_create_binfile(struct qdf_dev_obj *devobj, struct qdf_vf_bin_attr *attr)
64*5113495bSYour Name {
65*5113495bSYour Name 	int ret;
66*5113495bSYour Name 
67*5113495bSYour Name 	if (!devobj || !attr)
68*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
69*5113495bSYour Name 
70*5113495bSYour Name 	ret = sysfs_create_bin_file((struct kobject *)devobj,
71*5113495bSYour Name 				    (struct bin_attribute *)attr);
72*5113495bSYour Name 
73*5113495bSYour Name 	return qdf_status_from_os_return(ret);
74*5113495bSYour Name }
75*5113495bSYour Name 
76*5113495bSYour Name qdf_export_symbol(qdf_vfs_create_binfile);
77*5113495bSYour Name 
78*5113495bSYour Name QDF_STATUS
qdf_vfs_delete_binfile(struct qdf_dev_obj * devobj,struct qdf_vf_bin_attr * attr)79*5113495bSYour Name qdf_vfs_delete_binfile(struct qdf_dev_obj *devobj, struct qdf_vf_bin_attr *attr)
80*5113495bSYour Name {
81*5113495bSYour Name 	if (!devobj || !attr)
82*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
83*5113495bSYour Name 
84*5113495bSYour Name 	sysfs_remove_bin_file((struct kobject *)devobj,
85*5113495bSYour Name 			      (struct bin_attribute *)attr);
86*5113495bSYour Name 
87*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
88*5113495bSYour Name }
89*5113495bSYour Name 
90*5113495bSYour Name qdf_export_symbol(qdf_vfs_delete_binfile);
91