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
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
#define USBLP_REQ_RESET 0x02
#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
#endif
#define USBLP_MINOR_BASE 0
#define USBLP_WRITE_TIMEOUT (5*HZ)
/* 5 seconds */
...
...
@@ -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_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.
...
...
@@ -366,6 +372,7 @@ static void usblp_cleanup (struct usblp *usblp)
{
devfs_unregister
(
usblp
->
devfs
);
usblp_table
[
usblp
->
minor
]
=
NULL
;
usb_deregister_dev
(
&
usblp_driver
,
1
,
usblp
->
minor
);
info
(
"usblp%d: removed"
,
usblp
->
minor
);
kfree
(
usblp
->
writeurb
->
transfer_buffer
);
...
...
@@ -801,12 +808,14 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
init_waitqueue_head
(
&
usblp
->
wait
);
usblp
->
ifnum
=
ifnum
;
/* Look for a free usblp_table entry. */
while
(
usblp_table
[
usblp
->
minor
])
{
usblp
->
minor
++
;
if
(
usblp
->
minor
>=
USBLP_MINORS
)
{
err
(
"no more free usblp devices"
);
goto
abort
;
if
(
usb_register_dev
(
&
usblp_driver
,
1
,
&
usblp
->
minor
))
{
/* Look for a free usblp_table entry on our own. */
while
(
usblp_table
[
usblp
->
minor
])
{
usblp
->
minor
++
;
if
(
usblp
->
minor
>=
USBLP_MINORS
)
{
err
(
"no more free usblp devices"
);
goto
abort
;
}
}
}
...
...
drivers/usb/image/mdc800.c
View file @
6efe5cc9
...
...
@@ -119,8 +119,12 @@
#define TO_READ_FROM_IRQ 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) */
#define MDC800_DEVICE_MINOR_BASE 32
#endif
/**************************************************************************
...
...
@@ -176,6 +180,7 @@ struct mdc800_data
int
pic_index
;
// Cache for the Imagesize (-1 for nothing cached )
int
pic_len
;
int
minor
;
};
...
...
@@ -470,6 +475,8 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
down
(
&
mdc800
->
io_lock
);
usb_register_dev
(
&
mdc800_usb_driver
,
1
,
&
mdc800
->
minor
);
mdc800
->
dev
=
dev
;
mdc800
->
open
=
0
;
...
...
@@ -525,6 +532,8 @@ static void mdc800_usb_disconnect (struct usb_device *dev,void* ptr)
if
(
mdc800
->
state
==
NOT_CONNECTED
)
return
;
usb_deregister_dev
(
&
mdc800_usb_driver
,
1
,
mdc800
->
minor
);
mdc800
->
state
=
NOT_CONNECTED
;
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,
down
(
&
scn_mutex
);
for
(
scn_minor
=
0
;
scn_minor
<
SCN_MAX_MNR
;
scn_minor
++
)
{
if
(
!
p_scn_table
[
scn_minor
])
break
;
if
(
usb_register_dev
(
&
scanner_driver
,
1
,
&
scn_minor
))
{
for
(
scn_minor
=
0
;
scn_minor
<
SCN_MAX_MNR
;
scn_minor
++
)
{
if
(
!
p_scn_table
[
scn_minor
])
break
;
}
}
/* Check to make sure that the last slot isn't already taken */
...
...
@@ -1086,6 +1088,7 @@ disconnect_scanner(struct usb_device *dev, void *ptr)
dbg
(
"disconnect_scanner: De-allocating minor:%d"
,
scn
->
scn_minor
);
devfs_unregister
(
scn
->
devfs
);
usb_deregister_dev
(
&
scanner_driver
,
1
,
scn
->
scn_minor
);
p_scn_table
[
scn
->
scn_minor
]
=
NULL
;
usb_free_urb
(
scn
->
scn_irq
);
up
(
&
(
scn
->
sem
));
...
...
drivers/usb/image/scanner.h
View file @
6efe5cc9
...
...
@@ -233,8 +233,13 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids);
#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_BASE_MNR 48
/* USB Scanners start at minor 48 */
#endif
static
DECLARE_MUTEX
(
scn_mutex
);
/* Initializes to unlocked */
...
...
drivers/usb/input/hiddev.c
View file @
6efe5cc9
...
...
@@ -25,10 +25,7 @@
* e-mail - mail your message to Paul Stewart <stewart@wetlogic.net>
*/
#define HIDDEV_MINOR_BASE 96
#define HIDDEV_MINORS 16
#define HIDDEV_BUFFER_SIZE 64
#include <linux/config.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/module.h>
...
...
@@ -39,6 +36,15 @@
#include "hid.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
{
int
exist
;
int
open
;
...
...
@@ -62,6 +68,9 @@ struct hiddev_list {
static
struct
hiddev
*
hiddev_table
[
HIDDEV_MINORS
];
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
* 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)
static
void
hiddev_cleanup
(
struct
hiddev
*
hiddev
)
{
devfs_unregister
(
hiddev
->
devfs
);
usb_deregister_dev
(
&
hiddev_driver
,
1
,
hiddev
->
minor
);
hiddev_table
[
hiddev
->
minor
]
=
NULL
;
kfree
(
hiddev
);
}
...
...
@@ -605,10 +615,12 @@ int hiddev_connect(struct hid_device *hid)
if
(
i
==
hid
->
maxapplication
)
return
-
1
;
for
(
minor
=
0
;
minor
<
HIDDEV_MINORS
&&
hiddev_table
[
minor
];
minor
++
);
if
(
minor
==
HIDDEV_MINORS
)
{
printk
(
KERN_ERR
"hiddev: no more free hiddev devices
\n
"
);
return
-
1
;
if
(
usb_register_dev
(
&
hiddev_driver
,
1
,
&
minor
))
{
for
(
minor
=
0
;
minor
<
HIDDEV_MINORS
&&
hiddev_table
[
minor
];
minor
++
);
if
(
minor
==
HIDDEV_MINORS
)
{
printk
(
KERN_ERR
"hiddev: no more free hiddev devices
\n
"
);
return
-
1
;
}
}
if
(
!
(
hiddev
=
kmalloc
(
sizeof
(
struct
hiddev
),
GFP_KERNEL
)))
...
...
drivers/usb/media/dabusb.c
View file @
6efe5cc9
...
...
@@ -52,12 +52,17 @@
/* --------------------------------------------------------------------- */
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define NRDABUSB 256
#else
#define NRDABUSB 4
#endif
/*-------------------------------------------------------------------*/
static
dabusb_t
dabusb
[
NRDABUSB
];
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,
if
(
ifnum
!=
_DABUSB_IF
&&
usbdev
->
descriptor
.
idProduct
==
0x9999
)
return
NULL
;
devnum
=
dabusb_find_struct
();
if
(
devnum
==
-
1
)
return
NULL
;
if
(
usb_register_dev
(
&
dabusb_driver
,
1
,
&
devnum
))
{
devnum
=
dabusb_find_struct
();
if
(
devnum
==
-
1
)
return
NULL
;
}
s
=
&
dabusb
[
devnum
];
down
(
&
s
->
mutex
);
s
->
remove_pending
=
0
;
s
->
usbdev
=
usbdev
;
s
->
devnum
=
devnum
;
if
(
usb_set_configuration
(
usbdev
,
usbdev
->
config
[
0
].
bConfigurationValue
)
<
0
)
{
err
(
"set_configuration failed"
);
...
...
@@ -777,6 +785,7 @@ static void dabusb_disconnect (struct usb_device *usbdev, void *ptr)
dbg
(
"dabusb_disconnect"
);
usb_deregister_dev
(
&
dabusb_driver
,
1
,
s
->
devnum
);
s
->
remove_pending
=
1
;
wake_up
(
&
s
->
wait
);
if
(
s
->
state
==
_started
)
...
...
drivers/usb/media/dabusb.h
View file @
6efe5cc9
...
...
@@ -6,7 +6,11 @@ typedef struct
unsigned
int
pipe
;
}
bulk_transfer_t
,
*
pbulk_transfer_t
;
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define DABUSB_MINOR 0
#else
#define DABUSB_MINOR 240
/* some unassigned USB minor */
#endif
#define DABUSB_VERSION 0x1000
#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
...
...
@@ -31,6 +35,7 @@ typedef struct
unsigned
int
overruns
;
int
readptr
;
int
opened
;
int
devnum
;
struct
list_head
free_buff_list
;
struct
list_head
rec_buff_list
;
}
dabusb_t
,
*
pdabusb_t
;
...
...
drivers/usb/misc/auerswald.c
View file @
6efe5cc9
...
...
@@ -60,12 +60,17 @@ do { \
/* Auerswald Vendor ID */
#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 */
#endif
/* we can have up to this number of device plugged in at once */
#define AUER_MAX_DEVICES 16
#endif
/* prefix for the device descriptors in /dev/usb */
#define AU_PREFIX "auer"
...
...
@@ -284,6 +289,7 @@ typedef struct
/* Forwards */
static
void
auerswald_ctrlread_complete
(
struct
urb
*
urb
);
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,
auerbuf_init
(
&
cp
->
bufctl
);
init_waitqueue_head
(
&
cp
->
bufferwait
);
/* find a free slot in the device table */
down
(
&
dev_table_mutex
);
for
(
dtindex
=
0
;
dtindex
<
AUER_MAX_DEVICES
;
++
dtindex
)
{
if
(
dev_table
[
dtindex
]
==
NULL
)
break
;
}
if
(
dtindex
>=
AUER_MAX_DEVICES
)
{
err
(
"more than %d devices plugged in, can not handle this device"
,
AUER_MAX_DEVICES
);
up
(
&
dev_table_mutex
);
goto
pfail
;
if
(
usb_register_dev
(
&
auerswald_driver
,
1
,
&
dtindex
))
{
/* find a free slot in the device table */
for
(
dtindex
=
0
;
dtindex
<
AUER_MAX_DEVICES
;
++
dtindex
)
{
if
(
dev_table
[
dtindex
]
==
NULL
)
break
;
}
if
(
dtindex
>=
AUER_MAX_DEVICES
)
{
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 */
...
...
@@ -2081,6 +2089,9 @@ static void auerswald_disconnect (struct usb_device *usbdev, void *driver_contex
/* Nobody can see this device any more */
devfs_unregister
(
cp
->
devfs
);
/* give back our USB minor number */
usb_deregister_dev
(
&
auerswald_driver
,
1
,
cp
->
dtindex
);
/* Stop the interrupt endpoint */
auerswald_int_release
(
cp
);
...
...
drivers/usb/misc/brlvger.c
View file @
6efe5cc9
...
...
@@ -315,14 +315,16 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
down
(
&
reserve_sem
);
for
(
i
=
0
;
i
<
MAX_NR_BRLVGER_DEVS
;
i
++
)
if
(
display_table
[
i
]
==
NULL
)
break
;
if
(
i
==
MAX_NR_BRLVGER_DEVS
)
{
err
(
"This driver cannot handle more than %d "
"braille displays"
,
MAX_NR_BRLVGER_DEVS
);
goto
error
;
if
(
usb_register_dev
(
&
brlvger_driver
,
1
,
&
i
))
{
for
(
i
=
0
;
i
<
MAX_NR_BRLVGER_DEVS
;
i
++
)
if
(
display_table
[
i
]
==
NULL
)
break
;
if
(
i
==
MAX_NR_BRLVGER_DEVS
)
{
err
(
"This driver cannot handle more than %d "
"braille displays"
,
MAX_NR_BRLVGER_DEVS
);
goto
error
;
}
}
if
(
!
(
priv
=
kmalloc
(
sizeof
*
priv
,
GFP_KERNEL
))
){
...
...
@@ -423,7 +425,8 @@ brlvger_disconnect(struct usb_device *dev, void *ptr)
info
(
"Display %d disconnecting"
,
priv
->
subminor
);
devfs_unregister
(
priv
->
devfs
);
usb_deregister_dev
(
&
brlvger_driver
,
1
,
priv
->
subminor
);
down
(
&
disconnect_sem
);
display_table
[
priv
->
subminor
]
=
NULL
;
up
(
&
disconnect_sem
);
...
...
drivers/usb/usb-skeleton.c
View file @
6efe5cc9
...
...
@@ -85,12 +85,20 @@ static struct usb_device_id 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 */
#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 */
#define MAX_DEVICES 16
#endif
/* Structure to hold all of our device specific stuff */
struct
usb_skel
{
...
...
@@ -192,9 +200,6 @@ static struct usb_driver skel_driver = {
};
/**
* usb_skel_debug_data
*/
...
...
@@ -529,15 +534,17 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
return
NULL
;
}
/* select a "subminor" number (part of a minor number) */
down
(
&
minor_table_mutex
);
for
(
minor
=
0
;
minor
<
MAX_DEVICES
;
++
minor
)
{
if
(
minor_table
[
minor
]
==
NULL
)
break
;
}
if
(
minor
>=
MAX_DEVICES
)
{
info
(
"Too many devices plugged in, can not handle this device."
);
goto
exit
;
if
(
usb_register_dev
(
&
skel_driver
,
1
,
&
minor
))
{
/* we could not get a dynamic minor, so lets find one of our own */
for
(
minor
=
0
;
minor
<
MAX_DEVICES
;
++
minor
)
{
if
(
minor_table
[
minor
]
==
NULL
)
break
;
}
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 */
...
...
@@ -642,8 +649,11 @@ static void skel_disconnect(struct usb_device *udev, void *ptr)
minor
=
dev
->
minor
;
/* 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
(
!
dev
->
open_count
)
{
up
(
&
dev
->
sem
);
...
...
include/linux/brlvger.h
View file @
6efe5cc9
...
...
@@ -30,11 +30,16 @@
#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