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
e9f92fa1
Commit
e9f92fa1
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
added helper functions for allocation and freeing tty_driver
parent
0835153f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
1 deletion
+91
-1
drivers/char/tty_io.c
drivers/char/tty_io.c
+52
-0
include/linux/tty_driver.h
include/linux/tty_driver.h
+39
-1
No files found.
drivers/char/tty_io.c
View file @
e9f92fa1
...
...
@@ -2213,6 +2213,58 @@ EXPORT_SYMBOL(tty_register_device);
EXPORT_SYMBOL
(
tty_unregister_device
);
static
struct
kobject
tty_kobj
=
{.
name
=
"tty"
};
struct
tty_driver
*
alloc_tty_driver
(
int
lines
)
{
struct
tty_driver
*
driver
;
driver
=
kmalloc
(
sizeof
(
struct
tty_driver
),
GFP_KERNEL
);
if
(
driver
)
{
memset
(
driver
,
0
,
sizeof
(
struct
tty_driver
));
driver
->
magic
=
TTY_DRIVER_MAGIC
;
driver
->
num
=
lines
;
/* later we'll move allocation of tables here */
}
return
driver
;
}
void
put_tty_driver
(
struct
tty_driver
*
driver
)
{
kfree
(
driver
);
}
void
tty_set_operations
(
struct
tty_driver
*
driver
,
struct
tty_operations
*
op
)
{
driver
->
open
=
op
->
open
;
driver
->
close
=
op
->
close
;
driver
->
write
=
op
->
write
;
driver
->
put_char
=
op
->
put_char
;
driver
->
flush_chars
=
op
->
flush_chars
;
driver
->
write_room
=
op
->
write_room
;
driver
->
chars_in_buffer
=
op
->
chars_in_buffer
;
driver
->
ioctl
=
op
->
ioctl
;
driver
->
set_termios
=
op
->
set_termios
;
driver
->
throttle
=
op
->
throttle
;
driver
->
unthrottle
=
op
->
unthrottle
;
driver
->
stop
=
op
->
stop
;
driver
->
start
=
op
->
start
;
driver
->
hangup
=
op
->
hangup
;
driver
->
break_ctl
=
op
->
break_ctl
;
driver
->
flush_buffer
=
op
->
flush_buffer
;
driver
->
set_ldisc
=
op
->
set_ldisc
;
driver
->
wait_until_sent
=
op
->
wait_until_sent
;
driver
->
send_xchar
=
op
->
send_xchar
;
driver
->
read_proc
=
op
->
read_proc
;
driver
->
write_proc
=
op
->
write_proc
;
driver
->
tiocmget
=
op
->
tiocmget
;
driver
->
tiocmset
=
op
->
tiocmset
;
}
EXPORT_SYMBOL
(
alloc_tty_driver
);
EXPORT_SYMBOL
(
put_tty_driver
);
EXPORT_SYMBOL
(
tty_set_operations
);
/*
* Called by a tty driver to register itself.
*/
...
...
include/linux/tty_driver.h
View file @
e9f92fa1
...
...
@@ -119,6 +119,39 @@
#include <linux/list.h>
#include <linux/cdev.h>
struct
tty_struct
;
struct
tty_operations
{
int
(
*
open
)(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
void
(
*
close
)(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
int
(
*
write
)(
struct
tty_struct
*
tty
,
int
from_user
,
const
unsigned
char
*
buf
,
int
count
);
void
(
*
put_char
)(
struct
tty_struct
*
tty
,
unsigned
char
ch
);
void
(
*
flush_chars
)(
struct
tty_struct
*
tty
);
int
(
*
write_room
)(
struct
tty_struct
*
tty
);
int
(
*
chars_in_buffer
)(
struct
tty_struct
*
tty
);
int
(
*
ioctl
)(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
);
void
(
*
set_termios
)(
struct
tty_struct
*
tty
,
struct
termios
*
old
);
void
(
*
throttle
)(
struct
tty_struct
*
tty
);
void
(
*
unthrottle
)(
struct
tty_struct
*
tty
);
void
(
*
stop
)(
struct
tty_struct
*
tty
);
void
(
*
start
)(
struct
tty_struct
*
tty
);
void
(
*
hangup
)(
struct
tty_struct
*
tty
);
void
(
*
break_ctl
)(
struct
tty_struct
*
tty
,
int
state
);
void
(
*
flush_buffer
)(
struct
tty_struct
*
tty
);
void
(
*
set_ldisc
)(
struct
tty_struct
*
tty
);
void
(
*
wait_until_sent
)(
struct
tty_struct
*
tty
,
int
timeout
);
void
(
*
send_xchar
)(
struct
tty_struct
*
tty
,
char
ch
);
int
(
*
read_proc
)(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
);
int
(
*
write_proc
)(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
void
*
data
);
int
(
*
tiocmget
)(
struct
tty_struct
*
tty
,
struct
file
*
file
);
int
(
*
tiocmset
)(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
set
,
unsigned
int
clear
);
};
struct
tty_driver
{
int
magic
;
/* magic number for this structure */
struct
cdev
cdev
;
...
...
@@ -148,7 +181,7 @@ struct tty_driver {
/*
* Interface routines from the upper tty layer to the tty
* driver.
* driver.
Will be replaced with struct tty_operations.
*/
int
(
*
open
)(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
void
(
*
close
)(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
...
...
@@ -178,11 +211,16 @@ struct tty_driver {
int
(
*
tiocmget
)(
struct
tty_struct
*
tty
,
struct
file
*
file
);
int
(
*
tiocmset
)(
struct
tty_struct
*
tty
,
struct
file
*
file
,
unsigned
int
set
,
unsigned
int
clear
);
struct
list_head
tty_drivers
;
};
extern
struct
list_head
tty_drivers
;
struct
tty_driver
*
alloc_tty_driver
(
int
lines
);
void
put_tty_driver
(
struct
tty_driver
*
driver
);
void
tty_set_operations
(
struct
tty_driver
*
driver
,
struct
tty_operations
*
op
);
/* tty driver magic number */
#define TTY_DRIVER_MAGIC 0x5402
...
...
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