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
0bf9a040
Commit
0bf9a040
authored
Dec 11, 2002
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] USB: Moved usb-serial bus specific code to a separate file.
parent
8570cd0b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
160 additions
and
111 deletions
+160
-111
drivers/usb/serial/Makefile
drivers/usb/serial/Makefile
+1
-1
drivers/usb/serial/bus.c
drivers/usb/serial/bus.c
+138
-0
drivers/usb/serial/usb-serial.c
drivers/usb/serial/usb-serial.c
+16
-110
drivers/usb/serial/usb-serial.h
drivers/usb/serial/usb-serial.h
+5
-0
No files found.
drivers/usb/serial/Makefile
View file @
0bf9a040
...
...
@@ -33,7 +33,7 @@ obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
# Objects that export symbols.
export-objs
:=
usb-serial.o ezusb.o
usbserial-objs
:=
usb-serial.o generic.o
$
(
usbserial-obj-y
)
usbserial-objs
:=
usb-serial.o generic.o
bus.o
$
(
usbserial-obj-y
)
include
$(TOPDIR)/Rules.make
drivers/usb/serial/bus.c
0 → 100644
View file @
0bf9a040
/*
* USB Serial Converter Bus specific functions
*
* Copyright (C) 2002 Greg Kroah-Hartman (greg@kroah.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
static
int
debug
=
1
;
#else
static
int
debug
;
#endif
#include "usb-serial.h"
static
int
usb_serial_device_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
{
struct
usb_serial_device_type
*
driver
;
const
struct
usb_serial_port
*
port
;
/*
* drivers are already assigned to ports in serial_probe so it's
* a simple check here.
*/
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
return
0
;
driver
=
to_usb_serial_driver
(
drv
);
if
(
driver
==
port
->
serial
->
type
)
return
1
;
return
0
;
}
struct
bus_type
usb_serial_bus_type
=
{
.
name
=
"usb-serial"
,
.
match
=
usb_serial_device_match
,
};
static
int
usb_serial_device_probe
(
struct
device
*
dev
)
{
struct
usb_serial_device_type
*
driver
;
struct
usb_serial_port
*
port
;
int
retval
=
0
;
int
minor
;
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
{
retval
=
-
ENODEV
;
goto
exit
;
}
driver
=
port
->
serial
->
type
;
if
(
driver
->
port_probe
)
{
if
(
!
try_module_get
(
driver
->
owner
))
{
err
(
"module get failed, exiting"
);
retval
=
-
EIO
;
goto
exit
;
}
retval
=
driver
->
port_probe
(
port
);
module_put
(
driver
->
owner
);
if
(
retval
)
goto
exit
;
}
minor
=
port
->
number
;
tty_register_devfs
(
&
usb_serial_tty_driver
,
0
,
minor
);
info
(
"%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)"
,
driver
->
name
,
minor
,
minor
);
exit:
return
retval
;
}
static
int
usb_serial_device_remove
(
struct
device
*
dev
)
{
struct
usb_serial_device_type
*
driver
;
struct
usb_serial_port
*
port
;
int
retval
=
0
;
int
minor
;
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
{
return
-
ENODEV
;
}
driver
=
port
->
serial
->
type
;
if
(
driver
->
port_remove
)
{
if
(
!
try_module_get
(
driver
->
owner
))
{
err
(
"module get failed, exiting"
);
retval
=
-
EIO
;
goto
exit
;
}
retval
=
driver
->
port_remove
(
port
);
module_put
(
driver
->
owner
);
}
exit:
minor
=
port
->
number
;
tty_unregister_devfs
(
&
usb_serial_tty_driver
,
minor
);
info
(
"%s converter now disconnected from ttyUSB%d"
,
driver
->
name
,
minor
);
return
retval
;
}
int
usb_serial_bus_register
(
struct
usb_serial_device_type
*
device
)
{
int
retval
;
device
->
driver
.
name
=
(
char
*
)
device
->
name
;
device
->
driver
.
bus
=
&
usb_serial_bus_type
;
device
->
driver
.
probe
=
usb_serial_device_probe
;
device
->
driver
.
remove
=
usb_serial_device_remove
;
retval
=
driver_register
(
&
device
->
driver
);
return
retval
;
}
void
usb_serial_bus_deregister
(
struct
usb_serial_device_type
*
device
)
{
driver_unregister
(
&
device
->
driver
);
}
drivers/usb/serial/usb-serial.c
View file @
0bf9a040
...
...
@@ -382,38 +382,12 @@ static struct usb_driver usb_serial_driver = {
*/
static
int
serial_refcount
;
static
struct
tty_driver
serial_tty_driver
;
static
struct
tty_struct
*
serial_tty
[
SERIAL_TTY_MINORS
];
static
struct
termios
*
serial_termios
[
SERIAL_TTY_MINORS
];
static
struct
termios
*
serial_termios_locked
[
SERIAL_TTY_MINORS
];
static
struct
usb_serial
*
serial_table
[
SERIAL_TTY_MINORS
];
/* initially all NULL */
static
LIST_HEAD
(
usb_serial_driver_list
);
static
int
usb_serial_device_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
{
struct
usb_serial_device_type
*
driver
;
const
struct
usb_serial_port
*
port
;
/*
* drivers are already assigned to ports in serial_probe so it's
* a simple check here.
*/
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
return
0
;
driver
=
to_usb_serial_driver
(
drv
);
if
(
driver
==
port
->
serial
->
type
)
return
1
;
return
0
;
}
static
struct
bus_type
usb_serial_bus_type
=
{
.
name
=
"usb-serial"
,
.
match
=
usb_serial_device_match
,
};
struct
usb_serial
*
usb_serial_get_by_minor
(
unsigned
int
minor
)
{
...
...
@@ -1283,7 +1257,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
}
st
atic
struct
tty_driver
serial_tty_driver
=
{
st
ruct
tty_driver
usb_
serial_tty_driver
=
{
.
magic
=
TTY_DRIVER_MAGIC
,
.
driver_name
=
"usb-serial"
,
#ifndef CONFIG_DEVFS_FS
...
...
@@ -1337,9 +1311,9 @@ static int __init usb_serial_init(void)
}
/* register the tty driver */
serial_tty_driver
.
init_termios
=
tty_std_termios
;
serial_tty_driver
.
init_termios
.
c_cflag
=
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
result
=
tty_register_driver
(
&
serial_tty_driver
);
usb_serial_tty_driver
.
init_termios
=
tty_std_termios
;
usb_serial_tty_driver
.
init_termios
.
c_cflag
=
B9600
|
CS8
|
CREAD
|
HUPCL
|
CLOCAL
;
result
=
tty_register_driver
(
&
usb_
serial_tty_driver
);
if
(
result
)
{
err
(
"%s - tty_register_driver failed"
,
__FUNCTION__
);
goto
exit_generic
;
...
...
@@ -1357,7 +1331,7 @@ static int __init usb_serial_init(void)
return
result
;
exit_tty:
tty_unregister_driver
(
&
serial_tty_driver
);
tty_unregister_driver
(
&
usb_
serial_tty_driver
);
exit_generic:
usb_serial_generic_deregister
();
...
...
@@ -1375,7 +1349,7 @@ static void __exit usb_serial_exit(void)
usb_serial_generic_deregister
();
usb_deregister
(
&
usb_serial_driver
);
tty_unregister_driver
(
&
serial_tty_driver
);
tty_unregister_driver
(
&
usb_
serial_tty_driver
);
bus_unregister
(
&
usb_serial_bus_type
);
}
...
...
@@ -1383,72 +1357,6 @@ static void __exit usb_serial_exit(void)
module_init
(
usb_serial_init
);
module_exit
(
usb_serial_exit
);
static
int
usb_serial_device_probe
(
struct
device
*
dev
)
{
struct
usb_serial_device_type
*
driver
;
struct
usb_serial_port
*
port
;
int
retval
=
0
;
int
minor
;
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
{
retval
=
-
ENODEV
;
goto
exit
;
}
driver
=
port
->
serial
->
type
;
if
(
driver
->
port_probe
)
{
if
(
!
try_module_get
(
driver
->
owner
))
{
err
(
"module get failed, exiting"
);
retval
=
-
EIO
;
goto
exit
;
}
retval
=
driver
->
port_probe
(
port
);
module_put
(
driver
->
owner
);
if
(
retval
)
goto
exit
;
}
minor
=
port
->
number
;
tty_register_devfs
(
&
serial_tty_driver
,
0
,
minor
);
info
(
"%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)"
,
driver
->
name
,
minor
,
minor
);
exit:
return
retval
;
}
static
int
usb_serial_device_remove
(
struct
device
*
dev
)
{
struct
usb_serial_device_type
*
driver
;
struct
usb_serial_port
*
port
;
int
retval
=
0
;
int
minor
;
port
=
to_usb_serial_port
(
dev
);
if
(
!
port
)
{
return
-
ENODEV
;
}
driver
=
port
->
serial
->
type
;
if
(
driver
->
port_remove
)
{
if
(
!
try_module_get
(
driver
->
owner
))
{
err
(
"module get failed, exiting"
);
retval
=
-
EIO
;
goto
exit
;
}
retval
=
driver
->
port_remove
(
port
);
module_put
(
driver
->
owner
);
}
exit:
minor
=
port
->
number
;
tty_unregister_devfs
(
&
serial_tty_driver
,
minor
);
info
(
"%s converter now disconnected from ttyUSB%d"
,
driver
->
name
,
minor
);
return
retval
;
}
int
usb_serial_register
(
struct
usb_serial_device_type
*
new_device
)
{
...
...
@@ -1457,20 +1365,17 @@ int usb_serial_register(struct usb_serial_device_type *new_device)
/* Add this device to our list of devices */
list_add
(
&
new_device
->
driver_list
,
&
usb_serial_driver_list
);
new_device
->
driver
.
name
=
(
char
*
)
new_device
->
name
;
new_device
->
driver
.
bus
=
&
usb_serial_bus_type
;
new_device
->
driver
.
probe
=
usb_serial_device_probe
;
new_device
->
driver
.
remove
=
usb_serial_device_remove
;
retval
=
usb_serial_bus_register
(
new_device
)
;
if
(
retval
)
goto
error
;
retval
=
driver_register
(
&
new_device
->
driver
);
info
(
"USB Serial support registered for %s"
,
new_device
->
name
);
if
(
!
retval
)
{
info
(
"USB Serial support registered for %s"
,
new_device
->
name
);
}
else
{
err
(
"problem %d when registering driver %s"
,
retval
,
new_device
->
name
);
}
return
retval
;
error:
err
(
"problem %d when registering driver %s"
,
retval
,
new_device
->
name
);
list_del
(
&
new_device
->
driver_list
);
return
retval
;
}
...
...
@@ -1493,6 +1398,7 @@ void usb_serial_deregister(struct usb_serial_device_type *device)
}
list_del
(
&
device
->
driver_list
);
usb_serial_bus_deregister
(
device
);
}
...
...
drivers/usb/serial/usb-serial.h
View file @
0bf9a040
...
...
@@ -269,7 +269,12 @@ extern void usb_serial_generic_shutdown (struct usb_serial *serial);
extern
int
usb_serial_generic_register
(
int
debug
);
extern
void
usb_serial_generic_deregister
(
void
);
extern
int
usb_serial_bus_register
(
struct
usb_serial_device_type
*
device
);
extern
void
usb_serial_bus_deregister
(
struct
usb_serial_device_type
*
device
);
extern
struct
usb_serial_device_type
usb_serial_generic_device
;
extern
struct
bus_type
usb_serial_bus_type
;
extern
struct
tty_driver
usb_serial_tty_driver
;
/* Inline functions to check the sanity of a pointer that is passed to us */
static
inline
int
serial_paranoia_check
(
struct
usb_serial
*
serial
,
const
char
*
function
)
...
...
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