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
2d67b792
Commit
2d67b792
authored
May 06, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] USB: converted scanner over to new usb_register_dev() changes.
parent
3a672820
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
29 deletions
+19
-29
drivers/usb/image/scanner.c
drivers/usb/image/scanner.c
+19
-25
drivers/usb/image/scanner.h
drivers/usb/image/scanner.h
+0
-4
No files found.
drivers/usb/image/scanner.c
View file @
2d67b792
...
...
@@ -397,7 +397,6 @@
*/
#include <linux/devfs_fs_kernel.h>
#include <asm/byteorder.h>
/*
...
...
@@ -843,9 +842,6 @@ static void destroy_scanner (struct kobject *kobj)
kfree
(
scn
->
ibuf
);
kfree
(
scn
->
obuf
);
dbg
(
"%s: De-allocating minor:%d"
,
__FUNCTION__
,
scn
->
scn_minor
);
devfs_remove
(
"usb/scanner%d"
,
scn
->
scn_minor
-
SCN_BASE_MNR
);
usb_deregister_dev
(
1
,
scn
->
scn_minor
);
usb_free_urb
(
scn
->
scn_irq
);
usb_put_dev
(
scn
->
scn_dev
);
up
(
&
(
scn
->
sem
));
...
...
@@ -867,6 +863,13 @@ file_operations usb_scanner_fops = {
.
release
=
close_scanner
,
};
static
struct
usb_class_driver
scanner_class
=
{
.
name
=
"usb/scanner%d"
,
.
fops
=
&
usb_scanner_fops
,
.
mode
=
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
|
S_IWOTH
,
.
minor_base
=
SCN_BASE_MNR
,
};
static
int
probe_scanner
(
struct
usb_interface
*
intf
,
const
struct
usb_device_id
*
id
)
...
...
@@ -878,7 +881,6 @@ probe_scanner(struct usb_interface *intf,
int
ep_cnt
;
int
ix
;
int
scn_minor
;
int
retval
;
char
valid_device
=
0
;
...
...
@@ -1011,14 +1013,14 @@ probe_scanner(struct usb_interface *intf,
down
(
&
scn_mutex
);
retval
=
usb_register_dev
(
&
usb_scanner_fops
,
SCN_BASE_MNR
,
1
,
&
scn_minor
);
retval
=
usb_register_dev
(
intf
,
&
scanner_class
);
if
(
retval
)
{
err
(
"Not able to get a minor for this device."
);
up
(
&
scn_mutex
);
return
-
ENOMEM
;
}
dbg
(
"probe_scanner: Allocated minor:%d"
,
scn_
minor
);
dbg
(
"probe_scanner: Allocated minor:%d"
,
intf
->
minor
);
if
(
!
(
scn
=
kmalloc
(
sizeof
(
struct
scn_usb_data
),
GFP_KERNEL
)))
{
err
(
"probe_scanner: Out of memory."
);
...
...
@@ -1038,11 +1040,11 @@ probe_scanner(struct usb_interface *intf,
init_MUTEX
(
&
(
scn
->
sem
));
/* Initializes to unlocked */
dbg
(
"probe_scanner(%d): Address of scn:%p"
,
scn_
minor
,
scn
);
dbg
(
"probe_scanner(%d): Address of scn:%p"
,
intf
->
minor
,
scn
);
/* Ok, if we detected an interrupt EP, setup a handler for it */
if
(
have_intr
)
{
dbg
(
"probe_scanner(%d): Configuring IRQ handler for intr EP:%d"
,
scn_
minor
,
have_intr
);
dbg
(
"probe_scanner(%d): Configuring IRQ handler for intr EP:%d"
,
intf
->
minor
,
have_intr
);
usb_fill_int_urb
(
scn
->
scn_irq
,
dev
,
usb_rcvintpipe
(
dev
,
have_intr
),
&
scn
->
button
,
1
,
irq_scanner
,
scn
,
...
...
@@ -1050,7 +1052,7 @@ probe_scanner(struct usb_interface *intf,
250
);
if
(
usb_submit_urb
(
scn
->
scn_irq
,
GFP_KERNEL
))
{
err
(
"probe_scanner(%d): Unable to allocate INT URB."
,
scn_
minor
);
err
(
"probe_scanner(%d): Unable to allocate INT URB."
,
intf
->
minor
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
-
ENOMEM
;
...
...
@@ -1060,21 +1062,21 @@ probe_scanner(struct usb_interface *intf,
/* Ok, now initialize all the relevant values */
if
(
!
(
scn
->
obuf
=
(
char
*
)
kmalloc
(
OBUF_SIZE
,
GFP_KERNEL
)))
{
err
(
"probe_scanner(%d): Not enough memory for the output buffer."
,
scn_
minor
);
err
(
"probe_scanner(%d): Not enough memory for the output buffer."
,
intf
->
minor
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
-
ENOMEM
;
}
dbg
(
"probe_scanner(%d): obuf address:%p"
,
scn_
minor
,
scn
->
obuf
);
dbg
(
"probe_scanner(%d): obuf address:%p"
,
intf
->
minor
,
scn
->
obuf
);
if
(
!
(
scn
->
ibuf
=
(
char
*
)
kmalloc
(
IBUF_SIZE
,
GFP_KERNEL
)))
{
err
(
"probe_scanner(%d): Not enough memory for the input buffer."
,
scn_
minor
);
err
(
"probe_scanner(%d): Not enough memory for the input buffer."
,
intf
->
minor
);
kfree
(
scn
->
obuf
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
-
ENOMEM
;
}
dbg
(
"probe_scanner(%d): ibuf address:%p"
,
scn_
minor
,
scn
->
ibuf
);
dbg
(
"probe_scanner(%d): ibuf address:%p"
,
intf
->
minor
,
scn
->
ibuf
);
switch
(
dev
->
descriptor
.
idVendor
)
{
/* Scanner specific read timeout parameters */
...
...
@@ -1101,24 +1103,15 @@ probe_scanner(struct usb_interface *intf,
scn
->
intr_ep
=
have_intr
;
scn
->
present
=
1
;
scn
->
scn_dev
=
dev
;
scn
->
scn_minor
=
scn_
minor
;
scn
->
scn_minor
=
intf
->
minor
;
scn
->
isopen
=
0
;
sprintf
(
name
,
"usb/scanner%d"
,
scn
->
scn_minor
-
SCN_BASE_MNR
);
devfs_register
(
NULL
,
name
,
DEVFS_FL_DEFAULT
,
USB_MAJOR
,
scn
->
scn_minor
,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
|
S_IWOTH
,
&
usb_scanner_fops
,
NULL
);
info
(
"USB scanner device (0x%04x/0x%04x) now attached to %s"
,
dev
->
descriptor
.
idVendor
,
dev
->
descriptor
.
idProduct
,
name
);
up
(
&
scn_mutex
);
usb_set_intfdata
(
intf
,
scn
);
intf
->
minor
=
scn_minor
;
return
0
;
}
...
...
@@ -1129,7 +1122,8 @@ disconnect_scanner(struct usb_interface *intf)
struct
scn_usb_data
*
scn
=
usb_get_intfdata
(
intf
);
/* disable open() */
intf
->
minor
=
-
1
;
dbg
(
"%s: De-allocating minor:%d"
,
__FUNCTION__
,
scn
->
scn_minor
);
usb_deregister_dev
(
intf
,
&
scanner_class
);
usb_set_intfdata
(
intf
,
NULL
);
if
(
scn
->
intr_ep
)
{
...
...
drivers/usb/image/scanner.h
View file @
2d67b792
...
...
@@ -323,11 +323,7 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids);
USB - Vivid III */
#define SCN_CLASS_SCANJET 16
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define SCN_BASE_MNR 0
#else
#define SCN_BASE_MNR 48
/* USB Scanners start at minor 48 */
#endif
static
DECLARE_MUTEX
(
scn_mutex
);
/* Initializes to unlocked */
...
...
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