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
6efe5cc9
Commit
6efe5cc9
authored
Apr 25, 2002
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for USB_DYNAMIC_MINORS to the usb drivers that can use it.
parent
96b06627
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
135 additions
and
54 deletions
+135
-54
drivers/usb/class/printer.c
drivers/usb/class/printer.c
+15
-6
drivers/usb/image/mdc800.c
drivers/usb/image/mdc800.c
+9
-0
drivers/usb/image/scanner.c
drivers/usb/image/scanner.c
+6
-3
drivers/usb/image/scanner.h
drivers/usb/image/scanner.h
+5
-0
drivers/usb/input/hiddev.c
drivers/usb/input/hiddev.c
+20
-8
drivers/usb/media/dabusb.c
drivers/usb/media/dabusb.c
+12
-3
drivers/usb/media/dabusb.h
drivers/usb/media/dabusb.h
+5
-0
drivers/usb/misc/auerswald.c
drivers/usb/misc/auerswald.c
+22
-11
drivers/usb/misc/brlvger.c
drivers/usb/misc/brlvger.c
+12
-9
drivers/usb/usb-skeleton.c
drivers/usb/usb-skeleton.c
+24
-14
include/linux/brlvger.h
include/linux/brlvger.h
+5
-0
No files found.
drivers/usb/class/printer.c
View file @
6efe5cc9
...
@@ -107,7 +107,11 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H
...
@@ -107,7 +107,11 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H
#define USBLP_REQ_RESET 0x02
#define USBLP_REQ_RESET 0x02
#define USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST 0x00
/* HP Vendor-specific */
#define USBLP_REQ_HP_CHANNEL_CHANGE_REQUEST 0x00
/* HP Vendor-specific */
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define USBLP_MINORS 256
#else
#define USBLP_MINORS 16
#define USBLP_MINORS 16
#endif
#define USBLP_MINOR_BASE 0
#define USBLP_MINOR_BASE 0
#define USBLP_WRITE_TIMEOUT (5*HZ)
/* 5 seconds */
#define USBLP_WRITE_TIMEOUT (5*HZ)
/* 5 seconds */
...
@@ -208,6 +212,8 @@ static int usblp_select_alts(struct usblp *usblp);
...
@@ -208,6 +212,8 @@ static int usblp_select_alts(struct usblp *usblp);
static
int
usblp_set_protocol
(
struct
usblp
*
usblp
,
int
protocol
);
static
int
usblp_set_protocol
(
struct
usblp
*
usblp
,
int
protocol
);
static
int
usblp_cache_device_id_string
(
struct
usblp
*
usblp
);
static
int
usblp_cache_device_id_string
(
struct
usblp
*
usblp
);
/* forward reference to make our lives easier */
extern
struct
usb_driver
usblp_driver
;
/*
/*
* Functions for usblp control messages.
* Functions for usblp control messages.
...
@@ -366,6 +372,7 @@ static void usblp_cleanup (struct usblp *usblp)
...
@@ -366,6 +372,7 @@ static void usblp_cleanup (struct usblp *usblp)
{
{
devfs_unregister
(
usblp
->
devfs
);
devfs_unregister
(
usblp
->
devfs
);
usblp_table
[
usblp
->
minor
]
=
NULL
;
usblp_table
[
usblp
->
minor
]
=
NULL
;
usb_deregister_dev
(
&
usblp_driver
,
1
,
usblp
->
minor
);
info
(
"usblp%d: removed"
,
usblp
->
minor
);
info
(
"usblp%d: removed"
,
usblp
->
minor
);
kfree
(
usblp
->
writeurb
->
transfer_buffer
);
kfree
(
usblp
->
writeurb
->
transfer_buffer
);
...
@@ -801,12 +808,14 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
...
@@ -801,12 +808,14 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
init_waitqueue_head
(
&
usblp
->
wait
);
init_waitqueue_head
(
&
usblp
->
wait
);
usblp
->
ifnum
=
ifnum
;
usblp
->
ifnum
=
ifnum
;
/* Look for a free usblp_table entry. */
if
(
usb_register_dev
(
&
usblp_driver
,
1
,
&
usblp
->
minor
))
{
while
(
usblp_table
[
usblp
->
minor
])
{
/* Look for a free usblp_table entry on our own. */
usblp
->
minor
++
;
while
(
usblp_table
[
usblp
->
minor
])
{
if
(
usblp
->
minor
>=
USBLP_MINORS
)
{
usblp
->
minor
++
;
err
(
"no more free usblp devices"
);
if
(
usblp
->
minor
>=
USBLP_MINORS
)
{
goto
abort
;
err
(
"no more free usblp devices"
);
goto
abort
;
}
}
}
}
}
...
...
drivers/usb/image/mdc800.c
View file @
6efe5cc9
...
@@ -119,8 +119,12 @@
...
@@ -119,8 +119,12 @@
#define TO_READ_FROM_IRQ TO_DEFAULT_COMMAND
#define TO_READ_FROM_IRQ TO_DEFAULT_COMMAND
#define TO_GET_READY TO_DEFAULT_COMMAND
#define TO_GET_READY TO_DEFAULT_COMMAND
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define MDC800_DEVICE_MINOR_BASE 0
#else
/* Minor Number of the device (create with mknod /dev/mustek c 180 32) */
/* Minor Number of the device (create with mknod /dev/mustek c 180 32) */
#define MDC800_DEVICE_MINOR_BASE 32
#define MDC800_DEVICE_MINOR_BASE 32
#endif
/**************************************************************************
/**************************************************************************
...
@@ -176,6 +180,7 @@ struct mdc800_data
...
@@ -176,6 +180,7 @@ struct mdc800_data
int
pic_index
;
// Cache for the Imagesize (-1 for nothing cached )
int
pic_index
;
// Cache for the Imagesize (-1 for nothing cached )
int
pic_len
;
int
pic_len
;
int
minor
;
};
};
...
@@ -470,6 +475,8 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
...
@@ -470,6 +475,8 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
down
(
&
mdc800
->
io_lock
);
down
(
&
mdc800
->
io_lock
);
usb_register_dev
(
&
mdc800_usb_driver
,
1
,
&
mdc800
->
minor
);
mdc800
->
dev
=
dev
;
mdc800
->
dev
=
dev
;
mdc800
->
open
=
0
;
mdc800
->
open
=
0
;
...
@@ -525,6 +532,8 @@ static void mdc800_usb_disconnect (struct usb_device *dev,void* ptr)
...
@@ -525,6 +532,8 @@ static void mdc800_usb_disconnect (struct usb_device *dev,void* ptr)
if
(
mdc800
->
state
==
NOT_CONNECTED
)
if
(
mdc800
->
state
==
NOT_CONNECTED
)
return
;
return
;
usb_deregister_dev
(
&
mdc800_usb_driver
,
1
,
mdc800
->
minor
);
mdc800
->
state
=
NOT_CONNECTED
;
mdc800
->
state
=
NOT_CONNECTED
;
usb_unlink_urb
(
mdc800
->
irq_urb
);
usb_unlink_urb
(
mdc800
->
irq_urb
);
...
...
drivers/usb/image/scanner.c
View file @
6efe5cc9
...
@@ -953,9 +953,11 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
...
@@ -953,9 +953,11 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
down
(
&
scn_mutex
);
down
(
&
scn_mutex
);
for
(
scn_minor
=
0
;
scn_minor
<
SCN_MAX_MNR
;
scn_minor
++
)
{
if
(
usb_register_dev
(
&
scanner_driver
,
1
,
&
scn_minor
))
{
if
(
!
p_scn_table
[
scn_minor
])
for
(
scn_minor
=
0
;
scn_minor
<
SCN_MAX_MNR
;
scn_minor
++
)
{
break
;
if
(
!
p_scn_table
[
scn_minor
])
break
;
}
}
}
/* Check to make sure that the last slot isn't already taken */
/* Check to make sure that the last slot isn't already taken */
...
@@ -1086,6 +1088,7 @@ disconnect_scanner(struct usb_device *dev, void *ptr)
...
@@ -1086,6 +1088,7 @@ disconnect_scanner(struct usb_device *dev, void *ptr)
dbg
(
"disconnect_scanner: De-allocating minor:%d"
,
scn
->
scn_minor
);
dbg
(
"disconnect_scanner: De-allocating minor:%d"
,
scn
->
scn_minor
);
devfs_unregister
(
scn
->
devfs
);
devfs_unregister
(
scn
->
devfs
);
usb_deregister_dev
(
&
scanner_driver
,
1
,
scn
->
scn_minor
);
p_scn_table
[
scn
->
scn_minor
]
=
NULL
;
p_scn_table
[
scn
->
scn_minor
]
=
NULL
;
usb_free_urb
(
scn
->
scn_irq
);
usb_free_urb
(
scn
->
scn_irq
);
up
(
&
(
scn
->
sem
));
up
(
&
(
scn
->
sem
));
...
...
drivers/usb/image/scanner.h
View file @
6efe5cc9
...
@@ -233,8 +233,13 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids);
...
@@ -233,8 +233,13 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids);
#define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, struct usb_ctrlrequest)
#define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, struct usb_ctrlrequest)
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define SCN_MAX_MNR 256
#define SCN_BASE_MNR 0
#else
#define SCN_MAX_MNR 16
/* We're allocated 16 minors */
#define SCN_MAX_MNR 16
/* We're allocated 16 minors */
#define SCN_BASE_MNR 48
/* USB Scanners start at minor 48 */
#define SCN_BASE_MNR 48
/* USB Scanners start at minor 48 */
#endif
static
DECLARE_MUTEX
(
scn_mutex
);
/* Initializes to unlocked */
static
DECLARE_MUTEX
(
scn_mutex
);
/* Initializes to unlocked */
...
...
drivers/usb/input/hiddev.c
View file @
6efe5cc9
...
@@ -25,10 +25,7 @@
...
@@ -25,10 +25,7 @@
* e-mail - mail your message to Paul Stewart <stewart@wetlogic.net>
* e-mail - mail your message to Paul Stewart <stewart@wetlogic.net>
*/
*/
#define HIDDEV_MINOR_BASE 96
#include <linux/config.h>
#define HIDDEV_MINORS 16
#define HIDDEV_BUFFER_SIZE 64
#include <linux/poll.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/module.h>
...
@@ -39,6 +36,15 @@
...
@@ -39,6 +36,15 @@
#include "hid.h"
#include "hid.h"
#include <linux/hiddev.h>
#include <linux/hiddev.h>
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define HIDDEV_MINOR_BASE 0
#define HIDDEV_MINORS 256
#else
#define HIDDEV_MINOR_BASE 96
#define HIDDEV_MINORS 16
#endif
#define HIDDEV_BUFFER_SIZE 64
struct
hiddev
{
struct
hiddev
{
int
exist
;
int
exist
;
int
open
;
int
open
;
...
@@ -62,6 +68,9 @@ struct hiddev_list {
...
@@ -62,6 +68,9 @@ struct hiddev_list {
static
struct
hiddev
*
hiddev_table
[
HIDDEV_MINORS
];
static
struct
hiddev
*
hiddev_table
[
HIDDEV_MINORS
];
static
devfs_handle_t
hiddev_devfs_handle
;
static
devfs_handle_t
hiddev_devfs_handle
;
/* forward reference to make our lives easier */
extern
struct
usb_driver
hiddev_driver
;
/*
/*
* Find a report, given the report's type and ID. The ID can be specified
* Find a report, given the report's type and ID. The ID can be specified
* indirectly by REPORT_ID_FIRST (which returns the first report of the given
* indirectly by REPORT_ID_FIRST (which returns the first report of the given
...
@@ -184,6 +193,7 @@ static int hiddev_fasync(int fd, struct file *file, int on)
...
@@ -184,6 +193,7 @@ static int hiddev_fasync(int fd, struct file *file, int on)
static
void
hiddev_cleanup
(
struct
hiddev
*
hiddev
)
static
void
hiddev_cleanup
(
struct
hiddev
*
hiddev
)
{
{
devfs_unregister
(
hiddev
->
devfs
);
devfs_unregister
(
hiddev
->
devfs
);
usb_deregister_dev
(
&
hiddev_driver
,
1
,
hiddev
->
minor
);
hiddev_table
[
hiddev
->
minor
]
=
NULL
;
hiddev_table
[
hiddev
->
minor
]
=
NULL
;
kfree
(
hiddev
);
kfree
(
hiddev
);
}
}
...
@@ -605,10 +615,12 @@ int hiddev_connect(struct hid_device *hid)
...
@@ -605,10 +615,12 @@ int hiddev_connect(struct hid_device *hid)
if
(
i
==
hid
->
maxapplication
)
if
(
i
==
hid
->
maxapplication
)
return
-
1
;
return
-
1
;
for
(
minor
=
0
;
minor
<
HIDDEV_MINORS
&&
hiddev_table
[
minor
];
minor
++
);
if
(
usb_register_dev
(
&
hiddev_driver
,
1
,
&
minor
))
{
if
(
minor
==
HIDDEV_MINORS
)
{
for
(
minor
=
0
;
minor
<
HIDDEV_MINORS
&&
hiddev_table
[
minor
];
minor
++
);
printk
(
KERN_ERR
"hiddev: no more free hiddev devices
\n
"
);
if
(
minor
==
HIDDEV_MINORS
)
{
return
-
1
;
printk
(
KERN_ERR
"hiddev: no more free hiddev devices
\n
"
);
return
-
1
;
}
}
}
if
(
!
(
hiddev
=
kmalloc
(
sizeof
(
struct
hiddev
),
GFP_KERNEL
)))
if
(
!
(
hiddev
=
kmalloc
(
sizeof
(
struct
hiddev
),
GFP_KERNEL
)))
...
...
drivers/usb/media/dabusb.c
View file @
6efe5cc9
...
@@ -52,12 +52,17 @@
...
@@ -52,12 +52,17 @@
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define NRDABUSB 256
#else
#define NRDABUSB 4
#define NRDABUSB 4
#endif
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
static
dabusb_t
dabusb
[
NRDABUSB
];
static
dabusb_t
dabusb
[
NRDABUSB
];
static
int
buffers
=
256
;
static
int
buffers
=
256
;
extern
struct
usb_driver
dabusb_driver
;
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
...
@@ -734,15 +739,18 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
...
@@ -734,15 +739,18 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
if
(
ifnum
!=
_DABUSB_IF
&&
usbdev
->
descriptor
.
idProduct
==
0x9999
)
if
(
ifnum
!=
_DABUSB_IF
&&
usbdev
->
descriptor
.
idProduct
==
0x9999
)
return
NULL
;
return
NULL
;
devnum
=
dabusb_find_struct
();
if
(
usb_register_dev
(
&
dabusb_driver
,
1
,
&
devnum
))
{
if
(
devnum
==
-
1
)
devnum
=
dabusb_find_struct
();
return
NULL
;
if
(
devnum
==
-
1
)
return
NULL
;
}
s
=
&
dabusb
[
devnum
];
s
=
&
dabusb
[
devnum
];
down
(
&
s
->
mutex
);
down
(
&
s
->
mutex
);
s
->
remove_pending
=
0
;
s
->
remove_pending
=
0
;
s
->
usbdev
=
usbdev
;
s
->
usbdev
=
usbdev
;
s
->
devnum
=
devnum
;
if
(
usb_set_configuration
(
usbdev
,
usbdev
->
config
[
0
].
bConfigurationValue
)
<
0
)
{
if
(
usb_set_configuration
(
usbdev
,
usbdev
->
config
[
0
].
bConfigurationValue
)
<
0
)
{
err
(
"set_configuration failed"
);
err
(
"set_configuration failed"
);
...
@@ -777,6 +785,7 @@ static void dabusb_disconnect (struct usb_device *usbdev, void *ptr)
...
@@ -777,6 +785,7 @@ static void dabusb_disconnect (struct usb_device *usbdev, void *ptr)
dbg
(
"dabusb_disconnect"
);
dbg
(
"dabusb_disconnect"
);
usb_deregister_dev
(
&
dabusb_driver
,
1
,
s
->
devnum
);
s
->
remove_pending
=
1
;
s
->
remove_pending
=
1
;
wake_up
(
&
s
->
wait
);
wake_up
(
&
s
->
wait
);
if
(
s
->
state
==
_started
)
if
(
s
->
state
==
_started
)
...
...
drivers/usb/media/dabusb.h
View file @
6efe5cc9
...
@@ -6,7 +6,11 @@ typedef struct
...
@@ -6,7 +6,11 @@ typedef struct
unsigned
int
pipe
;
unsigned
int
pipe
;
}
bulk_transfer_t
,
*
pbulk_transfer_t
;
}
bulk_transfer_t
,
*
pbulk_transfer_t
;
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define DABUSB_MINOR 0
#else
#define DABUSB_MINOR 240
/* some unassigned USB minor */
#define DABUSB_MINOR 240
/* some unassigned USB minor */
#endif
#define DABUSB_VERSION 0x1000
#define DABUSB_VERSION 0x1000
#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
...
@@ -31,6 +35,7 @@ typedef struct
...
@@ -31,6 +35,7 @@ typedef struct
unsigned
int
overruns
;
unsigned
int
overruns
;
int
readptr
;
int
readptr
;
int
opened
;
int
opened
;
int
devnum
;
struct
list_head
free_buff_list
;
struct
list_head
free_buff_list
;
struct
list_head
rec_buff_list
;
struct
list_head
rec_buff_list
;
}
dabusb_t
,
*
pdabusb_t
;
}
dabusb_t
,
*
pdabusb_t
;
...
...
drivers/usb/misc/auerswald.c
View file @
6efe5cc9
...
@@ -60,12 +60,17 @@ do { \
...
@@ -60,12 +60,17 @@ do { \
/* Auerswald Vendor ID */
/* Auerswald Vendor ID */
#define ID_AUERSWALD 0x09BF
#define ID_AUERSWALD 0x09BF
#ifndef AUER_MINOR_BASE
/* allow external override */
#ifdef CONFIG_USB_DYNAMIC_MINORS
/* we can have up to 256 devices at once */
#define AUER_MINOR_BASE 0
#define AUER_MAX_DEVICES 256
#else
#define AUER_MINOR_BASE 112
/* auerswald driver minor number */
#define AUER_MINOR_BASE 112
/* auerswald driver minor number */
#endif
/* we can have up to this number of device plugged in at once */
/* we can have up to this number of device plugged in at once */
#define AUER_MAX_DEVICES 16
#define AUER_MAX_DEVICES 16
#endif
/* prefix for the device descriptors in /dev/usb */
/* prefix for the device descriptors in /dev/usb */
#define AU_PREFIX "auer"
#define AU_PREFIX "auer"
...
@@ -284,6 +289,7 @@ typedef struct
...
@@ -284,6 +289,7 @@ typedef struct
/* Forwards */
/* Forwards */
static
void
auerswald_ctrlread_complete
(
struct
urb
*
urb
);
static
void
auerswald_ctrlread_complete
(
struct
urb
*
urb
);
static
void
auerswald_removeservice
(
pauerswald_t
cp
,
pauerscon_t
scp
);
static
void
auerswald_removeservice
(
pauerswald_t
cp
,
pauerscon_t
scp
);
extern
struct
usb_driver
auerswald_driver
;
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
...
@@ -1941,16 +1947,18 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
...
@@ -1941,16 +1947,18 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
auerbuf_init
(
&
cp
->
bufctl
);
auerbuf_init
(
&
cp
->
bufctl
);
init_waitqueue_head
(
&
cp
->
bufferwait
);
init_waitqueue_head
(
&
cp
->
bufferwait
);
/* find a free slot in the device table */
down
(
&
dev_table_mutex
);
down
(
&
dev_table_mutex
);
for
(
dtindex
=
0
;
dtindex
<
AUER_MAX_DEVICES
;
++
dtindex
)
{
if
(
usb_register_dev
(
&
auerswald_driver
,
1
,
&
dtindex
))
{
if
(
dev_table
[
dtindex
]
==
NULL
)
/* find a free slot in the device table */
break
;
for
(
dtindex
=
0
;
dtindex
<
AUER_MAX_DEVICES
;
++
dtindex
)
{
}
if
(
dev_table
[
dtindex
]
==
NULL
)
if
(
dtindex
>=
AUER_MAX_DEVICES
)
{
break
;
err
(
"more than %d devices plugged in, can not handle this device"
,
AUER_MAX_DEVICES
);
}
up
(
&
dev_table_mutex
);
if
(
dtindex
>=
AUER_MAX_DEVICES
)
{
goto
pfail
;
err
(
"more than %d devices plugged in, can not handle this device"
,
AUER_MAX_DEVICES
);
up
(
&
dev_table_mutex
);
goto
pfail
;
}
}
}
/* Give the device a name */
/* Give the device a name */
...
@@ -2081,6 +2089,9 @@ static void auerswald_disconnect (struct usb_device *usbdev, void *driver_contex
...
@@ -2081,6 +2089,9 @@ static void auerswald_disconnect (struct usb_device *usbdev, void *driver_contex
/* Nobody can see this device any more */
/* Nobody can see this device any more */
devfs_unregister
(
cp
->
devfs
);
devfs_unregister
(
cp
->
devfs
);
/* give back our USB minor number */
usb_deregister_dev
(
&
auerswald_driver
,
1
,
cp
->
dtindex
);
/* Stop the interrupt endpoint */
/* Stop the interrupt endpoint */
auerswald_int_release
(
cp
);
auerswald_int_release
(
cp
);
...
...
drivers/usb/misc/brlvger.c
View file @
6efe5cc9
...
@@ -315,14 +315,16 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
...
@@ -315,14 +315,16 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
down
(
&
reserve_sem
);
down
(
&
reserve_sem
);
for
(
i
=
0
;
i
<
MAX_NR_BRLVGER_DEVS
;
i
++
)
if
(
usb_register_dev
(
&
brlvger_driver
,
1
,
&
i
))
{
if
(
display_table
[
i
]
==
NULL
)
for
(
i
=
0
;
i
<
MAX_NR_BRLVGER_DEVS
;
i
++
)
break
;
if
(
display_table
[
i
]
==
NULL
)
break
;
if
(
i
==
MAX_NR_BRLVGER_DEVS
)
{
err
(
"This driver cannot handle more than %d "
if
(
i
==
MAX_NR_BRLVGER_DEVS
)
{
"braille displays"
,
MAX_NR_BRLVGER_DEVS
);
err
(
"This driver cannot handle more than %d "
goto
error
;
"braille displays"
,
MAX_NR_BRLVGER_DEVS
);
goto
error
;
}
}
}
if
(
!
(
priv
=
kmalloc
(
sizeof
*
priv
,
GFP_KERNEL
))
){
if
(
!
(
priv
=
kmalloc
(
sizeof
*
priv
,
GFP_KERNEL
))
){
...
@@ -423,7 +425,8 @@ brlvger_disconnect(struct usb_device *dev, void *ptr)
...
@@ -423,7 +425,8 @@ brlvger_disconnect(struct usb_device *dev, void *ptr)
info
(
"Display %d disconnecting"
,
priv
->
subminor
);
info
(
"Display %d disconnecting"
,
priv
->
subminor
);
devfs_unregister
(
priv
->
devfs
);
devfs_unregister
(
priv
->
devfs
);
usb_deregister_dev
(
&
brlvger_driver
,
1
,
priv
->
subminor
);
down
(
&
disconnect_sem
);
down
(
&
disconnect_sem
);
display_table
[
priv
->
subminor
]
=
NULL
;
display_table
[
priv
->
subminor
]
=
NULL
;
up
(
&
disconnect_sem
);
up
(
&
disconnect_sem
);
...
...
drivers/usb/usb-skeleton.c
View file @
6efe5cc9
...
@@ -85,12 +85,20 @@ static struct usb_device_id skel_table [] = {
...
@@ -85,12 +85,20 @@ static struct usb_device_id skel_table [] = {
MODULE_DEVICE_TABLE
(
usb
,
skel_table
);
MODULE_DEVICE_TABLE
(
usb
,
skel_table
);
#ifdef CONFIG_USB_DYNAMIC_MINORS
/*
* if the user wants to use dynamic minor numbers, then we can have up to 256
* devices
*/
#define USB_SKEL_MINOR_BASE 0
#define MAX_DEVICES 256
#else
/* Get a minor range for your devices from the usb maintainer */
/* Get a minor range for your devices from the usb maintainer */
#define USB_SKEL_MINOR_BASE 200
#define USB_SKEL_MINOR_BASE 200
/* we can have up to this number of device plugged in at once */
/* we can have up to this number of device plugged in at once */
#define MAX_DEVICES 16
#define MAX_DEVICES 16
#endif
/* Structure to hold all of our device specific stuff */
/* Structure to hold all of our device specific stuff */
struct
usb_skel
{
struct
usb_skel
{
...
@@ -192,9 +200,6 @@ static struct usb_driver skel_driver = {
...
@@ -192,9 +200,6 @@ static struct usb_driver skel_driver = {
};
};
/**
/**
* usb_skel_debug_data
* usb_skel_debug_data
*/
*/
...
@@ -529,15 +534,17 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
...
@@ -529,15 +534,17 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
return
NULL
;
return
NULL
;
}
}
/* select a "subminor" number (part of a minor number) */
down
(
&
minor_table_mutex
);
down
(
&
minor_table_mutex
);
for
(
minor
=
0
;
minor
<
MAX_DEVICES
;
++
minor
)
{
if
(
usb_register_dev
(
&
skel_driver
,
1
,
&
minor
))
{
if
(
minor_table
[
minor
]
==
NULL
)
/* we could not get a dynamic minor, so lets find one of our own */
break
;
for
(
minor
=
0
;
minor
<
MAX_DEVICES
;
++
minor
)
{
}
if
(
minor_table
[
minor
]
==
NULL
)
if
(
minor
>=
MAX_DEVICES
)
{
break
;
info
(
"Too many devices plugged in, can not handle this device."
);
}
goto
exit
;
if
(
minor
>=
MAX_DEVICES
)
{
info
(
"Too many devices plugged in, can not handle this device."
);
goto
exit
;
}
}
}
/* allocate memory for our device state and intialize it */
/* allocate memory for our device state and intialize it */
...
@@ -642,8 +649,11 @@ static void skel_disconnect(struct usb_device *udev, void *ptr)
...
@@ -642,8 +649,11 @@ static void skel_disconnect(struct usb_device *udev, void *ptr)
minor
=
dev
->
minor
;
minor
=
dev
->
minor
;
/* remove our devfs node */
/* remove our devfs node */
devfs_unregister
(
dev
->
devfs
);
devfs_unregister
(
dev
->
devfs
);
/* give back our dynamic minor */
usb_deregister_dev
(
&
skel_driver
,
1
,
minor
);
/* if the device is not opened, then we clean up right now */
/* if the device is not opened, then we clean up right now */
if
(
!
dev
->
open_count
)
{
if
(
!
dev
->
open_count
)
{
up
(
&
dev
->
sem
);
up
(
&
dev
->
sem
);
...
...
include/linux/brlvger.h
View file @
6efe5cc9
...
@@ -30,11 +30,16 @@
...
@@ -30,11 +30,16 @@
#define BRLVGER_DISPLAY_OFF 3
#define BRLVGER_DISPLAY_OFF 3
#define BRLVGER_BUZZ 4
#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 */
/* Number of supported devices, and range of covered minors */
#define MAX_NR_BRLVGER_DEVS 4
#define MAX_NR_BRLVGER_DEVS 4
/* Base minor for the char devices */
/* Base minor for the char devices */
#define BRLVGER_MINOR 128
#define BRLVGER_MINOR 128
#endif
/* Size of some fields */
/* Size of some fields */
#define BRLVGER_HWVER_SIZE 2
#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