Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
a01b0c57
Commit
a01b0c57
authored
Mar 30, 2013
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
silicom: switch to create_proc_data(), clean procfs side of things up
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
121daf5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
379 additions
and
820 deletions
+379
-820
drivers/staging/silicom/bp_mod.c
drivers/staging/silicom/bp_mod.c
+379
-820
No files found.
drivers/staging/silicom/bp_mod.c
View file @
a01b0c57
...
@@ -60,35 +60,9 @@ typedef enum {
...
@@ -60,35 +60,9 @@ typedef enum {
bp_none
,
bp_none
,
}
bp_media_type
;
}
bp_media_type
;
struct
pfs_unit_sd
{
struct
proc_dir_entry
*
proc_entry
;
char
proc_name
[
32
];
};
struct
bypass_pfs_sd
{
struct
bypass_pfs_sd
{
char
dir_name
[
32
];
char
dir_name
[
32
];
struct
proc_dir_entry
*
bypass_entry
;
struct
proc_dir_entry
*
bypass_entry
;
struct
pfs_unit_sd
bypass_info
;
struct
pfs_unit_sd
bypass_slave
;
struct
pfs_unit_sd
bypass_caps
;
struct
pfs_unit_sd
wd_set_caps
;
struct
pfs_unit_sd
bypass
;
struct
pfs_unit_sd
bypass_change
;
struct
pfs_unit_sd
bypass_wd
;
struct
pfs_unit_sd
wd_expire_time
;
struct
pfs_unit_sd
reset_bypass_wd
;
struct
pfs_unit_sd
dis_bypass
;
struct
pfs_unit_sd
bypass_pwup
;
struct
pfs_unit_sd
bypass_pwoff
;
struct
pfs_unit_sd
std_nic
;
struct
pfs_unit_sd
tap
;
struct
pfs_unit_sd
dis_tap
;
struct
pfs_unit_sd
tap_pwup
;
struct
pfs_unit_sd
tap_change
;
struct
pfs_unit_sd
wd_exp_mode
;
struct
pfs_unit_sd
wd_autoreset
;
struct
pfs_unit_sd
tpl
;
};
};
typedef
struct
_bpctl_dev
{
typedef
struct
_bpctl_dev
{
...
@@ -7250,78 +7224,11 @@ EXPORT_SYMBOL_NOVERS(bp_if_scan_sd);
...
@@ -7250,78 +7224,11 @@ EXPORT_SYMBOL_NOVERS(bp_if_scan_sd);
#define BP_PROC_DIR "bypass"
#define BP_PROC_DIR "bypass"
#define GPIO6_SET_ENTRY_SD "gpio6_set"
#define GPIO6_CLEAR_ENTRY_SD "gpio6_clear"
#define GPIO7_SET_ENTRY_SD "gpio7_set"
#define GPIO7_CLEAR_ENTRY_SD "gpio7_clear"
#define PULSE_SET_ENTRY_SD "pulse_set"
#define ZERO_SET_ENTRY_SD "zero_set"
#define PULSE_GET1_ENTRY_SD "pulse_get1"
#define PULSE_GET2_ENTRY_SD "pulse_get2"
#define CMND_ON_ENTRY_SD "cmnd_on"
#define CMND_OFF_ENTRY_SD "cmnd_off"
#define RESET_CONT_ENTRY_SD "reset_cont"
/*COMMANDS*/
#define BYPASS_INFO_ENTRY_SD "bypass_info"
#define BYPASS_SLAVE_ENTRY_SD "bypass_slave"
#define BYPASS_CAPS_ENTRY_SD "bypass_caps"
#define WD_SET_CAPS_ENTRY_SD "wd_set_caps"
#define BYPASS_ENTRY_SD "bypass"
#define BYPASS_CHANGE_ENTRY_SD "bypass_change"
#define BYPASS_WD_ENTRY_SD "bypass_wd"
#define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time"
#define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd"
#define DIS_BYPASS_ENTRY_SD "dis_bypass"
#define BYPASS_PWUP_ENTRY_SD "bypass_pwup"
#define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff"
#define STD_NIC_ENTRY_SD "std_nic"
#define STD_NIC_ENTRY_SD "std_nic"
#define TAP_ENTRY_SD "tap"
#define TAP_CHANGE_ENTRY_SD "tap_change"
#define DIS_TAP_ENTRY_SD "dis_tap"
#define TAP_PWUP_ENTRY_SD "tap_pwup"
#define TWO_PORT_LINK_ENTRY_SD "two_port_link"
#define WD_EXP_MODE_ENTRY_SD "wd_exp_mode"
#define WD_AUTORESET_ENTRY_SD "wd_autoreset"
#define TPL_ENTRY_SD "tpl"
#define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup"
#define HW_RESET_ENTRY_SD "hw_reset"
#define DISC_ENTRY_SD "disc"
#define DISC_CHANGE_ENTRY_SD "disc_change"
#define DIS_DISC_ENTRY_SD "dis_disc"
#define DISC_PWUP_ENTRY_SD "disc_pwup"
static
struct
proc_dir_entry
*
bp_procfs_dir
;
static
struct
proc_dir_entry
*
bp_procfs_dir
;
static
struct
proc_dir_entry
*
proc_getdir
(
char
*
name
,
struct
proc_dir_entry
*
proc_dir
)
{
struct
proc_dir_entry
*
pde
=
proc_dir
;
for
(
pde
=
pde
->
subdir
;
pde
;
pde
=
pde
->
next
)
{
if
(
pde
->
namelen
&&
(
strcmp
(
name
,
pde
->
name
)
==
0
))
{
/* directory exists */
break
;
}
}
if
(
pde
==
(
struct
proc_dir_entry
*
)
0
)
{
/* create the directory */
pde
=
proc_mkdir
(
name
,
proc_dir
);
if
(
pde
==
(
struct
proc_dir_entry
*
)
0
)
{
return
pde
;
}
}
return
pde
;
}
int
bp_proc_create
(
void
)
int
bp_proc_create
(
void
)
{
{
bp_procfs_dir
=
proc_
get
dir
(
BP_PROC_DIR
,
init_net
.
proc_net
);
bp_procfs_dir
=
proc_
mk
dir
(
BP_PROC_DIR
,
init_net
.
proc_net
);
if
(
bp_procfs_dir
==
(
struct
proc_dir_entry
*
)
0
)
{
if
(
bp_procfs_dir
==
(
struct
proc_dir_entry
*
)
0
)
{
printk
(
KERN_DEBUG
printk
(
KERN_DEBUG
"Could not create procfs nicinfo directory %s
\n
"
,
"Could not create procfs nicinfo directory %s
\n
"
,
...
@@ -7331,104 +7238,87 @@ int bp_proc_create(void)
...
@@ -7331,104 +7238,87 @@ int bp_proc_create(void)
return
0
;
return
0
;
}
}
int
static
int
procfs_add
(
char
*
proc_name
,
const
struct
file_operations
*
fops
,
bypass_proc_create_entry_sd
(
struct
pfs_unit_sd
*
pfs_unit_curr
,
bpctl_dev_t
*
dev
)
char
*
proc_name
,
write_proc_t
*
write_proc
,
read_proc_t
*
read_proc
,
struct
proc_dir_entry
*
parent_pfs
,
void
*
data
)
{
{
strcpy
(
pfs_unit_curr
->
proc_name
,
proc_name
);
struct
bypass_pfs_sd
*
pfs
=
&
dev
->
bypass_pfs_set
;
pfs_unit_curr
->
proc_entry
=
create_proc_entry
(
pfs_unit_curr
->
proc_name
,
if
(
!
proc_create_data
(
proc_name
,
0644
,
pfs
->
bypass_entry
,
fops
,
dev
))
S_IFREG
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
,
parent_pfs
);
if
(
pfs_unit_curr
->
proc_entry
==
NULL
)
return
-
1
;
return
-
1
;
pfs_unit_curr
->
proc_entry
->
read_proc
=
read_proc
;
pfs_unit_curr
->
proc_entry
->
write_proc
=
write_proc
;
pfs_unit_curr
->
proc_entry
->
data
=
data
;
return
0
;
return
0
;
}
}
int
#define RO_FOPS(name) \
get_bypass_info_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
static int name##_open(struct inode *inode, struct file *file) \
int
*
eof
,
void
*
data
)
{ \
{
return single_open(file, show_##name, PDE(inode)->data);\
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
} \
int
len
=
0
;
static const struct file_operations name##_ops = { \
.open = name##_open, \
len
+=
sprintf
(
page
,
"Name
\t\t\t
%s
\n
"
,
pbp_device_block
->
name
);
.read = seq_read, \
len
+=
.llseek = seq_lseek, \
sprintf
(
page
+
len
,
"Firmware version
\t
0x%x
\n
"
,
.release = single_release, \
pbp_device_block
->
bp_fw_ver
)
;
}
;
*
eof
=
1
;
#define RW_FOPS(name) \
return
len
;
static int name##_open(struct inode *inode, struct file *file) \
}
{ \
return single_open(file, show_##name, PDE(inode)->data);\
} \
static const struct file_operations name##_ops = { \
.open = name##_open, \
.read = seq_read, \
.write = name##_write, \
.llseek = seq_lseek, \
.release = single_release, \
};
int
static
int
show_bypass_info
(
struct
seq_file
*
m
,
void
*
v
)
get_bypass_slave_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
len
=
0
;
seq_printf
(
m
,
"Name
\t\t\t
%s
\n
"
,
dev
->
name
);
bpctl_dev_t
*
pbp_device_block_slave
=
get_status_port_fn
(
pbp_device_block
);
seq_printf
(
m
,
"Firmware version
\t
0x%x
\n
"
,
dev
->
bp_fw_ver
);
struct
net_device
*
net_slave_dev
=
NULL
;
return
0
;
if
(
!
pbp_device_block_slave
)
pbp_device_block_slave
=
pbp_device_block
;
if
(
!
pbp_device_block_slave
)
{
len
=
sprintf
(
page
,
"fail
\n
"
);
*
eof
=
1
;
return
len
;
}
net_slave_dev
=
pbp_device_block_slave
->
ndev
;
if
(
net_slave_dev
)
len
=
sprintf
(
page
,
"%s
\n
"
,
net_slave_dev
->
name
);
*
eof
=
1
;
return
len
;
}
}
RO_FOPS
(
bypass_info
)
int
static
int
show_bypass_slave
(
struct
seq_file
*
m
,
void
*
v
)
get_bypass_caps_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
bpctl_dev_t
*
slave
=
get_status_port_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
if
(
!
slave
)
slave
=
dev
;
if
(
!
slave
)
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
slave
->
ndev
)
seq_printf
(
m
,
"%s
\n
"
,
slave
->
ndev
->
name
);
return
0
;
}
RO_FOPS
(
bypass_slave
)
ret
=
get_bypass_caps_fn
(
pbp_device_block
);
static
int
show_bypass_caps
(
struct
seq_file
*
m
,
void
*
v
)
{
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_bypass_caps_fn
(
dev
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"-1
\n
"
);
seq_printf
(
m
,
"-1
\n
"
);
else
else
len
=
sprintf
(
page
,
"0x%x
\n
"
,
ret
);
seq_printf
(
m
,
"0x%x
\n
"
,
ret
);
*
eof
=
1
;
return
0
;
return
len
;
}
}
RO_FOPS
(
bypass_caps
)
int
static
int
show_wd_set_caps
(
struct
seq_file
*
m
,
void
*
v
)
get_wd_set_caps_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_wd_set_caps_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_wd_set_caps_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"-1
\n
"
);
seq_printf
(
m
,
"-1
\n
"
);
else
else
len
=
sprintf
(
page
,
"0x%x
\n
"
,
ret
);
seq_printf
(
m
,
"0x%x
\n
"
,
ret
);
*
eof
=
1
;
return
0
;
return
len
;
}
}
RO_FOPS
(
wd_set_caps
)
static
int
user_on_off
(
const
void
__user
*
buffer
,
size_t
count
)
static
int
user_on_off
(
const
void
__user
*
buffer
,
size_t
count
)
{
{
...
@@ -7454,625 +7344,461 @@ static int user_on_off(const void __user *buffer, size_t count)
...
@@ -7454,625 +7344,461 @@ static int user_on_off(const void __user *buffer, size_t count)
return
0
;
return
0
;
}
}
int
static
ssize_t
bypass_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_bypass_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
user_on_off
(
buffer
,
count
);
int
bypass_param
=
user_on_off
(
buffer
,
count
);
if
(
bypass_param
<
0
)
if
(
bypass_param
<
0
)
return
-
1
;
return
-
1
;
set_bypass_fn
(
pbp_device_block
,
bypass_param
);
set_bypass_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_bypass
(
struct
seq_file
*
m
,
void
*
v
)
int
set_tap_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
dev
=
m
->
private
;
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
ret
=
get_bypass_fn
(
dev
);
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
ret
==
BP_NOT_CAP
)
if
(
tap_param
<
0
)
seq_printf
(
m
,
"fail
\n
"
);
return
-
1
;
else
if
(
ret
==
1
)
seq_printf
(
m
,
"on
\n
"
);
set_tap_fn
(
pbp_device_block
,
tap_param
);
else
if
(
ret
==
0
)
return
count
;
seq_printf
(
m
,
"off
\n
"
);
return
0
;
}
}
RW_FOPS
(
bypass
)
int
static
ssize_t
tap_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_disc_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
if
(
tap_param
<
0
)
return
-
1
;
return
-
1
;
set_
disc_fn
(
pbp_device_block
,
tap_param
);
set_
tap_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
);
return
count
;
return
count
;
}
}
static
int
show_tap
(
struct
seq_file
*
m
,
void
*
v
)
int
get_bypass_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_tap_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_bypass_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
tap
)
int
static
ssize_t
disc_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_tap_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
int
len
=
0
,
ret
=
0
;
return
-
1
;
ret
=
get_tap_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
*
eof
=
1
;
set_disc_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
)
;
return
len
;
return
count
;
}
}
static
int
show_disc
(
struct
seq_file
*
m
,
void
*
v
)
int
get_disc_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_disc_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_disc_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
disc
)
int
static
int
show_bypass_change
(
struct
seq_file
*
m
,
void
*
v
)
get_bypass_change_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_bypass_change_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_bypass_change_fn
(
pbp_device_block
);
if
(
ret
==
1
)
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RO_FOPS
(
bypass_change
)
int
static
int
show_tap_change
(
struct
seq_file
*
m
,
void
*
v
)
get_tap_change_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_tap_change_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_tap_change_fn
(
pbp_device_block
);
if
(
ret
==
1
)
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RO_FOPS
(
tap_change
)
int
static
int
show_disc_change
(
struct
seq_file
*
m
,
void
*
v
)
get_disc_change_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_disc_change_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_disc_change_fn
(
pbp_device_block
);
if
(
ret
==
1
)
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
#define isdigit(c) (c >= '0' && c <= '9')
__inline
static
int
atoi
(
char
**
s
)
{
int
i
=
0
;
while
(
isdigit
(
**
s
))
i
=
i
*
10
+
*
((
*
s
)
++
)
-
'0'
;
return
i
;
}
}
RO_FOPS
(
disc_change
)
int
static
ssize_t
bypass_wd_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_bypass_wd_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
PDE
(
file_inode
(
file
))
->
data
;
int
timeout
;
int
timeout
;
int
ret
;
int
ret
=
kstrtoint_from_user
(
buffer
,
count
,
10
,
&
timeout
);
ret
=
kstrtoint_from_user
(
buffer
,
count
,
10
,
&
timeout
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
set_bypass_wd_fn
(
pbp_device_block
,
timeout
);
set_bypass_wd_fn
(
dev
,
timeout
);
return
count
;
return
count
;
}
}
static
int
show_bypass_wd
(
struct
seq_file
*
m
,
void
*
v
)
int
get_bypass_wd_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
0
,
timeout
=
0
;
int
len
=
0
,
ret
=
0
,
timeout
=
0
;
ret
=
get_bypass_wd_fn
(
pbp_device_block
,
&
timeout
);
ret
=
get_bypass_wd_fn
(
dev
,
&
timeout
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
timeout
==
-
1
)
else
if
(
timeout
==
-
1
)
len
=
sprintf
(
page
,
"unknown
\n
"
);
seq_printf
(
m
,
"unknown
\n
"
);
else
if
(
timeout
==
0
)
else
if
(
timeout
==
0
)
len
=
sprintf
(
page
,
"disable
\n
"
);
seq_printf
(
m
,
"disable
\n
"
);
else
else
len
=
sprintf
(
page
,
"%d
\n
"
,
timeout
);
seq_printf
(
m
,
"%d
\n
"
,
timeout
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
bypass_wd
)
int
static
int
show_wd_expire_time
(
struct
seq_file
*
m
,
void
*
v
)
get_wd_expire_time_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
0
,
timeout
=
0
;
int
len
=
0
,
ret
=
0
,
timeout
=
0
;
ret
=
get_wd_expire_time_fn
(
dev
,
&
timeout
);
ret
=
get_wd_expire_time_fn
(
pbp_device_block
,
&
timeout
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
timeout
==
-
1
)
else
if
(
timeout
==
-
1
)
len
=
sprintf
(
page
,
"expire
\n
"
);
seq_printf
(
m
,
"expire
\n
"
);
else
if
(
timeout
==
0
)
else
if
(
timeout
==
0
)
len
=
sprintf
(
page
,
"disable
\n
"
);
seq_printf
(
m
,
"disable
\n
"
);
else
else
len
=
sprintf
(
page
,
"%d
\n
"
,
timeout
);
seq_printf
(
m
,
"%d
\n
"
,
timeout
);
*
eof
=
1
;
return
0
;
return
len
;
}
}
RO_FOPS
(
wd_expire_time
)
int
static
ssize_t
tpl_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_tpl_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
PDE
(
file_inode
(
file
))
->
data
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
int
len
=
0
,
ret
=
0
;
if
(
tpl_param
<
0
)
return
-
1
;
ret
=
get_tpl_fn
(
pbp_device_block
);
set_tpl_fn
(
dev
,
tpl_param
);
return
count
;
}
static
int
show_tpl
(
struct
seq_file
*
m
,
void
*
v
)
{
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_tpl_fn
(
dev
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
tpl
)
#ifdef PMC_FIX_FLAG
#ifdef PMC_FIX_FLAG
int
static
ssize_t
wait_at_pwup_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_wait_at_pwup_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
PDE
(
file_inode
(
file
))
->
data
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
int
len
=
0
,
ret
=
0
;
if
(
tpl_param
<
0
)
return
-
1
;
ret
=
get_bp_wait_at_pwup_fn
(
pbp_device_block
);
set_bp_wait_at_pwup_fn
(
dev
,
tpl_param
);
return
count
;
}
static
int
show_wait_at_pwup
(
struct
seq_file
*
m
,
void
*
v
)
{
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_bp_wait_at_pwup_fn
(
dev
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
wait_at_pwup
)
int
static
ssize_t
hw_reset_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_hw_reset_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
PDE
(
file_inode
(
file
))
->
data
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
int
len
=
0
,
ret
=
0
;
if
(
tpl_param
<
0
)
return
-
1
;
ret
=
get_bp_hw_reset_fn
(
pbp_device_block
);
set_bp_hw_reset_fn
(
dev
,
tpl_param
);
return
count
;
}
static
int
show_hw_reset
(
struct
seq_file
*
m
,
void
*
v
)
{
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_bp_hw_reset_fn
(
dev
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
hw_reset
)
#endif
/*PMC_WAIT_FLAG */
#endif
/*PMC_WAIT_FLAG */
int
static
int
show_reset_bypass_wd
(
struct
seq_file
*
m
,
void
*
v
)
reset_bypass_wd_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
reset_bypass_wd_timer_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
reset_bypass_wd_timer_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"disable
\n
"
);
seq_printf
(
m
,
"disable
\n
"
);
else
if
(
ret
==
1
)
else
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"success
\n
"
);
seq_printf
(
m
,
"success
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RO_FOPS
(
reset_bypass_wd
)
int
static
ssize_t
dis_bypass_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_dis_bypass_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
user_on_off
(
buffer
,
count
);
int
bypass_param
=
user_on_off
(
buffer
,
count
);
if
(
bypass_param
<
0
)
if
(
bypass_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_dis_bypass_fn
(
pbp_device_block
,
bypass_param
);
set_dis_bypass_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_dis_bypass
(
struct
seq_file
*
m
,
void
*
v
)
int
set_dis_tap_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
dev
=
m
->
private
;
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
ret
=
get_dis_bypass_fn
(
dev
);
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
ret
==
BP_NOT_CAP
)
if
(
tap_param
<
0
)
seq_printf
(
m
,
"fail
\n
"
);
return
-
EINVAL
;
else
if
(
ret
==
0
)
seq_printf
(
m
,
"off
\n
"
);
set_dis_tap_fn
(
pbp_device_block
,
tap_param
);
else
return
count
;
seq_printf
(
m
,
"on
\n
"
);
return
0
;
}
}
RW_FOPS
(
dis_bypass
)
int
static
ssize_t
dis_tap_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_dis_disc_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
if
(
tap_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_dis_
disc_fn
(
pbp_device_block
,
tap_param
);
set_dis_
tap_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
);
return
count
;
return
count
;
}
}
static
int
show_dis_tap
(
struct
seq_file
*
m
,
void
*
v
)
int
get_dis_bypass_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_dis_tap_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_dis_bypass_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
dis_tap
)
int
static
ssize_t
dis_disc_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_dis_tap_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
int
len
=
0
,
ret
=
0
;
return
-
EINVAL
;
ret
=
get_dis_tap_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
else
len
=
sprintf
(
page
,
"on
\n
"
);
*
eof
=
1
;
set_dis_disc_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
)
;
return
len
;
return
count
;
}
}
static
int
show_dis_disc
(
struct
seq_file
*
m
,
void
*
v
)
int
get_dis_disc_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_dis_disc_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_dis_disc_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
dis_disc
)
int
static
ssize_t
bypass_pwup_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_bypass_pwup_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
user_on_off
(
buffer
,
count
);
int
bypass_param
=
user_on_off
(
buffer
,
count
);
if
(
bypass_param
<
0
)
if
(
bypass_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_bypass_pwup_fn
(
pbp_device_block
,
bypass_param
);
set_bypass_pwup_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_bypass_pwup
(
struct
seq_file
*
m
,
void
*
v
)
{
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_bypass_pwup_fn
(
dev
);
if
(
ret
==
BP_NOT_CAP
)
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
seq_printf
(
m
,
"off
\n
"
);
else
seq_printf
(
m
,
"on
\n
"
);
return
0
;
}
RW_FOPS
(
bypass_pwup
)
int
static
ssize_t
bypass_pwoff_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_bypass_pwoff_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
user_on_off
(
buffer
,
count
);
int
bypass_param
=
user_on_off
(
buffer
,
count
);
if
(
bypass_param
<
0
)
if
(
bypass_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_bypass_pwoff_fn
(
pbp_device_block
,
bypass_param
);
set_bypass_pwoff_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_bypass_pwoff
(
struct
seq_file
*
m
,
void
*
v
)
int
set_tap_pwup_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
int
ret
=
get_bypass_pwoff_fn
(
dev
);
if
(
tap_param
<
0
)
if
(
ret
==
BP_NOT_CAP
)
return
-
EINVAL
;
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
set_tap_pwup_fn
(
pbp_device_block
,
tap_param
);
seq_printf
(
m
,
"off
\n
"
);
return
count
;
else
seq_printf
(
m
,
"on
\n
"
);
return
0
;
}
}
RW_FOPS
(
bypass_pwoff
)
int
static
ssize_t
tap_pwup_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_disc_pwup_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
if
(
tap_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_
disc_pwup_fn
(
pbp_device_block
,
tap_param
);
set_
tap_pwup_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
);
return
count
;
return
count
;
}
}
static
int
show_tap_pwup
(
struct
seq_file
*
m
,
void
*
v
)
int
get_bypass_pwup_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_tap_pwup_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_bypass_pwup_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
int
get_bypass_pwoff_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
len
=
0
,
ret
=
0
;
ret
=
get_bypass_pwoff_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
else
len
=
sprintf
(
page
,
"on
\n
"
);
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
tap_pwup
)
int
static
ssize_t
disc_pwup_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
get_tap_pwup_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
size_t
count
,
loff_t
*
pos
)
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tap_param
=
user_on_off
(
buffer
,
count
);
if
(
tap_param
<
0
)
int
len
=
0
,
ret
=
0
;
return
-
EINVAL
;
ret
=
get_tap_pwup_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
else
len
=
sprintf
(
page
,
"on
\n
"
);
*
eof
=
1
;
set_disc_pwup_fn
(
PDE
(
file_inode
(
file
))
->
data
,
tap_param
)
;
return
len
;
return
count
;
}
}
static
int
show_disc_pwup
(
struct
seq_file
*
m
,
void
*
v
)
int
get_disc_pwup_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_disc_pwup_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_disc_pwup_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
else
len
=
sprintf
(
page
,
"on
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
disc_pwup
)
int
static
ssize_t
std_nic_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_std_nic_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
user_on_off
(
buffer
,
count
);
int
bypass_param
=
user_on_off
(
buffer
,
count
);
if
(
bypass_param
<
0
)
if
(
bypass_param
<
0
)
return
-
EINVAL
;
return
-
EINVAL
;
set_std_nic_fn
(
pbp_device_block
,
bypass_param
);
set_std_nic_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_std_nic
(
struct
seq_file
*
m
,
void
*
v
)
int
get_std_nic_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_std_nic_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
ret
=
get_std_nic_fn
(
pbp_device_block
);
if
(
ret
==
BP_NOT_CAP
)
if
(
ret
==
BP_NOT_CAP
)
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"off
\n
"
);
else
len
=
sprintf
(
page
,
"on
\n
"
);
*
eof
=
1
;
return
len
;
}
int
get_wd_exp_mode_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
len
=
0
,
ret
=
0
;
ret
=
get_wd_exp_mode_fn
(
pbp_device_block
);
if
(
ret
==
1
)
len
=
sprintf
(
page
,
"tap
\n
"
);
else
if
(
ret
==
0
)
else
if
(
ret
==
0
)
len
=
sprintf
(
page
,
"bypass
\n
"
);
seq_printf
(
m
,
"off
\n
"
);
else
if
(
ret
==
2
)
len
=
sprintf
(
page
,
"disc
\n
"
);
else
else
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"on
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
std_nic
)
int
static
ssize_t
wd_exp_mode_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_wd_exp_mode_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
char
kbuf
[
256
];
char
kbuf
[
256
];
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
bypass_param
=
0
,
length
=
0
;
int
bypass_param
=
0
,
length
=
0
;
if
(
count
>
(
sizeof
(
kbuf
)
-
1
))
if
(
count
>
(
sizeof
(
kbuf
)
-
1
))
return
-
1
;
return
-
1
;
if
(
copy_from_user
(
&
kbuf
,
buffer
,
count
))
{
if
(
copy_from_user
(
&
kbuf
,
buffer
,
count
))
return
-
1
;
return
-
1
;
}
kbuf
[
count
]
=
'\0'
;
kbuf
[
count
]
=
'\0'
;
length
=
strlen
(
kbuf
);
length
=
strlen
(
kbuf
);
...
@@ -8086,86 +7812,47 @@ set_wd_exp_mode_pfs(struct file *file, const char *buffer,
...
@@ -8086,86 +7812,47 @@ set_wd_exp_mode_pfs(struct file *file, const char *buffer,
else
if
(
strcmp
(
kbuf
,
"disc"
)
==
0
)
else
if
(
strcmp
(
kbuf
,
"disc"
)
==
0
)
bypass_param
=
2
;
bypass_param
=
2
;
set_wd_exp_mode_fn
(
pbp_device_block
,
bypass_param
);
set_wd_exp_mode_fn
(
PDE
(
file_inode
(
file
))
->
data
,
bypass_param
);
return
count
;
return
count
;
}
}
static
int
show_wd_exp_mode
(
struct
seq_file
*
m
,
void
*
v
)
int
get_wd_autoreset_pfs
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
ret
=
get_wd_exp_mode_fn
(
dev
);
int
len
=
0
,
ret
=
0
;
if
(
ret
==
1
)
seq_printf
(
m
,
"tap
\n
"
);
ret
=
get_wd_autoreset_fn
(
pbp_device_block
);
else
if
(
ret
==
0
)
if
(
ret
>=
0
)
seq_printf
(
m
,
"bypass
\n
"
);
len
=
sprintf
(
page
,
"%d
\n
"
,
ret
);
else
if
(
ret
==
2
)
seq_printf
(
m
,
"disc
\n
"
);
else
else
len
=
sprintf
(
page
,
"fail
\n
"
);
seq_printf
(
m
,
"fail
\n
"
);
return
0
;
*
eof
=
1
;
return
len
;
}
}
RW_FOPS
(
wd_exp_mode
)
int
static
ssize_t
wd_autoreset_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
set_wd_autoreset_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
size_t
count
,
loff_t
*
pos
)
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
timeout
;
int
timeout
;
int
ret
;
int
ret
=
kstrtoint_from_user
(
buffer
,
count
,
10
,
&
timeout
);
ret
=
kstrtoint_from_user
(
buffer
,
count
,
10
,
&
timeout
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
set_wd_autoreset_fn
(
pbp_device_block
,
timeout
);
set_wd_autoreset_fn
(
PDE
(
file_inode
(
file
))
->
data
,
timeout
);
return
count
;
return
count
;
}
}
static
int
show_wd_autoreset
(
struct
seq_file
*
m
,
void
*
v
)
int
set_tpl_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
bpctl_dev_t
*
dev
=
m
->
private
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
int
ret
=
get_wd_autoreset_fn
(
dev
);
if
(
tpl_param
<
0
)
if
(
ret
>=
0
)
return
-
1
;
seq_printf
(
m
,
"%d
\n
"
,
ret
);
else
set_tpl_fn
(
pbp_device_block
,
tpl_param
);
seq_printf
(
m
,
"fail
\n
"
);
return
count
;
return
0
;
}
#ifdef PMC_FIX_FLAG
int
set_wait_at_pwup_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
if
(
tpl_param
<
0
)
return
-
1
;
set_bp_wait_at_pwup_fn
(
pbp_device_block
,
tpl_param
);
return
count
;
}
int
set_hw_reset_pfs
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
)
{
bpctl_dev_t
*
pbp_device_block
=
(
bpctl_dev_t
*
)
data
;
int
tpl_param
=
user_on_off
(
buffer
,
count
);
if
(
tpl_param
<
0
)
return
-
1
;
set_bp_hw_reset_fn
(
pbp_device_block
,
tpl_param
);
return
count
;
}
}
RW_FOPS
(
wd_autoreset
)
#endif
/*PMC_FIX_FLAG */
int
bypass_proc_create_dev_sd
(
bpctl_dev_t
*
pbp_device_block
)
int
bypass_proc_create_dev_sd
(
bpctl_dev_t
*
pbp_device_block
)
{
{
...
@@ -8182,168 +7869,54 @@ int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block)
...
@@ -8182,168 +7869,54 @@ int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block)
return
-
1
;
return
-
1
;
/* create device proc dir */
/* create device proc dir */
procfs_dir
=
proc_
get
dir
(
current_pfs
->
dir_name
,
bp_procfs_dir
);
procfs_dir
=
proc_
mk
dir
(
current_pfs
->
dir_name
,
bp_procfs_dir
);
if
(
procfs_dir
==
0
)
{
if
(
!
procfs_dir
)
{
printk
(
KERN_DEBUG
"Could not create procfs directory %s
\n
"
,
printk
(
KERN_DEBUG
"Could not create procfs directory %s
\n
"
,
current_pfs
->
dir_name
);
current_pfs
->
dir_name
);
return
-
1
;
return
-
1
;
}
}
current_pfs
->
bypass_entry
=
procfs_dir
;
current_pfs
->
bypass_entry
=
procfs_dir
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_info
),
BYPASS_INFO_ENTRY_SD
,
NULL
,
/* write */
#define ENTRY(x) ret |= procfs_add(#x, &x##_ops, pbp_device_block)
get_bypass_info_pfs
,
/* read */
ENTRY
(
bypass_info
);
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
pbp_device_block
->
bp_caps
&
SW_CTL_CAP
)
{
if
(
pbp_device_block
->
bp_caps
&
SW_CTL_CAP
)
{
/* Create set param proc's */
/* Create set param proc's */
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_slave
),
BYPASS_SLAVE_ENTRY_SD
,
NULL
,
/* write */
ENTRY
(
bypass_slave
);
get_bypass_slave_pfs
,
/* read */
ENTRY
(
bypass_caps
);
procfs_dir
,
pbp_device_block
))
ENTRY
(
wd_set_caps
);
ret
=
-
1
;
ENTRY
(
bypass_wd
);
ENTRY
(
wd_expire_time
);
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_caps
),
BYPASS_CAPS_ENTRY_SD
,
NULL
,
/* write */
ENTRY
(
reset_bypass_wd
);
get_bypass_caps_pfs
,
/* read */
ENTRY
(
std_nic
);
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
wd_set_caps
),
WD_SET_CAPS_ENTRY_SD
,
NULL
,
/* write */
get_wd_set_caps_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_wd
),
BYPASS_WD_ENTRY_SD
,
set_bypass_wd_pfs
,
/* write */
get_bypass_wd_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
wd_expire_time
),
WD_EXPIRE_TIME_ENTRY_SD
,
NULL
,
/* write */
get_wd_expire_time_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
reset_bypass_wd
),
RESET_BYPASS_WD_ENTRY_SD
,
NULL
,
/* write */
reset_bypass_wd_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
std_nic
),
STD_NIC_ENTRY_SD
,
set_std_nic_pfs
,
/* write */
get_std_nic_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
pbp_device_block
->
bp_caps
&
BP_CAP
)
{
if
(
pbp_device_block
->
bp_caps
&
BP_CAP
)
{
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass
),
BYPASS_ENTRY_SD
,
set_bypass_pfs
,
/* write */
ENTRY
(
bypass
);
get_bypass_pfs
,
/* read */
ENTRY
(
dis_bypass
);
procfs_dir
,
ENTRY
(
bypass_pwup
);
pbp_device_block
))
ENTRY
(
bypass_pwoff
);
ret
=
-
1
;
ENTRY
(
bypass_change
);
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
dis_bypass
),
DIS_BYPASS_ENTRY_SD
,
set_dis_bypass_pfs
,
/* write */
get_dis_bypass_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_pwup
),
BYPASS_PWUP_ENTRY_SD
,
set_bypass_pwup_pfs
,
/* write */
get_bypass_pwup_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_pwoff
),
BYPASS_PWOFF_ENTRY_SD
,
set_bypass_pwoff_pfs
,
/* write */
get_bypass_pwoff_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
bypass_change
),
BYPASS_CHANGE_ENTRY_SD
,
NULL
,
/* write */
get_bypass_change_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
}
}
if
(
pbp_device_block
->
bp_caps
&
TAP_CAP
)
{
if
(
pbp_device_block
->
bp_caps
&
TAP_CAP
)
{
ENTRY
(
tap
);
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap
),
TAP_ENTRY_SD
,
set_tap_pfs
,
/* write */
ENTRY
(
dis_tap
);
get_tap_pfs
,
/* read */
ENTRY
(
tap_pwup
);
procfs_dir
,
ENTRY
(
tap_change
);
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
dis_tap
),
DIS_TAP_ENTRY_SD
,
set_dis_tap_pfs
,
/* write */
get_dis_tap_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap_pwup
),
TAP_PWUP_ENTRY_SD
,
set_tap_pwup_pfs
,
/* write */
get_tap_pwup_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap_change
),
TAP_CHANGE_ENTRY_SD
,
NULL
,
/* write */
get_tap_change_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
}
}
if
(
pbp_device_block
->
bp_caps
&
DISC_CAP
)
{
if
(
pbp_device_block
->
bp_caps
&
DISC_CAP
)
{
ENTRY
(
disc
);
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap
),
DISC_ENTRY_SD
,
set_disc_pfs
,
/* write */
ENTRY
(
dis_disc
);
get_disc_pfs
,
/* read */
ENTRY
(
disc_pwup
);
procfs_dir
,
ENTRY
(
disc_change
);
pbp_device_block
))
ret
=
-
1
;
#if 1
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
dis_tap
),
DIS_DISC_ENTRY_SD
,
set_dis_disc_pfs
,
/* write */
get_dis_disc_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
#endif
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap_pwup
),
DISC_PWUP_ENTRY_SD
,
set_disc_pwup_pfs
,
/* write */
get_disc_pwup_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tap_change
),
DISC_CHANGE_ENTRY_SD
,
NULL
,
/* write */
get_disc_change_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
}
}
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
wd_exp_mode
),
WD_EXP_MODE_ENTRY_SD
,
set_wd_exp_mode_pfs
,
/* write */
ENTRY
(
wd_exp_mode
);
get_wd_exp_mode_pfs
,
/* read */
ENTRY
(
wd_autoreset
);
procfs_dir
,
pbp_device_block
))
ENTRY
(
tpl
);
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
wd_autoreset
),
WD_AUTORESET_ENTRY_SD
,
set_wd_autoreset_pfs
,
/* write */
get_wd_autoreset_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tpl
),
TPL_ENTRY_SD
,
set_tpl_pfs
,
/* write */
get_tpl_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
#ifdef PMC_FIX_FLAG
#ifdef PMC_FIX_FLAG
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tpl
),
WAIT_AT_PWUP_ENTRY_SD
,
set_wait_at_pwup_pfs
,
/* write */
ENTRY
(
wait_at_pwup
);
get_wait_at_pwup_pfs
,
/* read */
ENTRY
(
hw_reset
);
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
if
(
bypass_proc_create_entry_sd
(
&
(
current_pfs
->
tpl
),
HW_RESET_ENTRY_SD
,
set_hw_reset_pfs
,
/* write */
get_hw_reset_pfs
,
/* read */
procfs_dir
,
pbp_device_block
))
ret
=
-
1
;
#endif
#endif
}
}
#undef ENTRY
if
(
ret
<
0
)
if
(
ret
<
0
)
printk
(
KERN_DEBUG
"Create proc entry failed
\n
"
);
printk
(
KERN_DEBUG
"Create proc entry failed
\n
"
);
...
@@ -8354,21 +7927,7 @@ int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block)
...
@@ -8354,21 +7927,7 @@ int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block)
{
{
struct
bypass_pfs_sd
*
current_pfs
=
&
pbp_device_block
->
bypass_pfs_set
;
struct
bypass_pfs_sd
*
current_pfs
=
&
pbp_device_block
->
bypass_pfs_set
;
struct
proc_dir_entry
*
pde
=
current_pfs
->
bypass_entry
,
*
pde_curr
=
remove_proc_subtree
(
current_pfs
->
dir_name
,
bp_procfs_dir
);
NULL
;
char
name
[
256
];
if
(
!
pde
)
return
0
;
for
(
pde
=
pde
->
subdir
;
pde
;)
{
strcpy
(
name
,
pde
->
name
);
pde_curr
=
pde
;
pde
=
pde
->
next
;
remove_proc_entry
(
name
,
current_pfs
->
bypass_entry
);
}
if
(
!
pde
)
remove_proc_entry
(
current_pfs
->
dir_name
,
bp_procfs_dir
);
current_pfs
->
bypass_entry
=
NULL
;
current_pfs
->
bypass_entry
=
NULL
;
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment