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
6cc6a67d
Commit
6cc6a67d
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/char/esp.c converted to dynamic allocation
parent
33621cc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
35 deletions
+41
-35
drivers/char/esp.c
drivers/char/esp.c
+41
-35
No files found.
drivers/char/esp.c
View file @
6cc6a67d
...
@@ -109,7 +109,7 @@ static char serial_version[] __initdata = "2.2";
...
@@ -109,7 +109,7 @@ static char serial_version[] __initdata = "2.2";
static
DECLARE_TASK_QUEUE
(
tq_esp
);
static
DECLARE_TASK_QUEUE
(
tq_esp
);
static
struct
tty_driver
esp_driver
;
static
struct
tty_driver
*
esp_driver
;
/* serial subtype definitions */
/* serial subtype definitions */
#define SERIAL_TYPE_NORMAL 1
#define SERIAL_TYPE_NORMAL 1
...
@@ -2442,6 +2442,26 @@ static _INLINE_ int autoconfig(struct esp_struct * info, int *region_start)
...
@@ -2442,6 +2442,26 @@ static _INLINE_ int autoconfig(struct esp_struct * info, int *region_start)
return
(
port_detected
);
return
(
port_detected
);
}
}
static
struct
tty_operations
esp_ops
=
{
.
open
=
esp_open
,
.
close
=
rs_close
,
.
write
=
rs_write
,
.
put_char
=
rs_put_char
,
.
flush_chars
=
rs_flush_chars
,
.
write_room
=
rs_write_room
,
.
chars_in_buffer
=
rs_chars_in_buffer
,
.
flush_buffer
=
rs_flush_buffer
,
.
ioctl
=
rs_ioctl
,
.
throttle
=
rs_throttle
,
.
unthrottle
=
rs_unthrottle
,
.
set_termios
=
rs_set_termios
,
.
stop
=
rs_stop
,
.
start
=
rs_start
,
.
hangup
=
esp_hangup
,
.
break_ctl
=
esp_break
,
.
wait_until_sent
=
rs_wait_until_sent
,
};
/*
/*
* The serial driver boot-time initialization code!
* The serial driver boot-time initialization code!
*/
*/
...
@@ -2452,6 +2472,10 @@ int __init espserial_init(void)
...
@@ -2452,6 +2472,10 @@ int __init espserial_init(void)
struct
esp_struct
*
info
;
struct
esp_struct
*
info
;
struct
esp_struct
*
last_primary
=
0
;
struct
esp_struct
*
last_primary
=
0
;
int
esp
[]
=
{
0x100
,
0x140
,
0x180
,
0x200
,
0x240
,
0x280
,
0x300
,
0x380
};
int
esp
[]
=
{
0x100
,
0x140
,
0x180
,
0x200
,
0x240
,
0x280
,
0x300
,
0x380
};
esp_driver
=
alloc_tty_driver
(
NR_PORTS
);
if
(
!
esp_driver
)
return
-
ENOMEM
;
init_bh
(
ESP_BH
,
do_serial_bh
);
init_bh
(
ESP_BH
,
do_serial_bh
);
...
@@ -2490,41 +2514,21 @@ int __init espserial_init(void)
...
@@ -2490,41 +2514,21 @@ int __init espserial_init(void)
/* Initialize the tty_driver structure */
/* Initialize the tty_driver structure */
memset
(
&
esp_driver
,
0
,
sizeof
(
struct
tty_driver
));
esp_driver
->
owner
=
THIS_MODULE
;
esp_driver
.
magic
=
TTY_DRIVER_MAGIC
;
esp_driver
->
name
=
"ttyP"
;
esp_driver
.
owner
=
THIS_MODULE
;
esp_driver
->
major
=
ESP_IN_MAJOR
;
esp_driver
.
name
=
"ttyP"
;
esp_driver
->
minor_start
=
0
;
esp_driver
.
major
=
ESP_IN_MAJOR
;
esp_driver
->
type
=
TTY_DRIVER_TYPE_SERIAL
;
esp_driver
.
minor_start
=
0
;
esp_driver
->
subtype
=
SERIAL_TYPE_NORMAL
;
esp_driver
.
num
=
NR_PORTS
;
esp_driver
->
init_termios
=
tty_std_termios
;
esp_driver
.
type
=
TTY_DRIVER_TYPE_SERIAL
;
esp_driver
->
init_termios
.
c_cflag
=
esp_driver
.
subtype
=
SERIAL_TYPE_NORMAL
;
esp_driver
.
init_termios
=
tty_std_termios
;
esp_driver
.
init_termios
.
c_cflag
=
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
esp_driver
.
flags
=
TTY_DRIVER_REAL_RAW
;
esp_driver
->
flags
=
TTY_DRIVER_REAL_RAW
;
tty_set_operations
(
esp_driver
,
&
esp_ops
);
esp_driver
.
open
=
esp_open
;
if
(
tty_register_driver
(
esp_driver
))
esp_driver
.
close
=
rs_close
;
esp_driver
.
write
=
rs_write
;
esp_driver
.
put_char
=
rs_put_char
;
esp_driver
.
flush_chars
=
rs_flush_chars
;
esp_driver
.
write_room
=
rs_write_room
;
esp_driver
.
chars_in_buffer
=
rs_chars_in_buffer
;
esp_driver
.
flush_buffer
=
rs_flush_buffer
;
esp_driver
.
ioctl
=
rs_ioctl
;
esp_driver
.
throttle
=
rs_throttle
;
esp_driver
.
unthrottle
=
rs_unthrottle
;
esp_driver
.
set_termios
=
rs_set_termios
;
esp_driver
.
stop
=
rs_stop
;
esp_driver
.
start
=
rs_start
;
esp_driver
.
hangup
=
esp_hangup
;
esp_driver
.
break_ctl
=
esp_break
;
esp_driver
.
wait_until_sent
=
rs_wait_until_sent
;
if
(
tty_register_driver
(
&
esp_driver
))
{
{
printk
(
KERN_ERR
"Couldn't register esp serial driver"
);
printk
(
KERN_ERR
"Couldn't register esp serial driver"
);
put_tty_driver
(
esp_driver
);
return
1
;
return
1
;
}
}
...
@@ -2533,7 +2537,8 @@ int __init espserial_init(void)
...
@@ -2533,7 +2537,8 @@ int __init espserial_init(void)
if
(
!
info
)
if
(
!
info
)
{
{
printk
(
KERN_ERR
"Couldn't allocate memory for esp serial device information
\n
"
);
printk
(
KERN_ERR
"Couldn't allocate memory for esp serial device information
\n
"
);
tty_unregister_driver
(
&
esp_driver
);
tty_unregister_driver
(
esp_driver
);
put_tty_driver
(
esp_driver
);
return
1
;
return
1
;
}
}
...
@@ -2636,10 +2641,11 @@ static void __exit espserial_exit(void)
...
@@ -2636,10 +2641,11 @@ static void __exit espserial_exit(void)
save_flags
(
flags
);
save_flags
(
flags
);
cli
();
cli
();
remove_bh
(
ESP_BH
);
remove_bh
(
ESP_BH
);
if
((
e1
=
tty_unregister_driver
(
&
esp_driver
)))
if
((
e1
=
tty_unregister_driver
(
esp_driver
)))
printk
(
"SERIAL: failed to unregister serial driver (%d)
\n
"
,
printk
(
"SERIAL: failed to unregister serial driver (%d)
\n
"
,
e1
);
e1
);
restore_flags
(
flags
);
restore_flags
(
flags
);
put_tty_driver
(
esp_driver
);
while
(
ports
)
{
while
(
ports
)
{
if
(
ports
->
port
)
{
if
(
ports
->
port
)
{
...
...
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