2007-02-10 21:25:27 +07:00
|
|
|
#include <linux/dcache.h>
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/delay.h>
|
2011-06-06 17:43:46 +07:00
|
|
|
#include <linux/hardirq.h>
|
2007-02-10 21:25:27 +07:00
|
|
|
#include <linux/mm.h>
|
2007-10-08 14:43:02 +07:00
|
|
|
#include <linux/string.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2011-05-28 03:14:23 +07:00
|
|
|
#include <linux/export.h>
|
2007-05-25 11:37:28 +07:00
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
#include "decl.h"
|
2007-12-18 11:48:31 +07:00
|
|
|
#include "cmd.h"
|
2010-06-14 23:31:26 +07:00
|
|
|
#include "debugfs.h"
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static struct dentry *lbs_dir;
|
2007-02-10 21:25:27 +07:00
|
|
|
static char *szStates[] = {
|
|
|
|
"Connected",
|
|
|
|
"Disconnected"
|
|
|
|
};
|
|
|
|
|
2007-05-25 11:37:28 +07:00
|
|
|
#ifdef PROC_DEBUG
|
2008-03-19 20:25:58 +07:00
|
|
|
static void lbs_debug_init(struct lbs_private *priv);
|
2007-05-25 11:37:28 +07:00
|
|
|
#endif
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
static ssize_t write_file_dummy(struct file *file, const char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const size_t len = PAGE_SIZE;
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t pos = 0;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
|
|
|
ssize_t res;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
pos += snprintf(buf+pos, len-pos, "state = %s\n",
|
2007-12-09 03:04:36 +07:00
|
|
|
szStates[priv->connect_status]);
|
2007-02-10 21:25:27 +07:00
|
|
|
pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
|
2007-12-09 03:04:36 +07:00
|
|
|
(u32) priv->regioncode);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
|
|
|
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_sleepparams_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *user_buf, size_t count,
|
|
|
|
loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-12-18 11:48:31 +07:00
|
|
|
ssize_t buf_size, ret;
|
|
|
|
struct sleep_params sp;
|
2007-02-10 21:25:27 +07:00
|
|
|
int p1, p2, p3, p4, p5, p6;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, user_buf, buf_size)) {
|
2007-12-18 11:48:31 +07:00
|
|
|
ret = -EFAULT;
|
2007-02-10 21:25:27 +07:00
|
|
|
goto out_unlock;
|
|
|
|
}
|
2007-12-18 11:48:31 +07:00
|
|
|
ret = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6);
|
|
|
|
if (ret != 6) {
|
|
|
|
ret = -EINVAL;
|
2007-02-10 21:25:27 +07:00
|
|
|
goto out_unlock;
|
|
|
|
}
|
2007-12-18 11:48:31 +07:00
|
|
|
sp.sp_error = p1;
|
|
|
|
sp.sp_offset = p2;
|
|
|
|
sp.sp_stabletime = p3;
|
|
|
|
sp.sp_calcontrol = p4;
|
|
|
|
sp.sp_extsleepclk = p5;
|
|
|
|
sp.sp_reserved = p6;
|
|
|
|
|
|
|
|
ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_SET, &sp);
|
|
|
|
if (!ret)
|
|
|
|
ret = count;
|
|
|
|
else if (ret > 0)
|
|
|
|
ret = -EINVAL;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
2007-12-18 11:48:31 +07:00
|
|
|
return ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-12-18 11:48:31 +07:00
|
|
|
ssize_t ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t pos = 0;
|
2007-12-18 11:48:31 +07:00
|
|
|
struct sleep_params sp;
|
2007-02-10 21:25:27 +07:00
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 11:48:31 +07:00
|
|
|
ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
|
|
|
|
if (ret)
|
2007-02-10 21:25:27 +07:00
|
|
|
goto out_unlock;
|
|
|
|
|
2007-12-18 11:48:31 +07:00
|
|
|
pos += snprintf(buf, len, "%d %d %d %d %d %d\n", sp.sp_error,
|
|
|
|
sp.sp_offset, sp.sp_stabletime,
|
|
|
|
sp.sp_calcontrol, sp.sp_extsleepclk,
|
|
|
|
sp.sp_reserved);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 11:48:31 +07:00
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
2007-12-18 11:48:31 +07:00
|
|
|
return ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2010-07-08 08:13:48 +07:00
|
|
|
static ssize_t lbs_host_sleep_write(struct file *file,
|
|
|
|
const char __user *user_buf, size_t count,
|
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = file->private_data;
|
|
|
|
ssize_t buf_size, ret;
|
|
|
|
int host_sleep;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, user_buf, buf_size)) {
|
|
|
|
ret = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
ret = sscanf(buf, "%d", &host_sleep);
|
|
|
|
if (ret != 1) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_sleep == 0)
|
|
|
|
ret = lbs_set_host_sleep(priv, 0);
|
|
|
|
else if (host_sleep == 1) {
|
|
|
|
if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
|
2011-05-03 06:49:15 +07:00
|
|
|
netdev_info(priv->dev,
|
|
|
|
"wake parameters not configured\n");
|
2010-07-08 08:13:48 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
ret = lbs_set_host_sleep(priv, 1);
|
|
|
|
} else {
|
2011-05-03 06:49:15 +07:00
|
|
|
netdev_err(priv->dev, "invalid option\n");
|
2010-07-08 08:13:48 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = count;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv = file->private_data;
|
|
|
|
ssize_t ret;
|
|
|
|
size_t pos = 0;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pos += snprintf(buf, len, "%d\n", priv->is_host_sleep_activated);
|
|
|
|
|
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
|
|
|
|
|
|
|
free_page(addr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
/*
|
|
|
|
* When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might
|
|
|
|
* get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the
|
|
|
|
* firmware. Here's an example:
|
|
|
|
* 04 01 02 00 00 00 05 01 02 00 00 00 06 01 02 00
|
|
|
|
* 00 00 07 01 02 00 3c 00 00 00 00 00 00 00 03 03
|
|
|
|
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
|
|
|
*
|
|
|
|
* The 04 01 is the TLV type (here TLV_TYPE_RSSI_LOW), 02 00 is the length,
|
|
|
|
* 00 00 are the data bytes of this TLV. For this TLV, their meaning is
|
|
|
|
* defined in mrvlietypes_thresholds
|
|
|
|
*
|
|
|
|
* This function searches in this TLV data chunk for a given TLV type
|
|
|
|
* and returns a pointer to the first data byte of the TLV, or to NULL
|
|
|
|
* if the TLV hasn't been found.
|
|
|
|
*/
|
2007-12-18 14:01:37 +07:00
|
|
|
static void *lbs_tlv_find(uint16_t tlv_type, const uint8_t *tlv, uint16_t size)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2009-05-23 07:03:09 +07:00
|
|
|
struct mrvl_ie_header *tlv_h;
|
2007-12-18 14:01:37 +07:00
|
|
|
uint16_t length;
|
|
|
|
ssize_t pos = 0;
|
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
while (pos < size) {
|
2009-05-23 07:03:09 +07:00
|
|
|
tlv_h = (struct mrvl_ie_header *) tlv;
|
2007-12-18 14:01:37 +07:00
|
|
|
if (!tlv_h->len)
|
2007-11-26 16:07:14 +07:00
|
|
|
return NULL;
|
2007-12-18 14:01:37 +07:00
|
|
|
if (tlv_h->type == cpu_to_le16(tlv_type))
|
|
|
|
return tlv_h;
|
|
|
|
length = le16_to_cpu(tlv_h->len) + sizeof(*tlv_h);
|
2007-11-26 16:07:14 +07:00
|
|
|
pos += length;
|
|
|
|
tlv += length;
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
|
|
|
|
struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-12-18 14:01:37 +07:00
|
|
|
struct cmd_ds_802_11_subscribe_event *subscribed;
|
2009-05-23 07:03:09 +07:00
|
|
|
struct mrvl_ie_thresholds *got;
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-12-18 14:01:37 +07:00
|
|
|
ssize_t ret = 0;
|
2007-11-26 16:07:14 +07:00
|
|
|
size_t pos = 0;
|
2007-12-18 14:01:37 +07:00
|
|
|
char *buf;
|
2007-11-26 16:07:14 +07:00
|
|
|
u8 value;
|
|
|
|
u8 freq;
|
2007-12-10 18:19:55 +07:00
|
|
|
int events = 0;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
buf = (char *)get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
subscribed = kzalloc(sizeof(*subscribed), GFP_KERNEL);
|
|
|
|
if (!subscribed) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_page;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
subscribed->hdr.size = cpu_to_le16(sizeof(*subscribed));
|
|
|
|
subscribed->action = cpu_to_le16(CMD_ACT_GET);
|
|
|
|
|
|
|
|
ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, subscribed);
|
|
|
|
if (ret)
|
|
|
|
goto out_cmd;
|
|
|
|
|
2007-12-10 18:19:55 +07:00
|
|
|
got = lbs_tlv_find(tlv_type, subscribed->tlv, sizeof(subscribed->tlv));
|
2007-11-26 16:07:14 +07:00
|
|
|
if (got) {
|
|
|
|
value = got->value;
|
|
|
|
freq = got->freq;
|
2007-12-10 18:19:55 +07:00
|
|
|
events = le16_to_cpu(subscribed->events);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
pos += snprintf(buf, len, "%d %d %d\n", value, freq,
|
2007-12-18 14:01:37 +07:00
|
|
|
!!(events & event_mask));
|
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
out_cmd:
|
|
|
|
kfree(subscribed);
|
|
|
|
|
|
|
|
out_page:
|
|
|
|
free_page((unsigned long)buf);
|
|
|
|
return ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
|
|
|
|
struct file *file,
|
|
|
|
const char __user *userbuf, size_t count,
|
|
|
|
loff_t *ppos)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-26 16:07:14 +07:00
|
|
|
struct cmd_ds_802_11_subscribe_event *events;
|
2009-05-23 07:03:09 +07:00
|
|
|
struct mrvl_ie_thresholds *tlv;
|
2007-12-18 14:01:37 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
|
|
|
ssize_t buf_size;
|
|
|
|
int value, freq, new_mask;
|
|
|
|
uint16_t curr_mask;
|
|
|
|
char *buf;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
buf = (char *)get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
2007-12-18 14:01:37 +07:00
|
|
|
ret = -EFAULT;
|
|
|
|
goto out_page;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
2007-12-18 14:01:37 +07:00
|
|
|
ret = sscanf(buf, "%d %d %d", &value, &freq, &new_mask);
|
|
|
|
if (ret != 3) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_page;
|
|
|
|
}
|
|
|
|
events = kzalloc(sizeof(*events), GFP_KERNEL);
|
|
|
|
if (!events) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_page;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
2007-12-18 14:01:37 +07:00
|
|
|
|
|
|
|
events->hdr.size = cpu_to_le16(sizeof(*events));
|
|
|
|
events->action = cpu_to_le16(CMD_ACT_GET);
|
|
|
|
|
|
|
|
ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
|
|
|
|
if (ret)
|
|
|
|
goto out_events;
|
|
|
|
|
|
|
|
curr_mask = le16_to_cpu(events->events);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
if (new_mask)
|
|
|
|
new_mask = curr_mask | event_mask;
|
|
|
|
else
|
|
|
|
new_mask = curr_mask & ~event_mask;
|
|
|
|
|
|
|
|
/* Now everything is set and we can send stuff down to the firmware */
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
tlv = (void *)events->tlv;
|
|
|
|
|
|
|
|
events->action = cpu_to_le16(CMD_ACT_SET);
|
|
|
|
events->events = cpu_to_le16(new_mask);
|
|
|
|
tlv->header.type = cpu_to_le16(tlv_type);
|
|
|
|
tlv->header.len = cpu_to_le16(sizeof(*tlv) - sizeof(tlv->header));
|
|
|
|
tlv->value = value;
|
|
|
|
if (tlv_type != TLV_TYPE_BCNMISS)
|
|
|
|
tlv->freq = freq;
|
|
|
|
|
2008-05-30 19:53:22 +07:00
|
|
|
/* The command header, the action, the event mask, and one TLV */
|
|
|
|
events->hdr.size = cpu_to_le16(sizeof(events->hdr) + 4 + sizeof(*tlv));
|
2007-12-18 14:01:37 +07:00
|
|
|
|
|
|
|
ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = count;
|
|
|
|
out_events:
|
|
|
|
kfree(events);
|
|
|
|
out_page:
|
|
|
|
free_page((unsigned long)buf);
|
|
|
|
return ret;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_lowrssi_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-26 16:07:14 +07:00
|
|
|
return lbs_threshold_read(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_lowrssi_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_lowsnr_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_read(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_lowsnr_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_failcount_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_read(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_failcount_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-26 16:07:14 +07:00
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_highrssi_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-26 16:07:14 +07:00
|
|
|
return lbs_threshold_read(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_highrssi_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_highsnr_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_read(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_highsnr_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_bcnmiss_read(struct file *file, char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-26 16:07:14 +07:00
|
|
|
return lbs_threshold_read(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-11-26 16:07:14 +07:00
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
|
2007-12-18 14:01:37 +07:00
|
|
|
static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
2007-11-26 16:07:14 +07:00
|
|
|
{
|
|
|
|
return lbs_threshold_write(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
|
2007-12-18 14:01:37 +07:00
|
|
|
file, userbuf, count, ppos);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t pos = 0;
|
|
|
|
int ret;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2010-07-28 03:01:07 +07:00
|
|
|
u32 val = 0;
|
|
|
|
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
ret = lbs_get_reg(priv, CMD_MAC_REG_ACCESS, priv->mac_offset, &val);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!ret) {
|
2010-07-28 03:01:07 +07:00
|
|
|
pos = snprintf(buf, len, "MAC[0x%x] = 0x%08x\n",
|
|
|
|
priv->mac_offset, val);
|
2009-10-09 09:38:45 +07:00
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
free_page(addr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdmac_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
priv->mac_offset = simple_strtoul((char *)buf, NULL, 16);
|
|
|
|
res = count;
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_wrmac_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
u32 offset, value;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
res = sscanf(buf, "%x %x", &offset, &value);
|
|
|
|
if (res != 2) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
res = lbs_set_reg(priv, CMD_MAC_REG_ACCESS, offset, value);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
|
|
|
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!res)
|
|
|
|
res = count;
|
2007-02-10 21:25:27 +07:00
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t pos = 0;
|
|
|
|
int ret;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2010-07-28 03:01:07 +07:00
|
|
|
u32 val;
|
|
|
|
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
ret = lbs_get_reg(priv, CMD_BBP_REG_ACCESS, priv->bbp_offset, &val);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!ret) {
|
2010-07-28 03:01:07 +07:00
|
|
|
pos = snprintf(buf, len, "BBP[0x%x] = 0x%08x\n",
|
|
|
|
priv->bbp_offset, val);
|
2009-10-09 09:38:45 +07:00
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
free_page(addr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdbbp_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
priv->bbp_offset = simple_strtoul((char *)buf, NULL, 16);
|
|
|
|
res = count;
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_wrbbp_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
u32 offset, value;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
res = sscanf(buf, "%x %x", &offset, &value);
|
|
|
|
if (res != 2) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
res = lbs_set_reg(priv, CMD_BBP_REG_ACCESS, offset, value);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
|
|
|
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!res)
|
|
|
|
res = count;
|
2007-02-10 21:25:27 +07:00
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t pos = 0;
|
|
|
|
int ret;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2010-07-28 03:01:07 +07:00
|
|
|
u32 val;
|
|
|
|
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
ret = lbs_get_reg(priv, CMD_RF_REG_ACCESS, priv->rf_offset, &val);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!ret) {
|
2010-07-28 03:01:07 +07:00
|
|
|
pos = snprintf(buf, len, "RF[0x%x] = 0x%08x\n",
|
|
|
|
priv->rf_offset, val);
|
2009-10-09 09:38:45 +07:00
|
|
|
ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
|
|
|
|
}
|
2007-02-10 21:25:27 +07:00
|
|
|
free_page(addr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_rdrf_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
2009-01-15 04:52:18 +07:00
|
|
|
priv->rf_offset = simple_strtoul(buf, NULL, 16);
|
2007-02-10 21:25:27 +07:00
|
|
|
res = count;
|
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_wrrf_write(struct file *file,
|
2007-02-10 21:25:27 +07:00
|
|
|
const char __user *userbuf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
|
2007-11-23 21:43:44 +07:00
|
|
|
struct lbs_private *priv = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
ssize_t res, buf_size;
|
|
|
|
u32 offset, value;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
buf_size = min(count, len - 1);
|
|
|
|
if (copy_from_user(buf, userbuf, buf_size)) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
res = sscanf(buf, "%x %x", &offset, &value);
|
|
|
|
if (res != 2) {
|
|
|
|
res = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
2010-07-28 03:01:07 +07:00
|
|
|
res = lbs_set_reg(priv, CMD_RF_REG_ACCESS, offset, value);
|
2007-02-10 21:25:27 +07:00
|
|
|
mdelay(10);
|
|
|
|
|
2009-10-09 09:38:45 +07:00
|
|
|
if (!res)
|
|
|
|
res = count;
|
2007-02-10 21:25:27 +07:00
|
|
|
out_unlock:
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FOPS(fread, fwrite) { \
|
|
|
|
.owner = THIS_MODULE, \
|
2012-04-06 04:25:11 +07:00
|
|
|
.open = simple_open, \
|
2007-02-10 21:25:27 +07:00
|
|
|
.read = (fread), \
|
|
|
|
.write = (fwrite), \
|
2010-07-07 00:05:31 +07:00
|
|
|
.llseek = generic_file_llseek, \
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
struct lbs_debugfs_files {
|
2009-01-15 04:52:18 +07:00
|
|
|
const char *name;
|
2011-07-24 15:33:43 +07:00
|
|
|
umode_t perm;
|
2007-02-10 21:25:27 +07:00
|
|
|
struct file_operations fops;
|
|
|
|
};
|
|
|
|
|
2009-01-15 04:52:18 +07:00
|
|
|
static const struct lbs_debugfs_files debugfs_files[] = {
|
2007-11-16 06:05:47 +07:00
|
|
|
{ "info", 0444, FOPS(lbs_dev_info, write_file_dummy), },
|
|
|
|
{ "sleepparams", 0644, FOPS(lbs_sleepparams_read,
|
|
|
|
lbs_sleepparams_write), },
|
2010-07-08 08:13:48 +07:00
|
|
|
{ "hostsleep", 0644, FOPS(lbs_host_sleep_read,
|
|
|
|
lbs_host_sleep_write), },
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
2009-01-15 04:52:18 +07:00
|
|
|
static const struct lbs_debugfs_files debugfs_events_files[] = {
|
2007-11-16 06:05:47 +07:00
|
|
|
{"low_rssi", 0644, FOPS(lbs_lowrssi_read,
|
|
|
|
lbs_lowrssi_write), },
|
|
|
|
{"low_snr", 0644, FOPS(lbs_lowsnr_read,
|
|
|
|
lbs_lowsnr_write), },
|
|
|
|
{"failure_count", 0644, FOPS(lbs_failcount_read,
|
|
|
|
lbs_failcount_write), },
|
|
|
|
{"beacon_missed", 0644, FOPS(lbs_bcnmiss_read,
|
|
|
|
lbs_bcnmiss_write), },
|
|
|
|
{"high_rssi", 0644, FOPS(lbs_highrssi_read,
|
|
|
|
lbs_highrssi_write), },
|
|
|
|
{"high_snr", 0644, FOPS(lbs_highsnr_read,
|
|
|
|
lbs_highsnr_write), },
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
2009-01-15 04:52:18 +07:00
|
|
|
static const struct lbs_debugfs_files debugfs_regs_files[] = {
|
2007-11-16 06:05:47 +07:00
|
|
|
{"rdmac", 0644, FOPS(lbs_rdmac_read, lbs_rdmac_write), },
|
|
|
|
{"wrmac", 0600, FOPS(NULL, lbs_wrmac_write), },
|
|
|
|
{"rdbbp", 0644, FOPS(lbs_rdbbp_read, lbs_rdbbp_write), },
|
|
|
|
{"wrbbp", 0600, FOPS(NULL, lbs_wrbbp_write), },
|
|
|
|
{"rdrf", 0644, FOPS(lbs_rdrf_read, lbs_rdrf_write), },
|
|
|
|
{"wrrf", 0600, FOPS(NULL, lbs_wrrf_write), },
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
void lbs_debugfs_init(void)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-16 06:05:47 +07:00
|
|
|
if (!lbs_dir)
|
|
|
|
lbs_dir = debugfs_create_dir("lbs_wireless", NULL);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
void lbs_debugfs_remove(void)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
2007-11-16 06:05:47 +07:00
|
|
|
if (lbs_dir)
|
|
|
|
debugfs_remove(lbs_dir);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-11-23 21:43:44 +07:00
|
|
|
void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
|
|
|
int i;
|
2009-01-15 04:52:18 +07:00
|
|
|
const struct lbs_debugfs_files *files;
|
2007-11-16 06:05:47 +07:00
|
|
|
if (!lbs_dir)
|
2007-02-10 21:25:27 +07:00
|
|
|
goto exit;
|
|
|
|
|
2007-11-16 06:05:47 +07:00
|
|
|
priv->debugfs_dir = debugfs_create_dir(dev->name, lbs_dir);
|
2007-02-10 21:25:27 +07:00
|
|
|
if (!priv->debugfs_dir)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
for (i=0; i<ARRAY_SIZE(debugfs_files); i++) {
|
|
|
|
files = &debugfs_files[i];
|
|
|
|
priv->debugfs_files[i] = debugfs_create_file(files->name,
|
|
|
|
files->perm,
|
|
|
|
priv->debugfs_dir,
|
|
|
|
priv,
|
|
|
|
&files->fops);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir);
|
|
|
|
if (!priv->events_dir)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
for (i=0; i<ARRAY_SIZE(debugfs_events_files); i++) {
|
|
|
|
files = &debugfs_events_files[i];
|
|
|
|
priv->debugfs_events_files[i] = debugfs_create_file(files->name,
|
|
|
|
files->perm,
|
|
|
|
priv->events_dir,
|
|
|
|
priv,
|
|
|
|
&files->fops);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir);
|
|
|
|
if (!priv->regs_dir)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
for (i=0; i<ARRAY_SIZE(debugfs_regs_files); i++) {
|
|
|
|
files = &debugfs_regs_files[i];
|
|
|
|
priv->debugfs_regs_files[i] = debugfs_create_file(files->name,
|
|
|
|
files->perm,
|
|
|
|
priv->regs_dir,
|
|
|
|
priv,
|
|
|
|
&files->fops);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PROC_DEBUG
|
2008-03-19 20:25:58 +07:00
|
|
|
lbs_debug_init(priv);
|
2007-02-10 21:25:27 +07:00
|
|
|
#endif
|
|
|
|
exit:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-23 21:43:44 +07:00
|
|
|
void lbs_debugfs_remove_one(struct lbs_private *priv)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i<ARRAY_SIZE(debugfs_regs_files); i++)
|
|
|
|
debugfs_remove(priv->debugfs_regs_files[i]);
|
|
|
|
|
|
|
|
debugfs_remove(priv->regs_dir);
|
|
|
|
|
2007-05-25 10:47:34 +07:00
|
|
|
for(i=0; i<ARRAY_SIZE(debugfs_events_files); i++)
|
2007-02-10 21:25:27 +07:00
|
|
|
debugfs_remove(priv->debugfs_events_files[i]);
|
|
|
|
|
|
|
|
debugfs_remove(priv->events_dir);
|
|
|
|
#ifdef PROC_DEBUG
|
|
|
|
debugfs_remove(priv->debugfs_debug);
|
|
|
|
#endif
|
|
|
|
for(i=0; i<ARRAY_SIZE(debugfs_files); i++)
|
|
|
|
debugfs_remove(priv->debugfs_files[i]);
|
2007-05-25 10:47:34 +07:00
|
|
|
debugfs_remove(priv->debugfs_dir);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2007-05-25 11:37:28 +07:00
|
|
|
|
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
/* debug entry */
|
|
|
|
|
2007-05-25 11:37:28 +07:00
|
|
|
#ifdef PROC_DEBUG
|
|
|
|
|
2007-12-09 03:04:36 +07:00
|
|
|
#define item_size(n) (FIELD_SIZEOF(struct lbs_private, n))
|
|
|
|
#define item_addr(n) (offsetof(struct lbs_private, n))
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-05-25 11:37:28 +07:00
|
|
|
|
2007-02-10 21:25:27 +07:00
|
|
|
struct debug_data {
|
|
|
|
char name[32];
|
|
|
|
u32 size;
|
2007-05-11 10:10:18 +07:00
|
|
|
size_t addr;
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
2007-12-09 03:04:36 +07:00
|
|
|
/* To debug any member of struct lbs_private, simply add one line here.
|
2007-02-10 21:25:27 +07:00
|
|
|
*/
|
|
|
|
static struct debug_data items[] = {
|
|
|
|
{"psmode", item_size(psmode), item_addr(psmode)},
|
|
|
|
{"psstate", item_size(psstate), item_addr(psstate)},
|
|
|
|
};
|
|
|
|
|
2007-03-09 09:11:46 +07:00
|
|
|
static int num_of_items = ARRAY_SIZE(items);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
/**
|
2011-04-27 05:25:29 +07:00
|
|
|
* lbs_debugfs_read - proc read function
|
2007-02-10 21:25:27 +07:00
|
|
|
*
|
2011-04-27 05:25:29 +07:00
|
|
|
* @file: file to read
|
|
|
|
* @userbuf: pointer to buffer
|
|
|
|
* @count: number of bytes to read
|
|
|
|
* @ppos: read data starting position
|
|
|
|
*
|
|
|
|
* returns: amount of data read or negative error code
|
2007-02-10 21:25:27 +07:00
|
|
|
*/
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
int val = 0;
|
|
|
|
size_t pos = 0;
|
|
|
|
ssize_t res;
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
struct debug_data *d;
|
|
|
|
unsigned long addr = get_zeroed_page(GFP_KERNEL);
|
|
|
|
char *buf = (char *)addr;
|
2009-08-28 19:17:59 +07:00
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
2010-07-13 03:50:06 +07:00
|
|
|
d = file->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
for (i = 0; i < num_of_items; i++) {
|
|
|
|
if (d[i].size == 1)
|
|
|
|
val = *((u8 *) d[i].addr);
|
|
|
|
else if (d[i].size == 2)
|
|
|
|
val = *((u16 *) d[i].addr);
|
|
|
|
else if (d[i].size == 4)
|
|
|
|
val = *((u32 *) d[i].addr);
|
2007-05-11 10:10:18 +07:00
|
|
|
else if (d[i].size == 8)
|
|
|
|
val = *((u64 *) d[i].addr);
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = simple_read_from_buffer(userbuf, count, ppos, p, pos);
|
|
|
|
|
|
|
|
free_page(addr);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-27 05:25:29 +07:00
|
|
|
* lbs_debugfs_write - proc write function
|
|
|
|
*
|
|
|
|
* @f: file pointer
|
|
|
|
* @buf: pointer to data buffer
|
|
|
|
* @cnt: data number to write
|
|
|
|
* @ppos: file position
|
2007-02-10 21:25:27 +07:00
|
|
|
*
|
2011-04-27 05:25:29 +07:00
|
|
|
* returns: amount of data written
|
2007-02-10 21:25:27 +07:00
|
|
|
*/
|
2007-11-16 06:05:47 +07:00
|
|
|
static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
|
2007-02-10 21:25:27 +07:00
|
|
|
size_t cnt, loff_t *ppos)
|
|
|
|
{
|
|
|
|
int r, i;
|
|
|
|
char *pdata;
|
|
|
|
char *p;
|
|
|
|
char *p0;
|
|
|
|
char *p1;
|
|
|
|
char *p2;
|
2010-07-13 03:50:06 +07:00
|
|
|
struct debug_data *d = f->private_data;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
2007-08-24 22:48:16 +07:00
|
|
|
pdata = kmalloc(cnt, GFP_KERNEL);
|
2007-02-10 21:25:27 +07:00
|
|
|
if (pdata == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (copy_from_user(pdata, buf, cnt)) {
|
2007-05-25 22:27:16 +07:00
|
|
|
lbs_deb_debugfs("Copy from user failed\n");
|
2007-02-10 21:25:27 +07:00
|
|
|
kfree(pdata);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
p0 = pdata;
|
|
|
|
for (i = 0; i < num_of_items; i++) {
|
|
|
|
do {
|
|
|
|
p = strstr(p0, d[i].name);
|
|
|
|
if (p == NULL)
|
|
|
|
break;
|
|
|
|
p1 = strchr(p, '\n');
|
|
|
|
if (p1 == NULL)
|
|
|
|
break;
|
|
|
|
p0 = p1++;
|
|
|
|
p2 = strchr(p, '=');
|
|
|
|
if (!p2)
|
|
|
|
break;
|
|
|
|
p2++;
|
2007-03-09 09:11:46 +07:00
|
|
|
r = simple_strtoul(p2, NULL, 0);
|
2007-02-10 21:25:27 +07:00
|
|
|
if (d[i].size == 1)
|
|
|
|
*((u8 *) d[i].addr) = (u8) r;
|
|
|
|
else if (d[i].size == 2)
|
|
|
|
*((u16 *) d[i].addr) = (u16) r;
|
|
|
|
else if (d[i].size == 4)
|
|
|
|
*((u32 *) d[i].addr) = (u32) r;
|
2007-05-11 10:10:18 +07:00
|
|
|
else if (d[i].size == 8)
|
|
|
|
*((u64 *) d[i].addr) = (u64) r;
|
2007-02-10 21:25:27 +07:00
|
|
|
break;
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
kfree(pdata);
|
|
|
|
|
2007-05-11 10:10:18 +07:00
|
|
|
return (ssize_t)cnt;
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
|
|
|
|
2009-01-15 04:52:18 +07:00
|
|
|
static const struct file_operations lbs_debug_fops = {
|
2007-02-10 21:25:27 +07:00
|
|
|
.owner = THIS_MODULE,
|
2012-04-06 04:25:11 +07:00
|
|
|
.open = simple_open,
|
2007-11-16 06:05:47 +07:00
|
|
|
.write = lbs_debugfs_write,
|
|
|
|
.read = lbs_debugfs_read,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 23:52:59 +07:00
|
|
|
.llseek = default_llseek,
|
2007-02-10 21:25:27 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-04-27 05:25:29 +07:00
|
|
|
* lbs_debug_init - create debug proc file
|
|
|
|
*
|
|
|
|
* @priv: pointer to &struct lbs_private
|
2007-02-10 21:25:27 +07:00
|
|
|
*
|
2011-04-27 05:25:29 +07:00
|
|
|
* returns: N/A
|
2007-02-10 21:25:27 +07:00
|
|
|
*/
|
2008-03-19 20:25:58 +07:00
|
|
|
static void lbs_debug_init(struct lbs_private *priv)
|
2007-02-10 21:25:27 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!priv->debugfs_dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < num_of_items; i++)
|
2007-12-09 03:04:36 +07:00
|
|
|
items[i].addr += (size_t) priv;
|
2007-02-10 21:25:27 +07:00
|
|
|
|
|
|
|
priv->debugfs_debug = debugfs_create_file("debug", 0644,
|
|
|
|
priv->debugfs_dir, &items[0],
|
2007-11-16 06:05:47 +07:00
|
|
|
&lbs_debug_fops);
|
2007-02-10 21:25:27 +07:00
|
|
|
}
|
2007-05-25 11:37:28 +07:00
|
|
|
#endif
|