|
@@ -0,0 +1,131 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
|
|
|
+ *
|
|
|
+ * Permission to use, copy, modify, and/or distribute this software for
|
|
|
+ * any purpose with or without fee is hereby granted, provided that the
|
|
|
+ * above copyright notice and this permission notice appear in all
|
|
|
+ * copies.
|
|
|
+ *
|
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
|
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
|
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
|
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
+ * PERFORMANCE OF THIS SOFTWARE.
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * DOC: wlan_hdd_sysfs_wow_ito.c
|
|
|
+ *
|
|
|
+ * implementation for creating sysfs wow_ito
|
|
|
+ */
|
|
|
+
|
|
|
+#include <wlan_hdd_includes.h>
|
|
|
+#include "osif_psoc_sync.h"
|
|
|
+#include <wlan_hdd_sysfs.h>
|
|
|
+#include <wlan_hdd_sysfs_wow_ito.h>
|
|
|
+#include "wlan_pmo_ucfg_api.h"
|
|
|
+#include "cfg_ucfg_api.h"
|
|
|
+
|
|
|
+static ssize_t
|
|
|
+__hdd_sysfs_wow_ito_store(struct hdd_context *hdd_ctx,
|
|
|
+ struct kobj_attribute *attr,
|
|
|
+ const char *buf, size_t count)
|
|
|
+{
|
|
|
+ char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
|
|
|
+ char *sptr, *token;
|
|
|
+ uint8_t value;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if (!wlan_hdd_validate_modules_state(hdd_ctx))
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (!hdd_ctx->psoc)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
|
|
|
+ buf, count);
|
|
|
+ if (ret) {
|
|
|
+ hdd_err_rl("invalid input");
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ sptr = buf_local;
|
|
|
+ hdd_debug("wow_ito: count %zu buf_local:(%s)",
|
|
|
+ count, buf_local);
|
|
|
+
|
|
|
+ /* Get value */
|
|
|
+ token = strsep(&sptr, " ");
|
|
|
+ if (!token)
|
|
|
+ return -EINVAL;
|
|
|
+ if (kstrtou8(token, 0, &value))
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
+ if (!cfg_in_range(CFG_PMO_WOW_DATA_INACTIVITY_TIMEOUT, value)) {
|
|
|
+ hdd_err_rl("Invalid value %d", value);
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ ucfg_pmo_set_wow_data_inactivity_timeout(hdd_ctx->psoc, value);
|
|
|
+
|
|
|
+ return count;
|
|
|
+}
|
|
|
+
|
|
|
+static ssize_t
|
|
|
+hdd_sysfs_wow_ito_store(struct kobject *kobj,
|
|
|
+ struct kobj_attribute *attr,
|
|
|
+ const char *buf, size_t count)
|
|
|
+{
|
|
|
+ struct osif_psoc_sync *psoc_sync;
|
|
|
+ struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
|
|
|
+ ssize_t errno_size;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ret = wlan_hdd_validate_context(hdd_ctx);
|
|
|
+ if (ret)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
|
|
|
+ &psoc_sync);
|
|
|
+ if (errno_size)
|
|
|
+ return errno_size;
|
|
|
+
|
|
|
+ errno_size = __hdd_sysfs_wow_ito_store(hdd_ctx, attr, buf, count);
|
|
|
+
|
|
|
+ osif_psoc_sync_op_stop(psoc_sync);
|
|
|
+
|
|
|
+ return errno_size;
|
|
|
+}
|
|
|
+
|
|
|
+static struct kobj_attribute wow_ito_attribute =
|
|
|
+ __ATTR(wow_ito, 0220, NULL,
|
|
|
+ hdd_sysfs_wow_ito_store);
|
|
|
+
|
|
|
+int hdd_sysfs_wow_ito_create(struct kobject *driver_kobject)
|
|
|
+{
|
|
|
+ int error;
|
|
|
+
|
|
|
+ if (!driver_kobject) {
|
|
|
+ hdd_err("could not get driver kobject!");
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ error = sysfs_create_file(driver_kobject,
|
|
|
+ &wow_ito_attribute.attr);
|
|
|
+ if (error)
|
|
|
+ hdd_err("could not create wow_ito sysfs file");
|
|
|
+
|
|
|
+ return error;
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+hdd_sysfs_wow_ito_destroy(struct kobject *driver_kobject)
|
|
|
+{
|
|
|
+ if (!driver_kobject) {
|
|
|
+ hdd_err("could not get driver kobject!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ sysfs_remove_file(driver_kobject, &wow_ito_attribute.attr);
|
|
|
+}
|