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
7fabc884
Commit
7fabc884
authored
Sep 05, 2014
by
Marti Bolivar
Committed by
Greg Kroah-Hartman
Sep 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greybus: uart-gb.c: dynamically allocate device numbers
parent
f8089c0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
drivers/staging/greybus/uart-gb.c
drivers/staging/greybus/uart-gb.c
+33
-14
No files found.
drivers/staging/greybus/uart-gb.c
View file @
7fabc884
...
...
@@ -23,10 +23,13 @@
#include <linux/tty_flip.h>
#include <linux/serial.h>
#include <linux/idr.h>
#include <linux/fs.h>
#include <linux/kdev_t.h>
#include "greybus.h"
#define GB_TTY_MAJOR 180
/* FIXME use a real number!!! */
#define GB_NUM_MINORS 255
/* 255 is enough for anyone... */
#define GB_NAME "ttyGB"
struct
gb_tty
{
struct
tty_port
port
;
...
...
@@ -467,16 +470,24 @@ static struct greybus_driver tty_gb_driver = {
int
__init
gb_tty_init
(
void
)
{
int
retval
;
int
retval
=
0
;
dev_t
dev
;
retval
=
alloc_chrdev_region
(
&
dev
,
0
,
GB_NUM_MINORS
,
GB_NAME
);
if
(
retval
)
return
retval
;
gb_tty_driver
=
tty_alloc_driver
(
GB_NUM_MINORS
,
0
);
if
(
IS_ERR
(
gb_tty_driver
))
return
-
ENOMEM
;
if
(
IS_ERR
(
gb_tty_driver
))
{
retval
=
-
ENOMEM
;
goto
fail_unregister_dev
;
}
gb_tty_driver
->
owner
=
THIS_MODULE
;
gb_tty_driver
->
driver_name
=
"gb"
;
gb_tty_driver
->
name
=
"ttyGB"
;
gb_tty_driver
->
major
=
GB_TTY_MAJOR
;
gb_tty_driver
->
minor_start
=
0
;
gb_tty_driver
->
name
=
GB_NAME
;
gb_tty_driver
->
major
=
MAJOR
(
dev
)
;
gb_tty_driver
->
minor_start
=
MINOR
(
dev
)
;
gb_tty_driver
->
type
=
TTY_DRIVER_TYPE_SERIAL
;
gb_tty_driver
->
subtype
=
SERIAL_TYPE_NORMAL
;
gb_tty_driver
->
flags
=
TTY_DRIVER_REAL_RAW
|
TTY_DRIVER_DYNAMIC_DEV
;
...
...
@@ -485,24 +496,32 @@ int __init gb_tty_init(void)
tty_set_operations
(
gb_tty_driver
,
&
gb_ops
);
retval
=
tty_register_driver
(
gb_tty_driver
);
if
(
retval
)
{
put_tty_driver
(
gb_tty_driver
);
return
retval
;
}
if
(
retval
)
goto
fail_put_gb_tty
;
retval
=
greybus_register
(
&
tty_gb_driver
);
if
(
retval
)
{
if
(
retval
)
goto
fail_unregister_gb_tty
;
return
0
;
fail_unregister_gb_tty:
tty_unregister_driver
(
gb_tty_driver
);
fail_put_gb_tty:
put_tty_driver
(
gb_tty_driver
);
}
fail_unregister_dev:
unregister_chrdev_region
(
dev
,
GB_NUM_MINORS
);
return
retval
;
}
void
__exit
gb_tty_exit
(
void
)
{
int
major
=
MAJOR
(
gb_tty_driver
->
major
);
int
minor
=
gb_tty_driver
->
minor_start
;
greybus_deregister
(
&
tty_gb_driver
);
tty_unregister_driver
(
gb_tty_driver
);
put_tty_driver
(
gb_tty_driver
);
unregister_chrdev_region
(
MKDEV
(
major
,
minor
),
GB_NUM_MINORS
);
}
#if 0
...
...
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