HSO: add option hso driver
Subsystems (4)
PATCH 1/1 HSO: add option hso driver
From: Greg Kroah-Hartman <[email protected]>
This driver is for a number of different Option devices. Originally written by Option and Andrew Bird, but cleaned up massivly for acceptance into mainline by me and others.
Many thanks to the following for their help in cleaning up the driver by providing feedback and patches to it:
- Paulius Zaleckas <[email protected]>
- Oliver Neukum <[email protected]>
- Alan Cox <alan-qBU/[email protected]>
- Javier Marcet <[email protected]>
---
Jeff, please queue this up for 2.6.27 if there are no problems that you can see. It has been in the linux-next tree for a while, and many users are reporting that it is working for them.
Or if you feel it's ok for 2.6.26, I will not object to that either :)
drivers/net/Makefile | 1 drivers/net/usb/Kconfig | 10 drivers/net/usb/Makefile | 1 drivers/net/usb/hso.c | 2841 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2853 insertions(+)
drivers/net/Makefile +1 -0
@@ -236,6 +236,7 @@ obj-$(CONFIG_USB_CATC) += usb/ obj-$(CONFIG_USB_KAWETH) += usb/ obj-$(CONFIG_USB_PEGASUS) += usb/ obj-$(CONFIG_USB_RTL8150) += usb/ +obj-$(CONFIG_USB_HSO) += usb/ obj-$(CONFIG_USB_USBNET) += usb/ obj-$(CONFIG_USB_ZD1201) += usb/
drivers/net/usb/hso.c new file +2841 -0
2,841 lines not on this page · raw message
drivers/net/usb/Kconfig +10 -0
@@ -154,6 +154,16 @@ config USB_NET_AX8817X This driver creates an interface named "ethX", where X depends on what other networking devices you have in use. +config USB_HSO + tristate "Option USB High Speed Mobile Devices" + depends on USB && RFKILL + default n + help + Choose this option if you have an Option HSDPA/HSUPA card. + These cards support downlink speeds of 7.2Mbps or greater. + + To compile this driver as a module, choose M here: the + module will be called hso. config USB_NET_CDCETHER tristate "CDC Ethernet support (smart devices such as cable modems)"
drivers/net/usb/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_USB_CATC) += catc.o obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o +obj-$(CONFIG_USB_HSO) += hso.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_DM9601) += dm9601.o
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
Jeff, please queue this up for 2.6.27 if there are no problems that you can see. It has been in the linux-next tree for a while, and many users are reporting that it is working for them.
Or if you feel it's ok for 2.6.26, I will not object to that either :)
Can we get it into 2.6.26 - its a driver for new hardware and the driver is going to get a clean up for 2.6.27 anyway.
Comments below are minor and I don't think blockers
So for the serial side
drivers/net/usb/hso.c line 994
Quoted 1 line
drivers/net/usb/hso.c new file +1
-0+ termios = serial->tty->termios;
tty is passed why keep using serial->tty (hint: think about parallel hangup versus close/open)
drivers/net/usb/hso.c line 1101
Quoted 13 lines
drivers/net/usb/hso.c new file +13
-0+/* close the requested serial port */ +static void hso_serial_close (struct tty_struct *tty,struct file *filp) +{ +struct hso_serial *serial = tty->driver_data; +u8 usb_gone; + +D1 ("Closing serial port" ); + +/* sanity check */ +if (tty ==NULL || serial ==NULL ) { +D1 ("(tty == NULL || tty->driver_data == NULL)" ); +return ; + }
tty cannot be NULL here
drivers/net/usb/hso.c line 1137
Quoted 10 lines
drivers/net/usb/hso.c new file +10
-0+static int hso_serial_write (struct tty_struct *tty,const unsigned char *buf, +int count) +{ +struct hso_serial *serial =get_serial_by_tty (tty); +int space, tx_bytes; +unsigned long flags; + +/* sanity check */ +if (serial ==NULL ) { + printk(KERN_ERR "%s: tty or tty->driver_data is NULL\n",
Checks one thing printks another 8)
drivers/net/usb/hso.c line 1189
Quoted 4 lines
drivers/net/usb/hso.c new file +4
-0+/* the actual setup */ +spin_lock_irqsave (&serial->serial_lock, flags); +if (serial->open_count) +_hso_serial_set_termios (tty, old);
(else *tty->termios = *old_termios)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Alan Cox
Quoted 5 lines
Jeff, please queue this up for 2.6.27 if there are no problems that you can see. It has been in the linux-next tree for a while, and many users are reporting that it is working for them.
Or if you feel it's ok for 2.6.26, I will not object to that either :)
Quoted 8 lines
Can we get it into 2.6.26 - its a driver for new hardware and the driver is going to get a clean up for 2.6.27 anyway.
Comments below are minor and I don't think blockers
So for the serial side
Acked-by Alan Cox <[email protected]>
AFAIK new drivers are OK post-rc1, since no possibility of regression and it enables new users.
However, an exception to that might be a super-huge driver slipped in at the last minute with no review (clearly not the case here)
Jeff
Quoted 11 lines · Jeff Garzik
Quoted 10 lines · Alan Cox
Quoted 5 lines
Jeff, please queue this up for 2.6.27 if there are no problems that you can see. It has been in the linux-next tree for a while, and many users are reporting that it is working for them.
Or if you feel it's ok for 2.6.26, I will not object to that either :)
Can we get it into 2.6.26 - its a driver for new hardware and the driver is going to get a clean up for 2.6.27 anyway.
Comments below are minor and I don't think blockers
So for the serial sideAcked-by Alan Cox <[email protected]>
Thanks, I'll provide a clean-up patch based on this review in a few hours.
Unless Jeff would just like a whole new patch?
Quoted 2 lines
AFAIK new drivers are OK post-rc1, since no possibility of regression and it enables new users.
Thanks, I appreciate it.
greg k-h
Quoted 13 lines · Alan Cox
Quoted 5 lines
Jeff, please queue this up for 2.6.27 if there are no problems that you can see. It has been in the linux-next tree for a while, and many users are reporting that it is working for them.
Or if you feel it's ok for 2.6.26, I will not object to that either :)
Can we get it into 2.6.26 - its a driver for new hardware and the driver is going to get a clean up for 2.6.27 anyway.
Comments below are minor and I don't think blockers
So for the serial side
Quoted 7 lines
Acked-by Alan Cox <[email protected]>drivers/net/usb/hso.c line 994
Quoted 1 line
drivers/net/usb/hso.c new file +1
-0+ termios = serial->tty->termios;tty is passed why keep using
serial->tty(hint: think about parallel hangup versus close/open)
Ick, now fixed.
Quoted 7 lines
Quoted 7 lines
drivers/net/usb/hso.c new file +7
-0+/* close the requested serial port */ +static void hso_serial_close (struct tty_struct *tty,struct file *filp) +{ +struct hso_serial *serial = tty->driver_data; +u8 usb_gone; + +D1 ("Closing serial port" );
Quoted 8 lines
drivers/net/usb/hso.c line 1101
Quoted 6 lines
drivers/net/usb/hso.c new file +6
-0+ +/* sanity check */ +if (tty ==NULL || serial ==NULL ) { +D1 ("(tty == NULL || tty->driver_data == NULL)" ); +return ; + }tty cannot be NULL here
removed.
Quoted 4 lines
Quoted 4 lines
drivers/net/usb/hso.c new file +4
-0+static int hso_serial_write (struct tty_struct *tty,const unsigned char *buf, +int count) +{ +struct hso_serial *serial =get_serial_by_tty (tty);
Quoted 8 lines
drivers/net/usb/hso.c line 1137
Quoted 6 lines
drivers/net/usb/hso.c new file +6
-0+int space, tx_bytes; +unsigned long flags; + +/* sanity check */ +if (serial ==NULL ) { + printk(KERN_ERR "%s: tty or tty->driver_data is NULL\n",Checks one thing printks another 8)
Fixed.
Quoted 6 lines
drivers/net/usb/hso.c line 1189
Quoted 4 lines
drivers/net/usb/hso.c new file +4
-0+/* the actual setup */ +spin_lock_irqsave (&serial->serial_lock, flags); +if (serial->open_count) +_hso_serial_set_termios (tty, old);(else
*tty->termios=*old_termios)
Added.
Thanks for the review, I really appreciate it.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
This driver is for a number of different Option devices. Originally written by Option and Andrew Bird, but cleaned up massivly for acceptance into mainline by me and others.
Many thanks to the following for their help in cleaning up the driver by providing feedback and patches to it:
- Paulius Zaleckas <[email protected]>
- Oliver Neukum <[email protected]>
- Alan Cox <alan-qBU/[email protected]>
- Javier Marcet <[email protected]>
---
Jeff, this is an updated version from what I previously sent. I have no objection for this to go into 2.6.26.
drivers/net/Makefile | 1 drivers/net/usb/Kconfig | 10 drivers/net/usb/Makefile | 1 drivers/net/usb/hso.c | 2836 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2848 insertions(+)
drivers/net/Makefile +1 -0
@@ -236,6 +236,7 @@ obj-$(CONFIG_USB_CATC) += usb/ obj-$(CONFIG_USB_KAWETH) += usb/ obj-$(CONFIG_USB_PEGASUS) += usb/ obj-$(CONFIG_USB_RTL8150) += usb/ +obj-$(CONFIG_USB_HSO) += usb/ obj-$(CONFIG_USB_USBNET) += usb/ obj-$(CONFIG_USB_ZD1201) += usb/
drivers/net/usb/hso.c new file +2836 -0
2,836 lines not on this page · raw message
drivers/net/usb/Kconfig +10 -0
@@ -154,6 +154,16 @@ config USB_NET_AX8817X This driver creates an interface named "ethX", where X depends on what other networking devices you have in use. +config USB_HSO + tristate "Option USB High Speed Mobile Devices" + depends on USB && RFKILL + default n + help + Choose this option if you have an Option HSDPA/HSUPA card. + These cards support downlink speeds of 7.2Mbps or greater. + + To compile this driver as a module, choose M here: the + module will be called hso. config USB_NET_CDCETHER tristate "CDC Ethernet support (smart devices such as cable modems)"
drivers/net/usb/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_USB_CATC) += catc.o obj-$(CONFIG_USB_KAWETH) += kaweth.o obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o +obj-$(CONFIG_USB_HSO) += hso.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_DM9601) += dm9601.o
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Greg Kroah-Hartman
+#define
DRIVER_VERSION"1.2"
Maybe we should bump the version?
Now it is the same as the different driver at PHARscape.
Quoted 69 lines
drivers/net/usb/hso.c new file +69
-0+/* called once for each interface upon device insertion */ +static int hso_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{ +int mux, i, if_num, port_spec; +unsigned char port_mask; +struct hso_device *hso_dev =NULL ; +struct hso_shared_int *shared_int; +struct hso_device *tmp_dev =NULL ; + + if_num = interface->altsetting->desc.bInterfaceNumber; + +/* Get the interface/port specification from either driver_info or from +* the device itself */ +if (id->driver_info) + port_spec = ((u32 *)(id->driver_info))[if_num]; +else + port_spec =hso_get_config_data (interface); + +if (interface->cur_altsetting->desc.bInterfaceClass !=0xFF ) { +dev_err (&interface->dev,"Not our interface\n" ); +return -ENODEV ; + } +/* Check if we need to switch to alt interfaces prior to port +* configuration */ +if (interface->num_altsetting >1 ) +usb_set_interface (interface_to_usbdev (interface), if_num,1 ); + interface->needs_remote_wakeup =1 ; + +/* Allocate new hso device(s) */ +switch (port_spec &HSO_INTF_MASK ) { +case HSO_INTF_MUX : +if ((port_spec &HSO_PORT_MASK ) ==HSO_PORT_NETWORK ) { +/* Create the network device */ +if (!disable_net) { + hso_dev =hso_create_net_device (interface); +if (!hso_dev) + goto exit; + tmp_dev = hso_dev; + } + } + +if (hso_get_mux_ports (interface, &port_mask)) +/* TODO: de-allocate everything */ + goto exit; + + shared_int =hso_create_shared_int (interface); +if (!shared_int) + goto exit; + +for (i =1 , mux =0 ; i <0x100 ; i = i <<1 , mux++) { +if (port_mask & i) { + hso_dev =hso_create_mux_serial_device ( + interface, i, shared_int); +if (!hso_dev) + goto exit; + } + } + +if (tmp_dev) + hso_dev = tmp_dev; +break ; + +case HSO_INTF_BULK : +/* It's a regular bulk interface */ +if (((port_spec &HSO_PORT_MASK ) ==HSO_PORT_NETWORK ) + && !disable_net) + hso_dev =hso_create_net_device (interface); +else
drivers/net/usb/hso.c line 2483
Quoted 10 lines
drivers/net/usb/hso.c new file +10
-0+ hso_dev = +hso_create_bulk_serial_device (interface, port_spec); +if (!hso_dev) + goto exit; +break ; +default : + goto exit; + } + +usb_driver_claim_interface (&hso_driver, interface, hso_dev);
Is usb_driver_claim_interface really needed?
drivers/net/usb/hso.c line 2493
Quoted 9 lines
drivers/net/usb/hso.c new file +9
-0+/* save our data pointer in this device */ +usb_set_intfdata (interface, hso_dev); + +/* done */ +return 0 ; +exit: +hso_free_interface (interface); +return -ENODEV ; +}
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Paulius Zaleckas schreef:
Quoted 5 lines
Quoted 1 line · Greg Kroah-Hartman
+#define
DRIVER_VERSION"1.2"Maybe we should bump the version?
Now it is the same as the different driver at PHARscape.
Probably the best thing would be to drop it altogether as it doesn't make a lot of sense to maintain it in the kernel. Also the pharscape version will continue to live it's own life till the hso driver is fully settled in an official kernel, so version conflicts would be bound to happen anyway.
Regards,
Filip-
drivers/net/usb/hso.c line 71
Quoted 4 lines · Greg KH
drivers/net/usb/hso.c new file +3
-0+#define MOD_AUTHOR "Option Wireless" +#define MOD_DESCRIPTION "USB High Speed Option driver" +#define MOD_LICENSE "GPL"
That MODULE_DESCRIPTION(MOD_DESCRIPTION) looks so redundant. [Same for MOD_AUTHOR and MOD_LICENSE.]
Just write MODULE_DESCRIPTION("USB High Speed Option driver"), no?
Also, "Option" sounds a bit misleading. Is Option a company name, a product name, or the original English word "option"? It's confusing.
drivers/net/usb/hso.c line 221
Quoted 5 lines
drivers/net/usb/hso.c new file +5
-0+struct hso_device { +union { +struct hso_serial *dev_serial; +struct hso_net *dev_net; + } port_data;
This does not really need a name, since it is an anon union anyway.
Review
Quoted 2 lines
(quoted diff) +2
-0+}; +
The usual bunch of \s.. er, has this gone through checkpatch? [Seems mostly clean though.]
Quoted 22 lines
drivers/net/usb/hso.c new file +22
-0+/* Type of interface */ +#define HSO_INTF_MASK 0xFF00 +#define HSO_INTF_MUX 0x0100 +#define HSO_INTF_BULK 0x0200 + +/* Type of port */ +#define HSO_PORT_MASK 0xFF +#define HSO_PORT_NO_PORT 0x0 +#define HSO_PORT_CONTROL 0x1 +#define HSO_PORT_APP 0x2 +#define HSO_PORT_GPS 0x3 +#define HSO_PORT_PCSC 0x4 +#define HSO_PORT_APP2 0x5 +#define HSO_PORT_GPS_CONTROL 0x6 +#define HSO_PORT_MSD 0x7 +#define HSO_PORT_VOICE 0x8 +#define HSO_PORT_DIAG2 0x9 +#define HSO_PORT_DIAG 0x10 +#define HSO_PORT_MODEM 0x11 +#define HSO_PORT_NETWORK 0x12 + +/* Additional device info */
drivers/net/usb/hso.c
Quoted 10 lines
drivers/net/usb/hso.c new file +10
-0+#define HSO_INFO_MASK 0xFF000000 +#define HSO_INFO_CRC_BUG 0x01000000 + +/* Sysfs attribute */ +static ssize_t hso_sysfs_show_porttype (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct hso_device *hso_dev = dev->driver_data; +char *port_name;
const char *port_name;
Quoted 7 lines
...
drivers/net/usb/hso.c new file +6
-0+case HSO_PORT_DIAG2 : + port_name ="Diagnostic2" ; +break ; +case HSO_PORT_MODEM : + port_name ="Modem" ; +break ;
drivers/net/usb/hso.c line 453
Quoted 10 lines
drivers/net/usb/hso.c new file +10
-0+case HSO_PORT_NETWORK : + port_name ="Network" ; +break ; +default : + port_name ="Unknown" ; +break ; + } + +return sprintf (buf,"%s\n" , port_name); +}
You could refactor this using a static array mapping from port to string. Same for the following three functions (hso_port_to_mux and hso_mux_to_port).
static const char *const names[] = {
[HSO_PORT_xxx] = "xxx";
};Quoted 1 line
+static struct
ethtool_opsops = {
const?
Quoted 6 lines
drivers/net/usb/hso.c new file +6
-0+ .get_drvinfo = hso_get_drvinfo, + .get_link = ethtool_op_get_link +}; + +static void hso_serial_set_termios (struct tty_struct *tty,struct ktermios *old) +{
[...]
drivers/net/usb/hso.c line 668
Quoted 3 lines
drivers/net/usb/hso.c new file +3
-0+/* done */ +return ; +}
I would have never thought! (Also elsewhere.)
Hi Paulius,
Quoted 73 lines
Quoted 73 lines
drivers/net/usb/hso.c new file +73
-0+/* called once for each interface upon device insertion */ +static int hso_probe (struct usb_interface *interface, +const struct usb_device_id *id) +{ +int mux, i, if_num, port_spec; +unsigned char port_mask; +struct hso_device *hso_dev =NULL ; +struct hso_shared_int *shared_int; +struct hso_device *tmp_dev =NULL ; + + if_num = interface->altsetting->desc.bInterfaceNumber; + +/* Get the interface/port specification from either driver_info or from +* the device itself */ +if (id->driver_info) + port_spec = ((u32 *)(id->driver_info))[if_num]; +else + port_spec =hso_get_config_data (interface); + +if (interface->cur_altsetting->desc.bInterfaceClass !=0xFF ) { +dev_err (&interface->dev,"Not our interface\n" ); +return -ENODEV ; + } +/* Check if we need to switch to alt interfaces prior to port +* configuration */ +if (interface->num_altsetting >1 ) +usb_set_interface (interface_to_usbdev (interface), if_num,1 ); + interface->needs_remote_wakeup =1 ; + +/* Allocate new hso device(s) */ +switch (port_spec &HSO_INTF_MASK ) { +case HSO_INTF_MUX : +if ((port_spec &HSO_PORT_MASK ) ==HSO_PORT_NETWORK ) { +/* Create the network device */ +if (!disable_net) { + hso_dev =hso_create_net_device (interface); +if (!hso_dev) + goto exit; + tmp_dev = hso_dev; + } + } + +if (hso_get_mux_ports (interface, &port_mask)) +/* TODO: de-allocate everything */ + goto exit; + + shared_int =hso_create_shared_int (interface); +if (!shared_int) + goto exit; + +for (i =1 , mux =0 ; i <0x100 ; i = i <<1 , mux++) { +if (port_mask & i) { + hso_dev =hso_create_mux_serial_device ( + interface, i, shared_int); +if (!hso_dev) + goto exit; + } + } + +if (tmp_dev) + hso_dev = tmp_dev; +break ; + +case HSO_INTF_BULK : +/* It's a regular bulk interface */ +if (((port_spec &HSO_PORT_MASK ) ==HSO_PORT_NETWORK ) + && !disable_net) + hso_dev =hso_create_net_device (interface); +else + hso_dev = +hso_create_bulk_serial_device (interface, port_spec); +if (!hso_dev) + goto exit;
Quoted 8 lines
drivers/net/usb/hso.c line 2483
Quoted 6 lines
drivers/net/usb/hso.c new file +6
-0+break ; +default : + goto exit; + } + +usb_driver_claim_interface (&hso_driver, interface, hso_dev);Is
usb_driver_claim_interfacereally needed?
no it is not. That can be removed.
Regards
Marcel
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Garzik
AppliedQuoted 23 lines · Greg Kroah-Hartman
This driver is for a number of different Option devices. Originally written by Option and Andrew Bird, but cleaned up massivly for acceptance into mainline by me and others.
Many thanks to the following for their help in cleaning up the driver by providing feedback and patches to it:
- Paulius Zaleckas <[email protected]>
- Oliver Neukum <[email protected]>
- Alan Cox <[email protected]>
- Javier Marcet <[email protected]>Cc Andrew Bird <[email protected]>Cc Javier Marcet <[email protected]>Cc Filip Aben <[email protected]>Cc Paulius Zaleckas <[email protected]>Cc Oliver Neukum <[email protected]>Acked-by Alan Cox <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Quoted 8 lines
Jeff, this is an updated version from what I previously sent. I have no objection for this to go into 2.6.26.
drivers/net/Makefile | 1 drivers/net/usb/Kconfig | 10 drivers/net/usb/Makefile | 1 drivers/net/usb/hso.c | 2836 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2848 insertions(+)
applied