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
81213932
Commit
81213932
authored
Aug 14, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USB: handle overloading of usb-serial functions in a much cleaner manner.
parent
5e103620
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
33 deletions
+33
-33
drivers/usb/serial/usb-serial.c
drivers/usb/serial/usb-serial.c
+33
-33
No files found.
drivers/usb/serial/usb-serial.c
View file @
81213932
...
@@ -482,10 +482,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
...
@@ -482,10 +482,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
if
(
port
->
open_count
==
1
)
{
if
(
port
->
open_count
==
1
)
{
/* only call the device specific open if this
/* only call the device specific open if this
* is the first time the port is opened */
* is the first time the port is opened */
if
(
serial
->
type
->
open
)
retval
=
serial
->
type
->
open
(
port
,
filp
);
retval
=
serial
->
type
->
open
(
port
,
filp
);
else
retval
=
usb_serial_generic_open
(
port
,
filp
);
if
(
retval
)
{
if
(
retval
)
{
port
->
open_count
=
0
;
port
->
open_count
=
0
;
module_put
(
serial
->
type
->
owner
);
module_put
(
serial
->
type
->
owner
);
...
@@ -507,10 +504,7 @@ static void __serial_close(struct usb_serial_port *port, struct file *filp)
...
@@ -507,10 +504,7 @@ static void __serial_close(struct usb_serial_port *port, struct file *filp)
if
(
port
->
open_count
<=
0
)
{
if
(
port
->
open_count
<=
0
)
{
/* only call the device specific close if this
/* only call the device specific close if this
* port is being closed by the last owner */
* port is being closed by the last owner */
if
(
port
->
serial
->
type
->
close
)
port
->
serial
->
type
->
close
(
port
,
filp
);
port
->
serial
->
type
->
close
(
port
,
filp
);
else
usb_serial_generic_close
(
port
,
filp
);
port
->
open_count
=
0
;
port
->
open_count
=
0
;
}
}
...
@@ -552,11 +546,8 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned
...
@@ -552,11 +546,8 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned
goto
exit
;
goto
exit
;
}
}
/* pass on to the driver specific version of this function if it is available */
/* pass on to the driver specific version of this function */
if
(
serial
->
type
->
write
)
retval
=
serial
->
type
->
write
(
port
,
from_user
,
buf
,
count
);
retval
=
serial
->
type
->
write
(
port
,
from_user
,
buf
,
count
);
else
retval
=
usb_serial_generic_write
(
port
,
from_user
,
buf
,
count
);
exit:
exit:
return
retval
;
return
retval
;
...
@@ -578,11 +569,8 @@ static int serial_write_room (struct tty_struct *tty)
...
@@ -578,11 +569,8 @@ static int serial_write_room (struct tty_struct *tty)
goto
exit
;
goto
exit
;
}
}
/* pass on to the driver specific version of this function if it is available */
/* pass on to the driver specific version of this function */
if
(
serial
->
type
->
write_room
)
retval
=
serial
->
type
->
write_room
(
port
);
retval
=
serial
->
type
->
write_room
(
port
);
else
retval
=
usb_serial_generic_write_room
(
port
);
exit:
exit:
return
retval
;
return
retval
;
...
@@ -604,11 +592,8 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
...
@@ -604,11 +592,8 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
goto
exit
;
goto
exit
;
}
}
/* pass on to the driver specific version of this function if it is available */
/* pass on to the driver specific version of this function */
if
(
serial
->
type
->
chars_in_buffer
)
retval
=
serial
->
type
->
chars_in_buffer
(
port
);
retval
=
serial
->
type
->
chars_in_buffer
(
port
);
else
retval
=
usb_serial_generic_chars_in_buffer
(
port
);
exit:
exit:
return
retval
;
return
retval
;
...
@@ -736,10 +721,7 @@ static void serial_shutdown (struct usb_serial *serial)
...
@@ -736,10 +721,7 @@ static void serial_shutdown (struct usb_serial *serial)
{
{
dbg
(
"%s"
,
__FUNCTION__
);
dbg
(
"%s"
,
__FUNCTION__
);
if
(
serial
->
type
->
shutdown
)
serial
->
type
->
shutdown
(
serial
);
serial
->
type
->
shutdown
(
serial
);
else
usb_serial_generic_shutdown
(
serial
);
}
}
static
int
serial_read_proc
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
static
int
serial_read_proc
(
char
*
page
,
char
**
start
,
off_t
off
,
int
count
,
int
*
eof
,
void
*
data
)
...
@@ -1186,9 +1168,7 @@ int usb_serial_probe(struct usb_interface *interface,
...
@@ -1186,9 +1168,7 @@ int usb_serial_probe(struct usb_interface *interface,
usb_rcvbulkpipe
(
dev
,
usb_rcvbulkpipe
(
dev
,
endpoint
->
bEndpointAddress
),
endpoint
->
bEndpointAddress
),
port
->
bulk_in_buffer
,
buffer_size
,
port
->
bulk_in_buffer
,
buffer_size
,
((
serial
->
type
->
read_bulk_callback
)
?
serial
->
type
->
read_bulk_callback
,
serial
->
type
->
read_bulk_callback
:
usb_serial_generic_read_bulk_callback
),
port
);
port
);
}
}
...
@@ -1212,9 +1192,7 @@ int usb_serial_probe(struct usb_interface *interface,
...
@@ -1212,9 +1192,7 @@ int usb_serial_probe(struct usb_interface *interface,
usb_sndbulkpipe
(
dev
,
usb_sndbulkpipe
(
dev
,
endpoint
->
bEndpointAddress
),
endpoint
->
bEndpointAddress
),
port
->
bulk_out_buffer
,
buffer_size
,
port
->
bulk_out_buffer
,
buffer_size
,
((
serial
->
type
->
write_bulk_callback
)
?
serial
->
type
->
write_bulk_callback
,
serial
->
type
->
write_bulk_callback
:
usb_serial_generic_write_bulk_callback
),
port
);
port
);
}
}
...
@@ -1429,11 +1407,33 @@ static void __exit usb_serial_exit(void)
...
@@ -1429,11 +1407,33 @@ static void __exit usb_serial_exit(void)
module_init
(
usb_serial_init
);
module_init
(
usb_serial_init
);
module_exit
(
usb_serial_exit
);
module_exit
(
usb_serial_exit
);
#define set_to_generic_if_null(type, function) \
do { \
if (!type->function) { \
type->function = usb_serial_generic_##function; \
dbg("Had to override the " #function \
" usb serial operation with the generic one.");\
} \
} while (0)
static
void
fixup_generic
(
struct
usb_serial_device_type
*
device
)
{
set_to_generic_if_null
(
device
,
open
);
set_to_generic_if_null
(
device
,
write
);
set_to_generic_if_null
(
device
,
close
);
set_to_generic_if_null
(
device
,
write_room
);
set_to_generic_if_null
(
device
,
chars_in_buffer
);
set_to_generic_if_null
(
device
,
read_bulk_callback
);
set_to_generic_if_null
(
device
,
write_bulk_callback
);
set_to_generic_if_null
(
device
,
shutdown
);
}
int
usb_serial_register
(
struct
usb_serial_device_type
*
new_device
)
int
usb_serial_register
(
struct
usb_serial_device_type
*
new_device
)
{
{
int
retval
;
int
retval
;
fixup_generic
(
new_device
);
/* Add this device to our list of devices */
/* Add this device to our list of devices */
list_add
(
&
new_device
->
driver_list
,
&
usb_serial_driver_list
);
list_add
(
&
new_device
->
driver_list
,
&
usb_serial_driver_list
);
...
...
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