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
nexedi
linux
Commits
33ee8ba6
Commit
33ee8ba6
authored
Jun 11, 2003
by
Alexander Viro
Committed by
Linus Torvalds
Jun 11, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] tty_driver refcounting
drivers/usb/class/cdc-acm.c converted to dynamic allocation
parent
6cc6a67d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
+27
-22
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-acm.c
+27
-22
No files found.
drivers/usb/class/cdc-acm.c
View file @
33ee8ba6
...
@@ -154,7 +154,7 @@ struct acm {
...
@@ -154,7 +154,7 @@ struct acm {
};
};
static
struct
usb_driver
acm_driver
;
static
struct
usb_driver
acm_driver
;
static
struct
tty_driver
acm_tty_driver
;
static
struct
tty_driver
*
acm_tty_driver
;
static
struct
acm
*
acm_table
[
ACM_TTY_MINORS
];
static
struct
acm
*
acm_table
[
ACM_TTY_MINORS
];
#define ACM_READY(acm) (acm && acm->dev && acm->used)
#define ACM_READY(acm) (acm && acm->dev && acm->used)
...
@@ -364,7 +364,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
...
@@ -364,7 +364,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
usb_unlink_urb
(
acm
->
writeurb
);
usb_unlink_urb
(
acm
->
writeurb
);
usb_unlink_urb
(
acm
->
readurb
);
usb_unlink_urb
(
acm
->
readurb
);
}
else
{
}
else
{
tty_unregister_device
(
&
acm_tty_driver
,
acm
->
minor
);
tty_unregister_device
(
acm_tty_driver
,
acm
->
minor
);
acm_table
[
acm
->
minor
]
=
NULL
;
acm_table
[
acm
->
minor
]
=
NULL
;
usb_free_urb
(
acm
->
ctrlurb
);
usb_free_urb
(
acm
->
ctrlurb
);
usb_free_urb
(
acm
->
readurb
);
usb_free_urb
(
acm
->
readurb
);
...
@@ -667,7 +667,7 @@ static int acm_probe (struct usb_interface *intf,
...
@@ -667,7 +667,7 @@ static int acm_probe (struct usb_interface *intf,
usb_driver_claim_interface
(
&
acm_driver
,
acm
->
iface
+
0
,
acm
);
usb_driver_claim_interface
(
&
acm_driver
,
acm
->
iface
+
0
,
acm
);
usb_driver_claim_interface
(
&
acm_driver
,
acm
->
iface
+
1
,
acm
);
usb_driver_claim_interface
(
&
acm_driver
,
acm
->
iface
+
1
,
acm
);
tty_register_device
(
&
acm_tty_driver
,
minor
,
&
intf
->
dev
);
tty_register_device
(
acm_tty_driver
,
minor
,
&
intf
->
dev
);
acm_table
[
minor
]
=
acm
;
acm_table
[
minor
]
=
acm
;
usb_set_intfdata
(
intf
,
acm
);
usb_set_intfdata
(
intf
,
acm
);
...
@@ -699,7 +699,7 @@ static void acm_disconnect(struct usb_interface *intf)
...
@@ -699,7 +699,7 @@ static void acm_disconnect(struct usb_interface *intf)
usb_driver_release_interface
(
&
acm_driver
,
acm
->
iface
+
1
);
usb_driver_release_interface
(
&
acm_driver
,
acm
->
iface
+
1
);
if
(
!
acm
->
used
)
{
if
(
!
acm
->
used
)
{
tty_unregister_device
(
&
acm_tty_driver
,
acm
->
minor
);
tty_unregister_device
(
acm_tty_driver
,
acm
->
minor
);
acm_table
[
acm
->
minor
]
=
NULL
;
acm_table
[
acm
->
minor
]
=
NULL
;
usb_free_urb
(
acm
->
ctrlurb
);
usb_free_urb
(
acm
->
ctrlurb
);
usb_free_urb
(
acm
->
readurb
);
usb_free_urb
(
acm
->
readurb
);
...
@@ -736,18 +736,7 @@ static struct usb_driver acm_driver = {
...
@@ -736,18 +736,7 @@ static struct usb_driver acm_driver = {
* TTY driver structures.
* TTY driver structures.
*/
*/
static
struct
tty_driver
acm_tty_driver
=
{
static
struct
tty_operations
acm_ops
=
{
.
magic
=
TTY_DRIVER_MAGIC
,
.
owner
=
THIS_MODULE
,
.
driver_name
=
"acm"
,
.
name
=
"usb/acm/"
,
.
major
=
ACM_TTY_MAJOR
,
.
minor_start
=
0
,
.
num
=
ACM_TTY_MINORS
,
.
type
=
TTY_DRIVER_TYPE_SERIAL
,
.
subtype
=
SERIAL_TYPE_NORMAL
,
.
flags
=
TTY_DRIVER_REAL_RAW
|
TTY_DRIVER_NO_DEVFS
,
.
open
=
acm_tty_open
,
.
open
=
acm_tty_open
,
.
close
=
acm_tty_close
,
.
close
=
acm_tty_close
,
.
write
=
acm_tty_write
,
.
write
=
acm_tty_write
,
...
@@ -768,14 +757,29 @@ static struct tty_driver acm_tty_driver = {
...
@@ -768,14 +757,29 @@ static struct tty_driver acm_tty_driver = {
static
int
__init
acm_init
(
void
)
static
int
__init
acm_init
(
void
)
{
{
acm_tty_driver
.
init_termios
=
tty_std_termios
;
acm_tty_driver
=
alloc_tty_driver
(
ACM_TTY_MINORS
);
acm_tty_driver
.
init_termios
.
c_cflag
=
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
if
(
!
acm_tty_driver
)
return
-
ENOMEM
;
if
(
tty_register_driver
(
&
acm_tty_driver
))
acm_tty_driver
->
owner
=
THIS_MODULE
,
acm_tty_driver
->
driver_name
=
"acm"
,
acm_tty_driver
->
name
=
"usb/acm/"
,
acm_tty_driver
->
major
=
ACM_TTY_MAJOR
,
acm_tty_driver
->
minor_start
=
0
,
acm_tty_driver
->
type
=
TTY_DRIVER_TYPE_SERIAL
,
acm_tty_driver
->
subtype
=
SERIAL_TYPE_NORMAL
,
acm_tty_driver
->
flags
=
TTY_DRIVER_REAL_RAW
|
TTY_DRIVER_NO_DEVFS
,
acm_tty_driver
->
init_termios
=
tty_std_termios
;
acm_tty_driver
->
init_termios
.
c_cflag
=
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
tty_set_operations
(
acm_tty_driver
,
&
acm_ops
);
if
(
tty_register_driver
(
acm_tty_driver
))
{
put_tty_driver
(
acm_tty_driver
);
return
-
1
;
return
-
1
;
}
if
(
usb_register
(
&
acm_driver
)
<
0
)
{
if
(
usb_register
(
&
acm_driver
)
<
0
)
{
tty_unregister_driver
(
&
acm_tty_driver
);
tty_unregister_driver
(
acm_tty_driver
);
put_tty_driver
(
acm_tty_driver
);
return
-
1
;
return
-
1
;
}
}
...
@@ -787,7 +791,8 @@ static int __init acm_init(void)
...
@@ -787,7 +791,8 @@ static int __init acm_init(void)
static
void
__exit
acm_exit
(
void
)
static
void
__exit
acm_exit
(
void
)
{
{
usb_deregister
(
&
acm_driver
);
usb_deregister
(
&
acm_driver
);
tty_unregister_driver
(
&
acm_tty_driver
);
tty_unregister_driver
(
acm_tty_driver
);
put_tty_driver
(
acm_tty_driver
);
}
}
module_init
(
acm_init
);
module_init
(
acm_init
);
...
...
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