usbatm xusbatm.c,1.1,1.2
kagan at infradead.org
kagan at infradead.org
Thu Apr 7 06:36:29 EDT 2005
Update of /home/cvs/usbatm
In directory phoenix.infradead.org:/tmp/cvs-serv20673
Modified Files:
xusbatm.c
Log Message:
Convert all parameters to arrays
Index: xusbatm.c
===================================================================
RCS file: /home/cvs/usbatm/xusbatm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xusbatm.c 2 Apr 2005 20:12:53 -0000 1.1
+++ xusbatm.c 7 Apr 2005 10:36:26 -0000 1.2
@@ -17,54 +17,36 @@
*
******************************************************************************/
-#include <linux/delay.h>
#include <linux/module.h>
#include "usbatm.h"
-static struct usb_device_id xusbatm_usb_ids[] = {
- {
- .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
- },
- {}
-};
+#define XUSBATM_DRIVERS_MAX 8
-static uint vendor;
-module_param(vendor, uint, 0444);
-MODULE_PARM_DESC(vendor, "USB device vendor");
-static uint product;
-module_param(product, uint, 0444);
-MODULE_PARM_DESC(product, "USB device product");
-
-static uint rx_intf;
-module_param(rx_intf, uint, 0444);
-MODULE_PARM_DESC(rx_intf, "rx interface number (default 0)");
-static uint tx_intf;
-module_param(tx_intf, uint, 0444);
-MODULE_PARM_DESC(tx_intf, "tx interface number (default 0)");
+#define XUSBATM_PARM(name, type, desc) \
+ static type name[XUSBATM_DRIVERS_MAX]; \
+ static int num_##name; \
+ module_param_array(name, type, &num_##name, 0444); \
+ MODULE_PARM_DESC(name, desc)
-static const char xusbatm_driver_name[] = "xusbatm";
+XUSBATM_PARM(vendor, uint, "USB device vendor");
+XUSBATM_PARM(product, uint, "USB device product");
-static struct usbatm_driver xusbatm_driver = {
- .owner = THIS_MODULE,
- .driver_name = xusbatm_driver_name,
/*
- .bind = xusbatm_bind,
- .unbind = xusbatm_unbind,
+XUSBATM_PARM(rx_intf, uint, "rx interface number (default 0)");
+XUSBATM_PARM(tx_intf, uint, "tx interface number (default 0)");
*/
- .in = -1,
- .out = -1,
-};
-module_param_named(rx_endpoint, xusbatm_driver.in, int, 0444);
-MODULE_PARM_DESC(rx_endpoint, "rx endpoint number");
-module_param_named(tx_endpoint, xusbatm_driver.out, int, 0444);
-MODULE_PARM_DESC(tx_endpoint, "tx endpoint number");
-module_param_named(rx_padding, xusbatm_driver.rx_padding, uint, 0444);
-MODULE_PARM_DESC(rx_padding, "rx padding (default 0)");
-module_param_named(tx_padding, xusbatm_driver.tx_padding, uint, 0444);
-MODULE_PARM_DESC(tx_padding, "tx padding (default 0)");
+XUSBATM_PARM(rx_endpoint, int, "rx endpoint number");
+XUSBATM_PARM(tx_endpoint, int, "tx endpoint number");
+XUSBATM_PARM(rx_padding, uint, "rx padding (default 0)");
+XUSBATM_PARM(tx_padding, uint, "tx padding (default 0)");
+
+static const char xusbatm_driver_name[] = "xusbatm";
+
+static struct usbatm_driver xusbatm_drivers[XUSBATM_DRIVERS_MAX];
+static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1];
/*
static int xusbatm_bind(struct usbatm_data *usbatm_instance,
@@ -83,9 +65,11 @@
}
*/
-static int xusbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int xusbatm_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
{
- return usbatm_usb_probe(intf, id, &xusbatm_driver);
+ return usbatm_usb_probe(intf, id,
+ xusbatm_drivers + (id - xusbatm_usb_ids));
}
static struct usb_driver xusbatm_usb_driver = {
@@ -98,15 +82,35 @@
static int __init xusbatm_init(void)
{
+ int i;
+ int num_drivers = min_t(int,
+ min_t(int, num_vendor, num_product),
+ min_t(int, num_rx_endpoint, num_tx_endpoint));
+
dbg("xusbatm_init");
- if (xusbatm_driver.in < 0 || xusbatm_driver.out < 0) {
- warn("indicate the endpoints with `rx_endpoint' and `tx_endpoint' module parameters");
+ if (!num_drivers) {
+ warn("malformed module parameters");
return -EINVAL;
}
- xusbatm_usb_ids[0].idVendor = vendor;
- xusbatm_usb_ids[0].idProduct = product;
+ for (i = 0; i < num_drivers; i++) {
+ xusbatm_usb_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
+ xusbatm_usb_ids[i].idVendor = vendor[i];
+ xusbatm_usb_ids[i].idProduct = product[i];
+
+
+ xusbatm_drivers[i].owner = THIS_MODULE;
+ xusbatm_drivers[i].driver_name = xusbatm_driver_name;
+ /*
+ xusbatm_drivers[i].bind = xusbatm_bind;
+ xusbatm_drivers[i].unbind = xusbatm_unbind;
+ */
+ xusbatm_drivers[i].in = rx_endpoint[i];
+ xusbatm_drivers[i].out = tx_endpoint[i];
+ xusbatm_drivers[i].rx_padding = rx_padding[i];
+ xusbatm_drivers[i].tx_padding = tx_padding[i];
+ }
return usb_register(&xusbatm_usb_driver);
}
More information about the Usbatm-commits
mailing list