diff options
author | Olof Johansson <olof@lixom.net> | 2012-11-05 13:09:12 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-11-05 13:09:12 -0500 |
commit | 6d06721570aa0c38d886e3036796d59983963a27 (patch) | |
tree | d674cf54e26837bee89095c211ffa362c8546f03 /drivers/usb | |
parent | 148a8698763130c96004ef419b5f0d44a93d413c (diff) | |
parent | 54ec52b6dd3b0ba4bc4eb97e7e1b2534705b326c (diff) |
Merge branch 'depends/tty' into next/headers
Merging in Greg's tty tree including a cleanup patch needed by the OMAP serial
header cleanups.
* depends/tty: (305 commits)
tty/serial/8250: Make omap hardware workarounds local to 8250.h
serial/8250/8250_early: Prevent rounding error in uartclk
serial: samsung: use clk_prepare_enable and clk_disable_unprepare
TTY: Report warning when low_latency flag is wrongly used
console: use might_sleep in console_lock
TTY: move tty buffers to tty_port
TTY: add port -> tty link
TTY: tty_buffer, cache pointer to tty->buf
TTY: move TTY_FLUSH* flags to tty_port
TTY: n_tty, propagate n_tty_data
TTY: move ldisc data from tty_struct: locks
TTY: move ldisc data from tty_struct: read_* and echo_* and canon_* stuff
TTY: move ldisc data from tty_struct: bitmaps
TTY: move ldisc data from tty_struct: simple members
TTY: n_tty, add ldisc data to n_tty
TTY: audit, stop accessing tty->icount
TTY: n_tty, remove bogus checks
TTY: n_tty, simplify read_buf+echo_buf allocation
TTY: hci_ldisc, remove invalid check in open
TTY: ldisc, wait for idle ldisc in release
...
Diffstat (limited to 'drivers/usb')
36 files changed, 608 insertions, 554 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 981f2132d128..6e49ec6f3adc 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -817,10 +817,6 @@ static const __u32 acm_tty_speed[] = { | |||
817 | 2500000, 3000000, 3500000, 4000000 | 817 | 2500000, 3000000, 3500000, 4000000 |
818 | }; | 818 | }; |
819 | 819 | ||
820 | static const __u8 acm_tty_size[] = { | ||
821 | 5, 6, 7, 8 | ||
822 | }; | ||
823 | |||
824 | static void acm_tty_set_termios(struct tty_struct *tty, | 820 | static void acm_tty_set_termios(struct tty_struct *tty, |
825 | struct ktermios *termios_old) | 821 | struct ktermios *termios_old) |
826 | { | 822 | { |
@@ -834,7 +830,21 @@ static void acm_tty_set_termios(struct tty_struct *tty, | |||
834 | newline.bParityType = termios->c_cflag & PARENB ? | 830 | newline.bParityType = termios->c_cflag & PARENB ? |
835 | (termios->c_cflag & PARODD ? 1 : 2) + | 831 | (termios->c_cflag & PARODD ? 1 : 2) + |
836 | (termios->c_cflag & CMSPAR ? 2 : 0) : 0; | 832 | (termios->c_cflag & CMSPAR ? 2 : 0) : 0; |
837 | newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4]; | 833 | switch (termios->c_cflag & CSIZE) { |
834 | case CS5: | ||
835 | newline.bDataBits = 5; | ||
836 | break; | ||
837 | case CS6: | ||
838 | newline.bDataBits = 6; | ||
839 | break; | ||
840 | case CS7: | ||
841 | newline.bDataBits = 7; | ||
842 | break; | ||
843 | case CS8: | ||
844 | default: | ||
845 | newline.bDataBits = 8; | ||
846 | break; | ||
847 | } | ||
838 | /* FIXME: Needs to clear unsupported bits in the termios */ | 848 | /* FIXME: Needs to clear unsupported bits in the termios */ |
839 | acm->clocal = ((termios->c_cflag & CLOCAL) != 0); | 849 | acm->clocal = ((termios->c_cflag & CLOCAL) != 0); |
840 | 850 | ||
@@ -1233,7 +1243,7 @@ made_compressed_probe: | |||
1233 | 1243 | ||
1234 | if (usb_endpoint_xfer_int(epwrite)) | 1244 | if (usb_endpoint_xfer_int(epwrite)) |
1235 | usb_fill_int_urb(snd->urb, usb_dev, | 1245 | usb_fill_int_urb(snd->urb, usb_dev, |
1236 | usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), | 1246 | usb_sndintpipe(usb_dev, epwrite->bEndpointAddress), |
1237 | NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval); | 1247 | NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval); |
1238 | else | 1248 | else |
1239 | usb_fill_bulk_urb(snd->urb, usb_dev, | 1249 | usb_fill_bulk_urb(snd->urb, usb_dev, |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index e0356cb859b5..b78fbe222b72 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -1348,6 +1348,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1348 | ret = -EFAULT; | 1348 | ret = -EFAULT; |
1349 | goto error; | 1349 | goto error; |
1350 | } | 1350 | } |
1351 | uurb->buffer += u; | ||
1351 | } | 1352 | } |
1352 | totlen -= u; | 1353 | totlen -= u; |
1353 | } | 1354 | } |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index ddd820d25288..6056db7af410 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -367,6 +367,10 @@ static int usb_probe_interface(struct device *dev) | |||
367 | intf->condition = USB_INTERFACE_UNBOUND; | 367 | intf->condition = USB_INTERFACE_UNBOUND; |
368 | usb_cancel_queued_reset(intf); | 368 | usb_cancel_queued_reset(intf); |
369 | 369 | ||
370 | /* If the LPM disable succeeded, balance the ref counts. */ | ||
371 | if (!lpm_disable_error) | ||
372 | usb_unlocked_enable_lpm(udev); | ||
373 | |||
370 | /* Unbound interfaces are always runtime-PM-disabled and -suspended */ | 374 | /* Unbound interfaces are always runtime-PM-disabled and -suspended */ |
371 | if (driver->supports_autosuspend) | 375 | if (driver->supports_autosuspend) |
372 | pm_runtime_disable(dev); | 376 | pm_runtime_disable(dev); |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 673ee4696262..64854d76f529 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -3241,8 +3241,7 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state) | |||
3241 | (state == USB3_LPM_U2 && | 3241 | (state == USB3_LPM_U2 && |
3242 | (u2_sel > USB3_LPM_MAX_U2_SEL_PEL || | 3242 | (u2_sel > USB3_LPM_MAX_U2_SEL_PEL || |
3243 | u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) { | 3243 | u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) { |
3244 | dev_dbg(&udev->dev, "Device-initiated %s disabled due " | 3244 | dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n", |
3245 | "to long SEL %llu ms or PEL %llu ms\n", | ||
3246 | usb3_lpm_names[state], u1_sel, u1_pel); | 3245 | usb3_lpm_names[state], u1_sel, u1_pel); |
3247 | return -EINVAL; | 3246 | return -EINVAL; |
3248 | } | 3247 | } |
@@ -3320,16 +3319,6 @@ static int usb_set_device_initiated_lpm(struct usb_device *udev, | |||
3320 | 3319 | ||
3321 | if (enable) { | 3320 | if (enable) { |
3322 | /* | 3321 | /* |
3323 | * First, let the device know about the exit latencies | ||
3324 | * associated with the link state we're about to enable. | ||
3325 | */ | ||
3326 | ret = usb_req_set_sel(udev, state); | ||
3327 | if (ret < 0) { | ||
3328 | dev_warn(&udev->dev, "Set SEL for device-initiated " | ||
3329 | "%s failed.\n", usb3_lpm_names[state]); | ||
3330 | return -EBUSY; | ||
3331 | } | ||
3332 | /* | ||
3333 | * Now send the control transfer to enable device-initiated LPM | 3322 | * Now send the control transfer to enable device-initiated LPM |
3334 | * for either U1 or U2. | 3323 | * for either U1 or U2. |
3335 | */ | 3324 | */ |
@@ -3414,7 +3403,28 @@ static int usb_set_lpm_timeout(struct usb_device *udev, | |||
3414 | static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, | 3403 | static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, |
3415 | enum usb3_link_state state) | 3404 | enum usb3_link_state state) |
3416 | { | 3405 | { |
3417 | int timeout; | 3406 | int timeout, ret; |
3407 | __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat; | ||
3408 | __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat; | ||
3409 | |||
3410 | /* If the device says it doesn't have *any* exit latency to come out of | ||
3411 | * U1 or U2, it's probably lying. Assume it doesn't implement that link | ||
3412 | * state. | ||
3413 | */ | ||
3414 | if ((state == USB3_LPM_U1 && u1_mel == 0) || | ||
3415 | (state == USB3_LPM_U2 && u2_mel == 0)) | ||
3416 | return; | ||
3417 | |||
3418 | /* | ||
3419 | * First, let the device know about the exit latencies | ||
3420 | * associated with the link state we're about to enable. | ||
3421 | */ | ||
3422 | ret = usb_req_set_sel(udev, state); | ||
3423 | if (ret < 0) { | ||
3424 | dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", | ||
3425 | usb3_lpm_names[state]); | ||
3426 | return; | ||
3427 | } | ||
3418 | 3428 | ||
3419 | /* We allow the host controller to set the U1/U2 timeout internally | 3429 | /* We allow the host controller to set the U1/U2 timeout internally |
3420 | * first, so that it can change its schedule to account for the | 3430 | * first, so that it can change its schedule to account for the |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index b415c0c859d3..c14ebc975ba4 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -409,6 +409,10 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
409 | { | 409 | { |
410 | dwc3_event_buffers_cleanup(dwc); | 410 | dwc3_event_buffers_cleanup(dwc); |
411 | dwc3_free_event_buffers(dwc); | 411 | dwc3_free_event_buffers(dwc); |
412 | |||
413 | usb_phy_shutdown(dwc->usb2_phy); | ||
414 | usb_phy_shutdown(dwc->usb3_phy); | ||
415 | |||
412 | } | 416 | } |
413 | 417 | ||
414 | #define DWC3_ALIGN_MASK (16 - 1) | 418 | #define DWC3_ALIGN_MASK (16 - 1) |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c9e729a4bf65..7b7deddf6a52 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -1904,7 +1904,7 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum) | |||
1904 | ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); | 1904 | ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); |
1905 | WARN_ON_ONCE(ret); | 1905 | WARN_ON_ONCE(ret); |
1906 | dep->resource_index = 0; | 1906 | dep->resource_index = 0; |
1907 | 1907 | dep->flags &= ~DWC3_EP_BUSY; | |
1908 | udelay(100); | 1908 | udelay(100); |
1909 | } | 1909 | } |
1910 | 1910 | ||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index dfb51a45496c..e0ff51b89529 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -952,6 +952,7 @@ endif | |||
952 | config USB_G_WEBCAM | 952 | config USB_G_WEBCAM |
953 | tristate "USB Webcam Gadget" | 953 | tristate "USB Webcam Gadget" |
954 | depends on VIDEO_DEV | 954 | depends on VIDEO_DEV |
955 | select USB_LIBCOMPOSITE | ||
955 | help | 956 | help |
956 | The Webcam Gadget acts as a composite USB Audio and Video Class | 957 | The Webcam Gadget acts as a composite USB Audio and Video Class |
957 | device. It provides a userspace API to process UVC control requests | 958 | device. It provides a userspace API to process UVC control requests |
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index f696fb9b136d..21a9861dabf0 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c | |||
@@ -2930,10 +2930,10 @@ static void vbus_work(struct work_struct *work) | |||
2930 | 2930 | ||
2931 | /* Get the VBUS status from the transceiver */ | 2931 | /* Get the VBUS status from the transceiver */ |
2932 | value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client, | 2932 | value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client, |
2933 | ISP1301_I2C_OTG_CONTROL_2); | 2933 | ISP1301_I2C_INTERRUPT_SOURCE); |
2934 | 2934 | ||
2935 | /* VBUS on or off? */ | 2935 | /* VBUS on or off? */ |
2936 | if (value & OTG_B_SESS_VLD) | 2936 | if (value & INT_SESS_VLD) |
2937 | udc->vbus = 1; | 2937 | udc->vbus = 1; |
2938 | else | 2938 | else |
2939 | udc->vbus = 0; | 2939 | udc->vbus = 0; |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 9bfde82078ec..0d2f35ca93f1 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -222,7 +222,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
222 | 222 | ||
223 | if (pdata->controller_ver < 0) { | 223 | if (pdata->controller_ver < 0) { |
224 | dev_warn(hcd->self.controller, "Could not get controller version\n"); | 224 | dev_warn(hcd->self.controller, "Could not get controller version\n"); |
225 | return; | 225 | return -ENODEV; |
226 | } | 226 | } |
227 | 227 | ||
228 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); | 228 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); |
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c index 8e7eca62f169..9c2717d66730 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c | |||
@@ -160,7 +160,7 @@ static const struct hc_driver ehci_orion_hc_driver = { | |||
160 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 160 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
161 | }; | 161 | }; |
162 | 162 | ||
163 | static void __init | 163 | static void __devinit |
164 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | 164 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, |
165 | const struct mbus_dram_target_info *dram) | 165 | const struct mbus_dram_target_info *dram) |
166 | { | 166 | { |
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c index 96722bfebc84..d3c9a3e397b9 100644 --- a/drivers/usb/host/ehci-vt8500.c +++ b/drivers/usb/host/ehci-vt8500.c | |||
@@ -85,6 +85,8 @@ static const struct hc_driver vt8500_ehci_hc_driver = { | |||
85 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 85 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32); | ||
89 | |||
88 | static int vt8500_ehci_drv_probe(struct platform_device *pdev) | 90 | static int vt8500_ehci_drv_probe(struct platform_device *pdev) |
89 | { | 91 | { |
90 | struct usb_hcd *hcd; | 92 | struct usb_hcd *hcd; |
@@ -95,6 +97,14 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev) | |||
95 | if (usb_disabled()) | 97 | if (usb_disabled()) |
96 | return -ENODEV; | 98 | return -ENODEV; |
97 | 99 | ||
100 | /* | ||
101 | * Right now device-tree probed devices don't get dma_mask set. | ||
102 | * Since shared usb code relies on it, set it here for now. | ||
103 | * Once we have dma capability bindings this can go away. | ||
104 | */ | ||
105 | if (!pdev->dev.dma_mask) | ||
106 | pdev->dev.dma_mask = &vt8500_ehci_dma_mask; | ||
107 | |||
98 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { | 108 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { |
99 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | 109 | pr_debug("resource[1] is not IORESOURCE_IRQ"); |
100 | return -ENOMEM; | 110 | return -ENOMEM; |
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c index e4780491df4a..68ebf20e1519 100644 --- a/drivers/usb/host/uhci-platform.c +++ b/drivers/usb/host/uhci-platform.c | |||
@@ -60,6 +60,7 @@ static const struct hc_driver uhci_platform_hc_driver = { | |||
60 | .hub_control = uhci_hub_control, | 60 | .hub_control = uhci_hub_control, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32); | ||
63 | 64 | ||
64 | static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) | 65 | static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) |
65 | { | 66 | { |
@@ -71,6 +72,14 @@ static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) | |||
71 | if (usb_disabled()) | 72 | if (usb_disabled()) |
72 | return -ENODEV; | 73 | return -ENODEV; |
73 | 74 | ||
75 | /* | ||
76 | * Right now device-tree probed devices don't get dma_mask set. | ||
77 | * Since shared usb code relies on it, set it here for now. | ||
78 | * Once we have dma capability bindings this can go away. | ||
79 | */ | ||
80 | if (!pdev->dev.dma_mask) | ||
81 | pdev->dev.dma_mask = &platform_uhci_dma_mask; | ||
82 | |||
74 | hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, | 83 | hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, |
75 | pdev->name); | 84 | pdev->name); |
76 | if (!hcd) | 85 | if (!hcd) |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8d7fcbbe6ade..7d462bf20092 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -479,7 +479,8 @@ static bool compliance_mode_recovery_timer_quirk_check(void) | |||
479 | 479 | ||
480 | if (strstr(dmi_product_name, "Z420") || | 480 | if (strstr(dmi_product_name, "Z420") || |
481 | strstr(dmi_product_name, "Z620") || | 481 | strstr(dmi_product_name, "Z620") || |
482 | strstr(dmi_product_name, "Z820")) | 482 | strstr(dmi_product_name, "Z820") || |
483 | strstr(dmi_product_name, "Z1")) | ||
483 | return true; | 484 | return true; |
484 | 485 | ||
485 | return false; | 486 | return false; |
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 457f25e62c51..c964d6af178b 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -305,6 +305,12 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
305 | ret = IRQ_HANDLED; | 305 | ret = IRQ_HANDLED; |
306 | } | 306 | } |
307 | 307 | ||
308 | /* Drop spurious RX and TX if device is disconnected */ | ||
309 | if (musb->int_usb & MUSB_INTR_DISCONNECT) { | ||
310 | musb->int_tx = 0; | ||
311 | musb->int_rx = 0; | ||
312 | } | ||
313 | |||
308 | if (musb->int_tx || musb->int_rx || musb->int_usb) | 314 | if (musb->int_tx || musb->int_rx || musb->int_usb) |
309 | ret |= musb_interrupt(musb); | 315 | ret |= musb_interrupt(musb); |
310 | 316 | ||
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 35c5208f3249..61933a90e5bf 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -273,9 +273,9 @@ static irqreturn_t usbhs_interrupt(int irq, void *data) | |||
273 | usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC); | 273 | usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC); |
274 | usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); | 274 | usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); |
275 | 275 | ||
276 | usbhs_write(priv, BRDYSTS, 0); | 276 | usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); |
277 | usbhs_write(priv, NRDYSTS, 0); | 277 | usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); |
278 | usbhs_write(priv, BEMPSTS, 0); | 278 | usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); |
279 | 279 | ||
280 | /* | 280 | /* |
281 | * call irq callback functions | 281 | * call irq callback functions |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 08786c06dcf1..3d80c7b1fd1b 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -54,7 +54,7 @@ struct usbhs_pipe_info { | |||
54 | * pipe list | 54 | * pipe list |
55 | */ | 55 | */ |
56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ | 56 | #define __usbhs_for_each_pipe(start, pos, info, i) \ |
57 | for (i = start, pos = (info)->pipe; \ | 57 | for (i = start, pos = (info)->pipe + i; \ |
58 | i < (info)->size; \ | 58 | i < (info)->size; \ |
59 | i++, pos = (info)->pipe + i) | 59 | i++, pos = (info)->pipe + i) |
60 | 60 | ||
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index cf2522c397d3..bd50a8a41a0f 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -125,9 +125,6 @@ static inline int calc_divisor(int bps) | |||
125 | 125 | ||
126 | static int ark3116_attach(struct usb_serial *serial) | 126 | static int ark3116_attach(struct usb_serial *serial) |
127 | { | 127 | { |
128 | struct usb_serial_port *port = serial->port[0]; | ||
129 | struct ark3116_private *priv; | ||
130 | |||
131 | /* make sure we have our end-points */ | 128 | /* make sure we have our end-points */ |
132 | if ((serial->num_bulk_in == 0) || | 129 | if ((serial->num_bulk_in == 0) || |
133 | (serial->num_bulk_out == 0) || | 130 | (serial->num_bulk_out == 0) || |
@@ -142,8 +139,15 @@ static int ark3116_attach(struct usb_serial *serial) | |||
142 | return -EINVAL; | 139 | return -EINVAL; |
143 | } | 140 | } |
144 | 141 | ||
145 | priv = kzalloc(sizeof(struct ark3116_private), | 142 | return 0; |
146 | GFP_KERNEL); | 143 | } |
144 | |||
145 | static int ark3116_port_probe(struct usb_serial_port *port) | ||
146 | { | ||
147 | struct usb_serial *serial = port->serial; | ||
148 | struct ark3116_private *priv; | ||
149 | |||
150 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
147 | if (!priv) | 151 | if (!priv) |
148 | return -ENOMEM; | 152 | return -ENOMEM; |
149 | 153 | ||
@@ -198,18 +202,15 @@ static int ark3116_attach(struct usb_serial *serial) | |||
198 | return 0; | 202 | return 0; |
199 | } | 203 | } |
200 | 204 | ||
201 | static void ark3116_release(struct usb_serial *serial) | 205 | static int ark3116_port_remove(struct usb_serial_port *port) |
202 | { | 206 | { |
203 | struct usb_serial_port *port = serial->port[0]; | ||
204 | struct ark3116_private *priv = usb_get_serial_port_data(port); | 207 | struct ark3116_private *priv = usb_get_serial_port_data(port); |
205 | 208 | ||
206 | /* device is closed, so URBs and DMA should be down */ | 209 | /* device is closed, so URBs and DMA should be down */ |
207 | |||
208 | usb_set_serial_port_data(port, NULL); | ||
209 | |||
210 | mutex_destroy(&priv->hw_lock); | 210 | mutex_destroy(&priv->hw_lock); |
211 | |||
212 | kfree(priv); | 211 | kfree(priv); |
212 | |||
213 | return 0; | ||
213 | } | 214 | } |
214 | 215 | ||
215 | static void ark3116_init_termios(struct tty_struct *tty) | 216 | static void ark3116_init_termios(struct tty_struct *tty) |
@@ -723,7 +724,8 @@ static struct usb_serial_driver ark3116_device = { | |||
723 | .id_table = id_table, | 724 | .id_table = id_table, |
724 | .num_ports = 1, | 725 | .num_ports = 1, |
725 | .attach = ark3116_attach, | 726 | .attach = ark3116_attach, |
726 | .release = ark3116_release, | 727 | .port_probe = ark3116_port_probe, |
728 | .port_remove = ark3116_port_remove, | ||
727 | .set_termios = ark3116_set_termios, | 729 | .set_termios = ark3116_set_termios, |
728 | .init_termios = ark3116_init_termios, | 730 | .init_termios = ark3116_init_termios, |
729 | .ioctl = ark3116_ioctl, | 731 | .ioctl = ark3116_ioctl, |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 99449424193f..ea29556f0d72 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -45,8 +45,8 @@ | |||
45 | #define DRIVER_DESC "USB Belkin Serial converter driver" | 45 | #define DRIVER_DESC "USB Belkin Serial converter driver" |
46 | 46 | ||
47 | /* function prototypes for a Belkin USB Serial Adapter F5U103 */ | 47 | /* function prototypes for a Belkin USB Serial Adapter F5U103 */ |
48 | static int belkin_sa_startup(struct usb_serial *serial); | 48 | static int belkin_sa_port_probe(struct usb_serial_port *port); |
49 | static void belkin_sa_release(struct usb_serial *serial); | 49 | static int belkin_sa_port_remove(struct usb_serial_port *port); |
50 | static int belkin_sa_open(struct tty_struct *tty, | 50 | static int belkin_sa_open(struct tty_struct *tty, |
51 | struct usb_serial_port *port); | 51 | struct usb_serial_port *port); |
52 | static void belkin_sa_close(struct usb_serial_port *port); | 52 | static void belkin_sa_close(struct usb_serial_port *port); |
@@ -88,8 +88,8 @@ static struct usb_serial_driver belkin_device = { | |||
88 | .break_ctl = belkin_sa_break_ctl, | 88 | .break_ctl = belkin_sa_break_ctl, |
89 | .tiocmget = belkin_sa_tiocmget, | 89 | .tiocmget = belkin_sa_tiocmget, |
90 | .tiocmset = belkin_sa_tiocmset, | 90 | .tiocmset = belkin_sa_tiocmset, |
91 | .attach = belkin_sa_startup, | 91 | .port_probe = belkin_sa_port_probe, |
92 | .release = belkin_sa_release, | 92 | .port_remove = belkin_sa_port_remove, |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static struct usb_serial_driver * const serial_drivers[] = { | 95 | static struct usb_serial_driver * const serial_drivers[] = { |
@@ -118,17 +118,15 @@ struct belkin_sa_private { | |||
118 | (c), BELKIN_SA_SET_REQUEST_TYPE, \ | 118 | (c), BELKIN_SA_SET_REQUEST_TYPE, \ |
119 | (v), 0, NULL, 0, WDR_TIMEOUT) | 119 | (v), 0, NULL, 0, WDR_TIMEOUT) |
120 | 120 | ||
121 | /* do some startup allocations not currently performed by usb_serial_probe() */ | 121 | static int belkin_sa_port_probe(struct usb_serial_port *port) |
122 | static int belkin_sa_startup(struct usb_serial *serial) | ||
123 | { | 122 | { |
124 | struct usb_device *dev = serial->dev; | 123 | struct usb_device *dev = port->serial->dev; |
125 | struct belkin_sa_private *priv; | 124 | struct belkin_sa_private *priv; |
126 | 125 | ||
127 | /* allocate the private data structure */ | ||
128 | priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); | 126 | priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); |
129 | if (!priv) | 127 | if (!priv) |
130 | return -1; /* error */ | 128 | return -ENOMEM; |
131 | /* set initial values for control structures */ | 129 | |
132 | spin_lock_init(&priv->lock); | 130 | spin_lock_init(&priv->lock); |
133 | priv->control_state = 0; | 131 | priv->control_state = 0; |
134 | priv->last_lsr = 0; | 132 | priv->last_lsr = 0; |
@@ -140,18 +138,19 @@ static int belkin_sa_startup(struct usb_serial *serial) | |||
140 | le16_to_cpu(dev->descriptor.bcdDevice), | 138 | le16_to_cpu(dev->descriptor.bcdDevice), |
141 | priv->bad_flow_control); | 139 | priv->bad_flow_control); |
142 | 140 | ||
143 | init_waitqueue_head(&serial->port[0]->write_wait); | 141 | usb_set_serial_port_data(port, priv); |
144 | usb_set_serial_port_data(serial->port[0], priv); | ||
145 | 142 | ||
146 | return 0; | 143 | return 0; |
147 | } | 144 | } |
148 | 145 | ||
149 | static void belkin_sa_release(struct usb_serial *serial) | 146 | static int belkin_sa_port_remove(struct usb_serial_port *port) |
150 | { | 147 | { |
151 | int i; | 148 | struct belkin_sa_private *priv; |
152 | 149 | ||
153 | for (i = 0; i < serial->num_ports; ++i) | 150 | priv = usb_get_serial_port_data(port); |
154 | kfree(usb_get_serial_port_data(serial->port[i])); | 151 | kfree(priv); |
152 | |||
153 | return 0; | ||
155 | } | 154 | } |
156 | 155 | ||
157 | static int belkin_sa_open(struct tty_struct *tty, | 156 | static int belkin_sa_open(struct tty_struct *tty, |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 28af5acc3360..eb033fc92a15 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -162,7 +162,7 @@ static const struct usb_device_id id_table[] = { | |||
162 | 162 | ||
163 | MODULE_DEVICE_TABLE(usb, id_table); | 163 | MODULE_DEVICE_TABLE(usb, id_table); |
164 | 164 | ||
165 | struct cp210x_port_private { | 165 | struct cp210x_serial_private { |
166 | __u8 bInterfaceNumber; | 166 | __u8 bInterfaceNumber; |
167 | }; | 167 | }; |
168 | 168 | ||
@@ -276,7 +276,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
276 | unsigned int *data, int size) | 276 | unsigned int *data, int size) |
277 | { | 277 | { |
278 | struct usb_serial *serial = port->serial; | 278 | struct usb_serial *serial = port->serial; |
279 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | 279 | struct cp210x_serial_private *spriv = usb_get_serial_data(serial); |
280 | __le32 *buf; | 280 | __le32 *buf; |
281 | int result, i, length; | 281 | int result, i, length; |
282 | 282 | ||
@@ -292,7 +292,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
292 | /* Issue the request, attempting to read 'size' bytes */ | 292 | /* Issue the request, attempting to read 'size' bytes */ |
293 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 293 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
294 | request, REQTYPE_INTERFACE_TO_HOST, 0x0000, | 294 | request, REQTYPE_INTERFACE_TO_HOST, 0x0000, |
295 | port_priv->bInterfaceNumber, buf, size, | 295 | spriv->bInterfaceNumber, buf, size, |
296 | USB_CTRL_GET_TIMEOUT); | 296 | USB_CTRL_GET_TIMEOUT); |
297 | 297 | ||
298 | /* Convert data into an array of integers */ | 298 | /* Convert data into an array of integers */ |
@@ -323,7 +323,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
323 | unsigned int *data, int size) | 323 | unsigned int *data, int size) |
324 | { | 324 | { |
325 | struct usb_serial *serial = port->serial; | 325 | struct usb_serial *serial = port->serial; |
326 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | 326 | struct cp210x_serial_private *spriv = usb_get_serial_data(serial); |
327 | __le32 *buf; | 327 | __le32 *buf; |
328 | int result, i, length; | 328 | int result, i, length; |
329 | 329 | ||
@@ -345,13 +345,13 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
345 | result = usb_control_msg(serial->dev, | 345 | result = usb_control_msg(serial->dev, |
346 | usb_sndctrlpipe(serial->dev, 0), | 346 | usb_sndctrlpipe(serial->dev, 0), |
347 | request, REQTYPE_HOST_TO_INTERFACE, 0x0000, | 347 | request, REQTYPE_HOST_TO_INTERFACE, 0x0000, |
348 | port_priv->bInterfaceNumber, buf, size, | 348 | spriv->bInterfaceNumber, buf, size, |
349 | USB_CTRL_SET_TIMEOUT); | 349 | USB_CTRL_SET_TIMEOUT); |
350 | } else { | 350 | } else { |
351 | result = usb_control_msg(serial->dev, | 351 | result = usb_control_msg(serial->dev, |
352 | usb_sndctrlpipe(serial->dev, 0), | 352 | usb_sndctrlpipe(serial->dev, 0), |
353 | request, REQTYPE_HOST_TO_INTERFACE, data[0], | 353 | request, REQTYPE_HOST_TO_INTERFACE, data[0], |
354 | port_priv->bInterfaceNumber, NULL, 0, | 354 | spriv->bInterfaceNumber, NULL, 0, |
355 | USB_CTRL_SET_TIMEOUT); | 355 | USB_CTRL_SET_TIMEOUT); |
356 | } | 356 | } |
357 | 357 | ||
@@ -845,36 +845,30 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | |||
845 | 845 | ||
846 | static int cp210x_startup(struct usb_serial *serial) | 846 | static int cp210x_startup(struct usb_serial *serial) |
847 | { | 847 | { |
848 | struct cp210x_port_private *port_priv; | 848 | struct usb_host_interface *cur_altsetting; |
849 | int i; | 849 | struct cp210x_serial_private *spriv; |
850 | 850 | ||
851 | /* cp210x buffers behave strangely unless device is reset */ | 851 | /* cp210x buffers behave strangely unless device is reset */ |
852 | usb_reset_device(serial->dev); | 852 | usb_reset_device(serial->dev); |
853 | 853 | ||
854 | for (i = 0; i < serial->num_ports; i++) { | 854 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); |
855 | port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL); | 855 | if (!spriv) |
856 | if (!port_priv) | 856 | return -ENOMEM; |
857 | return -ENOMEM; | ||
858 | 857 | ||
859 | port_priv->bInterfaceNumber = | 858 | cur_altsetting = serial->interface->cur_altsetting; |
860 | serial->interface->cur_altsetting->desc.bInterfaceNumber; | 859 | spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber; |
861 | 860 | ||
862 | usb_set_serial_port_data(serial->port[i], port_priv); | 861 | usb_set_serial_data(serial, spriv); |
863 | } | ||
864 | 862 | ||
865 | return 0; | 863 | return 0; |
866 | } | 864 | } |
867 | 865 | ||
868 | static void cp210x_release(struct usb_serial *serial) | 866 | static void cp210x_release(struct usb_serial *serial) |
869 | { | 867 | { |
870 | struct cp210x_port_private *port_priv; | 868 | struct cp210x_serial_private *spriv; |
871 | int i; | ||
872 | 869 | ||
873 | for (i = 0; i < serial->num_ports; i++) { | 870 | spriv = usb_get_serial_data(serial); |
874 | port_priv = usb_get_serial_port_data(serial->port[i]); | 871 | kfree(spriv); |
875 | kfree(port_priv); | ||
876 | usb_set_serial_port_data(serial->port[i], NULL); | ||
877 | } | ||
878 | } | 872 | } |
879 | 873 | ||
880 | module_usb_serial_driver(serial_drivers, id_table); | 874 | module_usb_serial_driver(serial_drivers, id_table); |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 2a7aecc72237..4ee77dcbe690 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -55,9 +55,9 @@ | |||
55 | #define CYBERJACK_PRODUCT_ID 0x0100 | 55 | #define CYBERJACK_PRODUCT_ID 0x0100 |
56 | 56 | ||
57 | /* Function prototypes */ | 57 | /* Function prototypes */ |
58 | static int cyberjack_startup(struct usb_serial *serial); | ||
59 | static void cyberjack_disconnect(struct usb_serial *serial); | 58 | static void cyberjack_disconnect(struct usb_serial *serial); |
60 | static void cyberjack_release(struct usb_serial *serial); | 59 | static int cyberjack_port_probe(struct usb_serial_port *port); |
60 | static int cyberjack_port_remove(struct usb_serial_port *port); | ||
61 | static int cyberjack_open(struct tty_struct *tty, | 61 | static int cyberjack_open(struct tty_struct *tty, |
62 | struct usb_serial_port *port); | 62 | struct usb_serial_port *port); |
63 | static void cyberjack_close(struct usb_serial_port *port); | 63 | static void cyberjack_close(struct usb_serial_port *port); |
@@ -83,9 +83,9 @@ static struct usb_serial_driver cyberjack_device = { | |||
83 | .description = "Reiner SCT Cyberjack USB card reader", | 83 | .description = "Reiner SCT Cyberjack USB card reader", |
84 | .id_table = id_table, | 84 | .id_table = id_table, |
85 | .num_ports = 1, | 85 | .num_ports = 1, |
86 | .attach = cyberjack_startup, | ||
87 | .disconnect = cyberjack_disconnect, | 86 | .disconnect = cyberjack_disconnect, |
88 | .release = cyberjack_release, | 87 | .port_probe = cyberjack_port_probe, |
88 | .port_remove = cyberjack_port_remove, | ||
89 | .open = cyberjack_open, | 89 | .open = cyberjack_open, |
90 | .close = cyberjack_close, | 90 | .close = cyberjack_close, |
91 | .write = cyberjack_write, | 91 | .write = cyberjack_write, |
@@ -107,56 +107,45 @@ struct cyberjack_private { | |||
107 | short wrsent; /* Data already sent */ | 107 | short wrsent; /* Data already sent */ |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /* do some startup allocations not currently performed by usb_serial_probe() */ | 110 | static int cyberjack_port_probe(struct usb_serial_port *port) |
111 | static int cyberjack_startup(struct usb_serial *serial) | ||
112 | { | 111 | { |
113 | struct cyberjack_private *priv; | 112 | struct cyberjack_private *priv; |
114 | int i; | 113 | int result; |
115 | 114 | ||
116 | /* allocate the private data structure */ | ||
117 | priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); | 115 | priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); |
118 | if (!priv) | 116 | if (!priv) |
119 | return -ENOMEM; | 117 | return -ENOMEM; |
120 | 118 | ||
121 | /* set initial values */ | ||
122 | spin_lock_init(&priv->lock); | 119 | spin_lock_init(&priv->lock); |
123 | priv->rdtodo = 0; | 120 | priv->rdtodo = 0; |
124 | priv->wrfilled = 0; | 121 | priv->wrfilled = 0; |
125 | priv->wrsent = 0; | 122 | priv->wrsent = 0; |
126 | usb_set_serial_port_data(serial->port[0], priv); | ||
127 | 123 | ||
128 | init_waitqueue_head(&serial->port[0]->write_wait); | 124 | usb_set_serial_port_data(port, priv); |
129 | 125 | ||
130 | for (i = 0; i < serial->num_ports; ++i) { | 126 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
131 | int result; | 127 | if (result) |
132 | result = usb_submit_urb(serial->port[i]->interrupt_in_urb, | 128 | dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); |
133 | GFP_KERNEL); | ||
134 | if (result) | ||
135 | dev_err(&serial->dev->dev, | ||
136 | "usb_submit_urb(read int) failed\n"); | ||
137 | dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n", | ||
138 | __func__); | ||
139 | } | ||
140 | 129 | ||
141 | return 0; | 130 | return 0; |
142 | } | 131 | } |
143 | 132 | ||
144 | static void cyberjack_disconnect(struct usb_serial *serial) | 133 | static int cyberjack_port_remove(struct usb_serial_port *port) |
145 | { | 134 | { |
146 | int i; | 135 | struct cyberjack_private *priv; |
147 | 136 | ||
148 | for (i = 0; i < serial->num_ports; ++i) | 137 | priv = usb_get_serial_port_data(port); |
149 | usb_kill_urb(serial->port[i]->interrupt_in_urb); | 138 | kfree(priv); |
139 | |||
140 | return 0; | ||
150 | } | 141 | } |
151 | 142 | ||
152 | static void cyberjack_release(struct usb_serial *serial) | 143 | static void cyberjack_disconnect(struct usb_serial *serial) |
153 | { | 144 | { |
154 | int i; | 145 | int i; |
155 | 146 | ||
156 | for (i = 0; i < serial->num_ports; ++i) { | 147 | for (i = 0; i < serial->num_ports; ++i) |
157 | /* My special items, the standard routines free my urbs */ | 148 | usb_kill_urb(serial->port[i]->interrupt_in_urb); |
158 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
159 | } | ||
160 | } | 149 | } |
161 | 150 | ||
162 | static int cyberjack_open(struct tty_struct *tty, | 151 | static int cyberjack_open(struct tty_struct *tty, |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 1befce21e173..f0da1279c114 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -123,10 +123,10 @@ struct cypress_private { | |||
123 | }; | 123 | }; |
124 | 124 | ||
125 | /* function prototypes for the Cypress USB to serial device */ | 125 | /* function prototypes for the Cypress USB to serial device */ |
126 | static int cypress_earthmate_startup(struct usb_serial *serial); | 126 | static int cypress_earthmate_port_probe(struct usb_serial_port *port); |
127 | static int cypress_hidcom_startup(struct usb_serial *serial); | 127 | static int cypress_hidcom_port_probe(struct usb_serial_port *port); |
128 | static int cypress_ca42v2_startup(struct usb_serial *serial); | 128 | static int cypress_ca42v2_port_probe(struct usb_serial_port *port); |
129 | static void cypress_release(struct usb_serial *serial); | 129 | static int cypress_port_remove(struct usb_serial_port *port); |
130 | static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port); | 130 | static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port); |
131 | static void cypress_close(struct usb_serial_port *port); | 131 | static void cypress_close(struct usb_serial_port *port); |
132 | static void cypress_dtr_rts(struct usb_serial_port *port, int on); | 132 | static void cypress_dtr_rts(struct usb_serial_port *port, int on); |
@@ -156,8 +156,8 @@ static struct usb_serial_driver cypress_earthmate_device = { | |||
156 | .description = "DeLorme Earthmate USB", | 156 | .description = "DeLorme Earthmate USB", |
157 | .id_table = id_table_earthmate, | 157 | .id_table = id_table_earthmate, |
158 | .num_ports = 1, | 158 | .num_ports = 1, |
159 | .attach = cypress_earthmate_startup, | 159 | .port_probe = cypress_earthmate_port_probe, |
160 | .release = cypress_release, | 160 | .port_remove = cypress_port_remove, |
161 | .open = cypress_open, | 161 | .open = cypress_open, |
162 | .close = cypress_close, | 162 | .close = cypress_close, |
163 | .dtr_rts = cypress_dtr_rts, | 163 | .dtr_rts = cypress_dtr_rts, |
@@ -182,8 +182,8 @@ static struct usb_serial_driver cypress_hidcom_device = { | |||
182 | .description = "HID->COM RS232 Adapter", | 182 | .description = "HID->COM RS232 Adapter", |
183 | .id_table = id_table_cyphidcomrs232, | 183 | .id_table = id_table_cyphidcomrs232, |
184 | .num_ports = 1, | 184 | .num_ports = 1, |
185 | .attach = cypress_hidcom_startup, | 185 | .port_probe = cypress_hidcom_port_probe, |
186 | .release = cypress_release, | 186 | .port_remove = cypress_port_remove, |
187 | .open = cypress_open, | 187 | .open = cypress_open, |
188 | .close = cypress_close, | 188 | .close = cypress_close, |
189 | .dtr_rts = cypress_dtr_rts, | 189 | .dtr_rts = cypress_dtr_rts, |
@@ -208,8 +208,8 @@ static struct usb_serial_driver cypress_ca42v2_device = { | |||
208 | .description = "Nokia CA-42 V2 Adapter", | 208 | .description = "Nokia CA-42 V2 Adapter", |
209 | .id_table = id_table_nokiaca42v2, | 209 | .id_table = id_table_nokiaca42v2, |
210 | .num_ports = 1, | 210 | .num_ports = 1, |
211 | .attach = cypress_ca42v2_startup, | 211 | .port_probe = cypress_ca42v2_port_probe, |
212 | .release = cypress_release, | 212 | .port_remove = cypress_port_remove, |
213 | .open = cypress_open, | 213 | .open = cypress_open, |
214 | .close = cypress_close, | 214 | .close = cypress_close, |
215 | .dtr_rts = cypress_dtr_rts, | 215 | .dtr_rts = cypress_dtr_rts, |
@@ -438,10 +438,10 @@ static void cypress_set_dead(struct usb_serial_port *port) | |||
438 | *****************************************************************************/ | 438 | *****************************************************************************/ |
439 | 439 | ||
440 | 440 | ||
441 | static int generic_startup(struct usb_serial *serial) | 441 | static int cypress_generic_port_probe(struct usb_serial_port *port) |
442 | { | 442 | { |
443 | struct usb_serial *serial = port->serial; | ||
443 | struct cypress_private *priv; | 444 | struct cypress_private *priv; |
444 | struct usb_serial_port *port = serial->port[0]; | ||
445 | 445 | ||
446 | priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); | 446 | priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); |
447 | if (!priv) | 447 | if (!priv) |
@@ -490,14 +490,16 @@ static int generic_startup(struct usb_serial *serial) | |||
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | static int cypress_earthmate_startup(struct usb_serial *serial) | 493 | static int cypress_earthmate_port_probe(struct usb_serial_port *port) |
494 | { | 494 | { |
495 | struct usb_serial *serial = port->serial; | ||
495 | struct cypress_private *priv; | 496 | struct cypress_private *priv; |
496 | struct usb_serial_port *port = serial->port[0]; | 497 | int ret; |
497 | 498 | ||
498 | if (generic_startup(serial)) { | 499 | ret = cypress_generic_port_probe(port); |
500 | if (ret) { | ||
499 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); | 501 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
500 | return 1; | 502 | return ret; |
501 | } | 503 | } |
502 | 504 | ||
503 | priv = usb_get_serial_port_data(port); | 505 | priv = usb_get_serial_port_data(port); |
@@ -518,56 +520,53 @@ static int cypress_earthmate_startup(struct usb_serial *serial) | |||
518 | } | 520 | } |
519 | 521 | ||
520 | return 0; | 522 | return 0; |
521 | } /* cypress_earthmate_startup */ | 523 | } |
522 | |||
523 | 524 | ||
524 | static int cypress_hidcom_startup(struct usb_serial *serial) | 525 | static int cypress_hidcom_port_probe(struct usb_serial_port *port) |
525 | { | 526 | { |
526 | struct cypress_private *priv; | 527 | struct cypress_private *priv; |
527 | struct usb_serial_port *port = serial->port[0]; | 528 | int ret; |
528 | 529 | ||
529 | if (generic_startup(serial)) { | 530 | ret = cypress_generic_port_probe(port); |
531 | if (ret) { | ||
530 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); | 532 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
531 | return 1; | 533 | return ret; |
532 | } | 534 | } |
533 | 535 | ||
534 | priv = usb_get_serial_port_data(port); | 536 | priv = usb_get_serial_port_data(port); |
535 | priv->chiptype = CT_CYPHIDCOM; | 537 | priv->chiptype = CT_CYPHIDCOM; |
536 | 538 | ||
537 | return 0; | 539 | return 0; |
538 | } /* cypress_hidcom_startup */ | 540 | } |
539 | |||
540 | 541 | ||
541 | static int cypress_ca42v2_startup(struct usb_serial *serial) | 542 | static int cypress_ca42v2_port_probe(struct usb_serial_port *port) |
542 | { | 543 | { |
543 | struct cypress_private *priv; | 544 | struct cypress_private *priv; |
544 | struct usb_serial_port *port = serial->port[0]; | 545 | int ret; |
545 | 546 | ||
546 | if (generic_startup(serial)) { | 547 | ret = cypress_generic_port_probe(port); |
548 | if (ret) { | ||
547 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); | 549 | dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); |
548 | return 1; | 550 | return ret; |
549 | } | 551 | } |
550 | 552 | ||
551 | priv = usb_get_serial_port_data(port); | 553 | priv = usb_get_serial_port_data(port); |
552 | priv->chiptype = CT_CA42V2; | 554 | priv->chiptype = CT_CA42V2; |
553 | 555 | ||
554 | return 0; | 556 | return 0; |
555 | } /* cypress_ca42v2_startup */ | 557 | } |
556 | |||
557 | 558 | ||
558 | static void cypress_release(struct usb_serial *serial) | 559 | static int cypress_port_remove(struct usb_serial_port *port) |
559 | { | 560 | { |
560 | struct cypress_private *priv; | 561 | struct cypress_private *priv; |
561 | 562 | ||
562 | /* all open ports are closed at this point */ | 563 | priv = usb_get_serial_port_data(port); |
563 | priv = usb_get_serial_port_data(serial->port[0]); | ||
564 | 564 | ||
565 | if (priv) { | 565 | kfifo_free(&priv->write_fifo); |
566 | kfifo_free(&priv->write_fifo); | 566 | kfree(priv); |
567 | kfree(priv); | ||
568 | } | ||
569 | } | ||
570 | 567 | ||
568 | return 0; | ||
569 | } | ||
571 | 570 | ||
572 | static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) | 571 | static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) |
573 | { | 572 | { |
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 244477107e2f..6e4eb57d0177 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c | |||
@@ -318,39 +318,30 @@ static int f81232_ioctl(struct tty_struct *tty, | |||
318 | return -ENOIOCTLCMD; | 318 | return -ENOIOCTLCMD; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int f81232_startup(struct usb_serial *serial) | 321 | static int f81232_port_probe(struct usb_serial_port *port) |
322 | { | 322 | { |
323 | struct f81232_private *priv; | 323 | struct f81232_private *priv; |
324 | int i; | ||
325 | 324 | ||
326 | for (i = 0; i < serial->num_ports; ++i) { | 325 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
327 | priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL); | 326 | if (!priv) |
328 | if (!priv) | 327 | return -ENOMEM; |
329 | goto cleanup; | ||
330 | spin_lock_init(&priv->lock); | ||
331 | init_waitqueue_head(&priv->delta_msr_wait); | ||
332 | usb_set_serial_port_data(serial->port[i], priv); | ||
333 | } | ||
334 | return 0; | ||
335 | 328 | ||
336 | cleanup: | 329 | spin_lock_init(&priv->lock); |
337 | for (--i; i >= 0; --i) { | 330 | init_waitqueue_head(&priv->delta_msr_wait); |
338 | priv = usb_get_serial_port_data(serial->port[i]); | 331 | |
339 | kfree(priv); | 332 | usb_set_serial_port_data(port, priv); |
340 | usb_set_serial_port_data(serial->port[i], NULL); | 333 | |
341 | } | 334 | return 0; |
342 | return -ENOMEM; | ||
343 | } | 335 | } |
344 | 336 | ||
345 | static void f81232_release(struct usb_serial *serial) | 337 | static int f81232_port_remove(struct usb_serial_port *port) |
346 | { | 338 | { |
347 | int i; | ||
348 | struct f81232_private *priv; | 339 | struct f81232_private *priv; |
349 | 340 | ||
350 | for (i = 0; i < serial->num_ports; ++i) { | 341 | priv = usb_get_serial_port_data(port); |
351 | priv = usb_get_serial_port_data(serial->port[i]); | 342 | kfree(priv); |
352 | kfree(priv); | 343 | |
353 | } | 344 | return 0; |
354 | } | 345 | } |
355 | 346 | ||
356 | static struct usb_serial_driver f81232_device = { | 347 | static struct usb_serial_driver f81232_device = { |
@@ -373,8 +364,8 @@ static struct usb_serial_driver f81232_device = { | |||
373 | .tiocmset = f81232_tiocmset, | 364 | .tiocmset = f81232_tiocmset, |
374 | .process_read_urb = f81232_process_read_urb, | 365 | .process_read_urb = f81232_process_read_urb, |
375 | .read_int_callback = f81232_read_int_callback, | 366 | .read_int_callback = f81232_read_int_callback, |
376 | .attach = f81232_startup, | 367 | .port_probe = f81232_port_probe, |
377 | .release = f81232_release, | 368 | .port_remove = f81232_port_remove, |
378 | }; | 369 | }; |
379 | 370 | ||
380 | static struct usb_serial_driver * const serial_drivers[] = { | 371 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 3ee92648c02d..203358d7e7bc 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1405,11 +1405,10 @@ static void timeout_handler(unsigned long data) | |||
1405 | 1405 | ||
1406 | 1406 | ||
1407 | 1407 | ||
1408 | static int garmin_attach(struct usb_serial *serial) | 1408 | static int garmin_port_probe(struct usb_serial_port *port) |
1409 | { | 1409 | { |
1410 | int status = 0; | 1410 | int status; |
1411 | struct usb_serial_port *port = serial->port[0]; | 1411 | struct garmin_data *garmin_data_p; |
1412 | struct garmin_data *garmin_data_p = NULL; | ||
1413 | 1412 | ||
1414 | garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); | 1413 | garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); |
1415 | if (garmin_data_p == NULL) { | 1414 | if (garmin_data_p == NULL) { |
@@ -1434,22 +1433,14 @@ static int garmin_attach(struct usb_serial *serial) | |||
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | 1435 | ||
1437 | static void garmin_disconnect(struct usb_serial *serial) | 1436 | static int garmin_port_remove(struct usb_serial_port *port) |
1438 | { | 1437 | { |
1439 | struct usb_serial_port *port = serial->port[0]; | ||
1440 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 1438 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
1441 | 1439 | ||
1442 | usb_kill_urb(port->interrupt_in_urb); | 1440 | usb_kill_urb(port->interrupt_in_urb); |
1443 | del_timer_sync(&garmin_data_p->timer); | 1441 | del_timer_sync(&garmin_data_p->timer); |
1444 | } | ||
1445 | |||
1446 | |||
1447 | static void garmin_release(struct usb_serial *serial) | ||
1448 | { | ||
1449 | struct usb_serial_port *port = serial->port[0]; | ||
1450 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | ||
1451 | |||
1452 | kfree(garmin_data_p); | 1442 | kfree(garmin_data_p); |
1443 | return 0; | ||
1453 | } | 1444 | } |
1454 | 1445 | ||
1455 | 1446 | ||
@@ -1466,9 +1457,8 @@ static struct usb_serial_driver garmin_device = { | |||
1466 | .close = garmin_close, | 1457 | .close = garmin_close, |
1467 | .throttle = garmin_throttle, | 1458 | .throttle = garmin_throttle, |
1468 | .unthrottle = garmin_unthrottle, | 1459 | .unthrottle = garmin_unthrottle, |
1469 | .attach = garmin_attach, | 1460 | .port_probe = garmin_port_probe, |
1470 | .disconnect = garmin_disconnect, | 1461 | .port_remove = garmin_port_remove, |
1471 | .release = garmin_release, | ||
1472 | .write = garmin_write, | 1462 | .write = garmin_write, |
1473 | .write_room = garmin_write_room, | 1463 | .write_room = garmin_write_room, |
1474 | .write_bulk_callback = garmin_write_bulk_callback, | 1464 | .write_bulk_callback = garmin_write_bulk_callback, |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 8e6faaf3580c..5acc0d13864a 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -225,6 +225,8 @@ static int edge_get_icount(struct tty_struct *tty, | |||
225 | static int edge_startup(struct usb_serial *serial); | 225 | static int edge_startup(struct usb_serial *serial); |
226 | static void edge_disconnect(struct usb_serial *serial); | 226 | static void edge_disconnect(struct usb_serial *serial); |
227 | static void edge_release(struct usb_serial *serial); | 227 | static void edge_release(struct usb_serial *serial); |
228 | static int edge_port_probe(struct usb_serial_port *port); | ||
229 | static int edge_port_remove(struct usb_serial_port *port); | ||
228 | 230 | ||
229 | #include "io_tables.h" /* all of the devices that this driver supports */ | 231 | #include "io_tables.h" /* all of the devices that this driver supports */ |
230 | 232 | ||
@@ -2875,10 +2877,9 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2875 | static int edge_startup(struct usb_serial *serial) | 2877 | static int edge_startup(struct usb_serial *serial) |
2876 | { | 2878 | { |
2877 | struct edgeport_serial *edge_serial; | 2879 | struct edgeport_serial *edge_serial; |
2878 | struct edgeport_port *edge_port; | ||
2879 | struct usb_device *dev; | 2880 | struct usb_device *dev; |
2880 | struct device *ddev = &serial->dev->dev; | 2881 | struct device *ddev = &serial->dev->dev; |
2881 | int i, j; | 2882 | int i; |
2882 | int response; | 2883 | int response; |
2883 | bool interrupt_in_found; | 2884 | bool interrupt_in_found; |
2884 | bool bulk_in_found; | 2885 | bool bulk_in_found; |
@@ -2961,25 +2962,6 @@ static int edge_startup(struct usb_serial *serial) | |||
2961 | /* we set up the pointers to the endpoints in the edge_open function, | 2962 | /* we set up the pointers to the endpoints in the edge_open function, |
2962 | * as the structures aren't created yet. */ | 2963 | * as the structures aren't created yet. */ |
2963 | 2964 | ||
2964 | /* set up our port private structures */ | ||
2965 | for (i = 0; i < serial->num_ports; ++i) { | ||
2966 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); | ||
2967 | if (edge_port == NULL) { | ||
2968 | dev_err(ddev, "%s - Out of memory\n", __func__); | ||
2969 | for (j = 0; j < i; ++j) { | ||
2970 | kfree(usb_get_serial_port_data(serial->port[j])); | ||
2971 | usb_set_serial_port_data(serial->port[j], | ||
2972 | NULL); | ||
2973 | } | ||
2974 | usb_set_serial_data(serial, NULL); | ||
2975 | kfree(edge_serial); | ||
2976 | return -ENOMEM; | ||
2977 | } | ||
2978 | spin_lock_init(&edge_port->ep_lock); | ||
2979 | edge_port->port = serial->port[i]; | ||
2980 | usb_set_serial_port_data(serial->port[i], edge_port); | ||
2981 | } | ||
2982 | |||
2983 | response = 0; | 2965 | response = 0; |
2984 | 2966 | ||
2985 | if (edge_serial->is_epic) { | 2967 | if (edge_serial->is_epic) { |
@@ -3120,14 +3102,36 @@ static void edge_disconnect(struct usb_serial *serial) | |||
3120 | static void edge_release(struct usb_serial *serial) | 3102 | static void edge_release(struct usb_serial *serial) |
3121 | { | 3103 | { |
3122 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 3104 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
3123 | int i; | ||
3124 | |||
3125 | for (i = 0; i < serial->num_ports; ++i) | ||
3126 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
3127 | 3105 | ||
3128 | kfree(edge_serial); | 3106 | kfree(edge_serial); |
3129 | } | 3107 | } |
3130 | 3108 | ||
3109 | static int edge_port_probe(struct usb_serial_port *port) | ||
3110 | { | ||
3111 | struct edgeport_port *edge_port; | ||
3112 | |||
3113 | edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); | ||
3114 | if (!edge_port) | ||
3115 | return -ENOMEM; | ||
3116 | |||
3117 | spin_lock_init(&edge_port->ep_lock); | ||
3118 | edge_port->port = port; | ||
3119 | |||
3120 | usb_set_serial_port_data(port, edge_port); | ||
3121 | |||
3122 | return 0; | ||
3123 | } | ||
3124 | |||
3125 | static int edge_port_remove(struct usb_serial_port *port) | ||
3126 | { | ||
3127 | struct edgeport_port *edge_port; | ||
3128 | |||
3129 | edge_port = usb_get_serial_port_data(port); | ||
3130 | kfree(edge_port); | ||
3131 | |||
3132 | return 0; | ||
3133 | } | ||
3134 | |||
3131 | module_usb_serial_driver(serial_drivers, id_table_combined); | 3135 | module_usb_serial_driver(serial_drivers, id_table_combined); |
3132 | 3136 | ||
3133 | MODULE_AUTHOR(DRIVER_AUTHOR); | 3137 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 350afddb55ba..1511dd0ad324 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h | |||
@@ -110,6 +110,8 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
110 | .attach = edge_startup, | 110 | .attach = edge_startup, |
111 | .disconnect = edge_disconnect, | 111 | .disconnect = edge_disconnect, |
112 | .release = edge_release, | 112 | .release = edge_release, |
113 | .port_probe = edge_port_probe, | ||
114 | .port_remove = edge_port_remove, | ||
113 | .ioctl = edge_ioctl, | 115 | .ioctl = edge_ioctl, |
114 | .set_termios = edge_set_termios, | 116 | .set_termios = edge_set_termios, |
115 | .tiocmget = edge_tiocmget, | 117 | .tiocmget = edge_tiocmget, |
@@ -139,6 +141,8 @@ static struct usb_serial_driver edgeport_4port_device = { | |||
139 | .attach = edge_startup, | 141 | .attach = edge_startup, |
140 | .disconnect = edge_disconnect, | 142 | .disconnect = edge_disconnect, |
141 | .release = edge_release, | 143 | .release = edge_release, |
144 | .port_probe = edge_port_probe, | ||
145 | .port_remove = edge_port_remove, | ||
142 | .ioctl = edge_ioctl, | 146 | .ioctl = edge_ioctl, |
143 | .set_termios = edge_set_termios, | 147 | .set_termios = edge_set_termios, |
144 | .tiocmget = edge_tiocmget, | 148 | .tiocmget = edge_tiocmget, |
@@ -168,6 +172,8 @@ static struct usb_serial_driver edgeport_8port_device = { | |||
168 | .attach = edge_startup, | 172 | .attach = edge_startup, |
169 | .disconnect = edge_disconnect, | 173 | .disconnect = edge_disconnect, |
170 | .release = edge_release, | 174 | .release = edge_release, |
175 | .port_probe = edge_port_probe, | ||
176 | .port_remove = edge_port_remove, | ||
171 | .ioctl = edge_ioctl, | 177 | .ioctl = edge_ioctl, |
172 | .set_termios = edge_set_termios, | 178 | .set_termios = edge_set_termios, |
173 | .tiocmget = edge_tiocmget, | 179 | .tiocmget = edge_tiocmget, |
@@ -197,6 +203,8 @@ static struct usb_serial_driver epic_device = { | |||
197 | .attach = edge_startup, | 203 | .attach = edge_startup, |
198 | .disconnect = edge_disconnect, | 204 | .disconnect = edge_disconnect, |
199 | .release = edge_release, | 205 | .release = edge_release, |
206 | .port_probe = edge_port_probe, | ||
207 | .port_remove = edge_port_remove, | ||
200 | .ioctl = edge_ioctl, | 208 | .ioctl = edge_ioctl, |
201 | .set_termios = edge_set_termios, | 209 | .set_termios = edge_set_termios, |
202 | .tiocmget = edge_tiocmget, | 210 | .tiocmget = edge_tiocmget, |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index a2209cd45093..60023c2d2a31 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -2532,12 +2532,7 @@ static void edge_break(struct tty_struct *tty, int break_state) | |||
2532 | static int edge_startup(struct usb_serial *serial) | 2532 | static int edge_startup(struct usb_serial *serial) |
2533 | { | 2533 | { |
2534 | struct edgeport_serial *edge_serial; | 2534 | struct edgeport_serial *edge_serial; |
2535 | struct edgeport_port *edge_port; | ||
2536 | struct usb_device *dev; | ||
2537 | int status; | 2535 | int status; |
2538 | int i; | ||
2539 | |||
2540 | dev = serial->dev; | ||
2541 | 2536 | ||
2542 | /* create our private serial structure */ | 2537 | /* create our private serial structure */ |
2543 | edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); | 2538 | edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); |
@@ -2555,40 +2550,7 @@ static int edge_startup(struct usb_serial *serial) | |||
2555 | return status; | 2550 | return status; |
2556 | } | 2551 | } |
2557 | 2552 | ||
2558 | /* set up our port private structures */ | ||
2559 | for (i = 0; i < serial->num_ports; ++i) { | ||
2560 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); | ||
2561 | if (edge_port == NULL) { | ||
2562 | dev_err(&serial->dev->dev, "%s - Out of memory\n", | ||
2563 | __func__); | ||
2564 | goto cleanup; | ||
2565 | } | ||
2566 | spin_lock_init(&edge_port->ep_lock); | ||
2567 | if (kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE, | ||
2568 | GFP_KERNEL)) { | ||
2569 | dev_err(&serial->dev->dev, "%s - Out of memory\n", | ||
2570 | __func__); | ||
2571 | kfree(edge_port); | ||
2572 | goto cleanup; | ||
2573 | } | ||
2574 | edge_port->port = serial->port[i]; | ||
2575 | edge_port->edge_serial = edge_serial; | ||
2576 | usb_set_serial_port_data(serial->port[i], edge_port); | ||
2577 | edge_port->bUartMode = default_uart_mode; | ||
2578 | } | ||
2579 | |||
2580 | return 0; | 2553 | return 0; |
2581 | |||
2582 | cleanup: | ||
2583 | for (--i; i >= 0; --i) { | ||
2584 | edge_port = usb_get_serial_port_data(serial->port[i]); | ||
2585 | kfifo_free(&edge_port->write_fifo); | ||
2586 | kfree(edge_port); | ||
2587 | usb_set_serial_port_data(serial->port[i], NULL); | ||
2588 | } | ||
2589 | kfree(edge_serial); | ||
2590 | usb_set_serial_data(serial, NULL); | ||
2591 | return -ENOMEM; | ||
2592 | } | 2554 | } |
2593 | 2555 | ||
2594 | static void edge_disconnect(struct usb_serial *serial) | 2556 | static void edge_disconnect(struct usb_serial *serial) |
@@ -2597,17 +2559,54 @@ static void edge_disconnect(struct usb_serial *serial) | |||
2597 | 2559 | ||
2598 | static void edge_release(struct usb_serial *serial) | 2560 | static void edge_release(struct usb_serial *serial) |
2599 | { | 2561 | { |
2600 | int i; | 2562 | kfree(usb_get_serial_data(serial)); |
2563 | } | ||
2564 | |||
2565 | static int edge_port_probe(struct usb_serial_port *port) | ||
2566 | { | ||
2601 | struct edgeport_port *edge_port; | 2567 | struct edgeport_port *edge_port; |
2568 | int ret; | ||
2602 | 2569 | ||
2603 | for (i = 0; i < serial->num_ports; ++i) { | 2570 | edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); |
2604 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2571 | if (!edge_port) |
2572 | return -ENOMEM; | ||
2573 | |||
2574 | ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE, | ||
2575 | GFP_KERNEL); | ||
2576 | if (ret) { | ||
2577 | kfree(edge_port); | ||
2578 | return -ENOMEM; | ||
2579 | } | ||
2580 | |||
2581 | spin_lock_init(&edge_port->ep_lock); | ||
2582 | edge_port->port = port; | ||
2583 | edge_port->edge_serial = usb_get_serial_data(port->serial); | ||
2584 | edge_port->bUartMode = default_uart_mode; | ||
2585 | |||
2586 | usb_set_serial_port_data(port, edge_port); | ||
2587 | |||
2588 | ret = edge_create_sysfs_attrs(port); | ||
2589 | if (ret) { | ||
2605 | kfifo_free(&edge_port->write_fifo); | 2590 | kfifo_free(&edge_port->write_fifo); |
2606 | kfree(edge_port); | 2591 | kfree(edge_port); |
2592 | return ret; | ||
2607 | } | 2593 | } |
2608 | kfree(usb_get_serial_data(serial)); | 2594 | |
2595 | return 0; | ||
2609 | } | 2596 | } |
2610 | 2597 | ||
2598 | static int edge_port_remove(struct usb_serial_port *port) | ||
2599 | { | ||
2600 | struct edgeport_port *edge_port; | ||
2601 | |||
2602 | edge_port = usb_get_serial_port_data(port); | ||
2603 | |||
2604 | edge_remove_sysfs_attrs(port); | ||
2605 | kfifo_free(&edge_port->write_fifo); | ||
2606 | kfree(edge_port); | ||
2607 | |||
2608 | return 0; | ||
2609 | } | ||
2611 | 2610 | ||
2612 | /* Sysfs Attributes */ | 2611 | /* Sysfs Attributes */ |
2613 | 2612 | ||
@@ -2667,8 +2666,8 @@ static struct usb_serial_driver edgeport_1port_device = { | |||
2667 | .attach = edge_startup, | 2666 | .attach = edge_startup, |
2668 | .disconnect = edge_disconnect, | 2667 | .disconnect = edge_disconnect, |
2669 | .release = edge_release, | 2668 | .release = edge_release, |
2670 | .port_probe = edge_create_sysfs_attrs, | 2669 | .port_probe = edge_port_probe, |
2671 | .port_remove = edge_remove_sysfs_attrs, | 2670 | .port_remove = edge_port_remove, |
2672 | .ioctl = edge_ioctl, | 2671 | .ioctl = edge_ioctl, |
2673 | .set_termios = edge_set_termios, | 2672 | .set_termios = edge_set_termios, |
2674 | .tiocmget = edge_tiocmget, | 2673 | .tiocmget = edge_tiocmget, |
@@ -2698,8 +2697,8 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
2698 | .attach = edge_startup, | 2697 | .attach = edge_startup, |
2699 | .disconnect = edge_disconnect, | 2698 | .disconnect = edge_disconnect, |
2700 | .release = edge_release, | 2699 | .release = edge_release, |
2701 | .port_probe = edge_create_sysfs_attrs, | 2700 | .port_probe = edge_port_probe, |
2702 | .port_remove = edge_remove_sysfs_attrs, | 2701 | .port_remove = edge_port_remove, |
2703 | .ioctl = edge_ioctl, | 2702 | .ioctl = edge_ioctl, |
2704 | .set_termios = edge_set_termios, | 2703 | .set_termios = edge_set_termios, |
2705 | .tiocmget = edge_tiocmget, | 2704 | .tiocmget = edge_tiocmget, |
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 01da3ea36e89..cd5533e81de7 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -53,6 +53,8 @@ static int iuu_cardout; | |||
53 | static bool xmas; | 53 | static bool xmas; |
54 | static int vcc_default = 5; | 54 | static int vcc_default = 5; |
55 | 55 | ||
56 | static int iuu_create_sysfs_attrs(struct usb_serial_port *port); | ||
57 | static int iuu_remove_sysfs_attrs(struct usb_serial_port *port); | ||
56 | static void read_rxcmd_callback(struct urb *urb); | 58 | static void read_rxcmd_callback(struct urb *urb); |
57 | 59 | ||
58 | struct iuu_private { | 60 | struct iuu_private { |
@@ -72,63 +74,55 @@ struct iuu_private { | |||
72 | u32 clk; | 74 | u32 clk; |
73 | }; | 75 | }; |
74 | 76 | ||
75 | 77 | static int iuu_port_probe(struct usb_serial_port *port) | |
76 | static void iuu_free_buf(struct iuu_private *priv) | ||
77 | { | ||
78 | kfree(priv->buf); | ||
79 | kfree(priv->writebuf); | ||
80 | } | ||
81 | |||
82 | static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv) | ||
83 | { | ||
84 | priv->buf = kzalloc(256, GFP_KERNEL); | ||
85 | priv->writebuf = kzalloc(256, GFP_KERNEL); | ||
86 | if (!priv->buf || !priv->writebuf) { | ||
87 | iuu_free_buf(priv); | ||
88 | dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__); | ||
89 | return -ENOMEM; | ||
90 | } | ||
91 | dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | static int iuu_startup(struct usb_serial *serial) | ||
96 | { | 78 | { |
97 | struct iuu_private *priv; | 79 | struct iuu_private *priv; |
80 | int ret; | ||
98 | 81 | ||
99 | priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); | 82 | priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); |
100 | dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__); | ||
101 | if (!priv) | 83 | if (!priv) |
102 | return -ENOMEM; | 84 | return -ENOMEM; |
103 | if (iuu_alloc_buf(serial, priv)) { | 85 | |
86 | priv->buf = kzalloc(256, GFP_KERNEL); | ||
87 | if (!priv->buf) { | ||
88 | kfree(priv); | ||
89 | return -ENOMEM; | ||
90 | } | ||
91 | |||
92 | priv->writebuf = kzalloc(256, GFP_KERNEL); | ||
93 | if (!priv->writebuf) { | ||
94 | kfree(priv->buf); | ||
104 | kfree(priv); | 95 | kfree(priv); |
105 | return -ENOMEM; | 96 | return -ENOMEM; |
106 | } | 97 | } |
98 | |||
107 | priv->vcc = vcc_default; | 99 | priv->vcc = vcc_default; |
108 | spin_lock_init(&priv->lock); | 100 | spin_lock_init(&priv->lock); |
109 | init_waitqueue_head(&priv->delta_msr_wait); | 101 | init_waitqueue_head(&priv->delta_msr_wait); |
110 | usb_set_serial_port_data(serial->port[0], priv); | 102 | |
103 | usb_set_serial_port_data(port, priv); | ||
104 | |||
105 | ret = iuu_create_sysfs_attrs(port); | ||
106 | if (ret) { | ||
107 | kfree(priv->writebuf); | ||
108 | kfree(priv->buf); | ||
109 | kfree(priv); | ||
110 | return ret; | ||
111 | } | ||
112 | |||
111 | return 0; | 113 | return 0; |
112 | } | 114 | } |
113 | 115 | ||
114 | /* Release function */ | 116 | static int iuu_port_remove(struct usb_serial_port *port) |
115 | static void iuu_release(struct usb_serial *serial) | ||
116 | { | 117 | { |
117 | struct usb_serial_port *port = serial->port[0]; | ||
118 | struct iuu_private *priv = usb_get_serial_port_data(port); | 118 | struct iuu_private *priv = usb_get_serial_port_data(port); |
119 | if (!port) | ||
120 | return; | ||
121 | 119 | ||
122 | if (priv) { | 120 | iuu_remove_sysfs_attrs(port); |
123 | iuu_free_buf(priv); | 121 | kfree(priv->writebuf); |
124 | dev_dbg(&port->dev, "%s - I will free all\n", __func__); | 122 | kfree(priv->buf); |
125 | usb_set_serial_port_data(port, NULL); | 123 | kfree(priv); |
126 | |||
127 | dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__); | ||
128 | kfree(priv); | ||
129 | 124 | ||
130 | dev_dbg(&port->dev, "%s priv is now kfree\n", __func__); | 125 | return 0; |
131 | } | ||
132 | } | 126 | } |
133 | 127 | ||
134 | static int iuu_tiocmset(struct tty_struct *tty, | 128 | static int iuu_tiocmset(struct tty_struct *tty, |
@@ -1215,8 +1209,6 @@ static struct usb_serial_driver iuu_device = { | |||
1215 | .num_ports = 1, | 1209 | .num_ports = 1, |
1216 | .bulk_in_size = 512, | 1210 | .bulk_in_size = 512, |
1217 | .bulk_out_size = 512, | 1211 | .bulk_out_size = 512, |
1218 | .port_probe = iuu_create_sysfs_attrs, | ||
1219 | .port_remove = iuu_remove_sysfs_attrs, | ||
1220 | .open = iuu_open, | 1212 | .open = iuu_open, |
1221 | .close = iuu_close, | 1213 | .close = iuu_close, |
1222 | .write = iuu_uart_write, | 1214 | .write = iuu_uart_write, |
@@ -1225,8 +1217,8 @@ static struct usb_serial_driver iuu_device = { | |||
1225 | .tiocmset = iuu_tiocmset, | 1217 | .tiocmset = iuu_tiocmset, |
1226 | .set_termios = iuu_set_termios, | 1218 | .set_termios = iuu_set_termios, |
1227 | .init_termios = iuu_init_termios, | 1219 | .init_termios = iuu_init_termios, |
1228 | .attach = iuu_startup, | 1220 | .port_probe = iuu_port_probe, |
1229 | .release = iuu_release, | 1221 | .port_remove = iuu_port_remove, |
1230 | }; | 1222 | }; |
1231 | 1223 | ||
1232 | static struct usb_serial_driver * const serial_drivers[] = { | 1224 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index ca43ecb4a2bd..bb87e29c4ac2 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -713,29 +713,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw"); | |||
713 | MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); | 713 | MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); |
714 | #endif | 714 | #endif |
715 | 715 | ||
716 | static int keyspan_pda_startup(struct usb_serial *serial) | 716 | static int keyspan_pda_port_probe(struct usb_serial_port *port) |
717 | { | 717 | { |
718 | 718 | ||
719 | struct keyspan_pda_private *priv; | 719 | struct keyspan_pda_private *priv; |
720 | 720 | ||
721 | /* allocate the private data structures for all ports. Well, for all | ||
722 | one ports. */ | ||
723 | |||
724 | priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); | 721 | priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); |
725 | if (!priv) | 722 | if (!priv) |
726 | return 1; /* error */ | 723 | return -ENOMEM; |
727 | usb_set_serial_port_data(serial->port[0], priv); | 724 | |
728 | init_waitqueue_head(&serial->port[0]->write_wait); | ||
729 | INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); | 725 | INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); |
730 | INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); | 726 | INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); |
731 | priv->serial = serial; | 727 | priv->serial = port->serial; |
732 | priv->port = serial->port[0]; | 728 | priv->port = port; |
729 | |||
730 | usb_set_serial_port_data(port, priv); | ||
731 | |||
733 | return 0; | 732 | return 0; |
734 | } | 733 | } |
735 | 734 | ||
736 | static void keyspan_pda_release(struct usb_serial *serial) | 735 | static int keyspan_pda_port_remove(struct usb_serial_port *port) |
737 | { | 736 | { |
738 | kfree(usb_get_serial_port_data(serial->port[0])); | 737 | struct keyspan_pda_private *priv; |
738 | |||
739 | priv = usb_get_serial_port_data(port); | ||
740 | kfree(priv); | ||
741 | |||
742 | return 0; | ||
739 | } | 743 | } |
740 | 744 | ||
741 | #ifdef KEYSPAN | 745 | #ifdef KEYSPAN |
@@ -786,8 +790,8 @@ static struct usb_serial_driver keyspan_pda_device = { | |||
786 | .break_ctl = keyspan_pda_break_ctl, | 790 | .break_ctl = keyspan_pda_break_ctl, |
787 | .tiocmget = keyspan_pda_tiocmget, | 791 | .tiocmget = keyspan_pda_tiocmget, |
788 | .tiocmset = keyspan_pda_tiocmset, | 792 | .tiocmset = keyspan_pda_tiocmset, |
789 | .attach = keyspan_pda_startup, | 793 | .port_probe = keyspan_pda_port_probe, |
790 | .release = keyspan_pda_release, | 794 | .port_remove = keyspan_pda_port_remove, |
791 | }; | 795 | }; |
792 | 796 | ||
793 | static struct usb_serial_driver * const serial_drivers[] = { | 797 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 3f6d7376c02d..1f4517864cd2 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -60,8 +60,8 @@ | |||
60 | /* | 60 | /* |
61 | * Function prototypes | 61 | * Function prototypes |
62 | */ | 62 | */ |
63 | static int klsi_105_startup(struct usb_serial *serial); | 63 | static int klsi_105_port_probe(struct usb_serial_port *port); |
64 | static void klsi_105_release(struct usb_serial *serial); | 64 | static int klsi_105_port_remove(struct usb_serial_port *port); |
65 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); | 65 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); |
66 | static void klsi_105_close(struct usb_serial_port *port); | 66 | static void klsi_105_close(struct usb_serial_port *port); |
67 | static void klsi_105_set_termios(struct tty_struct *tty, | 67 | static void klsi_105_set_termios(struct tty_struct *tty, |
@@ -99,8 +99,8 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
99 | /*.break_ctl = klsi_105_break_ctl,*/ | 99 | /*.break_ctl = klsi_105_break_ctl,*/ |
100 | .tiocmget = klsi_105_tiocmget, | 100 | .tiocmget = klsi_105_tiocmget, |
101 | .tiocmset = klsi_105_tiocmset, | 101 | .tiocmset = klsi_105_tiocmset, |
102 | .attach = klsi_105_startup, | 102 | .port_probe = klsi_105_port_probe, |
103 | .release = klsi_105_release, | 103 | .port_remove = klsi_105_port_remove, |
104 | .throttle = usb_serial_generic_throttle, | 104 | .throttle = usb_serial_generic_throttle, |
105 | .unthrottle = usb_serial_generic_unthrottle, | 105 | .unthrottle = usb_serial_generic_unthrottle, |
106 | .process_read_urb = klsi_105_process_read_urb, | 106 | .process_read_urb = klsi_105_process_read_urb, |
@@ -223,60 +223,40 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
223 | * Driver's tty interface functions | 223 | * Driver's tty interface functions |
224 | */ | 224 | */ |
225 | 225 | ||
226 | static int klsi_105_startup(struct usb_serial *serial) | 226 | static int klsi_105_port_probe(struct usb_serial_port *port) |
227 | { | 227 | { |
228 | struct klsi_105_private *priv; | 228 | struct klsi_105_private *priv; |
229 | int i; | ||
230 | 229 | ||
231 | /* check if we support the product id (see keyspan.c) | 230 | priv = kmalloc(sizeof(*priv), GFP_KERNEL); |
232 | * FIXME | 231 | if (!priv) |
233 | */ | 232 | return -ENOMEM; |
234 | 233 | ||
235 | /* allocate the private data structure */ | 234 | /* set initial values for control structures */ |
236 | for (i = 0; i < serial->num_ports; i++) { | 235 | priv->cfg.pktlen = 5; |
237 | priv = kmalloc(sizeof(struct klsi_105_private), | 236 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
238 | GFP_KERNEL); | 237 | priv->cfg.databits = kl5kusb105a_dtb_8; |
239 | if (!priv) { | 238 | priv->cfg.unknown1 = 0; |
240 | dev_dbg(&serial->interface->dev, | 239 | priv->cfg.unknown2 = 1; |
241 | "%s - kmalloc for klsi_105_private failed.\n", | ||
242 | __func__); | ||
243 | i--; | ||
244 | goto err_cleanup; | ||
245 | } | ||
246 | /* set initial values for control structures */ | ||
247 | priv->cfg.pktlen = 5; | ||
248 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
249 | priv->cfg.databits = kl5kusb105a_dtb_8; | ||
250 | priv->cfg.unknown1 = 0; | ||
251 | priv->cfg.unknown2 = 1; | ||
252 | 240 | ||
253 | priv->line_state = 0; | 241 | priv->line_state = 0; |
254 | 242 | ||
255 | usb_set_serial_port_data(serial->port[i], priv); | 243 | spin_lock_init(&priv->lock); |
256 | 244 | ||
257 | spin_lock_init(&priv->lock); | 245 | /* priv->termios is left uninitialized until port opening */ |
258 | 246 | ||
259 | /* priv->termios is left uninitialized until port opening */ | 247 | usb_set_serial_port_data(port, priv); |
260 | init_waitqueue_head(&serial->port[i]->write_wait); | ||
261 | } | ||
262 | 248 | ||
263 | return 0; | 249 | return 0; |
264 | |||
265 | err_cleanup: | ||
266 | for (; i >= 0; i--) { | ||
267 | priv = usb_get_serial_port_data(serial->port[i]); | ||
268 | kfree(priv); | ||
269 | usb_set_serial_port_data(serial->port[i], NULL); | ||
270 | } | ||
271 | return -ENOMEM; | ||
272 | } | 250 | } |
273 | 251 | ||
274 | static void klsi_105_release(struct usb_serial *serial) | 252 | static int klsi_105_port_remove(struct usb_serial_port *port) |
275 | { | 253 | { |
276 | int i; | 254 | struct klsi_105_private *priv; |
255 | |||
256 | priv = usb_get_serial_port_data(port); | ||
257 | kfree(priv); | ||
277 | 258 | ||
278 | for (i = 0; i < serial->num_ports; ++i) | 259 | return 0; |
279 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
280 | } | 260 | } |
281 | 261 | ||
282 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) | 262 | static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 5c4d2fbd4e11..c9ca7a5b12e0 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -54,8 +54,8 @@ | |||
54 | 54 | ||
55 | 55 | ||
56 | /* Function prototypes */ | 56 | /* Function prototypes */ |
57 | static int kobil_startup(struct usb_serial *serial); | 57 | static int kobil_port_probe(struct usb_serial_port *probe); |
58 | static void kobil_release(struct usb_serial *serial); | 58 | static int kobil_port_remove(struct usb_serial_port *probe); |
59 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); | 59 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); |
60 | static void kobil_close(struct usb_serial_port *port); | 60 | static void kobil_close(struct usb_serial_port *port); |
61 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | 61 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -89,8 +89,8 @@ static struct usb_serial_driver kobil_device = { | |||
89 | .description = "KOBIL USB smart card terminal", | 89 | .description = "KOBIL USB smart card terminal", |
90 | .id_table = id_table, | 90 | .id_table = id_table, |
91 | .num_ports = 1, | 91 | .num_ports = 1, |
92 | .attach = kobil_startup, | 92 | .port_probe = kobil_port_probe, |
93 | .release = kobil_release, | 93 | .port_remove = kobil_port_remove, |
94 | .ioctl = kobil_ioctl, | 94 | .ioctl = kobil_ioctl, |
95 | .set_termios = kobil_set_termios, | 95 | .set_termios = kobil_set_termios, |
96 | .init_termios = kobil_init_termios, | 96 | .init_termios = kobil_init_termios, |
@@ -117,9 +117,10 @@ struct kobil_private { | |||
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | static int kobil_startup(struct usb_serial *serial) | 120 | static int kobil_port_probe(struct usb_serial_port *port) |
121 | { | 121 | { |
122 | int i; | 122 | int i; |
123 | struct usb_serial *serial = port->serial; | ||
123 | struct kobil_private *priv; | 124 | struct kobil_private *priv; |
124 | struct usb_device *pdev; | 125 | struct usb_device *pdev; |
125 | struct usb_host_config *actconfig; | 126 | struct usb_host_config *actconfig; |
@@ -149,7 +150,7 @@ static int kobil_startup(struct usb_serial *serial) | |||
149 | dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); | 150 | dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); |
150 | break; | 151 | break; |
151 | } | 152 | } |
152 | usb_set_serial_port_data(serial->port[0], priv); | 153 | usb_set_serial_port_data(port, priv); |
153 | 154 | ||
154 | /* search for the necessary endpoints */ | 155 | /* search for the necessary endpoints */ |
155 | pdev = serial->dev; | 156 | pdev = serial->dev; |
@@ -179,12 +180,14 @@ static int kobil_startup(struct usb_serial *serial) | |||
179 | } | 180 | } |
180 | 181 | ||
181 | 182 | ||
182 | static void kobil_release(struct usb_serial *serial) | 183 | static int kobil_port_remove(struct usb_serial_port *port) |
183 | { | 184 | { |
184 | int i; | 185 | struct kobil_private *priv; |
185 | 186 | ||
186 | for (i = 0; i < serial->num_ports; ++i) | 187 | priv = usb_get_serial_port_data(port); |
187 | kfree(usb_get_serial_port_data(serial->port[i])); | 188 | kfree(priv); |
189 | |||
190 | return 0; | ||
188 | } | 191 | } |
189 | 192 | ||
190 | static void kobil_init_termios(struct tty_struct *tty) | 193 | static void kobil_init_termios(struct tty_struct *tty) |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 30cff03e9f01..54d4148d01d1 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -503,11 +503,19 @@ static const struct option_blacklist_info net_intf5_blacklist = { | |||
503 | .reserved = BIT(5), | 503 | .reserved = BIT(5), |
504 | }; | 504 | }; |
505 | 505 | ||
506 | static const struct option_blacklist_info net_intf6_blacklist = { | ||
507 | .reserved = BIT(6), | ||
508 | }; | ||
509 | |||
506 | static const struct option_blacklist_info zte_mf626_blacklist = { | 510 | static const struct option_blacklist_info zte_mf626_blacklist = { |
507 | .sendsetup = BIT(0) | BIT(1), | 511 | .sendsetup = BIT(0) | BIT(1), |
508 | .reserved = BIT(4), | 512 | .reserved = BIT(4), |
509 | }; | 513 | }; |
510 | 514 | ||
515 | static const struct option_blacklist_info zte_1255_blacklist = { | ||
516 | .reserved = BIT(3) | BIT(4), | ||
517 | }; | ||
518 | |||
511 | static const struct usb_device_id option_ids[] = { | 519 | static const struct usb_device_id option_ids[] = { |
512 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 520 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
513 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 521 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -853,13 +861,19 @@ static const struct usb_device_id option_ids[] = { | |||
853 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff), | 861 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff), |
854 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | 862 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, |
855 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) }, | 863 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) }, |
856 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) }, | 864 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff), |
857 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) }, | 865 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, |
866 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff), | ||
867 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | ||
858 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) }, | 868 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) }, |
859 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) }, | 869 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff), |
860 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) }, | 870 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
861 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) }, | 871 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff), |
862 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) }, | 872 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, |
873 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff), | ||
874 | .driver_info = (kernel_ulong_t)&net_intf6_blacklist }, | ||
875 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), | ||
876 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | ||
863 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, | 877 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, |
864 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, | 878 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, |
865 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, | 879 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, |
@@ -872,7 +886,8 @@ static const struct usb_device_id option_ids[] = { | |||
872 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, | 886 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, |
873 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), | 887 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), |
874 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | 888 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, |
875 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, | 889 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff), |
890 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | ||
876 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, | 891 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, |
877 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, | 892 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, |
878 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, | 893 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, |
@@ -880,13 +895,22 @@ static const struct usb_device_id option_ids[] = { | |||
880 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, | 895 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, |
881 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), | 896 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), |
882 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 897 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
898 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ | ||
899 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
900 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ | ||
901 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, | ||
902 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ | ||
903 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | ||
883 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), | 904 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), |
884 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 905 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
885 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), | 906 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), |
886 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 907 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
887 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), | 908 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), |
888 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 909 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
889 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, | 910 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), |
911 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
912 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), | ||
913 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
890 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, | 914 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, |
891 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, | 915 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, |
892 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, | 916 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, |
@@ -1002,18 +1026,24 @@ static const struct usb_device_id option_ids[] = { | |||
1002 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) }, | 1026 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) }, |
1003 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) }, | 1027 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) }, |
1004 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) }, | 1028 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) }, |
1005 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff) }, | 1029 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff), |
1030 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1006 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) }, | 1031 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) }, |
1007 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff) }, | 1032 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff), |
1033 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1008 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) }, | 1034 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) }, |
1009 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) }, | 1035 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) }, |
1010 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) }, | 1036 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) }, |
1011 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) }, | 1037 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) }, |
1012 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff) }, | 1038 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff), |
1039 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1013 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) }, | 1040 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) }, |
1014 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff) }, | 1041 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff), |
1015 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff) }, | 1042 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1016 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff) }, | 1043 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff), |
1044 | .driver_info = (kernel_ulong_t)&zte_1255_blacklist }, | ||
1045 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff), | ||
1046 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1017 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) }, | 1047 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) }, |
1018 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) }, | 1048 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) }, |
1019 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) }, | 1049 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) }, |
@@ -1058,8 +1088,16 @@ static const struct usb_device_id option_ids[] = { | |||
1058 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, | 1088 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, |
1059 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, | 1089 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, |
1060 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, | 1090 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, |
1091 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), | ||
1092 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
1061 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), | 1093 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), |
1062 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | 1094 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, |
1095 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff), | ||
1096 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
1097 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff), | ||
1098 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
1099 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ | ||
1100 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
1063 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, | 1101 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, |
1064 | 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, | 1102 | 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, |
1065 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, | 1103 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, |
@@ -1071,15 +1109,21 @@ static const struct usb_device_id option_ids[] = { | |||
1071 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, | 1109 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, |
1072 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, | 1110 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, |
1073 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, | 1111 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, |
1074 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) }, | 1112 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff), |
1075 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) }, | 1113 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, |
1076 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) }, | 1114 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff), |
1115 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | ||
1116 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff), | ||
1117 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | ||
1077 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) }, | 1118 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) }, |
1078 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) }, | 1119 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) }, |
1079 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) }, | 1120 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff), |
1121 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
1080 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) }, | 1122 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) }, |
1081 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) }, | 1123 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff), |
1082 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) }, | 1124 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, |
1125 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), | ||
1126 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | ||
1083 | 1127 | ||
1084 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, | 1128 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, |
1085 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, | 1129 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 933241f03fd8..cee9a52ca891 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -137,8 +137,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty); | |||
137 | static int oti6858_tiocmget(struct tty_struct *tty); | 137 | static int oti6858_tiocmget(struct tty_struct *tty); |
138 | static int oti6858_tiocmset(struct tty_struct *tty, | 138 | static int oti6858_tiocmset(struct tty_struct *tty, |
139 | unsigned int set, unsigned int clear); | 139 | unsigned int set, unsigned int clear); |
140 | static int oti6858_startup(struct usb_serial *serial); | 140 | static int oti6858_port_probe(struct usb_serial_port *port); |
141 | static void oti6858_release(struct usb_serial *serial); | 141 | static int oti6858_port_remove(struct usb_serial_port *port); |
142 | 142 | ||
143 | /* device info */ | 143 | /* device info */ |
144 | static struct usb_serial_driver oti6858_device = { | 144 | static struct usb_serial_driver oti6858_device = { |
@@ -161,8 +161,8 @@ static struct usb_serial_driver oti6858_device = { | |||
161 | .write_bulk_callback = oti6858_write_bulk_callback, | 161 | .write_bulk_callback = oti6858_write_bulk_callback, |
162 | .write_room = oti6858_write_room, | 162 | .write_room = oti6858_write_room, |
163 | .chars_in_buffer = oti6858_chars_in_buffer, | 163 | .chars_in_buffer = oti6858_chars_in_buffer, |
164 | .attach = oti6858_startup, | 164 | .port_probe = oti6858_port_probe, |
165 | .release = oti6858_release, | 165 | .port_remove = oti6858_port_remove, |
166 | }; | 166 | }; |
167 | 167 | ||
168 | static struct usb_serial_driver * const serial_drivers[] = { | 168 | static struct usb_serial_driver * const serial_drivers[] = { |
@@ -331,36 +331,33 @@ static void send_data(struct work_struct *work) | |||
331 | usb_serial_port_softint(port); | 331 | usb_serial_port_softint(port); |
332 | } | 332 | } |
333 | 333 | ||
334 | static int oti6858_startup(struct usb_serial *serial) | 334 | static int oti6858_port_probe(struct usb_serial_port *port) |
335 | { | 335 | { |
336 | struct usb_serial_port *port = serial->port[0]; | ||
337 | struct oti6858_private *priv; | 336 | struct oti6858_private *priv; |
338 | int i; | ||
339 | |||
340 | for (i = 0; i < serial->num_ports; ++i) { | ||
341 | priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); | ||
342 | if (!priv) | ||
343 | break; | ||
344 | |||
345 | spin_lock_init(&priv->lock); | ||
346 | init_waitqueue_head(&priv->intr_wait); | ||
347 | /* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */ | ||
348 | /* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */ | ||
349 | priv->port = port; | ||
350 | INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); | ||
351 | INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); | ||
352 | |||
353 | usb_set_serial_port_data(serial->port[i], priv); | ||
354 | } | ||
355 | if (i == serial->num_ports) | ||
356 | return 0; | ||
357 | 337 | ||
358 | for (--i; i >= 0; --i) { | 338 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
359 | priv = usb_get_serial_port_data(serial->port[i]); | 339 | if (!priv) |
360 | kfree(priv); | 340 | return -ENOMEM; |
361 | usb_set_serial_port_data(serial->port[i], NULL); | 341 | |
362 | } | 342 | spin_lock_init(&priv->lock); |
363 | return -ENOMEM; | 343 | init_waitqueue_head(&priv->intr_wait); |
344 | priv->port = port; | ||
345 | INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); | ||
346 | INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); | ||
347 | |||
348 | usb_set_serial_port_data(port, priv); | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | static int oti6858_port_remove(struct usb_serial_port *port) | ||
354 | { | ||
355 | struct oti6858_private *priv; | ||
356 | |||
357 | priv = usb_get_serial_port_data(port); | ||
358 | kfree(priv); | ||
359 | |||
360 | return 0; | ||
364 | } | 361 | } |
365 | 362 | ||
366 | static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, | 363 | static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -709,15 +706,6 @@ static int oti6858_ioctl(struct tty_struct *tty, | |||
709 | return -ENOIOCTLCMD; | 706 | return -ENOIOCTLCMD; |
710 | } | 707 | } |
711 | 708 | ||
712 | |||
713 | static void oti6858_release(struct usb_serial *serial) | ||
714 | { | ||
715 | int i; | ||
716 | |||
717 | for (i = 0; i < serial->num_ports; ++i) | ||
718 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
719 | } | ||
720 | |||
721 | static void oti6858_read_int_callback(struct urb *urb) | 709 | static void oti6858_read_int_callback(struct urb *urb) |
722 | { | 710 | { |
723 | struct usb_serial_port *port = urb->context; | 711 | struct usb_serial_port *port = urb->context; |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 892ebdc7a364..600241901361 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -133,12 +133,15 @@ enum pl2303_type { | |||
133 | HX, /* HX version of the pl2303 chip */ | 133 | HX, /* HX version of the pl2303 chip */ |
134 | }; | 134 | }; |
135 | 135 | ||
136 | struct pl2303_serial_private { | ||
137 | enum pl2303_type type; | ||
138 | }; | ||
139 | |||
136 | struct pl2303_private { | 140 | struct pl2303_private { |
137 | spinlock_t lock; | 141 | spinlock_t lock; |
138 | wait_queue_head_t delta_msr_wait; | 142 | wait_queue_head_t delta_msr_wait; |
139 | u8 line_control; | 143 | u8 line_control; |
140 | u8 line_status; | 144 | u8 line_status; |
141 | enum pl2303_type type; | ||
142 | }; | 145 | }; |
143 | 146 | ||
144 | static int pl2303_vendor_read(__u16 value, __u16 index, | 147 | static int pl2303_vendor_read(__u16 value, __u16 index, |
@@ -167,14 +170,19 @@ static int pl2303_vendor_write(__u16 value, __u16 index, | |||
167 | 170 | ||
168 | static int pl2303_startup(struct usb_serial *serial) | 171 | static int pl2303_startup(struct usb_serial *serial) |
169 | { | 172 | { |
170 | struct pl2303_private *priv; | 173 | struct pl2303_serial_private *spriv; |
171 | enum pl2303_type type = type_0; | 174 | enum pl2303_type type = type_0; |
172 | unsigned char *buf; | 175 | unsigned char *buf; |
173 | int i; | 176 | |
177 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); | ||
178 | if (!spriv) | ||
179 | return -ENOMEM; | ||
174 | 180 | ||
175 | buf = kmalloc(10, GFP_KERNEL); | 181 | buf = kmalloc(10, GFP_KERNEL); |
176 | if (buf == NULL) | 182 | if (!buf) { |
183 | kfree(spriv); | ||
177 | return -ENOMEM; | 184 | return -ENOMEM; |
185 | } | ||
178 | 186 | ||
179 | if (serial->dev->descriptor.bDeviceClass == 0x02) | 187 | if (serial->dev->descriptor.bDeviceClass == 0x02) |
180 | type = type_0; | 188 | type = type_0; |
@@ -186,15 +194,8 @@ static int pl2303_startup(struct usb_serial *serial) | |||
186 | type = type_1; | 194 | type = type_1; |
187 | dev_dbg(&serial->interface->dev, "device type: %d\n", type); | 195 | dev_dbg(&serial->interface->dev, "device type: %d\n", type); |
188 | 196 | ||
189 | for (i = 0; i < serial->num_ports; ++i) { | 197 | spriv->type = type; |
190 | priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); | 198 | usb_set_serial_data(serial, spriv); |
191 | if (!priv) | ||
192 | goto cleanup; | ||
193 | spin_lock_init(&priv->lock); | ||
194 | init_waitqueue_head(&priv->delta_msr_wait); | ||
195 | priv->type = type; | ||
196 | usb_set_serial_port_data(serial->port[i], priv); | ||
197 | } | ||
198 | 199 | ||
199 | pl2303_vendor_read(0x8484, 0, serial, buf); | 200 | pl2303_vendor_read(0x8484, 0, serial, buf); |
200 | pl2303_vendor_write(0x0404, 0, serial); | 201 | pl2303_vendor_write(0x0404, 0, serial); |
@@ -213,15 +214,40 @@ static int pl2303_startup(struct usb_serial *serial) | |||
213 | 214 | ||
214 | kfree(buf); | 215 | kfree(buf); |
215 | return 0; | 216 | return 0; |
217 | } | ||
216 | 218 | ||
217 | cleanup: | 219 | static void pl2303_release(struct usb_serial *serial) |
218 | kfree(buf); | 220 | { |
219 | for (--i; i >= 0; --i) { | 221 | struct pl2303_serial_private *spriv; |
220 | priv = usb_get_serial_port_data(serial->port[i]); | 222 | |
221 | kfree(priv); | 223 | spriv = usb_get_serial_data(serial); |
222 | usb_set_serial_port_data(serial->port[i], NULL); | 224 | kfree(spriv); |
223 | } | 225 | } |
224 | return -ENOMEM; | 226 | |
227 | static int pl2303_port_probe(struct usb_serial_port *port) | ||
228 | { | ||
229 | struct pl2303_private *priv; | ||
230 | |||
231 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
232 | if (!priv) | ||
233 | return -ENOMEM; | ||
234 | |||
235 | spin_lock_init(&priv->lock); | ||
236 | init_waitqueue_head(&priv->delta_msr_wait); | ||
237 | |||
238 | usb_set_serial_port_data(port, priv); | ||
239 | |||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | static int pl2303_port_remove(struct usb_serial_port *port) | ||
244 | { | ||
245 | struct pl2303_private *priv; | ||
246 | |||
247 | priv = usb_get_serial_port_data(port); | ||
248 | kfree(priv); | ||
249 | |||
250 | return 0; | ||
225 | } | 251 | } |
226 | 252 | ||
227 | static int set_control_lines(struct usb_device *dev, u8 value) | 253 | static int set_control_lines(struct usb_device *dev, u8 value) |
@@ -240,6 +266,7 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
240 | struct usb_serial_port *port, struct ktermios *old_termios) | 266 | struct usb_serial_port *port, struct ktermios *old_termios) |
241 | { | 267 | { |
242 | struct usb_serial *serial = port->serial; | 268 | struct usb_serial *serial = port->serial; |
269 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); | ||
243 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 270 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
244 | unsigned long flags; | 271 | unsigned long flags; |
245 | unsigned int cflag; | 272 | unsigned int cflag; |
@@ -323,7 +350,7 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
323 | } | 350 | } |
324 | if (baud > 1228800) { | 351 | if (baud > 1228800) { |
325 | /* type_0, type_1 only support up to 1228800 baud */ | 352 | /* type_0, type_1 only support up to 1228800 baud */ |
326 | if (priv->type != HX) | 353 | if (spriv->type != HX) |
327 | baud = 1228800; | 354 | baud = 1228800; |
328 | else if (baud > 6000000) | 355 | else if (baud > 6000000) |
329 | baud = 6000000; | 356 | baud = 6000000; |
@@ -426,7 +453,7 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
426 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); | 453 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); |
427 | 454 | ||
428 | if (cflag & CRTSCTS) { | 455 | if (cflag & CRTSCTS) { |
429 | if (priv->type == HX) | 456 | if (spriv->type == HX) |
430 | pl2303_vendor_write(0x0, 0x61, serial); | 457 | pl2303_vendor_write(0x0, 0x61, serial); |
431 | else | 458 | else |
432 | pl2303_vendor_write(0x0, 0x41, serial); | 459 | pl2303_vendor_write(0x0, 0x41, serial); |
@@ -468,10 +495,10 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
468 | { | 495 | { |
469 | struct ktermios tmp_termios; | 496 | struct ktermios tmp_termios; |
470 | struct usb_serial *serial = port->serial; | 497 | struct usb_serial *serial = port->serial; |
471 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 498 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); |
472 | int result; | 499 | int result; |
473 | 500 | ||
474 | if (priv->type != HX) { | 501 | if (spriv->type != HX) { |
475 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 502 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
476 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 503 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
477 | } else { | 504 | } else { |
@@ -655,17 +682,6 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state) | |||
655 | dev_err(&port->dev, "error sending break = %d\n", result); | 682 | dev_err(&port->dev, "error sending break = %d\n", result); |
656 | } | 683 | } |
657 | 684 | ||
658 | static void pl2303_release(struct usb_serial *serial) | ||
659 | { | ||
660 | int i; | ||
661 | struct pl2303_private *priv; | ||
662 | |||
663 | for (i = 0; i < serial->num_ports; ++i) { | ||
664 | priv = usb_get_serial_port_data(serial->port[i]); | ||
665 | kfree(priv); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | static void pl2303_update_line_status(struct usb_serial_port *port, | 685 | static void pl2303_update_line_status(struct usb_serial_port *port, |
670 | unsigned char *data, | 686 | unsigned char *data, |
671 | unsigned int actual_length) | 687 | unsigned int actual_length) |
@@ -827,6 +843,8 @@ static struct usb_serial_driver pl2303_device = { | |||
827 | .read_int_callback = pl2303_read_int_callback, | 843 | .read_int_callback = pl2303_read_int_callback, |
828 | .attach = pl2303_startup, | 844 | .attach = pl2303_startup, |
829 | .release = pl2303_release, | 845 | .release = pl2303_release, |
846 | .port_probe = pl2303_port_probe, | ||
847 | .port_remove = pl2303_port_remove, | ||
830 | }; | 848 | }; |
831 | 849 | ||
832 | static struct usb_serial_driver * const serial_drivers[] = { | 850 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 9716efe92955..769c137f8975 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -157,13 +157,10 @@ struct spcp8x5_private { | |||
157 | u8 line_status; | 157 | u8 line_status; |
158 | }; | 158 | }; |
159 | 159 | ||
160 | /* desc : when device plug in,this function would be called. | 160 | static int spcp8x5_port_probe(struct usb_serial_port *port) |
161 | * thanks to usb_serial subsystem,then do almost every things for us. And what | ||
162 | * we should do just alloc the buffer */ | ||
163 | static int spcp8x5_startup(struct usb_serial *serial) | ||
164 | { | 161 | { |
162 | struct usb_serial *serial = port->serial; | ||
165 | struct spcp8x5_private *priv; | 163 | struct spcp8x5_private *priv; |
166 | int i; | ||
167 | enum spcp8x5_type type = SPCP825_007_TYPE; | 164 | enum spcp8x5_type type = SPCP825_007_TYPE; |
168 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); | 165 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); |
169 | 166 | ||
@@ -180,34 +177,27 @@ static int spcp8x5_startup(struct usb_serial *serial) | |||
180 | type = SPCP825_PHILIP_TYPE; | 177 | type = SPCP825_PHILIP_TYPE; |
181 | dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); | 178 | dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); |
182 | 179 | ||
183 | for (i = 0; i < serial->num_ports; ++i) { | 180 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
184 | priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); | 181 | if (!priv) |
185 | if (!priv) | 182 | return -ENOMEM; |
186 | goto cleanup; | ||
187 | 183 | ||
188 | spin_lock_init(&priv->lock); | 184 | spin_lock_init(&priv->lock); |
189 | init_waitqueue_head(&priv->delta_msr_wait); | 185 | init_waitqueue_head(&priv->delta_msr_wait); |
190 | priv->type = type; | 186 | priv->type = type; |
191 | usb_set_serial_port_data(serial->port[i] , priv); | 187 | |
192 | } | 188 | usb_set_serial_port_data(port , priv); |
193 | 189 | ||
194 | return 0; | 190 | return 0; |
195 | cleanup: | ||
196 | for (--i; i >= 0; --i) { | ||
197 | priv = usb_get_serial_port_data(serial->port[i]); | ||
198 | kfree(priv); | ||
199 | usb_set_serial_port_data(serial->port[i] , NULL); | ||
200 | } | ||
201 | return -ENOMEM; | ||
202 | } | 191 | } |
203 | 192 | ||
204 | /* call when the device plug out. free all the memory alloced by probe */ | 193 | static int spcp8x5_port_remove(struct usb_serial_port *port) |
205 | static void spcp8x5_release(struct usb_serial *serial) | ||
206 | { | 194 | { |
207 | int i; | 195 | struct spcp8x5_private *priv; |
208 | 196 | ||
209 | for (i = 0; i < serial->num_ports; i++) | 197 | priv = usb_get_serial_port_data(port); |
210 | kfree(usb_get_serial_port_data(serial->port[i])); | 198 | kfree(priv); |
199 | |||
200 | return 0; | ||
211 | } | 201 | } |
212 | 202 | ||
213 | /* set the modem control line of the device. | 203 | /* set the modem control line of the device. |
@@ -649,8 +639,8 @@ static struct usb_serial_driver spcp8x5_device = { | |||
649 | .ioctl = spcp8x5_ioctl, | 639 | .ioctl = spcp8x5_ioctl, |
650 | .tiocmget = spcp8x5_tiocmget, | 640 | .tiocmget = spcp8x5_tiocmget, |
651 | .tiocmset = spcp8x5_tiocmset, | 641 | .tiocmset = spcp8x5_tiocmset, |
652 | .attach = spcp8x5_startup, | 642 | .port_probe = spcp8x5_port_probe, |
653 | .release = spcp8x5_release, | 643 | .port_remove = spcp8x5_port_remove, |
654 | .process_read_urb = spcp8x5_process_read_urb, | 644 | .process_read_urb = spcp8x5_process_read_urb, |
655 | }; | 645 | }; |
656 | 646 | ||
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 015810b3785b..868d1e6852e2 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -67,13 +67,6 @@ struct ssu100_port_private { | |||
67 | struct async_icount icount; | 67 | struct async_icount icount; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static void ssu100_release(struct usb_serial *serial) | ||
71 | { | ||
72 | struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port); | ||
73 | |||
74 | kfree(priv); | ||
75 | } | ||
76 | |||
77 | static inline int ssu100_control_msg(struct usb_device *dev, | 70 | static inline int ssu100_control_msg(struct usb_device *dev, |
78 | u8 request, u16 data, u16 index) | 71 | u8 request, u16 data, u16 index) |
79 | { | 72 | { |
@@ -442,21 +435,33 @@ static int ssu100_ioctl(struct tty_struct *tty, | |||
442 | 435 | ||
443 | static int ssu100_attach(struct usb_serial *serial) | 436 | static int ssu100_attach(struct usb_serial *serial) |
444 | { | 437 | { |
438 | return ssu100_initdevice(serial->dev); | ||
439 | } | ||
440 | |||
441 | static int ssu100_port_probe(struct usb_serial_port *port) | ||
442 | { | ||
445 | struct ssu100_port_private *priv; | 443 | struct ssu100_port_private *priv; |
446 | struct usb_serial_port *port = *serial->port; | ||
447 | 444 | ||
448 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 445 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
449 | if (!priv) { | 446 | if (!priv) |
450 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, | ||
451 | sizeof(*priv)); | ||
452 | return -ENOMEM; | 447 | return -ENOMEM; |
453 | } | ||
454 | 448 | ||
455 | spin_lock_init(&priv->status_lock); | 449 | spin_lock_init(&priv->status_lock); |
456 | init_waitqueue_head(&priv->delta_msr_wait); | 450 | init_waitqueue_head(&priv->delta_msr_wait); |
451 | |||
457 | usb_set_serial_port_data(port, priv); | 452 | usb_set_serial_port_data(port, priv); |
458 | 453 | ||
459 | return ssu100_initdevice(serial->dev); | 454 | return 0; |
455 | } | ||
456 | |||
457 | static int ssu100_port_remove(struct usb_serial_port *port) | ||
458 | { | ||
459 | struct ssu100_port_private *priv; | ||
460 | |||
461 | priv = usb_get_serial_port_data(port); | ||
462 | kfree(priv); | ||
463 | |||
464 | return 0; | ||
460 | } | 465 | } |
461 | 466 | ||
462 | static int ssu100_tiocmget(struct tty_struct *tty) | 467 | static int ssu100_tiocmget(struct tty_struct *tty) |
@@ -647,7 +652,8 @@ static struct usb_serial_driver ssu100_device = { | |||
647 | .open = ssu100_open, | 652 | .open = ssu100_open, |
648 | .close = ssu100_close, | 653 | .close = ssu100_close, |
649 | .attach = ssu100_attach, | 654 | .attach = ssu100_attach, |
650 | .release = ssu100_release, | 655 | .port_probe = ssu100_port_probe, |
656 | .port_remove = ssu100_port_remove, | ||
651 | .dtr_rts = ssu100_dtr_rts, | 657 | .dtr_rts = ssu100_dtr_rts, |
652 | .process_read_urb = ssu100_process_read_urb, | 658 | .process_read_urb = ssu100_process_read_urb, |
653 | .tiocmget = ssu100_tiocmget, | 659 | .tiocmget = ssu100_tiocmget, |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 6f49392cda5b..f2530d2ef3c4 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -97,6 +97,8 @@ struct ti_device { | |||
97 | 97 | ||
98 | static int ti_startup(struct usb_serial *serial); | 98 | static int ti_startup(struct usb_serial *serial); |
99 | static void ti_release(struct usb_serial *serial); | 99 | static void ti_release(struct usb_serial *serial); |
100 | static int ti_port_probe(struct usb_serial_port *port); | ||
101 | static int ti_port_remove(struct usb_serial_port *port); | ||
100 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port); | 102 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port); |
101 | static void ti_close(struct usb_serial_port *port); | 103 | static void ti_close(struct usb_serial_port *port); |
102 | static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, | 104 | static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -221,6 +223,8 @@ static struct usb_serial_driver ti_1port_device = { | |||
221 | .num_ports = 1, | 223 | .num_ports = 1, |
222 | .attach = ti_startup, | 224 | .attach = ti_startup, |
223 | .release = ti_release, | 225 | .release = ti_release, |
226 | .port_probe = ti_port_probe, | ||
227 | .port_remove = ti_port_remove, | ||
224 | .open = ti_open, | 228 | .open = ti_open, |
225 | .close = ti_close, | 229 | .close = ti_close, |
226 | .write = ti_write, | 230 | .write = ti_write, |
@@ -249,6 +253,8 @@ static struct usb_serial_driver ti_2port_device = { | |||
249 | .num_ports = 2, | 253 | .num_ports = 2, |
250 | .attach = ti_startup, | 254 | .attach = ti_startup, |
251 | .release = ti_release, | 255 | .release = ti_release, |
256 | .port_probe = ti_port_probe, | ||
257 | .port_remove = ti_port_remove, | ||
252 | .open = ti_open, | 258 | .open = ti_open, |
253 | .close = ti_close, | 259 | .close = ti_close, |
254 | .write = ti_write, | 260 | .write = ti_write, |
@@ -347,11 +353,8 @@ module_exit(ti_exit); | |||
347 | static int ti_startup(struct usb_serial *serial) | 353 | static int ti_startup(struct usb_serial *serial) |
348 | { | 354 | { |
349 | struct ti_device *tdev; | 355 | struct ti_device *tdev; |
350 | struct ti_port *tport; | ||
351 | struct usb_device *dev = serial->dev; | 356 | struct usb_device *dev = serial->dev; |
352 | int status; | 357 | int status; |
353 | int i; | ||
354 | |||
355 | 358 | ||
356 | dev_dbg(&dev->dev, | 359 | dev_dbg(&dev->dev, |
357 | "%s - product 0x%4X, num configurations %d, configuration value %d", | 360 | "%s - product 0x%4X, num configurations %d, configuration value %d", |
@@ -399,42 +402,8 @@ static int ti_startup(struct usb_serial *serial) | |||
399 | goto free_tdev; | 402 | goto free_tdev; |
400 | } | 403 | } |
401 | 404 | ||
402 | /* set up port structures */ | ||
403 | for (i = 0; i < serial->num_ports; ++i) { | ||
404 | tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL); | ||
405 | if (tport == NULL) { | ||
406 | dev_err(&dev->dev, "%s - out of memory\n", __func__); | ||
407 | status = -ENOMEM; | ||
408 | goto free_tports; | ||
409 | } | ||
410 | spin_lock_init(&tport->tp_lock); | ||
411 | tport->tp_uart_base_addr = (i == 0 ? | ||
412 | TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); | ||
413 | tport->tp_closing_wait = closing_wait; | ||
414 | init_waitqueue_head(&tport->tp_msr_wait); | ||
415 | init_waitqueue_head(&tport->tp_write_wait); | ||
416 | if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, | ||
417 | GFP_KERNEL)) { | ||
418 | dev_err(&dev->dev, "%s - out of memory\n", __func__); | ||
419 | kfree(tport); | ||
420 | status = -ENOMEM; | ||
421 | goto free_tports; | ||
422 | } | ||
423 | tport->tp_port = serial->port[i]; | ||
424 | tport->tp_tdev = tdev; | ||
425 | usb_set_serial_port_data(serial->port[i], tport); | ||
426 | tport->tp_uart_mode = 0; /* default is RS232 */ | ||
427 | } | ||
428 | |||
429 | return 0; | 405 | return 0; |
430 | 406 | ||
431 | free_tports: | ||
432 | for (--i; i >= 0; --i) { | ||
433 | tport = usb_get_serial_port_data(serial->port[i]); | ||
434 | kfifo_free(&tport->write_fifo); | ||
435 | kfree(tport); | ||
436 | usb_set_serial_port_data(serial->port[i], NULL); | ||
437 | } | ||
438 | free_tdev: | 407 | free_tdev: |
439 | kfree(tdev); | 408 | kfree(tdev); |
440 | usb_set_serial_data(serial, NULL); | 409 | usb_set_serial_data(serial, NULL); |
@@ -444,21 +413,50 @@ free_tdev: | |||
444 | 413 | ||
445 | static void ti_release(struct usb_serial *serial) | 414 | static void ti_release(struct usb_serial *serial) |
446 | { | 415 | { |
447 | int i; | ||
448 | struct ti_device *tdev = usb_get_serial_data(serial); | 416 | struct ti_device *tdev = usb_get_serial_data(serial); |
417 | |||
418 | kfree(tdev); | ||
419 | } | ||
420 | |||
421 | static int ti_port_probe(struct usb_serial_port *port) | ||
422 | { | ||
449 | struct ti_port *tport; | 423 | struct ti_port *tport; |
450 | 424 | ||
451 | for (i = 0; i < serial->num_ports; ++i) { | 425 | tport = kzalloc(sizeof(*tport), GFP_KERNEL); |
452 | tport = usb_get_serial_port_data(serial->port[i]); | 426 | if (!tport) |
453 | if (tport) { | 427 | return -ENOMEM; |
454 | kfifo_free(&tport->write_fifo); | 428 | |
455 | kfree(tport); | 429 | spin_lock_init(&tport->tp_lock); |
456 | } | 430 | if (port == port->serial->port[0]) |
431 | tport->tp_uart_base_addr = TI_UART1_BASE_ADDR; | ||
432 | else | ||
433 | tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; | ||
434 | tport->tp_closing_wait = closing_wait; | ||
435 | init_waitqueue_head(&tport->tp_msr_wait); | ||
436 | init_waitqueue_head(&tport->tp_write_wait); | ||
437 | if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) { | ||
438 | kfree(tport); | ||
439 | return -ENOMEM; | ||
457 | } | 440 | } |
441 | tport->tp_port = port; | ||
442 | tport->tp_tdev = usb_get_serial_data(port->serial); | ||
443 | tport->tp_uart_mode = 0; /* default is RS232 */ | ||
458 | 444 | ||
459 | kfree(tdev); | 445 | usb_set_serial_port_data(port, tport); |
446 | |||
447 | return 0; | ||
460 | } | 448 | } |
461 | 449 | ||
450 | static int ti_port_remove(struct usb_serial_port *port) | ||
451 | { | ||
452 | struct ti_port *tport; | ||
453 | |||
454 | tport = usb_get_serial_port_data(port); | ||
455 | kfifo_free(&tport->write_fifo); | ||
456 | kfree(tport); | ||
457 | |||
458 | return 0; | ||
459 | } | ||
462 | 460 | ||
463 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) | 461 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) |
464 | { | 462 | { |