Commit 3132be9a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'usb-3.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are some tiny USB fixes for 3.11-rc4

  Nothing major, some gadget fixes, some new device ids, a new tiny
  driver for the ANT+ USB device, and a number of fixes for the mos7840
  driver that were much needed"

* tag 'usb-3.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  USB: serial: ftdi_sio: add more RT Systems ftdi devices
  usb: chipidea: fix the build error with randconfig
  usb: chipidea: cast PORTSC_PTS and DEVLC_PTS macros
  usb: gadget: udc-core: fix the typo of udc state attribute
  usb: gadget: f_phonet: remove unused preprocessor conditional
  usb: gadget: multi: fix error return code in cdc_do_config()
  USB: mos7840: fix pointer casts
  USB: mos7840: fix race in led handling
  USB: mos7840: fix device-type detection
  USB: mos7840: fix race in register handling
  USB: serial: add driver for Suunto ANT+ USB device
  usb: gadget: free opts struct on error recovery
  usb: gadget: ether: put_usb_function on unbind
  usb: musb: fix resource passed from glue layer to musb
parents a93f66dc fed1f1ed
...@@ -12,7 +12,7 @@ if USB_CHIPIDEA ...@@ -12,7 +12,7 @@ if USB_CHIPIDEA
config USB_CHIPIDEA_UDC config USB_CHIPIDEA_UDC
bool "ChipIdea device controller" bool "ChipIdea device controller"
depends on USB_GADGET=y || USB_CHIPIDEA=m depends on USB_GADGET=y || (USB_CHIPIDEA=m && USB_GADGET=m)
help help
Say Y here to enable device controller functionality of the Say Y here to enable device controller functionality of the
ChipIdea driver. ChipIdea driver.
...@@ -20,7 +20,7 @@ config USB_CHIPIDEA_UDC ...@@ -20,7 +20,7 @@ config USB_CHIPIDEA_UDC
config USB_CHIPIDEA_HOST config USB_CHIPIDEA_HOST
bool "ChipIdea host controller" bool "ChipIdea host controller"
depends on USB=y depends on USB=y
depends on USB_EHCI_HCD=y || USB_CHIPIDEA=m depends on USB_EHCI_HCD=y || (USB_CHIPIDEA=m && USB_EHCI_HCD=m)
select USB_EHCI_ROOT_HUB_TT select USB_EHCI_ROOT_HUB_TT
help help
Say Y here to enable host controller functionality of the Say Y here to enable host controller functionality of the
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#define PORTSC_PTC (0x0FUL << 16) #define PORTSC_PTC (0x0FUL << 16)
/* PTS and PTW for non lpm version only */ /* PTS and PTW for non lpm version only */
#define PORTSC_PTS(d) \ #define PORTSC_PTS(d) \
((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0)) (u32)((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
#define PORTSC_PTW BIT(28) #define PORTSC_PTW BIT(28)
#define PORTSC_STS BIT(29) #define PORTSC_STS BIT(29)
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#define DEVLC_PSPD_HS (0x02UL << 25) #define DEVLC_PSPD_HS (0x02UL << 25)
#define DEVLC_PTW BIT(27) #define DEVLC_PTW BIT(27)
#define DEVLC_STS BIT(28) #define DEVLC_STS BIT(28)
#define DEVLC_PTS(d) (((d) & 0x7) << 29) #define DEVLC_PTS(d) (u32)(((d) & 0x7) << 29)
/* Encoding for DEVLC_PTS and PORTSC_PTS */ /* Encoding for DEVLC_PTS and PORTSC_PTS */
#define PTS_UTMI 0 #define PTS_UTMI 0
......
...@@ -449,14 +449,20 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -449,14 +449,20 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
static int __exit eth_unbind(struct usb_composite_dev *cdev) static int __exit eth_unbind(struct usb_composite_dev *cdev)
{ {
if (has_rndis()) if (has_rndis()) {
usb_put_function(f_rndis);
usb_put_function_instance(fi_rndis); usb_put_function_instance(fi_rndis);
if (use_eem) }
if (use_eem) {
usb_put_function(f_eem);
usb_put_function_instance(fi_eem); usb_put_function_instance(fi_eem);
else if (can_support_ecm(cdev->gadget)) } else if (can_support_ecm(cdev->gadget)) {
usb_put_function(f_ecm);
usb_put_function_instance(fi_ecm); usb_put_function_instance(fi_ecm);
else } else {
usb_put_function(f_geth);
usb_put_function_instance(fi_geth); usb_put_function_instance(fi_geth);
}
return 0; return 0;
} }
......
...@@ -488,7 +488,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -488,7 +488,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
struct usb_ep *ep; struct usb_ep *ep;
int status, i; int status, i;
#ifndef USBF_PHONET_INCLUDED
struct f_phonet_opts *phonet_opts; struct f_phonet_opts *phonet_opts;
phonet_opts = container_of(f->fi, struct f_phonet_opts, func_inst); phonet_opts = container_of(f->fi, struct f_phonet_opts, func_inst);
...@@ -507,7 +506,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -507,7 +506,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
return status; return status;
phonet_opts->bound = true; phonet_opts->bound = true;
} }
#endif
/* Reserve interface IDs */ /* Reserve interface IDs */
status = usb_interface_id(c, f); status = usb_interface_id(c, f);
......
...@@ -160,10 +160,8 @@ static __init int rndis_do_config(struct usb_configuration *c) ...@@ -160,10 +160,8 @@ static __init int rndis_do_config(struct usb_configuration *c)
return ret; return ret;
f_acm_rndis = usb_get_function(fi_acm); f_acm_rndis = usb_get_function(fi_acm);
if (IS_ERR(f_acm_rndis)) { if (IS_ERR(f_acm_rndis))
ret = PTR_ERR(f_acm_rndis); return PTR_ERR(f_acm_rndis);
goto err_func_acm;
}
ret = usb_add_function(c, f_acm_rndis); ret = usb_add_function(c, f_acm_rndis);
if (ret) if (ret)
...@@ -178,7 +176,6 @@ static __init int rndis_do_config(struct usb_configuration *c) ...@@ -178,7 +176,6 @@ static __init int rndis_do_config(struct usb_configuration *c)
usb_remove_function(c, f_acm_rndis); usb_remove_function(c, f_acm_rndis);
err_conf: err_conf:
usb_put_function(f_acm_rndis); usb_put_function(f_acm_rndis);
err_func_acm:
return ret; return ret;
} }
...@@ -226,7 +223,7 @@ static __init int cdc_do_config(struct usb_configuration *c) ...@@ -226,7 +223,7 @@ static __init int cdc_do_config(struct usb_configuration *c)
/* implicit port_num is zero */ /* implicit port_num is zero */
f_acm_multi = usb_get_function(fi_acm); f_acm_multi = usb_get_function(fi_acm);
if (IS_ERR(f_acm_multi)) if (IS_ERR(f_acm_multi))
goto err_func_acm; return PTR_ERR(f_acm_multi);
ret = usb_add_function(c, f_acm_multi); ret = usb_add_function(c, f_acm_multi);
if (ret) if (ret)
...@@ -241,7 +238,6 @@ static __init int cdc_do_config(struct usb_configuration *c) ...@@ -241,7 +238,6 @@ static __init int cdc_do_config(struct usb_configuration *c)
usb_remove_function(c, f_acm_multi); usb_remove_function(c, f_acm_multi);
err_conf: err_conf:
usb_put_function(f_acm_multi); usb_put_function(f_acm_multi);
err_func_acm:
return ret; return ret;
} }
......
...@@ -109,7 +109,7 @@ void usb_gadget_set_state(struct usb_gadget *gadget, ...@@ -109,7 +109,7 @@ void usb_gadget_set_state(struct usb_gadget *gadget,
enum usb_device_state state) enum usb_device_state state)
{ {
gadget->state = state; gadget->state = state;
sysfs_notify(&gadget->dev.kobj, NULL, "status"); sysfs_notify(&gadget->dev.kobj, NULL, "state");
} }
EXPORT_SYMBOL_GPL(usb_gadget_set_state); EXPORT_SYMBOL_GPL(usb_gadget_set_state);
......
...@@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); ...@@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32);
static int omap2430_probe(struct platform_device *pdev) static int omap2430_probe(struct platform_device *pdev)
{ {
struct resource musb_resources[2]; struct resource musb_resources[3];
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct omap_musb_board_data *data; struct omap_musb_board_data *data;
struct platform_device *musb; struct platform_device *musb;
...@@ -581,6 +581,11 @@ static int omap2430_probe(struct platform_device *pdev) ...@@ -581,6 +581,11 @@ static int omap2430_probe(struct platform_device *pdev)
musb_resources[1].end = pdev->resource[1].end; musb_resources[1].end = pdev->resource[1].end;
musb_resources[1].flags = pdev->resource[1].flags; musb_resources[1].flags = pdev->resource[1].flags;
musb_resources[2].name = pdev->resource[2].name;
musb_resources[2].start = pdev->resource[2].start;
musb_resources[2].end = pdev->resource[2].end;
musb_resources[2].flags = pdev->resource[2].flags;
ret = platform_device_add_resources(musb, musb_resources, ret = platform_device_add_resources(musb, musb_resources,
ARRAY_SIZE(musb_resources)); ARRAY_SIZE(musb_resources));
if (ret) { if (ret) {
......
...@@ -1156,7 +1156,7 @@ static u64 tusb_dmamask = DMA_BIT_MASK(32); ...@@ -1156,7 +1156,7 @@ static u64 tusb_dmamask = DMA_BIT_MASK(32);
static int tusb_probe(struct platform_device *pdev) static int tusb_probe(struct platform_device *pdev)
{ {
struct resource musb_resources[2]; struct resource musb_resources[3];
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct platform_device *musb; struct platform_device *musb;
struct tusb6010_glue *glue; struct tusb6010_glue *glue;
...@@ -1199,6 +1199,11 @@ static int tusb_probe(struct platform_device *pdev) ...@@ -1199,6 +1199,11 @@ static int tusb_probe(struct platform_device *pdev)
musb_resources[1].end = pdev->resource[1].end; musb_resources[1].end = pdev->resource[1].end;
musb_resources[1].flags = pdev->resource[1].flags; musb_resources[1].flags = pdev->resource[1].flags;
musb_resources[2].name = pdev->resource[2].name;
musb_resources[2].start = pdev->resource[2].start;
musb_resources[2].end = pdev->resource[2].end;
musb_resources[2].flags = pdev->resource[2].flags;
ret = platform_device_add_resources(musb, musb_resources, ret = platform_device_add_resources(musb, musb_resources,
ARRAY_SIZE(musb_resources)); ARRAY_SIZE(musb_resources));
if (ret) { if (ret) {
......
...@@ -719,6 +719,13 @@ config USB_SERIAL_FLASHLOADER ...@@ -719,6 +719,13 @@ config USB_SERIAL_FLASHLOADER
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called flashloader. module will be called flashloader.
config USB_SERIAL_SUUNTO
tristate "USB Suunto ANT+ driver"
help
Say Y here if you want to use the Suunto ANT+ USB device.
To compile this driver as a module, choose M here: the
module will be called suunto.
config USB_SERIAL_DEBUG config USB_SERIAL_DEBUG
tristate "USB Debugging Device" tristate "USB Debugging Device"
......
...@@ -54,6 +54,7 @@ obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o ...@@ -54,6 +54,7 @@ obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
obj-$(CONFIG_USB_SERIAL_SSU100) += ssu100.o obj-$(CONFIG_USB_SERIAL_SSU100) += ssu100.o
obj-$(CONFIG_USB_SERIAL_SUUNTO) += suunto.o
obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o
obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o
obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
......
...@@ -735,9 +735,34 @@ static struct usb_device_id id_table_combined [] = { ...@@ -735,9 +735,34 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID), { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
.driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
{ USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) }, { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S03_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_CT29B_PID) }, { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_59_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_RTS01_PID) }, { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57A_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29A_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29F_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S01_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29C_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_81B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_82B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5D_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K4Y_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5G_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S05_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_60_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_61_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63B_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_64_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_65_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92D_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_W5R_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_A5R_PID) },
{ USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_PW1_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
{ USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
......
...@@ -816,10 +816,34 @@ ...@@ -816,10 +816,34 @@
* RT Systems programming cables for various ham radios * RT Systems programming cables for various ham radios
*/ */
#define RTSYSTEMS_VID 0x2100 /* Vendor ID */ #define RTSYSTEMS_VID 0x2100 /* Vendor ID */
#define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */ #define RTSYSTEMS_USB_S03_PID 0x9001 /* RTS-03 USB to Serial Adapter */
#define RTSYSTEMS_CT29B_PID 0x9e54 /* CT29B Radio Cable */ #define RTSYSTEMS_USB_59_PID 0x9e50 /* USB-59 USB to 8 pin plug */
#define RTSYSTEMS_RTS01_PID 0x9e57 /* USB-RTS01 Radio Cable */ #define RTSYSTEMS_USB_57A_PID 0x9e51 /* USB-57A USB to 4pin 3.5mm plug */
#define RTSYSTEMS_USB_57B_PID 0x9e52 /* USB-57B USB to extended 4pin 3.5mm plug */
#define RTSYSTEMS_USB_29A_PID 0x9e53 /* USB-29A USB to 3.5mm stereo plug */
#define RTSYSTEMS_USB_29B_PID 0x9e54 /* USB-29B USB to 6 pin mini din */
#define RTSYSTEMS_USB_29F_PID 0x9e55 /* USB-29F USB to 6 pin modular plug */
#define RTSYSTEMS_USB_62B_PID 0x9e56 /* USB-62B USB to 8 pin mini din plug*/
#define RTSYSTEMS_USB_S01_PID 0x9e57 /* USB-RTS01 USB to 3.5 mm stereo plug*/
#define RTSYSTEMS_USB_63_PID 0x9e58 /* USB-63 USB to 9 pin female*/
#define RTSYSTEMS_USB_29C_PID 0x9e59 /* USB-29C USB to 4 pin modular plug*/
#define RTSYSTEMS_USB_81B_PID 0x9e5A /* USB-81 USB to 8 pin mini din plug*/
#define RTSYSTEMS_USB_82B_PID 0x9e5B /* USB-82 USB to 2.5 mm stereo plug*/
#define RTSYSTEMS_USB_K5D_PID 0x9e5C /* USB-K5D USB to 8 pin modular plug*/
#define RTSYSTEMS_USB_K4Y_PID 0x9e5D /* USB-K4Y USB to 2.5/3.5 mm plugs*/
#define RTSYSTEMS_USB_K5G_PID 0x9e5E /* USB-K5G USB to 8 pin modular plug*/
#define RTSYSTEMS_USB_S05_PID 0x9e5F /* USB-RTS05 USB to 2.5 mm stereo plug*/
#define RTSYSTEMS_USB_60_PID 0x9e60 /* USB-60 USB to 6 pin din*/
#define RTSYSTEMS_USB_61_PID 0x9e61 /* USB-61 USB to 6 pin mini din*/
#define RTSYSTEMS_USB_62_PID 0x9e62 /* USB-62 USB to 8 pin mini din*/
#define RTSYSTEMS_USB_63B_PID 0x9e63 /* USB-63 USB to 9 pin female*/
#define RTSYSTEMS_USB_64_PID 0x9e64 /* USB-64 USB to 9 pin male*/
#define RTSYSTEMS_USB_65_PID 0x9e65 /* USB-65 USB to 9 pin female null modem*/
#define RTSYSTEMS_USB_92_PID 0x9e66 /* USB-92 USB to 12 pin plug*/
#define RTSYSTEMS_USB_92D_PID 0x9e67 /* USB-92D USB to 12 pin plug data*/
#define RTSYSTEMS_USB_W5R_PID 0x9e68 /* USB-W5R USB to 8 pin modular plug*/
#define RTSYSTEMS_USB_A5R_PID 0x9e69 /* USB-A5R USB to 8 pin modular plug*/
#define RTSYSTEMS_USB_PW1_PID 0x9e6A /* USB-PW1 USB to 8 pin modular plug*/
/* /*
* Physik Instrumente * Physik Instrumente
......
...@@ -183,7 +183,10 @@ ...@@ -183,7 +183,10 @@
#define LED_ON_MS 500 #define LED_ON_MS 500
#define LED_OFF_MS 500 #define LED_OFF_MS 500
static int device_type; enum mos7840_flag {
MOS7840_FLAG_CTRL_BUSY,
MOS7840_FLAG_LED_BUSY,
};
static const struct usb_device_id id_table[] = { static const struct usb_device_id id_table[] = {
{USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
...@@ -238,9 +241,12 @@ struct moschip_port { ...@@ -238,9 +241,12 @@ struct moschip_port {
/* For device(s) with LED indicator */ /* For device(s) with LED indicator */
bool has_led; bool has_led;
bool led_flag;
struct timer_list led_timer1; /* Timer for LED on */ struct timer_list led_timer1; /* Timer for LED on */
struct timer_list led_timer2; /* Timer for LED off */ struct timer_list led_timer2; /* Timer for LED off */
struct urb *led_urb;
struct usb_ctrlrequest *led_dr;
unsigned long flags;
}; };
/* /*
...@@ -460,10 +466,10 @@ static void mos7840_control_callback(struct urb *urb) ...@@ -460,10 +466,10 @@ static void mos7840_control_callback(struct urb *urb)
case -ESHUTDOWN: case -ESHUTDOWN:
/* this urb is terminated, clean up */ /* this urb is terminated, clean up */
dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
return; goto out;
default: default:
dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
return; goto out;
} }
dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length); dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
...@@ -476,6 +482,8 @@ static void mos7840_control_callback(struct urb *urb) ...@@ -476,6 +482,8 @@ static void mos7840_control_callback(struct urb *urb)
mos7840_handle_new_msr(mos7840_port, regval); mos7840_handle_new_msr(mos7840_port, regval);
else if (mos7840_port->MsrLsr == 1) else if (mos7840_port->MsrLsr == 1)
mos7840_handle_new_lsr(mos7840_port, regval); mos7840_handle_new_lsr(mos7840_port, regval);
out:
clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mos7840_port->flags);
} }
static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
...@@ -486,6 +494,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, ...@@ -486,6 +494,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
unsigned char *buffer = mcs->ctrl_buf; unsigned char *buffer = mcs->ctrl_buf;
int ret; int ret;
if (test_and_set_bit_lock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags))
return -EBUSY;
dr->bRequestType = MCS_RD_RTYPE; dr->bRequestType = MCS_RD_RTYPE;
dr->bRequest = MCS_RDREQ; dr->bRequest = MCS_RDREQ;
dr->wValue = cpu_to_le16(Wval); /* 0 */ dr->wValue = cpu_to_le16(Wval); /* 0 */
...@@ -497,6 +508,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, ...@@ -497,6 +508,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
mos7840_control_callback, mcs); mos7840_control_callback, mcs);
mcs->control_urb->transfer_buffer_length = 2; mcs->control_urb->transfer_buffer_length = 2;
ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC); ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC);
if (ret)
clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags);
return ret; return ret;
} }
...@@ -523,7 +537,7 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval, ...@@ -523,7 +537,7 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval,
__u16 reg) __u16 reg)
{ {
struct usb_device *dev = mcs->port->serial->dev; struct usb_device *dev = mcs->port->serial->dev;
struct usb_ctrlrequest *dr = mcs->dr; struct usb_ctrlrequest *dr = mcs->led_dr;
dr->bRequestType = MCS_WR_RTYPE; dr->bRequestType = MCS_WR_RTYPE;
dr->bRequest = MCS_WRREQ; dr->bRequest = MCS_WRREQ;
...@@ -531,10 +545,10 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval, ...@@ -531,10 +545,10 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval,
dr->wIndex = cpu_to_le16(reg); dr->wIndex = cpu_to_le16(reg);
dr->wLength = cpu_to_le16(0); dr->wLength = cpu_to_le16(0);
usb_fill_control_urb(mcs->control_urb, dev, usb_sndctrlpipe(dev, 0), usb_fill_control_urb(mcs->led_urb, dev, usb_sndctrlpipe(dev, 0),
(unsigned char *)dr, NULL, 0, mos7840_set_led_callback, NULL); (unsigned char *)dr, NULL, 0, mos7840_set_led_callback, NULL);
usb_submit_urb(mcs->control_urb, GFP_ATOMIC); usb_submit_urb(mcs->led_urb, GFP_ATOMIC);
} }
static void mos7840_set_led_sync(struct usb_serial_port *port, __u16 reg, static void mos7840_set_led_sync(struct usb_serial_port *port, __u16 reg,
...@@ -560,7 +574,19 @@ static void mos7840_led_flag_off(unsigned long arg) ...@@ -560,7 +574,19 @@ static void mos7840_led_flag_off(unsigned long arg)
{ {
struct moschip_port *mcs = (struct moschip_port *) arg; struct moschip_port *mcs = (struct moschip_port *) arg;
mcs->led_flag = false; clear_bit_unlock(MOS7840_FLAG_LED_BUSY, &mcs->flags);
}
static void mos7840_led_activity(struct usb_serial_port *port)
{
struct moschip_port *mos7840_port = usb_get_serial_port_data(port);
if (test_and_set_bit_lock(MOS7840_FLAG_LED_BUSY, &mos7840_port->flags))
return;
mos7840_set_led_async(mos7840_port, 0x0301, MODEM_CONTROL_REGISTER);
mod_timer(&mos7840_port->led_timer1,
jiffies + msecs_to_jiffies(LED_ON_MS));
} }
/***************************************************************************** /*****************************************************************************
...@@ -758,14 +784,8 @@ static void mos7840_bulk_in_callback(struct urb *urb) ...@@ -758,14 +784,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
return; return;
} }
/* Turn on LED */ if (mos7840_port->has_led)
if (mos7840_port->has_led && !mos7840_port->led_flag) { mos7840_led_activity(port);
mos7840_port->led_flag = true;
mos7840_set_led_async(mos7840_port, 0x0301,
MODEM_CONTROL_REGISTER);
mod_timer(&mos7840_port->led_timer1,
jiffies + msecs_to_jiffies(LED_ON_MS));
}
mos7840_port->read_urb_busy = true; mos7840_port->read_urb_busy = true;
retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
...@@ -816,18 +836,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) ...@@ -816,18 +836,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
/************************************************************************/ /************************************************************************/
/* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */ /* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */
/************************************************************************/ /************************************************************************/
#ifdef MCSSerialProbe
static int mos7840_serial_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{
/*need to implement the mode_reg reading and updating\
structures usb_serial_ device_type\
(i.e num_ports, num_bulkin,bulkout etc) */
/* Also we can update the changes attach */
return 1;
}
#endif
/***************************************************************************** /*****************************************************************************
* mos7840_open * mos7840_open
...@@ -1454,13 +1462,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -1454,13 +1462,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
data1 = urb->transfer_buffer; data1 = urb->transfer_buffer;
dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress); dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress);
/* Turn on LED */ if (mos7840_port->has_led)
if (mos7840_port->has_led && !mos7840_port->led_flag) { mos7840_led_activity(port);
mos7840_port->led_flag = true;
mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0301);
mod_timer(&mos7840_port->led_timer1,
jiffies + msecs_to_jiffies(LED_ON_MS));
}
/* send it down the pipe */ /* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC); status = usb_submit_urb(urb, GFP_ATOMIC);
...@@ -2187,38 +2190,48 @@ static int mos7810_check(struct usb_serial *serial) ...@@ -2187,38 +2190,48 @@ static int mos7810_check(struct usb_serial *serial)
return 0; return 0;
} }
static int mos7840_calc_num_ports(struct usb_serial *serial) static int mos7840_probe(struct usb_serial *serial,
const struct usb_device_id *id)
{ {
__u16 data = 0x00; u16 product = serial->dev->descriptor.idProduct;
u8 *buf; u8 *buf;
int mos7840_num_ports; int device_type;
if (product == MOSCHIP_DEVICE_ID_7810 ||
product == MOSCHIP_DEVICE_ID_7820) {
device_type = product;
goto out;
}
buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL); buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
if (buf) { if (!buf)
return -ENOMEM;
usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, buf, MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, buf,
VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT);
data = *buf;
kfree(buf);
}
if (serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7810 ||
serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7820) {
device_type = serial->dev->descriptor.idProduct;
} else {
/* For a MCS7840 device GPIO0 must be set to 1 */ /* For a MCS7840 device GPIO0 must be set to 1 */
if ((data & 0x01) == 1) if (buf[0] & 0x01)
device_type = MOSCHIP_DEVICE_ID_7840; device_type = MOSCHIP_DEVICE_ID_7840;
else if (mos7810_check(serial)) else if (mos7810_check(serial))
device_type = MOSCHIP_DEVICE_ID_7810; device_type = MOSCHIP_DEVICE_ID_7810;
else else
device_type = MOSCHIP_DEVICE_ID_7820; device_type = MOSCHIP_DEVICE_ID_7820;
}
kfree(buf);
out:
usb_set_serial_data(serial, (void *)(unsigned long)device_type);
return 0;
}
static int mos7840_calc_num_ports(struct usb_serial *serial)
{
int device_type = (unsigned long)usb_get_serial_data(serial);
int mos7840_num_ports;
mos7840_num_ports = (device_type >> 4) & 0x000F; mos7840_num_ports = (device_type >> 4) & 0x000F;
serial->num_bulk_in = mos7840_num_ports;
serial->num_bulk_out = mos7840_num_ports;
serial->num_ports = mos7840_num_ports;
return mos7840_num_ports; return mos7840_num_ports;
} }
...@@ -2226,6 +2239,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) ...@@ -2226,6 +2239,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
static int mos7840_port_probe(struct usb_serial_port *port) static int mos7840_port_probe(struct usb_serial_port *port)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int device_type = (unsigned long)usb_get_serial_data(serial);
struct moschip_port *mos7840_port; struct moschip_port *mos7840_port;
int status; int status;
int pnum; int pnum;
...@@ -2401,6 +2415,14 @@ static int mos7840_port_probe(struct usb_serial_port *port) ...@@ -2401,6 +2415,14 @@ static int mos7840_port_probe(struct usb_serial_port *port)
if (device_type == MOSCHIP_DEVICE_ID_7810) { if (device_type == MOSCHIP_DEVICE_ID_7810) {
mos7840_port->has_led = true; mos7840_port->has_led = true;
mos7840_port->led_urb = usb_alloc_urb(0, GFP_KERNEL);
mos7840_port->led_dr = kmalloc(sizeof(*mos7840_port->led_dr),
GFP_KERNEL);
if (!mos7840_port->led_urb || !mos7840_port->led_dr) {
status = -ENOMEM;
goto error;
}
init_timer(&mos7840_port->led_timer1); init_timer(&mos7840_port->led_timer1);
mos7840_port->led_timer1.function = mos7840_led_off; mos7840_port->led_timer1.function = mos7840_led_off;
mos7840_port->led_timer1.expires = mos7840_port->led_timer1.expires =
...@@ -2413,8 +2435,6 @@ static int mos7840_port_probe(struct usb_serial_port *port) ...@@ -2413,8 +2435,6 @@ static int mos7840_port_probe(struct usb_serial_port *port)
jiffies + msecs_to_jiffies(LED_OFF_MS); jiffies + msecs_to_jiffies(LED_OFF_MS);
mos7840_port->led_timer2.data = (unsigned long)mos7840_port; mos7840_port->led_timer2.data = (unsigned long)mos7840_port;
mos7840_port->led_flag = false;
/* Turn off LED */ /* Turn off LED */
mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300); mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300);
} }
...@@ -2436,6 +2456,8 @@ static int mos7840_port_probe(struct usb_serial_port *port) ...@@ -2436,6 +2456,8 @@ static int mos7840_port_probe(struct usb_serial_port *port)
} }
return 0; return 0;
error: error:
kfree(mos7840_port->led_dr);
usb_free_urb(mos7840_port->led_urb);
kfree(mos7840_port->dr); kfree(mos7840_port->dr);
kfree(mos7840_port->ctrl_buf); kfree(mos7840_port->ctrl_buf);
usb_free_urb(mos7840_port->control_urb); usb_free_urb(mos7840_port->control_urb);
...@@ -2456,6 +2478,10 @@ static int mos7840_port_remove(struct usb_serial_port *port) ...@@ -2456,6 +2478,10 @@ static int mos7840_port_remove(struct usb_serial_port *port)
del_timer_sync(&mos7840_port->led_timer1); del_timer_sync(&mos7840_port->led_timer1);
del_timer_sync(&mos7840_port->led_timer2); del_timer_sync(&mos7840_port->led_timer2);
usb_kill_urb(mos7840_port->led_urb);
usb_free_urb(mos7840_port->led_urb);
kfree(mos7840_port->led_dr);
} }
usb_kill_urb(mos7840_port->control_urb); usb_kill_urb(mos7840_port->control_urb);
usb_free_urb(mos7840_port->control_urb); usb_free_urb(mos7840_port->control_urb);
...@@ -2482,9 +2508,7 @@ static struct usb_serial_driver moschip7840_4port_device = { ...@@ -2482,9 +2508,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
.throttle = mos7840_throttle, .throttle = mos7840_throttle,
.unthrottle = mos7840_unthrottle, .unthrottle = mos7840_unthrottle,
.calc_num_ports = mos7840_calc_num_ports, .calc_num_ports = mos7840_calc_num_ports,
#ifdef MCSSerialProbe .probe = mos7840_probe,
.probe = mos7840_serial_probe,
#endif
.ioctl = mos7840_ioctl, .ioctl = mos7840_ioctl,
.set_termios = mos7840_set_termios, .set_termios = mos7840_set_termios,
.break_ctl = mos7840_break, .break_ctl = mos7840_break,
......
/*
* Suunto ANT+ USB Driver
*
* Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Copyright (C) 2013 Linux Foundation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation only.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/uaccess.h>
static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x0fcf, 0x1008) },
{ },
};
MODULE_DEVICE_TABLE(usb, id_table);
static struct usb_serial_driver suunto_device = {
.driver = {
.owner = THIS_MODULE,
.name = KBUILD_MODNAME,
},
.id_table = id_table,
.num_ports = 1,
};
static struct usb_serial_driver * const serial_drivers[] = {
&suunto_device,
NULL,
};
module_usb_serial_driver(serial_drivers, id_table);
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment