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