[PATCHS] Improvements to be approved
Nathael Pajani <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi!
Here are some small patchs mostly for the usb-serial.
I'm open to discussion about them (the first one should be discussed at least)
First patch: (see attached patch use_usb_match_dynamic_id.patch)
Why adding a "struct usb_dynids dynids;" in 'struct usb_serial_driver'
while there's already one in 'struct usb_driver'
This has you rewriting a match_dynamic_id() while there is already one in
"drivers/usb/core/driver.c" which just has to be exported. (Maybe this is a
bad idea, I don't know.)
And there is no "no_dynamic_id" (which may be ommited, OK)
I think having two "dynids" is confusing, and not necessary.
Also attached patches:
* drivers/usb/serial/console.c
--> typo in comments
(see usb_console_typo_in_comments.patch)
* drivers/usb/serial/usb-serial.c
--> "usb_serial_driver" changed to "usb_main_serial_driver" to prevent
confusion with the "struct usb_serial_driver" (compiler knows what to
do, but variable names are for users isn't it?)
(see usb_serial_namespace.patch)
* include/linux/usb/serial.h
--> using type "int" instead of "char" as minor numbers can be over 255
(see usb_serial_minor_over_255.patch)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
usb_console_typo_in_comments.patch
(text/x-patch, 580 B)
diff -urN a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
--- a/drivers/usb/serial/console.c 2007-08-30 20:10:37.000000000 +0100
+++ b/drivers/usb/serial/console.c 2007-08-30 10:52:25.000000000 +0200
@@ -274,7 +274,7 @@
* Register console.
* NOTES:
* console_setup() is called (back) immediately (from register_console).
- * console_write() is called immediately from register_console iff
+ * console_write() is called immediately from register_console if
* CON_PRINTBUFFER is set in flags.
*/
dbg ("registering the USB serial console.");
usb_serial_minor_over_255.patch
(text/x-patch, 1016 B)
diff -urN a/include/linux/usb/serial.h b/include/linux/usb/serial.h --- a/include/linux/usb/serial.h 2007-08-30 20:10:37.000000000 +0100 +++ b/include/linux/usb/serial.h 2007-08-30 15:44:59.000000000 +0200 @@ -18,7 +18,7 @@ #include <linux/mutex.h> #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ -#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ +#define SERIAL_TTY_MINORS 512 /* loads of devices :) */ #define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */ @@ -65,7 +65,7 @@ struct tty_struct * tty; spinlock_t lock; struct mutex mutex; - unsigned char number; + unsigned int number; unsigned char * interrupt_in_buffer; struct urb * interrupt_in_urb; @@ -128,7 +128,7 @@ struct usb_device * dev; struct usb_serial_driver * type; struct usb_interface * interface; - unsigned char minor; + unsigned int minor; unsigned char num_ports; unsigned char num_port_pointers; char num_interrupt_in;
usb_serial_namespace.patch
(text/x-patch, 1.7 KB)
diff -urN a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c 2007-08-30 20:10:37.000000000 +0100
+++ b/drivers/usb/serial/usb-serial.c 2007-08-30 18:29:24.000000000 +0200
@@ -42,7 +42,7 @@
static void port_free(struct usb_serial_port *port);
/* Driver structure we register with the USB core */
-static struct usb_driver usb_serial_driver = {
+static struct usb_driver usb_main_serial_driver = {
.name = "usbserial",
.probe = usb_serial_probe,
.disconnect = usb_serial_disconnect,
@@ -707,7 +755,7 @@
/* if this device type has a probe function, call it */
if (type->probe) {
- const struct usb_device_id *id;
+ const struct usb_device_id* id_tmp;
if (!try_module_get(type->driver.owner)) {
unlock_kernel();
@@ -716,8 +764,8 @@
return -EIO;
}
- id = get_iface_id(type, interface);
- retval = type->probe(serial, id);
+ id_tmp = get_iface_id(type, interface);
+ retval = type->probe(serial, id_tmp);
module_put(type->driver.owner);
if (retval) {
@@ -1157,7 +1220,7 @@
}
/* register the USB driver */
- result = usb_register(&usb_serial_driver);
+ result = usb_register(&usb_main_serial_driver);
if (result < 0) {
err("%s - usb_register failed", __FUNCTION__);
goto exit_tty;
@@ -1175,7 +1238,7 @@
return result;
exit_generic:
- usb_deregister(&usb_serial_driver);
+ usb_deregister(&usb_main_serial_driver);
exit_tty:
tty_unregister_driver(usb_serial_tty_driver);
@@ -1196,7 +1259,7 @@
usb_serial_generic_deregister();
- usb_deregister(&usb_serial_driver);
+ usb_deregister(&usb_main_serial_driver);
tty_unregister_driver(usb_serial_tty_driver);
put_tty_driver(usb_serial_tty_driver);
bus_unregister(&usb_serial_bus_type);
use_usb_match_dynamic_id.patch
(text/x-patch, 2.8 KB)
diff -urN a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
--- a/drivers/usb/core/driver.c 2007-08-30 20:10:37.000000000 +0100
+++ b/drivers/usb/core/driver.c 2007-08-30 18:29:24.000000000 +0200
@@ -133,7 +133,7 @@
}
#endif
-static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
+const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
struct usb_driver *drv)
{
struct usb_dynid *dynid;
@@ -148,6 +148,7 @@
spin_unlock(&drv->dynids.lock);
return NULL;
}
+EXPORT_SYMBOL_GPL_FUTURE(usb_match_dynamic_id);
/* called from driver core with dev locked */
diff -urN a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c 2007-08-30 20:10:37.000000000 +0100
+++ b/drivers/usb/serial/usb-serial.c 2007-08-30 18:29:24.000000000 +0200
@@ -616,22 +616,6 @@
return serial;
}
-static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf,
- struct usb_serial_driver *drv)
-{
- struct usb_dynid *dynid;
-
- spin_lock(&drv->dynids.lock);
- list_for_each_entry(dynid, &drv->dynids.list, node) {
- if (usb_match_one_id(intf, &dynid->id)) {
- spin_unlock(&drv->dynids.lock);
- return &dynid->id;
- }
- }
- spin_unlock(&drv->dynids.lock);
- return NULL;
-}
-
static const struct usb_device_id *get_iface_id(struct usb_serial_driver *drv,
struct usb_interface *intf)
{
@@ -642,9 +626,16 @@
dbg("static descriptor matches");
goto exit;
}
+
+ /* Check for driver with no dynamic IDs or uninitialised drivers */
+ if( (drv->usb_driver == NULL) || (drv->usb_driver->no_dynamic_id == 1) ){
+ return NULL;
+ }
+
- id = match_dynamic_id(intf, drv);
+ id = usb_match_dynamic_id( intf, drv->usb_driver );
if (id)
dbg("dynamic descriptor matches");
+
exit:
return id;
}
diff -urN a/include/linux/usb/serial.h b/include/linux/usb/serial.h
--- a/include/linux/usb/serial.h 2007-08-30 20:10:37.000000000 +0100
+++ b/include/linux/usb/serial.h 2007-08-30 18:29:24.000000000 +0200
@@ -210,7 +210,6 @@
struct list_head driver_list;
struct device_driver driver;
struct usb_driver *usb_driver;
- struct usb_dynids dynids;
int (*probe) (struct usb_serial *serial, const struct usb_device_id *id);
int (*attach) (struct usb_serial *serial);
diff -urN a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h 2007-08-30 20:10:37.000000000 +0100
+++ b/include/linux/usb.h 2007-08-30 18:29:24.000000000 +0200
@@ -483,6 +483,10 @@
/*-------------------------------------------------------------------------*/
+/* */
+extern const struct usb_device_id *usb_match_dynamic_id(
+ struct usb_interface *intf, struct usb_driver *drv);
+
/* for drivers using iso endpoints */
extern int usb_get_current_frame_number (struct usb_device *usb_dev);