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
45933ab2
Commit
45933ab2
authored
Sep 16, 2002
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USB: convert the drivers/usb/image files to the new USB driver model.
parent
72df1a80
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
103 deletions
+124
-103
drivers/usb/image/hpusbscsi.c
drivers/usb/image/hpusbscsi.c
+17
-12
drivers/usb/image/mdc800.c
drivers/usb/image/mdc800.c
+28
-23
drivers/usb/image/microtek.c
drivers/usb/image/microtek.c
+24
-21
drivers/usb/image/microtek.h
drivers/usb/image/microtek.h
+0
-2
drivers/usb/image/scanner.c
drivers/usb/image/scanner.c
+55
-45
No files found.
drivers/usb/image/hpusbscsi.c
View file @
45933ab2
...
...
@@ -30,13 +30,14 @@ struct list_head hpusbscsi_devices;
/* USB related parts */
static
void
*
hpusbscsi_usb_probe
(
struct
usb_
device
*
dev
,
unsigned
int
interface
,
static
int
hpusbscsi_usb_probe
(
struct
usb_
interface
*
intf
,
const
struct
usb_device_id
*
id
)
{
struct
hpusbscsi
*
new
;
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
struct
usb_interface_descriptor
*
altsetting
=
&
(
dev
->
actconfig
->
interface
[
interface
].
altsetting
[
0
]);
&
(
intf
->
altsetting
[
0
]);
int
i
,
result
;
...
...
@@ -44,7 +45,7 @@ hpusbscsi_usb_probe (struct usb_device *dev, unsigned int interface,
if
(
altsetting
->
bNumEndpoints
!=
3
)
{
printk
(
KERN_ERR
"Wrong number of endpoints
\n
"
);
return
NULL
;
return
-
ENODEV
;
}
/* descriptor allocation */
...
...
@@ -53,19 +54,19 @@ hpusbscsi_usb_probe (struct usb_device *dev, unsigned int interface,
(
struct
hpusbscsi
*
)
kmalloc
(
sizeof
(
struct
hpusbscsi
),
GFP_KERNEL
);
if
(
new
==
NULL
)
return
NULL
;
return
-
ENOMEM
;
DEBUG
(
"Allocated memory
\n
"
);
memset
(
new
,
0
,
sizeof
(
struct
hpusbscsi
));
new
->
dataurb
=
usb_alloc_urb
(
0
,
GFP_KERNEL
);
if
(
!
new
->
dataurb
)
{
kfree
(
new
);
return
NULL
;
return
-
ENOMEM
;
}
new
->
controlurb
=
usb_alloc_urb
(
0
,
GFP_KERNEL
);
if
(
!
new
->
controlurb
)
{
usb_free_urb
(
new
->
dataurb
);
kfree
(
new
);
return
NULL
;
return
-
ENOMEM
;
}
new
->
dev
=
dev
;
init_waitqueue_head
(
&
new
->
pending
);
...
...
@@ -135,20 +136,24 @@ hpusbscsi_usb_probe (struct usb_device *dev, unsigned int interface,
/* adding to list for module unload */
list_add
(
&
hpusbscsi_devices
,
&
new
->
lh
);
return
new
;
dev_set_drvdata
(
&
intf
->
dev
,
new
);
return
0
;
err_out:
usb_free_urb
(
new
->
controlurb
);
usb_free_urb
(
new
->
dataurb
);
kfree
(
new
);
return
NULL
;
return
-
ENODEV
;
}
static
void
hpusbscsi_usb_disconnect
(
struct
usb_
device
*
dev
,
void
*
ptr
)
hpusbscsi_usb_disconnect
(
struct
usb_
interface
*
intf
)
{
usb_unlink_urb
((((
struct
hpusbscsi
*
)
ptr
)
->
controlurb
));
((
struct
hpusbscsi
*
)
ptr
)
->
dev
=
NULL
;
struct
hpusbscsi
*
desc
=
dev_get_drvdata
(
&
intf
->
dev
);
dev_set_drvdata
(
&
intf
->
dev
,
NULL
);
if
(
desc
)
usb_unlink_urb
(
desc
->
controlurb
);
}
static
struct
usb_device_id
hpusbscsi_usb_ids
[]
=
{
...
...
drivers/usb/image/mdc800.c
View file @
45933ab2
...
...
@@ -406,11 +406,12 @@ static struct file_operations mdc800_device_ops;
/*
* Callback to search the Mustek MDC800 on the USB Bus
*/
static
void
*
mdc800_usb_probe
(
struct
usb_device
*
dev
,
unsigned
int
ifnum
,
static
int
mdc800_usb_probe
(
struct
usb_interface
*
intf
,
const
struct
usb_device_id
*
id
)
{
int
i
,
j
;
struct
usb_interface_descriptor
*
intf_desc
;
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
int
irq_interval
=
0
;
int
retval
;
...
...
@@ -420,15 +421,15 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
if
(
mdc800
->
dev
!=
0
)
{
warn
(
"only one Mustek MDC800 is supported."
);
return
0
;
return
-
ENODEV
;
}
if
(
dev
->
descriptor
.
bNumConfigurations
!=
1
)
{
err
(
"probe fails -> wrong Number of Configuration"
);
return
0
;
return
-
ENODEV
;
}
intf_desc
=&
dev
->
actconfig
->
interface
[
ifnum
].
altsetting
[
0
];
intf_desc
=
&
intf
->
altsetting
[
0
];
if
(
(
intf_desc
->
bInterfaceClass
!=
0xff
)
...
...
@@ -438,7 +439,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
)
{
err
(
"probe fails -> wrong Interface"
);
return
0
;
return
-
ENODEV
;
}
/* Check the Endpoints */
...
...
@@ -461,16 +462,16 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
if
(
mdc800
->
endpoint
[
i
]
==
-
1
)
{
err
(
"probe fails -> Wrong Endpoints."
);
return
0
;
return
-
ENODEV
;
}
}
usb_driver_claim_interface
(
&
mdc800_usb_driver
,
&
dev
->
actconfig
->
interface
[
ifnum
]
,
mdc800
);
if
(
usb_set_interface
(
dev
,
i
fnum
,
0
)
<
0
)
usb_driver_claim_interface
(
&
mdc800_usb_driver
,
intf
,
mdc800
);
if
(
usb_set_interface
(
dev
,
i
ntf_desc
->
bInterfaceNumber
,
0
)
<
0
)
{
err
(
"MDC800 Configuration fails."
);
return
0
;
return
-
ENODEV
;
}
info
(
"Found Mustek MDC800 on USB."
);
...
...
@@ -480,7 +481,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
retval
=
usb_register_dev
(
&
mdc800_device_ops
,
MDC800_DEVICE_MINOR_BASE
,
1
,
&
mdc800
->
minor
);
if
(
retval
&&
(
retval
!=
-
ENODEV
))
{
err
(
"Not able to get a minor for this device."
);
return
0
;
return
-
ENODEV
;
}
mdc800
->
dev
=
dev
;
...
...
@@ -522,19 +523,21 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
up
(
&
mdc800
->
io_lock
);
return
mdc800
;
dev_set_drvdata
(
&
intf
->
dev
,
mdc800
);
return
0
;
}
/*
* Disconnect USB device (maybe the MDC800)
*/
static
void
mdc800_usb_disconnect
(
struct
usb_
device
*
dev
,
void
*
ptr
)
static
void
mdc800_usb_disconnect
(
struct
usb_
interface
*
intf
)
{
struct
mdc800_data
*
mdc800
=
(
struct
mdc800_data
*
)
ptr
;
struct
mdc800_data
*
mdc800
=
dev_get_drvdata
(
&
intf
->
dev
)
;
dbg
(
"(mdc800_usb_disconnect) called"
);
if
(
mdc800
)
{
if
(
mdc800
->
state
==
NOT_CONNECTED
)
return
;
...
...
@@ -546,9 +549,11 @@ static void mdc800_usb_disconnect (struct usb_device *dev,void* ptr)
usb_unlink_urb
(
mdc800
->
write_urb
);
usb_unlink_urb
(
mdc800
->
download_urb
);
usb_driver_release_interface
(
&
mdc800_usb_driver
,
&
dev
->
actconfig
->
interface
[
1
]
);
usb_driver_release_interface
(
&
mdc800_usb_driver
,
intf
);
mdc800
->
dev
=
0
;
dev_set_drvdata
(
&
intf
->
dev
,
NULL
);
}
info
(
"Mustek MDC800 disconnected from USB."
);
}
...
...
drivers/usb/image/microtek.c
View file @
45933ab2
...
...
@@ -154,9 +154,9 @@
/* USB layer driver interface */
static
void
*
mts_usb_probe
(
struct
usb_device
*
dev
,
unsigned
int
interface
,
static
int
mts_usb_probe
(
struct
usb_interface
*
intf
,
const
struct
usb_device_id
*
id
);
static
void
mts_usb_disconnect
(
struct
usb_
device
*
dev
,
void
*
ptr
);
static
void
mts_usb_disconnect
(
struct
usb_
interface
*
intf
);
static
struct
usb_device_id
mts_usb_ids
[];
...
...
@@ -773,18 +773,21 @@ static Scsi_Host_Template mts_scsi_host_template = {
/* USB layer driver interface implementation */
static
void
mts_usb_disconnect
(
struct
usb_
device
*
dev
,
void
*
ptr
)
static
void
mts_usb_disconnect
(
struct
usb_
interface
*
intf
)
{
struct
mts_desc
*
to_remove
=
(
struct
mts_desc
*
)
ptr
;
struct
mts_desc
*
to_remove
=
dev_get_drvdata
(
&
intf
->
dev
)
;
MTS_DEBUG_GOT_HERE
();
dev_set_drvdata
(
&
intf
->
dev
,
NULL
);
if
(
to_remove
)
{
/* leave the list - lock it */
down
(
&
mts_list_semaphore
);
mts_remove_nolock
(
to_remove
);
up
(
&
mts_list_semaphore
);
}
}
struct
vendor_product
...
...
@@ -834,7 +837,7 @@ static struct usb_device_id mts_usb_ids [] =
MODULE_DEVICE_TABLE
(
usb
,
mts_usb_ids
);
static
void
*
mts_usb_probe
(
struct
usb_device
*
dev
,
unsigned
int
interface
,
static
int
mts_usb_probe
(
struct
usb_interface
*
intf
,
const
struct
usb_device_id
*
id
)
{
int
i
;
...
...
@@ -846,6 +849,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
struct
mts_desc
*
new_desc
;
struct
vendor_product
const
*
p
;
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
/* the altsettting 0 on the interface we're probing */
struct
usb_interface_descriptor
*
altsetting
;
...
...
@@ -869,8 +873,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
p
->
name
);
/* the altsettting 0 on the interface we're probing */
altsetting
=
&
(
dev
->
actconfig
->
interface
[
interface
].
altsetting
[
0
]);
altsetting
=
&
(
intf
->
altsetting
[
0
]);
/* Check if the config is sane */
...
...
@@ -878,7 +881,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
if
(
altsetting
->
bNumEndpoints
!=
MTS_EP_TOTAL
)
{
MTS_WARNING
(
"expecting %d got %d endpoints! Bailing out.
\n
"
,
(
int
)
MTS_EP_TOTAL
,
(
int
)
altsetting
->
bNumEndpoints
);
return
NULL
;
return
-
ENODEV
;
}
for
(
i
=
0
;
i
<
altsetting
->
bNumEndpoints
;
i
++
)
{
...
...
@@ -896,7 +899,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
else
{
if
(
ep_out
!=
-
1
)
{
MTS_WARNING
(
"can only deal with one output endpoints. Bailing out."
);
return
NULL
;
return
-
ENODEV
;
}
ep_out
=
altsetting
->
endpoint
[
i
].
bEndpointAddress
&
...
...
@@ -909,7 +912,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
if
(
ep_out
==
-
1
)
{
MTS_WARNING
(
"couldn't find an output bulk endpoint. Bailing out.
\n
"
);
return
NULL
;
return
-
ENODEV
;
}
...
...
@@ -932,7 +935,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
default:
MTS_DEBUG
(
"unknown error %d from usb_set_interface
\n
"
,
(
int
)
result
);
return
NULL
;
return
-
ENODEV
;
}
...
...
@@ -941,19 +944,18 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
if
(
new_desc
==
NULL
)
{
MTS_ERROR
(
"couldn't allocate scanner desc, bailing out!
\n
"
);
return
NULL
;
return
-
ENOMEM
;
}
memset
(
new_desc
,
0
,
sizeof
(
*
new_desc
)
);
new_desc
->
urb
=
usb_alloc_urb
(
0
,
GFP_KERNEL
);
if
(
!
new_desc
->
urb
)
{
kfree
(
new_desc
);
return
NULL
;
return
-
ENOMEM
;
}
/* initialising that descriptor */
new_desc
->
usb_dev
=
dev
;
new_desc
->
interface
=
interface
;
init_MUTEX
(
&
new_desc
->
lock
);
...
...
@@ -1000,7 +1002,7 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
/* FIXME: need more cleanup? */
kfree
(
new_desc
);
return
NULL
;
return
-
ENOMEM
;
}
MTS_DEBUG_GOT_HERE
();
...
...
@@ -1015,7 +1017,8 @@ static void * mts_usb_probe (struct usb_device *dev, unsigned int interface,
MTS_DEBUG
(
"completed probe and exiting happily
\n
"
);
return
(
void
*
)
new_desc
;
dev_set_drvdata
(
&
intf
->
dev
,
new_desc
);
return
0
;
}
...
...
drivers/usb/image/microtek.h
View file @
45933ab2
...
...
@@ -33,8 +33,6 @@ struct mts_desc {
struct
usb_device
*
usb_dev
;
int
interface
;
/* Endpoint addresses */
u8
ep_out
;
u8
ep_response
;
...
...
drivers/usb/image/scanner.c
View file @
45933ab2
...
...
@@ -818,10 +818,11 @@ file_operations usb_scanner_fops = {
.
release
=
close_scanner
,
};
static
void
*
probe_scanner
(
struct
usb_
device
*
dev
,
unsigned
int
ifnum
,
static
int
probe_scanner
(
struct
usb_
interface
*
intf
,
const
struct
usb_device_id
*
id
)
{
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
struct
scn_usb_data
*
scn
;
struct
usb_interface_descriptor
*
interface
;
struct
usb_endpoint_descriptor
*
endpoint
;
...
...
@@ -877,7 +878,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
}
if
(
!
valid_device
)
return
NULL
;
/* We didn't find anything pleasing */
return
-
ENODEV
;
/* We didn't find anything pleasing */
/*
* After this point we can be a little noisy about what we are trying to
...
...
@@ -886,16 +887,16 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
if
(
dev
->
descriptor
.
bNumConfigurations
!=
1
)
{
info
(
"probe_scanner: Only one device configuration is supported."
);
return
NULL
;
return
-
ENODEV
;
}
if
(
dev
->
config
[
0
].
bNumInterfaces
!=
1
)
{
info
(
"probe_scanner: Only one device interface is supported."
);
return
NULL
;
return
-
ENODEV
;
}
interface
=
dev
->
config
[
0
].
interface
[
ifnum
].
altsetting
;
endpoint
=
interface
[
ifnum
].
endpoint
;
interface
=
intf
->
altsetting
;
endpoint
=
interface
->
endpoint
;
/*
* Start checking for two bulk endpoints OR two bulk endpoints *and* one
...
...
@@ -907,7 +908,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
if
((
interface
->
bNumEndpoints
!=
2
)
&&
(
interface
->
bNumEndpoints
!=
3
))
{
info
(
"probe_scanner: Only two or three endpoints supported."
);
return
NULL
;
return
-
ENODEV
;
}
ep_cnt
=
have_bulk_in
=
have_bulk_out
=
have_intr
=
0
;
...
...
@@ -935,7 +936,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
continue
;
}
info
(
"probe_scanner: Undetected endpoint -- consult Documentation/usb/scanner.txt."
);
return
NULL
;
/* Shouldn't ever get here unless we have something weird */
return
-
EIO
;
/* Shouldn't ever get here unless we have something weird */
}
...
...
@@ -948,18 +949,18 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
case
2
:
if
(
!
have_bulk_in
||
!
have_bulk_out
)
{
info
(
"probe_scanner: Two bulk endpoints required."
);
return
NULL
;
return
-
EIO
;
}
break
;
case
3
:
if
(
!
have_bulk_in
||
!
have_bulk_out
||
!
have_intr
)
{
info
(
"probe_scanner: Two bulk endpoints and one interrupt endpoint required."
);
return
NULL
;
return
-
EIO
;
}
break
;
default:
info
(
"probe_scanner: Endpoint determination failed -- consult Documentation/usb/scanner.txt"
);
return
NULL
;
return
-
EIO
;
}
...
...
@@ -975,14 +976,14 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
if
(
retval
)
{
err
(
"Not able to get a minor for this device."
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
/* Check to make sure that the last slot isn't already taken */
if
(
p_scn_table
[
scn_minor
])
{
err
(
"probe_scanner: No more minor devices remaining."
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
dbg
(
"probe_scanner: Allocated minor:%d"
,
scn_minor
);
...
...
@@ -990,7 +991,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
if
(
!
(
scn
=
kmalloc
(
sizeof
(
struct
scn_usb_data
),
GFP_KERNEL
)))
{
err
(
"probe_scanner: Out of memory."
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
memset
(
scn
,
0
,
sizeof
(
struct
scn_usb_data
));
...
...
@@ -998,7 +999,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
if
(
!
scn
->
scn_irq
)
{
kfree
(
scn
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
init_MUTEX
(
&
(
scn
->
sem
));
/* Initializes to unlocked */
...
...
@@ -1018,7 +1019,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
err
(
"probe_scanner(%d): Unable to allocate INT URB."
,
scn_minor
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
}
...
...
@@ -1028,7 +1029,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
err
(
"probe_scanner(%d): Not enough memory for the output buffer."
,
scn_minor
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
dbg
(
"probe_scanner(%d): obuf address:%p"
,
scn_minor
,
scn
->
obuf
);
...
...
@@ -1037,7 +1038,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
kfree
(
scn
->
obuf
);
kfree
(
scn
);
up
(
&
scn_mutex
);
return
NULL
;
return
-
ENOMEM
;
}
dbg
(
"probe_scanner(%d): ibuf address:%p"
,
scn_minor
,
scn
->
ibuf
);
...
...
@@ -1083,14 +1084,17 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
up
(
&
scn_mutex
);
return
scn
;
dev_set_drvdata
(
&
intf
->
dev
,
scn
);
return
0
;
}
static
void
disconnect_scanner
(
struct
usb_
device
*
dev
,
void
*
ptr
)
disconnect_scanner
(
struct
usb_
interface
*
intf
)
{
struct
scn_usb_data
*
scn
=
(
struct
scn_usb_data
*
)
ptr
;
struct
scn_usb_data
*
scn
=
dev_get_drvdata
(
&
intf
->
dev
)
;
dev_set_drvdata
(
&
intf
->
dev
,
NULL
);
if
(
scn
)
{
down
(
&
scn_mutex
);
down
(
&
(
scn
->
sem
));
...
...
@@ -1112,16 +1116,22 @@ disconnect_scanner(struct usb_device *dev, void *ptr)
up
(
&
(
scn
->
sem
));
kfree
(
scn
);
up
(
&
scn_mutex
);
}
}
/* we want to look at all devices, as the vendor/product id can change
* depending on the command line argument */
static
struct
usb_device_id
ids
[]
=
{
{.
driver_info
=
42
},
{}
};
static
struct
usb_driver
scanner_driver
=
{
.
name
=
"usbscanner"
,
.
probe
=
probe_scanner
,
.
disconnect
=
disconnect_scanner
,
.
id_table
=
NULL
,
/* This would be scanner_device_ids, but we
need to check every USB device, in case
we match a user defined vendor/product ID. */
.
id_table
=
ids
,
};
void
__exit
...
...
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