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
e19168ff
Commit
e19168ff
authored
May 06, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] USB: converted brlvger over to new usb_register_dev() changes.
parent
b41c55be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
51 deletions
+22
-51
drivers/usb/misc/brlvger.c
drivers/usb/misc/brlvger.c
+22
-43
include/linux/brlvger.h
include/linux/brlvger.h
+0
-8
No files found.
drivers/usb/misc/brlvger.c
View file @
e19168ff
...
...
@@ -50,7 +50,6 @@ static const char longbanner[] = {
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <linux/poll.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/brlvger.h>
MODULE_AUTHOR
(
DRIVER_AUTHOR
);
...
...
@@ -180,12 +179,6 @@ struct brlvger_priv {
/* Globals */
/* Table of connected devices, a different minor for each. */
static
struct
brlvger_priv
*
display_table
[
MAX_NR_BRLVGER_DEVS
];
/* Mutex for the operation of removing a device from display_table */
static
DECLARE_MUTEX
(
disconnect_sem
);
/* For blocking open */
static
DECLARE_WAIT_QUEUE_HEAD
(
open_wait
);
...
...
@@ -237,6 +230,13 @@ static struct file_operations brlvger_fops =
.
poll
=
brlvger_poll
,
};
static
struct
usb_class_driver
brlvger_class
=
{
.
name
=
"usb/brlvger%d"
,
.
fops
=
&
brlvger_fops
,
.
mode
=
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
,
.
minor_base
=
BRLVGER_MINOR
,
};
static
struct
usb_driver
brlvger_driver
=
{
.
owner
=
THIS_MODULE
,
...
...
@@ -254,8 +254,6 @@ __init brlvger_init (void)
if
(
stall_tries
<
1
||
write_repeats
<
1
)
return
-
EINVAL
;
memset
(
display_table
,
0
,
sizeof
(
display_table
));
if
(
usb_register
(
&
brlvger_driver
))
{
err
(
"USB registration failed"
);
return
-
ENOSYS
;
...
...
@@ -284,14 +282,12 @@ brlvger_probe (struct usb_interface *intf,
{
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
struct
brlvger_priv
*
priv
=
NULL
;
int
i
;
int
retval
;
struct
usb_endpoint_descriptor
*
endpoint
;
struct
usb_host_interface
*
actifsettings
;
/* protects against reentrance: once we've found a free slot
we reserve it.*/
static
DECLARE_MUTEX
(
reserve_sem
);
char
devfs_name
[
20
];
actifsettings
=
dev
->
actconfig
->
interface
->
altsetting
;
...
...
@@ -311,7 +307,7 @@ brlvger_probe (struct usb_interface *intf,
down
(
&
reserve_sem
);
retval
=
usb_register_dev
(
&
brlvger_fops
,
BRLVGER_MINOR
,
1
,
&
i
);
retval
=
usb_register_dev
(
intf
,
&
brlvger_class
);
if
(
retval
)
{
err
(
"Not able to get a minor for this device."
);
goto
error
;
...
...
@@ -331,7 +327,7 @@ brlvger_probe (struct usb_interface *intf,
init_MUTEX
(
&
priv
->
open_sem
);
init_MUTEX
(
&
priv
->
dev_sem
);
priv
->
subminor
=
i
;
priv
->
subminor
=
i
ntf
->
minor
;
/* we found a interrupt in endpoint */
priv
->
in_interrupt
=
endpoint
;
...
...
@@ -372,17 +368,9 @@ brlvger_probe (struct usb_interface *intf,
};
dbg
(
"Display length: %d"
,
priv
->
plength
);
sprintf
(
devfs_name
,
"usb/brlvger%d"
,
priv
->
subminor
);
devfs_register
(
NULL
,
devfs_name
,
DEVFS_FL_DEFAULT
,
USB_MAJOR
,
BRLVGER_MINOR
+
priv
->
subminor
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
,
&
brlvger_fops
,
NULL
);
display_table
[
i
]
=
priv
;
usb_set_intfdata
(
intf
,
priv
);
info
(
"Braille display %d is device major %d minor %d"
,
i
,
USB_MAJOR
,
BRLVGER_MINOR
+
i
);
i
ntf
->
minor
,
USB_MAJOR
,
BRLVGER_MINOR
+
intf
->
minor
);
/* Tell anyone waiting on a blocking open */
wake_up_interruptible
(
&
open_wait
);
...
...
@@ -414,12 +402,7 @@ brlvger_disconnect(struct usb_interface *intf)
if
(
priv
){
info
(
"Display %d disconnecting"
,
priv
->
subminor
);
devfs_remove
(
"usb/brlvger%d"
,
priv
->
subminor
);
usb_deregister_dev
(
1
,
priv
->
subminor
);
down
(
&
disconnect_sem
);
display_table
[
priv
->
subminor
]
=
NULL
;
up
(
&
disconnect_sem
);
usb_deregister_dev
(
intf
,
&
brlvger_class
);
down
(
&
priv
->
open_sem
);
down
(
&
priv
->
dev_sem
);
...
...
@@ -450,21 +433,18 @@ static int
brlvger_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
int
devnum
=
minor
(
inode
->
i_rdev
);
struct
brlvger_priv
*
priv
;
struct
usb_interface
*
intf
=
NULL
;
struct
brlvger_priv
*
priv
=
NULL
;
int
n
,
ret
;
if
(
devnum
<
BRLVGER_MINOR
||
devnum
>=
(
BRLVGER_MINOR
+
MAX_NR_BRLVGER_DEVS
))
if
(
devnum
<
0
)
return
-
ENXIO
;
n
=
devnum
-
BRLVGER_MINOR
;
do
{
down
(
&
disconnect_sem
);
priv
=
display_table
[
n
];
if
(
!
priv
)
{
up
(
&
disconnect_sem
);
intf
=
usb_find_interface
(
&
brlvger_driver
,
devnum
);
if
(
!
intf
)
{
if
(
file
->
f_flags
&
O_NONBLOCK
)
{
dbg3
(
"Failing non-blocking open: "
"device %d not connected"
,
n
);
...
...
@@ -475,19 +455,18 @@ brlvger_open(struct inode *inode, struct file *file)
minor is connected. */
dbg2
(
"Waiting for device %d to be connected"
,
n
);
ret
=
wait_event_interruptible
(
open_wait
,
display_table
[
n
]
!=
NULL
);
if
(
ret
)
{
(
intf
=
usb_find_interface
(
&
brlvger_driver
,
devnum
)));
if
(
ret
)
{
dbg2
(
"Interrupted wait for device %d"
,
n
);
return
ret
;
}
}
}
while
(
!
priv
);
/* We grabbed an existing device. */
}
while
(
!
intf
);
priv
=
usb_get_intfdata
(
intf
);
/* We grabbed an existing device. */
if
(
down_interruptible
(
&
priv
->
open_sem
))
return
-
ERESTARTSYS
;
up
(
&
disconnect_sem
);
/* Only one process can open each device, no sharing. */
ret
=
-
EBUSY
;
...
...
include/linux/brlvger.h
View file @
e19168ff
...
...
@@ -30,16 +30,8 @@
#define BRLVGER_DISPLAY_OFF 3
#define BRLVGER_BUZZ 4
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define MAX_NR_BRLVGER_DEVS 256
#define BRLVGER_MINOR 0
#else
/* Number of supported devices, and range of covered minors */
#define MAX_NR_BRLVGER_DEVS 4
/* Base minor for the char devices */
#define BRLVGER_MINOR 128
#endif
/* Size of some fields */
#define BRLVGER_HWVER_SIZE 2
...
...
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