1 /*
2  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved..
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #include <wlan_hdd_includes.h>
18 #include "osif_psoc_sync.h"
19 #include <wlan_hdd_sysfs.h>
20 #include <wlan_hdd_sysfs_runtime_pm.h>
21 #include "hif.h"
22 #include "hif_runtime_pm.h"
23 
hdd_sysfs_runtime_pm_show(struct kobject * kobj,struct kobj_attribute * attr,char * buf)24 static ssize_t hdd_sysfs_runtime_pm_show(struct kobject *kobj,
25 					 struct kobj_attribute *attr,
26 					 char *buf)
27 {
28 	return hif_rtpm_log_debug_stats(buf, HIF_RTPM_FILL_TYPE_SYSFS);
29 }
30 
31 static struct kobj_attribute runtime_pm_attribute =
32 	__ATTR(runtime_pm, 0440, hdd_sysfs_runtime_pm_show,
33 	       NULL);
34 
hdd_sysfs_runtime_pm_create(struct kobject * driver_kobject)35 int hdd_sysfs_runtime_pm_create(struct kobject *driver_kobject)
36 {
37 	int error;
38 
39 	if (!driver_kobject) {
40 		hdd_err("could not get driver kobject!");
41 		return -EINVAL;
42 	}
43 
44 	error = sysfs_create_file(driver_kobject,
45 				  &runtime_pm_attribute.attr);
46 	if (error)
47 		hdd_err("could not create runtime_pm sysfs file");
48 
49 	return error;
50 }
51 
52 void
hdd_sysfs_runtime_pm_destroy(struct kobject * driver_kobject)53 hdd_sysfs_runtime_pm_destroy(struct kobject *driver_kobject)
54 {
55 	if (!driver_kobject) {
56 		hdd_err("could not get driver kobject!");
57 		return;
58 	}
59 	sysfs_remove_file(driver_kobject, &runtime_pm_attribute.attr);
60 }
61