Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FPGA Configuration Space
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
FPGA Configuration Space
Commits
48a3bc94
Commit
48a3bc94
authored
11 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
usb: add a vendor code to indicate device open/close status
parent
047d2add
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pcie-wb/usb_wb.c
+46
-0
46 additions, 0 deletions
pcie-wb/usb_wb.c
with
46 additions
and
0 deletions
pcie-wb/usb_wb.c
+
46
−
0
View file @
48a3bc94
...
...
@@ -14,6 +14,8 @@
#include
<linux/usb/serial.h>
#include
<linux/uaccess.h>
#define GSI_VENDOR_OPENCLOSE 0xB0
static
const
struct
usb_device_id
id_table
[]
=
{
{
USB_DEVICE_AND_INTERFACE_INFO
(
0x1D50
,
0x6062
,
0xFF
,
0xFF
,
0xFF
)
},
{
},
...
...
@@ -28,6 +30,48 @@ static struct usb_driver usb_wb_driver = {
.
no_dynamic_id
=
1
,
};
static
int
usb_wb_open
(
struct
tty_struct
*
tty
,
struct
usb_serial_port
*
port
)
{
struct
usb_device
*
dev
=
port
->
serial
->
dev
;
int
result
;
result
=
usb_control_msg
(
dev
,
usb_sndctrlpipe
(
dev
,
0
),
/* Send to EP0OUT */
GSI_VENDOR_OPENCLOSE
,
USB_DIR_OUT
|
USB_TYPE_VENDOR
|
USB_RECIP_INTERFACE
,
1
,
/* wValue (2..3) = device is open */
port
->
serial
->
interface
->
cur_altsetting
->
desc
.
bInterfaceNumber
,
0
,
0
,
/* no data stage */
5000
);
/* timeout */
if
(
result
<
0
)
dev_err
(
&
dev
->
dev
,
"Could not mark device as open (result = %d)
\n
"
,
result
);
return
usb_serial_generic_open
(
tty
,
port
);
}
static
void
usb_wb_close
(
struct
usb_serial_port
*
port
)
{
struct
usb_device
*
dev
=
port
->
serial
->
dev
;
int
result
;
result
=
usb_control_msg
(
dev
,
usb_sndctrlpipe
(
dev
,
0
),
/* Send to EP0OUT */
GSI_VENDOR_OPENCLOSE
,
USB_DIR_OUT
|
USB_TYPE_VENDOR
|
USB_RECIP_INTERFACE
,
0
,
/* wValue (2..3) = device is closed */
port
->
serial
->
interface
->
cur_altsetting
->
desc
.
bInterfaceNumber
,
0
,
0
,
/* no data stage */
5000
);
/* timeout */
if
(
result
<
0
)
dev_err
(
&
dev
->
dev
,
"Could not mark device as closed (result = %d)
\n
"
,
result
);
return
usb_serial_generic_close
(
port
);
}
static
struct
usb_serial_driver
usb_wb_device
=
{
.
driver
=
{
.
owner
=
THIS_MODULE
,
...
...
@@ -36,6 +80,8 @@ static struct usb_serial_driver usb_wb_device = {
.
id_table
=
id_table
,
.
usb_driver
=
&
usb_wb_driver
,
.
num_ports
=
1
,
.
open
=
&
usb_wb_open
,
.
close
=
&
usb_wb_close
,
};
static
int
__init
usb_wb_init
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment