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
de59104f
Commit
de59104f
authored
May 11, 2004
by
Hanna V. Linder
Committed by
Greg Kroah-Hartman
May 11, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] USB: Add class support to drivers/usb/misc/tiglusb.c
parent
8d5c15b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
15 deletions
+49
-15
drivers/usb/misc/tiglusb.c
drivers/usb/misc/tiglusb.c
+49
-15
No files found.
drivers/usb/misc/tiglusb.c
View file @
de59104f
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/smp_lock.h>
#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/device.h>
#include <linux/ticable.h>
#include <linux/ticable.h>
#include "tiglusb.h"
#include "tiglusb.h"
...
@@ -49,6 +50,7 @@
...
@@ -49,6 +50,7 @@
static
tiglusb_t
tiglusb
[
MAXTIGL
];
static
tiglusb_t
tiglusb
[
MAXTIGL
];
static
int
timeout
=
TIMAXTIME
;
/* timeout in tenth of seconds */
static
int
timeout
=
TIMAXTIME
;
/* timeout in tenth of seconds */
static
struct
class_simple
*
tiglusb_class
;
/*---------- misc functions ------------------------------------------- */
/*---------- misc functions ------------------------------------------- */
...
@@ -336,7 +338,7 @@ tiglusb_probe (struct usb_interface *intf,
...
@@ -336,7 +338,7 @@ tiglusb_probe (struct usb_interface *intf,
{
{
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
struct
usb_device
*
dev
=
interface_to_usbdev
(
intf
);
int
minor
=
-
1
;
int
minor
=
-
1
;
int
i
;
int
i
,
err
=
0
;
ptiglusb_t
s
;
ptiglusb_t
s
;
dbg
(
"probing vendor id 0x%x, device id 0x%x"
,
dbg
(
"probing vendor id 0x%x, device id 0x%x"
,
...
@@ -347,18 +349,23 @@ tiglusb_probe (struct usb_interface *intf,
...
@@ -347,18 +349,23 @@ tiglusb_probe (struct usb_interface *intf,
* the TIGL hardware, there's only 1 configuration.
* the TIGL hardware, there's only 1 configuration.
*/
*/
if
(
dev
->
descriptor
.
bNumConfigurations
!=
1
)
if
(
dev
->
descriptor
.
bNumConfigurations
!=
1
)
{
return
-
ENODEV
;
err
=
-
ENODEV
;
goto
out
;
}
if
((
dev
->
descriptor
.
idProduct
!=
0xe001
)
if
((
dev
->
descriptor
.
idProduct
!=
0xe001
)
&&
(
dev
->
descriptor
.
idVendor
!=
0x451
))
&&
(
dev
->
descriptor
.
idVendor
!=
0x451
))
{
return
-
ENODEV
;
err
=
-
ENODEV
;
goto
out
;
}
// NOTE: it's already in this config, this shouldn't be needed.
// NOTE: it's already in this config, this shouldn't be needed.
// is this working around some hardware bug?
// is this working around some hardware bug?
if
(
usb_reset_configuration
(
dev
)
<
0
)
{
if
(
usb_reset_configuration
(
dev
)
<
0
)
{
err
(
"tiglusb_probe: reset_configuration failed"
);
err
(
"tiglusb_probe: reset_configuration failed"
);
return
-
ENODEV
;
err
=
-
ENODEV
;
goto
out
;
}
}
/*
/*
...
@@ -372,8 +379,10 @@ tiglusb_probe (struct usb_interface *intf,
...
@@ -372,8 +379,10 @@ tiglusb_probe (struct usb_interface *intf,
}
}
}
}
if
(
minor
==
-
1
)
if
(
minor
==
-
1
)
{
return
-
ENODEV
;
err
=
-
ENODEV
;
goto
out
;
}
s
=
&
tiglusb
[
minor
];
s
=
&
tiglusb
[
minor
];
...
@@ -383,17 +392,28 @@ tiglusb_probe (struct usb_interface *intf,
...
@@ -383,17 +392,28 @@ tiglusb_probe (struct usb_interface *intf,
up
(
&
s
->
mutex
);
up
(
&
s
->
mutex
);
dbg
(
"bound to interface"
);
dbg
(
"bound to interface"
);
devfs_mk_cdev
(
MKDEV
(
TIUSB_MAJOR
,
TIUSB_MINOR
)
+
s
->
minor
,
class_simple_device_add
(
tiglusb_class
,
MKDEV
(
TIUSB_MAJOR
,
TIUSB_MINOR
+
s
->
minor
),
NULL
,
"usb%d"
,
s
->
minor
);
err
=
devfs_mk_cdev
(
MKDEV
(
TIUSB_MAJOR
,
TIUSB_MINOR
)
+
s
->
minor
,
S_IFCHR
|
S_IRUGO
|
S_IWUGO
,
S_IFCHR
|
S_IRUGO
|
S_IWUGO
,
"ticables/usb/%d"
,
s
->
minor
);
"ticables/usb/%d"
,
s
->
minor
);
if
(
err
)
goto
out_class
;
/* Display firmware version */
/* Display firmware version */
info
(
"firmware revision %i.%02x"
,
info
(
"firmware revision %i.%02x"
,
dev
->
descriptor
.
bcdDevice
>>
8
,
dev
->
descriptor
.
bcdDevice
>>
8
,
dev
->
descriptor
.
bcdDevice
&
0xff
);
dev
->
descriptor
.
bcdDevice
&
0xff
);
usb_set_intfdata
(
intf
,
s
);
usb_set_intfdata
(
intf
,
s
);
return
0
;
err
=
0
;
goto
out
;
out_class:
class_simple_device_remove
(
MKDEV
(
TIUSB_MAJOR
,
TIUSB_MINOR
+
s
->
minor
));
out:
return
err
;
}
}
static
void
static
void
...
@@ -423,6 +443,7 @@ tiglusb_disconnect (struct usb_interface *intf)
...
@@ -423,6 +443,7 @@ tiglusb_disconnect (struct usb_interface *intf)
s
->
dev
=
NULL
;
s
->
dev
=
NULL
;
s
->
opened
=
0
;
s
->
opened
=
0
;
class_simple_device_remove
(
MKDEV
(
TIUSB_MAJOR
,
TIUSB_MINOR
+
s
->
minor
));
devfs_remove
(
"ticables/usb/%d"
,
s
->
minor
);
devfs_remove
(
"ticables/usb/%d"
,
s
->
minor
);
info
(
"device %d removed"
,
s
->
minor
);
info
(
"device %d removed"
,
s
->
minor
);
...
@@ -473,7 +494,7 @@ static int __init
...
@@ -473,7 +494,7 @@ static int __init
tiglusb_init
(
void
)
tiglusb_init
(
void
)
{
{
unsigned
u
;
unsigned
u
;
int
result
;
int
result
,
err
=
0
;
/* initialize struct */
/* initialize struct */
for
(
u
=
0
;
u
<
MAXTIGL
;
u
++
)
{
for
(
u
=
0
;
u
<
MAXTIGL
;
u
++
)
{
...
@@ -490,28 +511,41 @@ tiglusb_init (void)
...
@@ -490,28 +511,41 @@ tiglusb_init (void)
/* register device */
/* register device */
if
(
register_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
,
&
tiglusb_fops
))
{
if
(
register_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
,
&
tiglusb_fops
))
{
err
(
"unable to get major %d"
,
TIUSB_MAJOR
);
err
(
"unable to get major %d"
,
TIUSB_MAJOR
);
return
-
EIO
;
err
=
-
EIO
;
goto
out
;
}
}
/* Use devfs, tree: /dev/ticables/usb/[0..3] */
/* Use devfs, tree: /dev/ticables/usb/[0..3] */
devfs_mk_dir
(
"ticables/usb"
);
devfs_mk_dir
(
"ticables/usb"
);
tiglusb_class
=
class_simple_create
(
THIS_MODULE
,
"tiglusb"
);
if
(
IS_ERR
(
tiglusb_class
))
{
err
=
PTR_ERR
(
tiglusb_class
);
goto
out_chrdev
;
}
/* register USB module */
/* register USB module */
result
=
usb_register
(
&
tiglusb_driver
);
result
=
usb_register
(
&
tiglusb_driver
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
unregister_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
)
;
err
=
-
1
;
return
-
1
;
goto
out_chrdev
;
}
}
info
(
DRIVER_DESC
", version "
DRIVER_VERSION
);
info
(
DRIVER_DESC
", version "
DRIVER_VERSION
);
return
0
;
err
=
0
;
goto
out
;
out_chrdev:
unregister_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
);
out:
return
err
;
}
}
static
void
__exit
static
void
__exit
tiglusb_cleanup
(
void
)
tiglusb_cleanup
(
void
)
{
{
usb_deregister
(
&
tiglusb_driver
);
usb_deregister
(
&
tiglusb_driver
);
class_simple_destroy
(
tiglusb_class
);
devfs_remove
(
"ticables/usb"
);
devfs_remove
(
"ticables/usb"
);
unregister_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
);
unregister_chrdev
(
TIUSB_MAJOR
,
"tiglusb"
);
}
}
...
...
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