Commit 8d244aa7 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge kroah.com:/home/linux/linux/BK/bleeding-2.5

into kroah.com:/home/linux/linux/BK/gregkh-2.5
parents 99a6e15b 3ff3774f
In Linux 2.5 kernels (and later), USB device drivers have additional control
over how DMA may be used to perform I/O operations. The APIs are detailed
in the kernel usb programming guide (kerneldoc, from the source code).
API OVERVIEW
The big picture is that USB drivers can continue to ignore most DMA issues,
though they still must provide DMA-ready buffers (see DMA-mapping.txt).
That's how they've worked through the 2.4 (and earlier) kernels.
OR: they can now be DMA-aware.
- New calls enable DMA-aware drivers, letting them allocate dma buffers and
manage dma mappings for existing dma-ready buffers (see below).
- URBs have an additional "transfer_dma" field, as well as a transfer_flags
bit saying if it's valid. (Control requests also needed "setup_dma".)
- "usbcore" will map those DMA addresses, if a DMA-aware driver didn't do it
first and set URB_NO_DMA_MAP. HCDs don't manage dma mappings for urbs.
- There's a new "generic DMA API", parts of which are usable by USB device
drivers. Never use dma_set_mask() on any USB interface or device; that
would potentially break all devices sharing that bus.
ELIMINATING COPIES
It's good to avoid making CPUs copy data needlessly. The costs can add up,
and effects like cache-trashing can impose subtle penalties.
- When you're allocating a buffer for DMA purposes anyway, use the buffer
primitives. Think of them as kmalloc and kfree that give you the right
kind of addresses to store in urb->transfer_buffer and urb->transfer_dma,
while guaranteeing that hidden copies through DMA "bounce" buffers won't
slow things down. You'd also set URB_NO_DMA_MAP in urb->transfer_flags:
void *usb_buffer_alloc (struct usb_device *dev, size_t size,
int mem_flags, dma_addr_t *dma);
void usb_buffer_free (struct usb_device *dev, size_t size,
void *addr, dma_addr_t dma);
The memory buffer returned is "dma-coherent"; sometimes you might need to
force a consistent memory access ordering by using memory barriers. It's
not using a streaming DMA mapping, so it's good for small transfers on
systems where the I/O would otherwise tie up an IOMMU mapping.
Asking for 1/Nth of a page (as well as asking for N pages) is reasonably
space-efficient.
- Devices on some EHCI controllers could handle DMA to/from high memory.
Driver probe() routines can notice this using a generic DMA call, then
tell higher level code (network, scsi, etc) about it like this:
if (dma_supported (&intf->dev, 0xffffffffffffffffULL))
net->features |= NETIF_F_HIGHDMA;
That can eliminate dma bounce buffering of requests that originate (or
terminate) in high memory, in cases where the buffers aren't allocated
with usb_buffer_alloc() but instead are dma-mapped.
WORKING WITH EXISTING BUFFERS
Existing buffers aren't usable for DMA without first being mapped into the
DMA address space of the device.
- When you're using scatterlists, you can map everything at once. On some
systems, this kicks in an IOMMU and turns the scatterlists into single
DMA transactions:
int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents);
void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);
void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);
It's probably easier to use the new usb_sg_*() calls, which do the DMA
mapping and apply other tweaks to make scatterlist i/o be fast.
- Some drivers may prefer to work with the model that they're mapping large
buffers, synchronizing their safe re-use. (If there's no re-use, then let
usbcore do the map/unmap.) Large periodic transfers make good examples
here, since it's cheaper to just synchronize the buffer than to unmap it
each time an urb completes and then re-map it on during resubmission.
These calls all work with initialized urbs: urb->dev, urb->pipe,
urb->transfer_buffer, and urb->transfer_buffer_length must all be
valid when these calls are used:
struct urb *usb_buffer_map (struct urb *urb);
void usb_buffer_dmasync (struct urb *urb);
void usb_buffer_unmap (struct urb *urb);
The calls manage urb->transfer_dma for you, and set URB_NO_DMA_MAP so that
usbcore won't map or unmap the buffer.
...@@ -91,27 +91,27 @@ HandSpring Visor, Palm USB, and Cli ...@@ -91,27 +91,27 @@ HandSpring Visor, Palm USB, and Cli
Kroah-Hartman at greg@kroah.com Kroah-Hartman at greg@kroah.com
Compaq iPAQ, HP Jornada and Casio EM500 driver PocketPC PDA Driver
This driver can be used to connect to Compaq iPAQ, HP Jornada and Casio EM500 This driver can be used to connect to Compaq iPAQ, HP Jornada, Casio EM500
PDAs running Windows CE 3.0 or PocketPC 2002 using a USB cable/cradle. and other PDAs running Windows CE 3.0 or PocketPC 2002 using a USB
It's very likely that every device supported by ActiveSync USB works with this cable/cradle.
driver. The driver supports the Compaq iPAQ, Jornada 548/568 and the Casio Most devices supported by ActiveSync are supported out of the box.
EM500 out of the box. For others, please use module parameters to specify For others, please use module parameters to specify the product and vendor
the product and vendor id. e.g. modprobe ipaq vendor=0x3f0 product=0x1125 id. e.g. modprobe ipaq vendor=0x3f0 product=0x1125
The driver presents a serial interface (usually on /dev/ttyUSB0) over The driver presents a serial interface (usually on /dev/ttyUSB0) over
which one may run ppp and establish a TCP/IP link to the iPAQ. Once this which one may run ppp and establish a TCP/IP link to the PDA. Once this
is done, you can transfer files, backup, download email etc. The most is done, you can transfer files, backup, download email etc. The most
significant advantage of using USB is speed - you can get 73 to 113 significant advantage of using USB is speed - I can get 73 to 113
kbytes/sec for download/upload to the iPAQ. kbytes/sec for download/upload to my iPAQ.
This driver is only one of a set of components required to utilize This driver is only one of a set of components required to utilize
the USB connection. Please visit http://synce.sourceforge.net which the USB connection. Please visit http://synce.sourceforge.net which
contains the necessary packages and a simple step-by-step howto. contains the necessary packages and a simple step-by-step howto.
Once connected, you can use Win CE programs like ftpView, Pocket Outlook Once connected, you can use Win CE programs like ftpView, Pocket Outlook
from the iPAQ and xcerdisp, synce utilities from the Linux side. from the PDA and xcerdisp, synce utilities from the Linux side.
To use Pocket IE, follow the instructions given at To use Pocket IE, follow the instructions given at
http://www.tekguru.co.uk/EM500/usbtonet.htm to achieve the same thing http://www.tekguru.co.uk/EM500/usbtonet.htm to achieve the same thing
...@@ -126,8 +126,18 @@ Compaq iPAQ, HP Jornada and Casio EM500 driver ...@@ -126,8 +126,18 @@ Compaq iPAQ, HP Jornada and Casio EM500 driver
If it doesn't work for some reason, load both the usbserial and ipaq module If it doesn't work for some reason, load both the usbserial and ipaq module
with the module parameter "debug" set to 1 and examine the system log. with the module parameter "debug" set to 1 and examine the system log.
You can also try soft-resetting your iPAQ before attempting a connection. You can also try soft-resetting your PDA before attempting a connection.
Other functionality may be possible depending on your PDA. According to
Wes Cilldhaire <billybobjoehenrybob@hotmail.com>, with the Toshiba E570,
...if you boot into the bootloader (hold down the power when hitting the
reset button, continuing to hold onto the power until the bootloader screen
is displayed), then put it in the cradle with the ipaq driver loaded, open
a terminal on /dev/ttyUSB0, it gives you a "USB Reflash" terminal, which can
be used to flash the ROM, as well as the microP code.. so much for needing
Toshiba's $350 serial cable for flashing!! :D
NOTE: This has NOT been tested. Use at your own risk.
For any questions or problems with the driver, please contact Ganesh For any questions or problems with the driver, please contact Ganesh
Varadarajan <ganesh@veritas.com> Varadarajan <ganesh@veritas.com>
......
...@@ -152,7 +152,7 @@ static void led_blink(struct st5481_adapter *adapter) ...@@ -152,7 +152,7 @@ static void led_blink(struct st5481_adapter *adapter)
st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL); st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL);
} }
static void usb_b_out_complete(struct urb *urb) static void usb_b_out_complete(struct urb *urb, struct pt_regs *regs)
{ {
struct st5481_bcs *bcs = urb->context; struct st5481_bcs *bcs = urb->context;
struct st5481_b_out *b_out = &bcs->b_out; struct st5481_b_out *b_out = &bcs->b_out;
......
...@@ -370,7 +370,7 @@ static void fifo_reseted(void *context) ...@@ -370,7 +370,7 @@ static void fifo_reseted(void *context)
FsmEvent(&adapter->d_out.fsm, EV_DOUT_RESETED, NULL); FsmEvent(&adapter->d_out.fsm, EV_DOUT_RESETED, NULL);
} }
static void usb_d_out_complete(struct urb *urb) static void usb_d_out_complete(struct urb *urb, struct pt_regs *regs)
{ {
struct st5481_adapter *adapter = urb->context; struct st5481_adapter *adapter = urb->context;
struct st5481_d_out *d_out = &adapter->d_out; struct st5481_d_out *d_out = &adapter->d_out;
......
...@@ -474,7 +474,7 @@ void st5481_release_isocpipes(struct urb* urb[2]) ...@@ -474,7 +474,7 @@ void st5481_release_isocpipes(struct urb* urb[2])
* called 50 times per second with 20 ISOC descriptors. * called 50 times per second with 20 ISOC descriptors.
* Called at interrupt. * Called at interrupt.
*/ */
static void usb_in_complete(struct urb *urb) static void usb_in_complete(struct urb *urb, struct pt_regs *regs)
{ {
struct st5481_in *in = urb->context; struct st5481_in *in = urb->context;
unsigned char *ptr; unsigned char *ptr;
......
...@@ -24,11 +24,14 @@ ...@@ -24,11 +24,14 @@
/* /*
* DMA-Consistent Buffers * DMA-Coherent Buffers
*/ */
/* FIXME tune these based on pool statistics ... */ /* FIXME tune these based on pool statistics ... */
static const size_t pool_max [HCD_BUFFER_POOLS] = { static const size_t pool_max [HCD_BUFFER_POOLS] = {
/* platforms without dma-friendly caches might need to
* prevent cacheline sharing...
*/
32, 32,
128, 128,
512, 512,
...@@ -133,98 +136,3 @@ void hcd_buffer_free ( ...@@ -133,98 +136,3 @@ void hcd_buffer_free (
} }
pci_free_consistent (hcd->pdev, size, addr, dma); pci_free_consistent (hcd->pdev, size, addr, dma);
} }
/*
* DMA-Mappings for arbitrary memory buffers
*/
int hcd_buffer_map (
struct usb_bus *bus,
void *addr,
dma_addr_t *dma,
size_t size,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
// FIXME pci_map_single() has no standard failure mode!
*dma = pci_map_single (hcd->pdev, addr, size,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
return 0;
}
void hcd_buffer_dmasync (
struct usb_bus *bus,
dma_addr_t dma,
size_t size,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
pci_dma_sync_single (hcd->pdev, dma, size,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
}
void hcd_buffer_unmap (
struct usb_bus *bus,
dma_addr_t dma,
size_t size,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
pci_unmap_single (hcd->pdev, dma, size,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
}
int hcd_buffer_map_sg (
struct usb_bus *bus,
struct scatterlist *sg,
int *n_hw_ents,
int nents,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
// FIXME pci_map_sg() has no standard failure mode!
*n_hw_ents = pci_map_sg(hcd->pdev, sg, nents,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
return 0;
}
void hcd_buffer_sync_sg (
struct usb_bus *bus,
struct scatterlist *sg,
int n_hw_ents,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
pci_dma_sync_sg(hcd->pdev, sg, n_hw_ents,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
}
void hcd_buffer_unmap_sg (
struct usb_bus *bus,
struct scatterlist *sg,
int n_hw_ents,
int direction
) {
struct usb_hcd *hcd = bus->hcpriv;
pci_unmap_sg(hcd->pdev, sg, n_hw_ents,
(direction == USB_DIR_IN)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
}
...@@ -138,7 +138,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -138,7 +138,8 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
hcd->pdev = dev; hcd->pdev = dev;
hcd->self.bus_name = dev->slot_name; hcd->self.bus_name = dev->slot_name;
hcd->product_desc = dev->dev.name; hcd->product_desc = dev->dev.name;
hcd->controller = &dev->dev; hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
if ((retval = hcd_buffer_create (hcd)) != 0) { if ((retval = hcd_buffer_create (hcd)) != 0) {
clean_3: clean_3:
......
...@@ -1031,19 +1031,19 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags) ...@@ -1031,19 +1031,19 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags)
/* lower level hcd code should use *_dma exclusively */ /* lower level hcd code should use *_dma exclusively */
if (!(urb->transfer_flags & URB_NO_DMA_MAP)) { if (!(urb->transfer_flags & URB_NO_DMA_MAP)) {
if (usb_pipecontrol (urb->pipe)) if (usb_pipecontrol (urb->pipe))
urb->setup_dma = pci_map_single ( urb->setup_dma = dma_map_single (
hcd->pdev, hcd->controller,
urb->setup_packet, urb->setup_packet,
sizeof (struct usb_ctrlrequest), sizeof (struct usb_ctrlrequest),
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
if (urb->transfer_buffer_length != 0) if (urb->transfer_buffer_length != 0)
urb->transfer_dma = pci_map_single ( urb->transfer_dma = dma_map_single (
hcd->pdev, hcd->controller,
urb->transfer_buffer, urb->transfer_buffer,
urb->transfer_buffer_length, urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
? PCI_DMA_FROMDEVICE ? DMA_FROM_DEVICE
: PCI_DMA_TODEVICE); : DMA_TO_DEVICE);
} }
status = hcd->driver->urb_enqueue (hcd, urb, mem_flags); status = hcd->driver->urb_enqueue (hcd, urb, mem_flags);
...@@ -1265,12 +1265,6 @@ struct usb_operations usb_hcd_operations = { ...@@ -1265,12 +1265,6 @@ struct usb_operations usb_hcd_operations = {
.deallocate = hcd_free_dev, .deallocate = hcd_free_dev,
.buffer_alloc = hcd_buffer_alloc, .buffer_alloc = hcd_buffer_alloc,
.buffer_free = hcd_buffer_free, .buffer_free = hcd_buffer_free,
.buffer_map = hcd_buffer_map,
.buffer_dmasync = hcd_buffer_dmasync,
.buffer_unmap = hcd_buffer_unmap,
.buffer_map_sg = hcd_buffer_map_sg,
.buffer_dmasync_sg = hcd_buffer_sync_sg,
.buffer_unmap_sg = hcd_buffer_unmap_sg,
}; };
EXPORT_SYMBOL (usb_hcd_operations); EXPORT_SYMBOL (usb_hcd_operations);
......
...@@ -145,26 +145,6 @@ struct usb_operations { ...@@ -145,26 +145,6 @@ struct usb_operations {
dma_addr_t *dma); dma_addr_t *dma);
void (*buffer_free)(struct usb_bus *bus, size_t size, void (*buffer_free)(struct usb_bus *bus, size_t size,
void *addr, dma_addr_t dma); void *addr, dma_addr_t dma);
int (*buffer_map) (struct usb_bus *bus,
void *addr, dma_addr_t *dma,
size_t size, int direction);
void (*buffer_dmasync) (struct usb_bus *bus,
dma_addr_t dma,
size_t size, int direction);
void (*buffer_unmap) (struct usb_bus *bus,
dma_addr_t dma,
size_t size, int direction);
int (*buffer_map_sg) (struct usb_bus *bus,
struct scatterlist *sg, int *n_hw_ents,
int nents, int direction);
void (*buffer_dmasync_sg) (struct usb_bus *bus,
struct scatterlist *sg,
int n_hw_ents, int direction);
void (*buffer_unmap_sg) (struct usb_bus *bus,
struct scatterlist *sg,
int n_hw_ents, int direction);
}; };
/* each driver provides one of these, and hardware init support */ /* each driver provides one of these, and hardware init support */
...@@ -248,23 +228,6 @@ void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, ...@@ -248,23 +228,6 @@ void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,
void hcd_buffer_free (struct usb_bus *bus, size_t size, void hcd_buffer_free (struct usb_bus *bus, size_t size,
void *addr, dma_addr_t dma); void *addr, dma_addr_t dma);
int hcd_buffer_map (struct usb_bus *bus,
void *addr, dma_addr_t *dma,
size_t size, int direction);
void hcd_buffer_dmasync (struct usb_bus *bus,
dma_addr_t dma,
size_t size, int direction);
void hcd_buffer_unmap (struct usb_bus *bus,
dma_addr_t dma,
size_t size, int direction);
int hcd_buffer_map_sg (struct usb_bus *bus, struct scatterlist *sg,
int *n_hw_ents, int nents, int direction);
void hcd_buffer_sync_sg (struct usb_bus *bus, struct scatterlist *sg,
int n_hw_ents, int direction);
void hcd_buffer_unmap_sg (struct usb_bus *bus, struct scatterlist *sg,
int n_hw_ents, int direction);
/* generic bus glue, needed for host controllers that don't use PCI */ /* generic bus glue, needed for host controllers that don't use PCI */
extern struct usb_operations usb_hcd_operations; extern struct usb_operations usb_hcd_operations;
extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r); extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
#endif #endif
#include <linux/usb.h> #include <linux/usb.h>
#include <asm/io.h>
#include <asm/scatterlist.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include "hcd.h" #include "hcd.h"
#include "usb.h" #include "usb.h"
...@@ -293,7 +298,7 @@ void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface ...@@ -293,7 +298,7 @@ void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface
dbg("%s driver claimed interface %p", driver->name, iface); dbg("%s driver claimed interface %p", driver->name, iface);
iface->driver = driver; iface->driver = driver;
iface->private_data = priv; usb_set_intfdata(iface, priv);
} }
/** /**
...@@ -336,7 +341,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac ...@@ -336,7 +341,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac
return; return;
iface->driver = NULL; iface->driver = NULL;
iface->private_data = NULL; usb_set_intfdata(iface, NULL);
} }
/** /**
...@@ -803,7 +808,7 @@ void usb_disconnect(struct usb_device **pdev) ...@@ -803,7 +808,7 @@ void usb_disconnect(struct usb_device **pdev)
*pdev = NULL; *pdev = NULL;
info("USB disconnect on device %d", dev->devnum); dev_info (dev->dev, "USB disconnect, address %d\n", dev->devnum);
/* Free up all the children before we remove this device */ /* Free up all the children before we remove this device */
for (i = 0; i < USB_MAXCHILDREN; i++) { for (i = 0; i < USB_MAXCHILDREN; i++) {
...@@ -812,7 +817,7 @@ void usb_disconnect(struct usb_device **pdev) ...@@ -812,7 +817,7 @@ void usb_disconnect(struct usb_device **pdev)
usb_disconnect(child); usb_disconnect(child);
} }
dbg ("unregistering interfaces on device %d", dev->devnum); dev_dbg (dev->dev, "unregistering interfaces\n");
if (dev->actconfig) { if (dev->actconfig) {
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
struct usb_interface *interface = &dev->actconfig->interface[i]; struct usb_interface *interface = &dev->actconfig->interface[i];
...@@ -822,7 +827,7 @@ void usb_disconnect(struct usb_device **pdev) ...@@ -822,7 +827,7 @@ void usb_disconnect(struct usb_device **pdev)
} }
} }
dbg ("unregistering the device %d", dev->devnum); dev_dbg (dev->dev, "unregistering device\n");
/* Free the device number and remove the /proc/bus/usb entry */ /* Free the device number and remove the /proc/bus/usb entry */
if (dev->devnum > 0) { if (dev->devnum > 0) {
clear_bit(dev->devnum, dev->bus->devmap.devicemap); clear_bit(dev->devnum, dev->bus->devmap.devicemap);
...@@ -980,6 +985,9 @@ int usb_new_device(struct usb_device *dev, struct device *parent) ...@@ -980,6 +985,9 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
sprintf (&dev->dev.bus_id[0], "%d-%s", sprintf (&dev->dev.bus_id[0], "%d-%s",
dev->bus->busnum, dev->devpath); dev->bus->busnum, dev->devpath);
/* dma masks come from the controller; readonly, except to hcd */
dev->dev.dma_mask = parent->dma_mask;
/* USB device state == default ... it's not usable yet */ /* USB device state == default ... it's not usable yet */
/* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
...@@ -1104,6 +1112,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) ...@@ -1104,6 +1112,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
interface->dev.parent = &dev->dev; interface->dev.parent = &dev->dev;
interface->dev.driver = NULL; interface->dev.driver = NULL;
interface->dev.bus = &usb_bus_type; interface->dev.bus = &usb_bus_type;
interface->dev.dma_mask = parent->dma_mask;
sprintf (&interface->dev.bus_id[0], "%d-%s:%d", sprintf (&interface->dev.bus_id[0], "%d-%s:%d",
dev->bus->busnum, dev->devpath, dev->bus->busnum, dev->devpath,
desc->bInterfaceNumber); desc->bInterfaceNumber);
...@@ -1206,24 +1215,21 @@ void usb_buffer_free ( ...@@ -1206,24 +1215,21 @@ void usb_buffer_free (
struct urb *usb_buffer_map (struct urb *urb) struct urb *usb_buffer_map (struct urb *urb)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
if (!urb if (!urb
|| usb_pipecontrol (urb->pipe) || usb_pipecontrol (urb->pipe)
|| !urb->dev || !urb->dev
|| !(bus = urb->dev->bus) || !(bus = urb->dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_map)
return 0; return 0;
if (op->buffer_map (bus, urb->transfer_dma = dma_map_single (controller,
urb->transfer_buffer, urb->transfer_buffer, urb->transfer_buffer_length,
&urb->transfer_dma,
urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
? USB_DIR_IN ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
: USB_DIR_OUT)) // FIXME generic api broken like pci, can't report errors
return 0; // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0;
urb->transfer_flags |= URB_NO_DMA_MAP; urb->transfer_flags |= URB_NO_DMA_MAP;
return urb; return urb;
} }
...@@ -1235,22 +1241,19 @@ struct urb *usb_buffer_map (struct urb *urb) ...@@ -1235,22 +1241,19 @@ struct urb *usb_buffer_map (struct urb *urb)
void usb_buffer_dmasync (struct urb *urb) void usb_buffer_dmasync (struct urb *urb)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
if (!urb if (!urb
|| !(urb->transfer_flags & URB_NO_DMA_MAP) || !(urb->transfer_flags & URB_NO_DMA_MAP)
|| !urb->dev || !urb->dev
|| !(bus = urb->dev->bus) || !(bus = urb->dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_dmasync)
return; return;
op->buffer_dmasync (bus, dma_sync_single (controller,
urb->transfer_dma, urb->transfer_dma, urb->transfer_buffer_length,
urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
? USB_DIR_IN ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
: USB_DIR_OUT);
} }
/** /**
...@@ -1262,23 +1265,21 @@ void usb_buffer_dmasync (struct urb *urb) ...@@ -1262,23 +1265,21 @@ void usb_buffer_dmasync (struct urb *urb)
void usb_buffer_unmap (struct urb *urb) void usb_buffer_unmap (struct urb *urb)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
if (!urb if (!urb
|| !(urb->transfer_flags & URB_NO_DMA_MAP) || !(urb->transfer_flags & URB_NO_DMA_MAP)
|| !urb->dev || !urb->dev
|| !(bus = urb->dev->bus) || !(bus = urb->dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_unmap)
return; return;
op->buffer_unmap (bus, dma_unmap_single (controller,
urb->transfer_dma, urb->transfer_dma, urb->transfer_buffer_length,
urb->transfer_buffer_length,
usb_pipein (urb->pipe) usb_pipein (urb->pipe)
? USB_DIR_IN ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
: USB_DIR_OUT);
} }
/** /**
* usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
* @dev: device to which the scatterlist will be mapped * @dev: device to which the scatterlist will be mapped
...@@ -1297,6 +1298,7 @@ void usb_buffer_unmap (struct urb *urb) ...@@ -1297,6 +1298,7 @@ void usb_buffer_unmap (struct urb *urb)
* to complete before starting the next I/O. This is particularly easy * to complete before starting the next I/O. This is particularly easy
* to do with scatterlists. Just allocate and submit one URB for each DMA * to do with scatterlists. Just allocate and submit one URB for each DMA
* mapping entry returned, stopping on the first error or when all succeed. * mapping entry returned, stopping on the first error or when all succeed.
* Better yet, use the usb_sg_*() calls, which do that (and more) for you.
* *
* This call would normally be used when translating scatterlist requests, * This call would normally be used when translating scatterlist requests,
* rather than usb_buffer_map(), since on some hardware (with IOMMUs) it * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it
...@@ -1308,26 +1310,17 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, ...@@ -1308,26 +1310,17 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents) struct scatterlist *sg, int nents)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
int n_hw_ents;
if (!dev if (!dev
|| usb_pipecontrol (pipe) || usb_pipecontrol (pipe)
|| !(bus = dev->bus) || !(bus = dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_map_sg)
return -1;
if (op->buffer_map_sg (bus,
sg,
&n_hw_ents,
nents,
usb_pipein (pipe)
? USB_DIR_IN
: USB_DIR_OUT))
return -1; return -1;
return n_hw_ents; // FIXME generic api broken like pci, can't report errors
return dma_map_sg (controller, sg, nents,
usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
} }
/** /**
...@@ -1344,20 +1337,15 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, ...@@ -1344,20 +1337,15 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents) struct scatterlist *sg, int n_hw_ents)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
if (!dev if (!dev
|| !(bus = dev->bus) || !(bus = dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_dmasync_sg)
return; return;
op->buffer_dmasync_sg (bus, dma_sync_sg (controller, sg, n_hw_ents,
sg, usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
n_hw_ents,
usb_pipein (pipe)
? USB_DIR_IN
: USB_DIR_OUT);
} }
/** /**
...@@ -1373,20 +1361,15 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, ...@@ -1373,20 +1361,15 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents) struct scatterlist *sg, int n_hw_ents)
{ {
struct usb_bus *bus; struct usb_bus *bus;
struct usb_operations *op; struct device *controller;
if (!dev if (!dev
|| !(bus = dev->bus) || !(bus = dev->bus)
|| !(op = bus->op) || !(controller = bus->controller))
|| !op->buffer_unmap_sg)
return; return;
op->buffer_unmap_sg (bus, dma_unmap_sg (controller, sg, n_hw_ents,
sg, usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
n_hw_ents,
usb_pipein (pipe)
? USB_DIR_IN
: USB_DIR_OUT);
} }
......
...@@ -405,9 +405,10 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -405,9 +405,10 @@ static int ehci_start (struct usb_hcd *hcd)
* streaming mappings for I/O buffers, like pci_map_single(), * streaming mappings for I/O buffers, like pci_map_single(),
* can return segments above 4GB, if the device allows. * can return segments above 4GB, if the device allows.
* *
* NOTE: layered drivers can't yet tell when we enable that, * NOTE: the dma mask is visible through dma_supported(), so
* so they can't pass this info along (like NETIF_F_HIGHDMA) * drivers can pass this info along ... like NETIF_F_HIGHDMA,
* (or like Scsi_Host.highmem_io) ... usb_bus.flags? * Scsi_Host.highmem_io, and so forth. It's readonly to all
* host side drivers though.
*/ */
if (HCC_64BIT_ADDR (hcc_params)) { if (HCC_64BIT_ADDR (hcc_params)) {
writel (0, &ehci->regs->segment); writel (0, &ehci->regs->segment);
......
...@@ -176,7 +176,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, ...@@ -176,7 +176,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver,
hcd->irq = dev->irq[1]; hcd->irq = dev->irq[1];
hcd->regs = dev->mapbase; hcd->regs = dev->mapbase;
hcd->pdev = SA1111_FAKE_PCIDEV; hcd->pdev = SA1111_FAKE_PCIDEV;
hcd->controller = &dev->dev; hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
retval = hcd_buffer_create (hcd); retval = hcd_buffer_create (hcd);
if (retval != 0) { if (retval != 0) {
......
...@@ -321,10 +321,13 @@ ...@@ -321,10 +321,13 @@
* "Jaeger, Gerhard" <gerhard@gjaeger.de>, Ira Childress * "Jaeger, Gerhard" <gerhard@gjaeger.de>, Ira Childress
* <ichildress@mn.rr.com>, Till Kamppeter <till.kamppeter@gmx.net>, * <ichildress@mn.rr.com>, Till Kamppeter <till.kamppeter@gmx.net>,
* Ed Hamrick <EdHamrick@aol.com>, Oliver Schwartz * Ed Hamrick <EdHamrick@aol.com>, Oliver Schwartz
* <Oliver.Schwartz@gmx.de> and everyone else who sent ids. * <Oliver.Schwartz@gmx.de> and everyone else who sent ids.
* - Some Benq, Genius and Plustek ids are identified now. * - Some Benq, Genius and Plustek ids are identified now.
* - Accept scanners with only one bulk (in) endpoint (thanks to Sergey * - Accept scanners with only one bulk (in) endpoint (thanks to Sergey
* Vlasov <vsu@mivlgu.murom.ru>). * Vlasov <vsu@mivlgu.murom.ru>).
* - Accept devices with more than one interface. Only use interfaces that
* look like belonging to scanners.
* - Fix compilation error when debugging is enabled.
* *
* TODO * TODO
* - Remove the 2/3 endpoint limitation * - Remove the 2/3 endpoint limitation
...@@ -858,7 +861,6 @@ probe_scanner(struct usb_interface *intf, ...@@ -858,7 +861,6 @@ probe_scanner(struct usb_interface *intf,
} }
dbg("probe_scanner: USB dev address:%p", dev); dbg("probe_scanner: USB dev address:%p", dev);
dbg("probe_scanner: ifnum:%u", ifnum);
/* /*
* 1. Check Vendor/Product * 1. Check Vendor/Product
...@@ -907,13 +909,15 @@ probe_scanner(struct usb_interface *intf, ...@@ -907,13 +909,15 @@ probe_scanner(struct usb_interface *intf,
return -ENODEV; return -ENODEV;
} }
if (dev->config[0].desc.bNumInterfaces != 1) { interface = intf->altsetting;
info("probe_scanner: Only one device interface is supported.");
if (interface[0].desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC &&
interface[0].desc.bInterfaceClass != USB_CLASS_PER_INTERFACE &&
interface[0].desc.bInterfaceClass != 16) {
dbg("probe_scanner: This interface doesn't look like a scanner (class=0x%x).", interface[0].desc.bInterfaceClass);
return -ENODEV; return -ENODEV;
} }
interface = intf->altsetting;
/* /*
* Start checking for one or two bulk endpoints and an optional * Start checking for one or two bulk endpoints and an optional
* interrupt endpoint. If we have an interrupt endpoint go ahead and * interrupt endpoint. If we have an interrupt endpoint go ahead and
......
...@@ -1317,6 +1317,9 @@ void hid_init_reports(struct hid_device *hid) ...@@ -1317,6 +1317,9 @@ void hid_init_reports(struct hid_device *hid)
#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204 #define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204
#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205 #define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205
#define USB_VENDOR_ID_TOPMAX 0x0663
#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
#define USB_VENDOR_ID_MGE 0x0463 #define USB_VENDOR_ID_MGE 0x0463
#define USB_DEVICE_ID_MGE_UPS 0xffff #define USB_DEVICE_ID_MGE_UPS 0xffff
#define USB_DEVICE_ID_MGE_UPS1 0x0001 #define USB_DEVICE_ID_MGE_UPS1 0x0001
...@@ -1355,6 +1358,7 @@ struct hid_blacklist { ...@@ -1355,6 +1358,7 @@ struct hid_blacklist {
{ USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_HIDDEV }, { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_HIDDEV },
{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_HIDDEV }, { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_HIDDEV },
{ USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
{ 0, 0 } { 0, 0 }
}; };
......
...@@ -357,6 +357,11 @@ static void hidinput_configure_usage(struct hid_device *device, struct hid_field ...@@ -357,6 +357,11 @@ static void hidinput_configure_usage(struct hid_device *device, struct hid_field
int a = field->logical_minimum; int a = field->logical_minimum;
int b = field->logical_maximum; int b = field->logical_maximum;
if ((device->quirks & HID_QUIRK_BADPAD) && (usage->code == ABS_X || usage->code == ABS_Y)) {
a = field->logical_minimum = 0;
b = field->logical_maximum = 255;
}
input->absmin[usage->code] = a; input->absmin[usage->code] = a;
input->absmax[usage->code] = b; input->absmax[usage->code] = b;
input->absfuzz[usage->code] = (b - a) >> 8; input->absfuzz[usage->code] = (b - a) >> 8;
......
...@@ -206,6 +206,7 @@ struct hid_item { ...@@ -206,6 +206,7 @@ struct hid_item {
#define HID_QUIRK_IGNORE 0x04 #define HID_QUIRK_IGNORE 0x04
#define HID_QUIRK_NOGET 0x08 #define HID_QUIRK_NOGET 0x08
#define HID_QUIRK_HIDDEV 0x10 #define HID_QUIRK_HIDDEV 0x10
#define HID_QUIRK_BADPAD 0x12
/* /*
* This is the global enviroment of the parser. This information is * This is the global enviroment of the parser. This information is
......
...@@ -133,6 +133,11 @@ static int hid_pid_erase(struct input_dev *dev, int id) ...@@ -133,6 +133,11 @@ static int hid_pid_erase(struct input_dev *dev, int id)
/* Find field */ /* Find field */
field = (struct hid_field *) kmalloc(sizeof(struct hid_field), GFP_KERNEL); field = (struct hid_field *) kmalloc(sizeof(struct hid_field), GFP_KERNEL);
if(!field) {
printk("Couldn't allocate field\n");
return -ENOMEM;
}
ret = hid_set_field(field, ret, pid->effects[id].device_id); ret = hid_set_field(field, ret, pid->effects[id].device_id);
if(!ret) { if(!ret) {
printk("Couldn't set field\n"); printk("Couldn't set field\n");
......
/* /*
* USB NB Camera driver * USB NB Camera driver
*
* HISTORY:
* 25-Dec-2002 Dmitri Removed lighting, sharpness parameters, methods.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -34,12 +37,6 @@ static int flags = 0; /* FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */ ...@@ -34,12 +37,6 @@ static int flags = 0; /* FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */
static const int min_canvasWidth = 8; static const int min_canvasWidth = 8;
static const int min_canvasHeight = 4; static const int min_canvasHeight = 4;
//static int lighting = 1; /* Medium */
#define SHARPNESS_MIN 0
#define SHARPNESS_MAX 6
//static int sharpness = 4; /* Low noise, good details */
#define FRAMERATE_MIN 0 #define FRAMERATE_MIN 0
#define FRAMERATE_MAX 6 #define FRAMERATE_MAX 6
static int framerate = -1; static int framerate = -1;
...@@ -77,10 +74,6 @@ MODULE_PARM_DESC(flags, ...@@ -77,10 +74,6 @@ MODULE_PARM_DESC(flags,
"6=clean frames"); "6=clean frames");
MODULE_PARM(framerate, "i"); MODULE_PARM(framerate, "i");
MODULE_PARM_DESC(framerate, "Framerate setting: 0=slowest, 6=fastest (default=2)"); MODULE_PARM_DESC(framerate, "Framerate setting: 0=slowest, 6=fastest (default=2)");
MODULE_PARM(lighting, "i");
MODULE_PARM_DESC(lighting, "Photosensitivity: 0=bright, 1=medium (default), 2=low light");
MODULE_PARM(sharpness, "i");
MODULE_PARM_DESC(sharpness, "Model1 noise reduction: 0=smooth, 6=sharp (default=4)");
MODULE_PARM(init_brightness, "i"); MODULE_PARM(init_brightness, "i");
MODULE_PARM_DESC(init_brightness, "Brightness preconfiguration: 0-255 (default=128)"); MODULE_PARM_DESC(init_brightness, "Brightness preconfiguration: 0-255 (default=128)");
...@@ -205,24 +198,6 @@ static void ultracam_adjust_contrast(struct uvd *uvd) ...@@ -205,24 +198,6 @@ static void ultracam_adjust_contrast(struct uvd *uvd)
{ {
} }
/*
* ultracam_change_lighting_conditions()
*/
static void ultracam_change_lighting_conditions(struct uvd *uvd)
{
}
/*
* ultracam_set_sharpness()
*
* Cameras model 1 have internal smoothing feature. It is controlled by value in
* range [0..6], where 0 is most smooth and 6 is most sharp (raw image, I guess).
* Recommended value is 4. Cameras model 2 do not have this feature at all.
*/
static void ultracam_set_sharpness(struct uvd *uvd)
{
}
/* /*
* ultracam_set_brightness() * ultracam_set_brightness()
* *
...@@ -272,8 +247,6 @@ static void ultracam_reinit_iso(struct uvd *uvd, int do_stop) ...@@ -272,8 +247,6 @@ static void ultracam_reinit_iso(struct uvd *uvd, int do_stop)
static void ultracam_video_start(struct uvd *uvd) static void ultracam_video_start(struct uvd *uvd)
{ {
ultracam_change_lighting_conditions(uvd);
ultracam_set_sharpness(uvd);
ultracam_reinit_iso(uvd, 0); ultracam_reinit_iso(uvd, 0);
} }
......
...@@ -978,7 +978,6 @@ static void usbtest_disconnect (struct usb_interface *intf) ...@@ -978,7 +978,6 @@ static void usbtest_disconnect (struct usb_interface *intf)
dev_set_drvdata (&intf->dev, 0); dev_set_drvdata (&intf->dev, 0);
info ("unbound %s", dev->id); info ("unbound %s", dev->id);
kfree (intf->private_data);
} }
/* Basic testing only needs a device that can source or sink bulk traffic. /* Basic testing only needs a device that can source or sink bulk traffic.
......
...@@ -146,6 +146,11 @@ ...@@ -146,6 +146,11 @@
#endif #endif
#include <linux/usb.h> #include <linux/usb.h>
#include <asm/io.h>
#include <asm/scatterlist.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
/* minidrivers _could_ be individually configured */ /* minidrivers _could_ be individually configured */
#define CONFIG_USB_AN2720 #define CONFIG_USB_AN2720
...@@ -2169,9 +2174,13 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -2169,9 +2174,13 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
memcpy (net->dev_addr, node_id, sizeof node_id); memcpy (net->dev_addr, node_id, sizeof node_id);
// point-to-point link ... we always use Ethernet headers // point-to-point link ... we always use Ethernet headers
// supports win32 interop and the bridge driver. // supports win32 interop (some devices) and the bridge driver.
ether_setup (net); ether_setup (net);
// possible with some EHCI controllers
if (dma_supported (&udev->dev, 0xffffffffffffffffULL))
net->features |= NETIF_F_HIGHDMA;
net->change_mtu = usbnet_change_mtu; net->change_mtu = usbnet_change_mtu;
net->get_stats = usbnet_get_stats; net->get_stats = usbnet_get_stats;
net->hard_start_xmit = usbnet_start_xmit; net->hard_start_xmit = usbnet_start_xmit;
......
...@@ -150,11 +150,11 @@ config USB_SERIAL_VISOR ...@@ -150,11 +150,11 @@ config USB_SERIAL_VISOR
module, say M here and read <file:Documentation/modules.txt>. module, say M here and read <file:Documentation/modules.txt>.
config USB_SERIAL_IPAQ config USB_SERIAL_IPAQ
tristate "USB Compaq iPAQ / HP Jornada / Casio EM500 Driver" tristate "USB PocketPC PDA Driver"
depends on USB_SERIAL depends on USB_SERIAL
help help
Say Y here if you want to connect to your Compaq iPAQ, HP Jornada Say Y here if you want to connect to your Compaq iPAQ, HP Jornada
548/568 or Casio EM500 running Windows CE 3.0 or PocketPC 2002 or any other PDA running Windows CE 3.0 or PocketPC 2002
using a USB cradle/cable. For information on using the driver, using a USB cradle/cable. For information on using the driver,
read <file:Documentation/usb/usb-serial.txt>. read <file:Documentation/usb/usb-serial.txt>.
......
...@@ -171,10 +171,9 @@ static int belkin_sa_startup (struct usb_serial *serial) ...@@ -171,10 +171,9 @@ static int belkin_sa_startup (struct usb_serial *serial)
struct belkin_sa_private *priv; struct belkin_sa_private *priv;
/* allocate the private data structure */ /* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
if (!serial->port->private) if (!priv)
return (-1); /* error */ return (-1); /* error */
priv = (struct belkin_sa_private *)serial->port->private;
/* set initial values for control structures */ /* set initial values for control structures */
priv->control_state = 0; priv->control_state = 0;
priv->last_lsr = 0; priv->last_lsr = 0;
...@@ -184,6 +183,7 @@ static int belkin_sa_startup (struct usb_serial *serial) ...@@ -184,6 +183,7 @@ static int belkin_sa_startup (struct usb_serial *serial)
info("bcdDevice: %04x, bfc: %d", dev->descriptor.bcdDevice, priv->bad_flow_control); info("bcdDevice: %04x, bfc: %d", dev->descriptor.bcdDevice, priv->bad_flow_control);
init_waitqueue_head(&serial->port->write_wait); init_waitqueue_head(&serial->port->write_wait);
usb_set_serial_port_data(serial->port, priv);
return (0); return (0);
} }
...@@ -191,6 +191,7 @@ static int belkin_sa_startup (struct usb_serial *serial) ...@@ -191,6 +191,7 @@ static int belkin_sa_startup (struct usb_serial *serial)
static void belkin_sa_shutdown (struct usb_serial *serial) static void belkin_sa_shutdown (struct usb_serial *serial)
{ {
struct belkin_sa_private *priv;
int i; int i;
dbg ("%s", __FUNCTION__); dbg ("%s", __FUNCTION__);
...@@ -198,8 +199,9 @@ static void belkin_sa_shutdown (struct usb_serial *serial) ...@@ -198,8 +199,9 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) priv = usb_get_serial_port_data(&serial->port[i]);
kfree(serial->port[i].private); if (priv)
kfree(priv);
} }
} }
...@@ -286,7 +288,7 @@ static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -286,7 +288,7 @@ static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs)
/* Handle known interrupt data */ /* Handle known interrupt data */
/* ignore data[0] and data[1] */ /* ignore data[0] and data[1] */
priv = (struct belkin_sa_private *)port->private; priv = usb_get_serial_port_data(port);
priv->last_msr = data[BELKIN_SA_MSR_INDEX]; priv->last_msr = data[BELKIN_SA_MSR_INDEX];
/* Record Control Line states */ /* Record Control Line states */
...@@ -344,7 +346,7 @@ static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -344,7 +346,7 @@ static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs)
static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios *old_termios) static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct belkin_sa_private *priv = (struct belkin_sa_private *)port->private; struct belkin_sa_private *priv = usb_get_serial_port_data(port);
unsigned int iflag; unsigned int iflag;
unsigned int cflag; unsigned int cflag;
unsigned int old_iflag = 0; unsigned int old_iflag = 0;
...@@ -485,7 +487,7 @@ static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, un ...@@ -485,7 +487,7 @@ static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, un
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
__u16 urb_value; /* Will hold the new flags */ __u16 urb_value; /* Will hold the new flags */
struct belkin_sa_private *priv = (struct belkin_sa_private *)port->private; struct belkin_sa_private *priv = usb_get_serial_port_data(port);
int ret, mask; int ret, mask;
/* Based on code from acm.c and others */ /* Based on code from acm.c and others */
......
...@@ -66,7 +66,7 @@ static int usb_serial_device_probe (struct device *dev) ...@@ -66,7 +66,7 @@ static int usb_serial_device_probe (struct device *dev)
driver = port->serial->type; driver = port->serial->type;
if (driver->port_probe) { if (driver->port_probe) {
if (!try_module_get(driver->owner)) { if (!try_module_get(driver->owner)) {
err ("module get failed, exiting"); dev_err(*dev, "module get failed, exiting\n");
retval = -EIO; retval = -EIO;
goto exit; goto exit;
} }
...@@ -79,8 +79,8 @@ static int usb_serial_device_probe (struct device *dev) ...@@ -79,8 +79,8 @@ static int usb_serial_device_probe (struct device *dev)
minor = port->number; minor = port->number;
tty_register_devfs (&usb_serial_tty_driver, 0, minor); tty_register_devfs (&usb_serial_tty_driver, 0, minor);
info("%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)", dev_info(*dev, "%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)\n",
driver->name, minor, minor); driver->name, minor, minor);
exit: exit:
return retval; return retval;
...@@ -101,7 +101,7 @@ static int usb_serial_device_remove (struct device *dev) ...@@ -101,7 +101,7 @@ static int usb_serial_device_remove (struct device *dev)
driver = port->serial->type; driver = port->serial->type;
if (driver->port_remove) { if (driver->port_remove) {
if (!try_module_get(driver->owner)) { if (!try_module_get(driver->owner)) {
err ("module get failed, exiting"); dev_err(*dev, "module get failed, exiting\n");
retval = -EIO; retval = -EIO;
goto exit; goto exit;
} }
...@@ -111,8 +111,8 @@ static int usb_serial_device_remove (struct device *dev) ...@@ -111,8 +111,8 @@ static int usb_serial_device_remove (struct device *dev)
exit: exit:
minor = port->number; minor = port->number;
tty_unregister_devfs (&usb_serial_tty_driver, minor); tty_unregister_devfs (&usb_serial_tty_driver, minor);
info("%s converter now disconnected from ttyUSB%d", dev_info(*dev, "%s converter now disconnected from ttyUSB%d\n",
driver->name, minor); driver->name, minor);
return retval; return retval;
} }
......
...@@ -114,15 +114,15 @@ static int cyberjack_startup (struct usb_serial *serial) ...@@ -114,15 +114,15 @@ static int cyberjack_startup (struct usb_serial *serial)
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
/* allocate the private data structure */ /* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
if (!serial->port->private) if (!priv)
return (-1); /* error */ return -ENOMEM;
/* set initial values */ /* set initial values */
priv = (struct cyberjack_private *)serial->port->private;
priv->rdtodo = 0; priv->rdtodo = 0;
priv->wrfilled = 0; priv->wrfilled = 0;
priv->wrsent = 0; priv->wrsent = 0;
usb_set_serial_port_data(serial->port, priv);
init_waitqueue_head(&serial->port->write_wait); init_waitqueue_head(&serial->port->write_wait);
...@@ -137,8 +137,8 @@ static void cyberjack_shutdown (struct usb_serial *serial) ...@@ -137,8 +137,8 @@ static void cyberjack_shutdown (struct usb_serial *serial)
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) kfree(usb_get_serial_port_data(&serial->port[i]));
kfree(serial->port[i].private); usb_set_serial_port_data(&serial->port[i], NULL);
} }
} }
...@@ -158,7 +158,7 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) ...@@ -158,7 +158,7 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
*/ */
port->tty->low_latency = 1; port->tty->low_latency = 1;
priv = (struct cyberjack_private *)port->private; priv = usb_get_serial_port_data(port);
priv->rdtodo = 0; priv->rdtodo = 0;
priv->wrfilled = 0; priv->wrfilled = 0;
priv->wrsent = 0; priv->wrsent = 0;
...@@ -192,7 +192,7 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp) ...@@ -192,7 +192,7 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct cyberjack_private *priv = (struct cyberjack_private *)port->private; struct cyberjack_private *priv = usb_get_serial_port_data(port);
int result; int result;
int wrexpected; int wrexpected;
...@@ -280,7 +280,7 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u ...@@ -280,7 +280,7 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const u
static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs ) static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs )
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct cyberjack_private *priv = (struct cyberjack_private *)port->private; struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial; struct usb_serial *serial;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -334,7 +334,7 @@ static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs ) ...@@ -334,7 +334,7 @@ static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs )
static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct cyberjack_private *priv = (struct cyberjack_private *)port->private; struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -389,7 +389,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -389,7 +389,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs) static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct cyberjack_private *priv = (struct cyberjack_private *)port->private; struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
......
This diff is collapsed.
...@@ -181,7 +181,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -181,7 +181,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
return result; return result;
} }
...@@ -205,7 +205,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) ...@@ -205,7 +205,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* dev_info (port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */
} }
...@@ -248,7 +248,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig ...@@ -248,7 +248,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig
if (urb->transfer_buffer == NULL) { if (urb->transfer_buffer == NULL) {
urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
if (urb->transfer_buffer == NULL) { if (urb->transfer_buffer == NULL) {
err("%s no more kernel memory...", __FUNCTION__); dev_err(port->dev, "%s no more kernel memory...\n", __FUNCTION__);
goto exit; goto exit;
} }
} }
...@@ -278,7 +278,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig ...@@ -278,7 +278,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig
/* send it down the pipe */ /* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC); status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) { if (status) {
err("%s - usb_submit_urb(write bulk) failed with status = %d", __FUNCTION__, status); dev_err(port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", __FUNCTION__, status);
bytes_sent = status; bytes_sent = status;
break; break;
} }
...@@ -426,7 +426,7 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -426,7 +426,7 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
return; return;
...@@ -451,7 +451,7 @@ static void empeg_unthrottle (struct usb_serial_port *port) ...@@ -451,7 +451,7 @@ static void empeg_unthrottle (struct usb_serial_port *port)
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
return; return;
} }
......
...@@ -41,7 +41,7 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da ...@@ -41,7 +41,7 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
transfer_buffer = kmalloc (length, GFP_KERNEL); transfer_buffer = kmalloc (length, GFP_KERNEL);
if (!transfer_buffer) { if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, length); dev_err(serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
return -ENOMEM; return -ENOMEM;
} }
memcpy (transfer_buffer, data, length); memcpy (transfer_buffer, data, length);
...@@ -56,7 +56,7 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit) ...@@ -56,7 +56,7 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit)
dbg("%s - %d", __FUNCTION__, reset_bit); dbg("%s - %d", __FUNCTION__, reset_bit);
response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0); response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0);
if (response < 0) { if (response < 0) {
err("%s- %d failed", __FUNCTION__, reset_bit); dev_err(serial->dev->dev, "%s- %d failed\n", __FUNCTION__, reset_bit);
} }
return response; return response;
} }
......
...@@ -267,7 +267,7 @@ static int ftdi_sio_startup (struct usb_serial *serial) ...@@ -267,7 +267,7 @@ static int ftdi_sio_startup (struct usb_serial *serial)
struct ftdi_private *priv; struct ftdi_private *priv;
priv = serial->port->private = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
if (!priv){ if (!priv){
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
return -ENOMEM; return -ENOMEM;
...@@ -275,7 +275,8 @@ static int ftdi_sio_startup (struct usb_serial *serial) ...@@ -275,7 +275,8 @@ static int ftdi_sio_startup (struct usb_serial *serial)
priv->ftdi_type = sio; priv->ftdi_type = sio;
priv->write_offset = 1; priv->write_offset = 1;
usb_set_serial_port_data(serial->port, priv);
return (0); return (0);
} }
...@@ -285,7 +286,7 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial) ...@@ -285,7 +286,7 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial)
struct ftdi_private *priv; struct ftdi_private *priv;
priv = serial->port->private = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
if (!priv){ if (!priv){
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
return -ENOMEM; return -ENOMEM;
...@@ -293,17 +294,21 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial) ...@@ -293,17 +294,21 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial)
priv->ftdi_type = F8U232AM; priv->ftdi_type = F8U232AM;
priv->write_offset = 0; priv->write_offset = 0;
usb_set_serial_port_data(serial->port, priv);
return (0); return (0);
} }
static void ftdi_sio_shutdown (struct usb_serial *serial) static void ftdi_sio_shutdown (struct usb_serial *serial)
{ {
void *priv;
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
if (serial->port[0].private){ priv = usb_get_serial_port_data(&serial->port[0]);
kfree(serial->port[0].private); if (priv){
serial->port[0].private = NULL; kfree(priv);
usb_set_serial_port_data(&serial->port[0], NULL);
} }
} }
...@@ -405,7 +410,7 @@ static int ftdi_sio_write (struct usb_serial_port *port, int from_user, ...@@ -405,7 +410,7 @@ static int ftdi_sio_write (struct usb_serial_port *port, int from_user,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ /* ftdi_sio_write */ { /* ftdi_sio_write */
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ftdi_private *priv = (struct ftdi_private *)port->private; struct ftdi_private *priv = usb_get_serial_port_data(port);
unsigned char *first_byte = port->write_urb->transfer_buffer; unsigned char *first_byte = port->write_urb->transfer_buffer;
int data_offset ; int data_offset ;
int result; int result;
...@@ -491,7 +496,7 @@ static void ftdi_sio_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -491,7 +496,7 @@ static void ftdi_sio_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
static int ftdi_sio_write_room( struct usb_serial_port *port ) static int ftdi_sio_write_room( struct usb_serial_port *port )
{ {
struct ftdi_private *priv = (struct ftdi_private *)port->private; struct ftdi_private *priv = usb_get_serial_port_data(port);
int room; int room;
if ( port->write_urb->status == -EINPROGRESS) { if ( port->write_urb->status == -EINPROGRESS) {
...@@ -670,7 +675,7 @@ static __u16 translate_baudrate_to_ftdi(unsigned int cflag, enum ftdi_type ftdi_ ...@@ -670,7 +675,7 @@ static __u16 translate_baudrate_to_ftdi(unsigned int cflag, enum ftdi_type ftdi_
static void ftdi_sio_break_ctl( struct usb_serial_port *port, int break_state ) static void ftdi_sio_break_ctl( struct usb_serial_port *port, int break_state )
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ftdi_private *priv = (struct ftdi_private *)port->private; struct ftdi_private *priv = usb_get_serial_port_data(port);
__u16 urb_value = 0; __u16 urb_value = 0;
char buf[1]; char buf[1];
...@@ -709,7 +714,7 @@ static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios * ...@@ -709,7 +714,7 @@ static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios *
{ /* ftdi_sio_set_termios */ { /* ftdi_sio_set_termios */
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
unsigned int cflag = port->tty->termios->c_cflag; unsigned int cflag = port->tty->termios->c_cflag;
struct ftdi_private *priv = (struct ftdi_private *)port->private; struct ftdi_private *priv = usb_get_serial_port_data(port);
__u16 urb_value; /* will hold the new flags */ __u16 urb_value; /* will hold the new flags */
char buf[1]; /* Perhaps I should dynamically alloc this? */ char buf[1]; /* Perhaps I should dynamically alloc this? */
...@@ -819,7 +824,7 @@ static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios * ...@@ -819,7 +824,7 @@ static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios *
static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ftdi_private *priv = (struct ftdi_private *)port->private; struct ftdi_private *priv = usb_get_serial_port_data(port);
__u16 urb_value=0; /* Will hold the new flags */ __u16 urb_value=0; /* Will hold the new flags */
char buf[2]; char buf[2];
int ret, mask; int ret, mask;
......
...@@ -106,7 +106,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) ...@@ -106,7 +106,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
port); port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
} }
return result; return result;
...@@ -176,7 +176,7 @@ int usb_serial_generic_write (struct usb_serial_port *port, int from_user, const ...@@ -176,7 +176,7 @@ int usb_serial_generic_write (struct usb_serial_port *port, int from_user, const
/* send the data out the bulk port */ /* send the data out the bulk port */
result = usb_submit_urb(port->write_urb, GFP_ATOMIC); result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed submitting write urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
else else
result = count; result = count;
...@@ -266,7 +266,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg ...@@ -266,7 +266,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
usb_serial_generic_read_bulk_callback), port); usb_serial_generic_read_bulk_callback), port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
} }
void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
......
This diff is collapsed.
This diff is collapsed.
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* (12/12/2002) ganesh
* Added support for practically all devices supported by ActiveSync
* on Windows. Thanks to Wes Cilldhaire <billybobjoehenrybob@hotmail.com>.
*
* (26/11/2002) ganesh * (26/11/2002) ganesh
* Added insmod options to specify product and vendor id. * Added insmod options to specify product and vendor id.
* Use modprobe ipaq vendor=0xfoo product=0xbar * Use modprobe ipaq vendor=0xfoo product=0xbar
...@@ -68,9 +72,9 @@ ...@@ -68,9 +72,9 @@
* Version Information * Version Information
*/ */
#define DRIVER_VERSION "v0.4" #define DRIVER_VERSION "v0.5"
#define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" #define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>"
#define DRIVER_DESC "USB Compaq iPAQ, HP Jornada, Casio EM500 driver" #define DRIVER_DESC "USB PocketPC PDA driver"
static int product, vendor; static int product, vendor;
...@@ -94,10 +98,36 @@ static void ipaq_destroy_lists(struct usb_serial_port *port); ...@@ -94,10 +98,36 @@ static void ipaq_destroy_lists(struct usb_serial_port *port);
static struct usb_device_id ipaq_id_table [] = { static struct usb_device_id ipaq_id_table [] = {
/* The first entry is a placeholder for the insmod-specified device */ /* The first entry is a placeholder for the insmod-specified device */
{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) }, { USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) },
{ USB_DEVICE(ASKEY_VENDOR_ID, ASKEY_PRODUCT_ID) },
{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0065_ID) },
{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0066_ID) },
{ USB_DEVICE(BCOM_VENDOR_ID, BCOM_0067_ID) },
{ USB_DEVICE(CASIO_VENDOR_ID, CASIO_2001_ID) },
{ USB_DEVICE(CASIO_VENDOR_ID, CASIO_EM500_ID) },
{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) }, { USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_IPAQ_ID) },
{ USB_DEVICE(COMPAQ_VENDOR_ID, COMPAQ_0032_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_548_ID) }, { USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_548_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_568_ID) }, { USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_568_ID) },
{ USB_DEVICE(CASIO_VENDOR_ID, CASIO_EM500_ID) }, { USB_DEVICE(HP_VENDOR_ID, HP_2016_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_2116_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_2216_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_3016_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_3116_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_3216_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_4016_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_4116_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_4216_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_5016_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_5116_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_5216_ID) },
{ USB_DEVICE(LINKUP_VENDOR_ID, LINKUP_PRODUCT_ID) },
{ USB_DEVICE(MICROSOFT_VENDOR_ID, MICROSOFT_00CE_ID) },
{ USB_DEVICE(PORTATEC_VENDOR_ID, PORTATEC_PRODUCT_ID) },
{ USB_DEVICE(SAGEM_VENDOR_ID, SAGEM_WIRELESS_ID) },
{ USB_DEVICE(SOCKET_VENDOR_ID, SOCKET_PRODUCT_ID) },
{ USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_ID) },
{ USB_DEVICE(HTC_VENDOR_ID, HTC_PRODUCT_ID) },
{ USB_DEVICE(NEC_VENDOR_ID, NEC_PRODUCT_ID) },
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
...@@ -114,7 +144,7 @@ static struct usb_driver ipaq_driver = { ...@@ -114,7 +144,7 @@ static struct usb_driver ipaq_driver = {
/* All of the device info needed for the Compaq iPAQ */ /* All of the device info needed for the Compaq iPAQ */
struct usb_serial_device_type ipaq_device = { struct usb_serial_device_type ipaq_device = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "Compaq iPAQ", .name = "PocketPC PDA",
.id_table = ipaq_id_table, .id_table = ipaq_id_table,
.num_interrupt_in = NUM_DONT_CARE, .num_interrupt_in = NUM_DONT_CARE,
.num_bulk_in = 1, .num_bulk_in = 1,
...@@ -156,7 +186,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -156,7 +186,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
err("%s - Out of memory", __FUNCTION__); err("%s - Out of memory", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
port->private = (void *)priv; usb_set_serial_port_data(port, priv);
priv->active = 0; priv->active = 0;
priv->queue_len = 0; priv->queue_len = 0;
INIT_LIST_HEAD(&priv->queue); INIT_LIST_HEAD(&priv->queue);
...@@ -251,7 +281,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -251,7 +281,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
static void ipaq_close(struct usb_serial_port *port, struct file *filp) static void ipaq_close(struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial; struct usb_serial *serial;
struct ipaq_private *priv = port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
if (port_paranoia_check(port, __FUNCTION__)) { if (port_paranoia_check(port, __FUNCTION__)) {
return; return;
...@@ -271,7 +301,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) ...@@ -271,7 +301,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
usb_unlink_urb(port->read_urb); usb_unlink_urb(port->read_urb);
ipaq_destroy_lists(port); ipaq_destroy_lists(port);
kfree(priv); kfree(priv);
port->private = NULL; usb_set_serial_port_data(port, NULL);
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
...@@ -355,7 +385,7 @@ static int ipaq_write(struct usb_serial_port *port, int from_user, const unsigne ...@@ -355,7 +385,7 @@ static int ipaq_write(struct usb_serial_port *port, int from_user, const unsigne
static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf, static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf,
int count) int count)
{ {
struct ipaq_private *priv = port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
struct ipaq_packet *pkt = NULL; struct ipaq_packet *pkt = NULL;
int result = 0; int result = 0;
unsigned long flags; unsigned long flags;
...@@ -406,7 +436,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const un ...@@ -406,7 +436,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const un
static void ipaq_write_gather(struct usb_serial_port *port) static void ipaq_write_gather(struct usb_serial_port *port)
{ {
struct ipaq_private *priv = (struct ipaq_private *)port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int count, room; int count, room;
struct ipaq_packet *pkt; struct ipaq_packet *pkt;
...@@ -448,7 +478,7 @@ static void ipaq_write_gather(struct usb_serial_port *port) ...@@ -448,7 +478,7 @@ static void ipaq_write_gather(struct usb_serial_port *port)
static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs) static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct ipaq_private *priv = (struct ipaq_private *)port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
int result; int result;
...@@ -480,7 +510,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs) ...@@ -480,7 +510,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
static int ipaq_write_room(struct usb_serial_port *port) static int ipaq_write_room(struct usb_serial_port *port)
{ {
struct ipaq_private *priv = (struct ipaq_private *)port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
dbg("%s - freelen %d", __FUNCTION__, priv->free_len); dbg("%s - freelen %d", __FUNCTION__, priv->free_len);
return priv->free_len; return priv->free_len;
...@@ -488,7 +518,7 @@ static int ipaq_write_room(struct usb_serial_port *port) ...@@ -488,7 +518,7 @@ static int ipaq_write_room(struct usb_serial_port *port)
static int ipaq_chars_in_buffer(struct usb_serial_port *port) static int ipaq_chars_in_buffer(struct usb_serial_port *port)
{ {
struct ipaq_private *priv = (struct ipaq_private *)port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
dbg("%s - queuelen %d", __FUNCTION__, priv->queue_len); dbg("%s - queuelen %d", __FUNCTION__, priv->queue_len);
return priv->queue_len; return priv->queue_len;
...@@ -496,7 +526,7 @@ static int ipaq_chars_in_buffer(struct usb_serial_port *port) ...@@ -496,7 +526,7 @@ static int ipaq_chars_in_buffer(struct usb_serial_port *port)
static void ipaq_destroy_lists(struct usb_serial_port *port) static void ipaq_destroy_lists(struct usb_serial_port *port)
{ {
struct ipaq_private *priv = (struct ipaq_private *)port->private; struct ipaq_private *priv = usb_get_serial_port_data(port);
struct list_head *tmp; struct list_head *tmp;
struct ipaq_packet *pkt; struct ipaq_packet *pkt;
......
...@@ -9,22 +9,66 @@ ...@@ -9,22 +9,66 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
*
*/ */
#ifndef __LINUX_USB_SERIAL_IPAQ_H #ifndef __LINUX_USB_SERIAL_IPAQ_H
#define __LINUX_USB_SERIAL_IPAQ_H #define __LINUX_USB_SERIAL_IPAQ_H
#define ASKEY_VENDOR_ID 0x1690
#define ASKEY_PRODUCT_ID 0x0601
#define BCOM_VENDOR_ID 0x0960
#define BCOM_0065_ID 0x0065
#define BCOM_0066_ID 0x0066
#define BCOM_0067_ID 0x0067
#define CASIO_VENDOR_ID 0x07cf
#define CASIO_2001_ID 0x2001
#define CASIO_EM500_ID 0x2002
#define COMPAQ_VENDOR_ID 0x049f #define COMPAQ_VENDOR_ID 0x049f
#define COMPAQ_IPAQ_ID 0x0003 #define COMPAQ_IPAQ_ID 0x0003
#define COMPAQ_0032_ID 0x0032
#define HP_VENDOR_ID 0x03f0 #define HP_VENDOR_ID 0x03f0
#define HP_JORNADA_548_ID 0x1016 #define HP_JORNADA_548_ID 0x1016
#define HP_JORNADA_568_ID 0x1116 #define HP_JORNADA_568_ID 0x1116
#define HP_2016_ID 0x2016
#define HP_2116_ID 0x2116
#define HP_2216_ID 0x2216
#define HP_3016_ID 0x3016
#define HP_3116_ID 0x3116
#define HP_3216_ID 0x3216
#define HP_4016_ID 0x4016
#define HP_4116_ID 0x4116
#define HP_4216_ID 0x4216
#define HP_5016_ID 0x5016
#define HP_5116_ID 0x5116
#define HP_5216_ID 0x5216
#define CASIO_VENDOR_ID 0x07cf #define LINKUP_VENDOR_ID 0x094b
#define CASIO_EM500_ID 0x2002 #define LINKUP_PRODUCT_ID 0x0001
#define MICROSOFT_VENDOR_ID 0x045e
#define MICROSOFT_00CE_ID 0x00ce
#define PORTATEC_VENDOR_ID 0x0961
#define PORTATEC_PRODUCT_ID 0x0010
#define SAGEM_VENDOR_ID 0x5e04
#define SAGEM_WIRELESS_ID 0xce00
#define SOCKET_VENDOR_ID 0x0104
#define SOCKET_PRODUCT_ID 0x00be
#define TOSHIBA_VENDOR_ID 0x0930
#define TOSHIBA_PRODUCT_ID 0x0700
#define HTC_VENDOR_ID 0x0bb4
#define HTC_PRODUCT_ID 0x00ce
#define NEC_VENDOR_ID 0x0409
#define NEC_PRODUCT_ID 0x00d5
/* /*
* Since we can't queue our bulk write urbs (don't know why - it just * Since we can't queue our bulk write urbs (don't know why - it just
...@@ -41,8 +85,7 @@ ...@@ -41,8 +85,7 @@
* *
* The value of PACKET_SIZE was empirically determined by * The value of PACKET_SIZE was empirically determined by
* checking the maximum write sizes sent down by the ppp ldisc. * checking the maximum write sizes sent down by the ppp ldisc.
* URBDATA_QUEUE_MAX is set to 64K, which is the maximum TCP window size * URBDATA_QUEUE_MAX is set to 64K, which is the maximum TCP window size.
* supported by the iPAQ.
*/ */
struct ipaq_packet { struct ipaq_packet {
......
...@@ -243,7 +243,7 @@ static int ir_startup (struct usb_serial *serial) ...@@ -243,7 +243,7 @@ static int ir_startup (struct usb_serial *serial)
irda_desc = irda_usb_find_class_desc (serial->dev, 0); irda_desc = irda_usb_find_class_desc (serial->dev, 0);
if (irda_desc == NULL) { if (irda_desc == NULL) {
err ("IRDA class descriptor not found, device not bound"); dev_err (serial->dev->dev, "IRDA class descriptor not found, device not bound\n");
return -ENODEV; return -ENODEV;
} }
...@@ -291,7 +291,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -291,7 +291,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
/* override the default buffer sizes */ /* override the default buffer sizes */
buffer = kmalloc (buffer_size, GFP_KERNEL); buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) { if (!buffer) {
err ("%s - out of memory.", __FUNCTION__); dev_err (port->dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
kfree (port->read_urb->transfer_buffer); kfree (port->read_urb->transfer_buffer);
...@@ -300,7 +300,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -300,7 +300,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
buffer = kmalloc (buffer_size, GFP_KERNEL); buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) { if (!buffer) {
err ("%s - out of memory.", __FUNCTION__); dev_err (port->dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
kfree (port->write_urb->transfer_buffer); kfree (port->write_urb->transfer_buffer);
...@@ -320,7 +320,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -320,7 +320,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
port); port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
return result; return result;
} }
...@@ -353,7 +353,7 @@ static int ir_write (struct usb_serial_port *port, int from_user, const unsigned ...@@ -353,7 +353,7 @@ static int ir_write (struct usb_serial_port *port, int from_user, const unsigned
dbg("%s - port = %d, count = %d", __FUNCTION__, port->number, count); dbg("%s - port = %d, count = %d", __FUNCTION__, port->number, count);
if (!port->tty) { if (!port->tty) {
err ("%s - no tty???", __FUNCTION__); dev_err (port->dev, "%s - no tty???\n", __FUNCTION__);
return 0; return 0;
} }
...@@ -399,7 +399,7 @@ static int ir_write (struct usb_serial_port *port, int from_user, const unsigned ...@@ -399,7 +399,7 @@ static int ir_write (struct usb_serial_port *port, int from_user, const unsigned
result = usb_submit_urb (port->write_urb, GFP_ATOMIC); result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed submitting write urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
else else
result = transfer_size; result = transfer_size;
...@@ -503,11 +503,9 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -503,11 +503,9 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
port); port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", dev_err(port->dev, "%s - failed resubmitting read urb, error %d\n",
__FUNCTION__, __FUNCTION__, result);
result);
break ; break ;
...@@ -601,7 +599,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct termios *old_te ...@@ -601,7 +599,7 @@ static void ir_set_termios (struct usb_serial_port *port, struct termios *old_te
result = usb_submit_urb (port->write_urb, GFP_KERNEL); result = usb_submit_urb (port->write_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed submitting write urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
} }
return; return;
} }
......
This diff is collapsed.
...@@ -231,7 +231,7 @@ static void keyspan_pda_rx_interrupt (struct urb *urb, struct pt_regs *regs) ...@@ -231,7 +231,7 @@ static void keyspan_pda_rx_interrupt (struct urb *urb, struct pt_regs *regs)
int i; int i;
int status; int status;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private); priv = usb_get_serial_port_data(port);
switch (urb->status) { switch (urb->status) {
case 0: case 0:
...@@ -532,7 +532,7 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user, ...@@ -532,7 +532,7 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user,
int rc = 0; int rc = 0;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private); priv = usb_get_serial_port_data(port);
/* guess how much room is left in the device's ring buffer, and if we /* guess how much room is left in the device's ring buffer, and if we
want to send more than that, check first, updating our notion of want to send more than that, check first, updating our notion of
what is left. If our write will result in no room left, ask the what is left. If our write will result in no room left, ask the
...@@ -643,7 +643,7 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *re ...@@ -643,7 +643,7 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *re
struct usb_serial *serial; struct usb_serial *serial;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private); priv = usb_get_serial_port_data(port);
if (port_paranoia_check (port, "keyspan_pda_rx_interrupt")) { if (port_paranoia_check (port, "keyspan_pda_rx_interrupt")) {
return; return;
...@@ -662,7 +662,8 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *re ...@@ -662,7 +662,8 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *re
static int keyspan_pda_write_room (struct usb_serial_port *port) static int keyspan_pda_write_room (struct usb_serial_port *port)
{ {
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private);
priv = usb_get_serial_port_data(port);
/* used by n_tty.c for processing of tabs and such. Giving it our /* used by n_tty.c for processing of tabs and such. Giving it our
conservative guess is probably good enough, but needs testing by conservative guess is probably good enough, but needs testing by
...@@ -675,7 +676,8 @@ static int keyspan_pda_write_room (struct usb_serial_port *port) ...@@ -675,7 +676,8 @@ static int keyspan_pda_write_room (struct usb_serial_port *port)
static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
{ {
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private);
priv = usb_get_serial_port_data(port);
/* when throttled, return at least WAKEUP_CHARS to tell select() (via /* when throttled, return at least WAKEUP_CHARS to tell select() (via
n_tty.c:normal_poll() ) that we're not writeable. */ n_tty.c:normal_poll() ) that we're not writeable. */
...@@ -711,7 +713,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) ...@@ -711,7 +713,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
rc = -EIO; rc = -EIO;
goto error; goto error;
} }
priv = (struct keyspan_pda_private *)(port->private); priv = usb_get_serial_port_data(port);
priv->tx_room = room; priv->tx_room = room;
priv->tx_throttled = room ? 0 : 1; priv->tx_throttled = room ? 0 : 1;
...@@ -803,10 +805,10 @@ static int keyspan_pda_startup (struct usb_serial *serial) ...@@ -803,10 +805,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
/* allocate the private data structures for all ports. Well, for all /* allocate the private data structures for all ports. Well, for all
one ports. */ one ports. */
priv = serial->port[0].private priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
= kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
if (!priv) if (!priv)
return (1); /* error */ return (1); /* error */
usb_set_serial_port_data(&serial->port[0], priv);
init_waitqueue_head(&serial->port[0].write_wait); init_waitqueue_head(&serial->port[0].write_wait);
INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write,
(void *)(&serial->port[0])); (void *)(&serial->port[0]));
...@@ -820,7 +822,7 @@ static void keyspan_pda_shutdown (struct usb_serial *serial) ...@@ -820,7 +822,7 @@ static void keyspan_pda_shutdown (struct usb_serial *serial)
{ {
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
kfree(serial->port[0].private); kfree(usb_get_serial_port_data(&serial->port[0]));
} }
#ifdef KEYSPAN #ifdef KEYSPAN
......
...@@ -265,13 +265,12 @@ static int klsi_105_startup (struct usb_serial *serial) ...@@ -265,13 +265,12 @@ static int klsi_105_startup (struct usb_serial *serial)
/* allocate the private data structure */ /* allocate the private data structure */
for (i=0; i<serial->num_ports; i++) { for (i=0; i<serial->num_ports; i++) {
serial->port[i].private = kmalloc(sizeof(struct klsi_105_private), priv = kmalloc(sizeof(struct klsi_105_private),
GFP_KERNEL); GFP_KERNEL);
if (!serial->port[i].private) { if (!priv) {
dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__); dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__);
return (-1); /* error */ return -ENOMEM;
} }
priv = (struct klsi_105_private *)serial->port[i].private;
/* set initial values for control structures */ /* set initial values for control structures */
priv->cfg.pktlen = 5; priv->cfg.pktlen = 5;
priv->cfg.baudrate = kl5kusb105a_sio_b9600; priv->cfg.baudrate = kl5kusb105a_sio_b9600;
...@@ -283,6 +282,7 @@ static int klsi_105_startup (struct usb_serial *serial) ...@@ -283,6 +282,7 @@ static int klsi_105_startup (struct usb_serial *serial)
priv->bytes_in = 0; priv->bytes_in = 0;
priv->bytes_out = 0; priv->bytes_out = 0;
usb_set_serial_port_data(&serial->port[i], priv);
spin_lock_init (&priv->write_urb_pool_lock); spin_lock_init (&priv->write_urb_pool_lock);
for (i=0; i<NUM_URBS; i++) { for (i=0; i<NUM_URBS; i++) {
...@@ -319,8 +319,7 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -319,8 +319,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */ /* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
struct klsi_105_private *priv = struct klsi_105_private *priv = usb_get_serial_port_data(&serial->port[i]);
(struct klsi_105_private*) serial->port[i].private;
unsigned long flags; unsigned long flags;
if (priv) { if (priv) {
...@@ -347,7 +346,8 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -347,7 +346,8 @@ static void klsi_105_shutdown (struct usb_serial *serial)
spin_unlock_irqrestore (&priv->write_urb_pool_lock, spin_unlock_irqrestore (&priv->write_urb_pool_lock,
flags); flags);
kfree(serial->port[i].private); kfree(priv);
usb_set_serial_port_data(&serial->port[i], NULL);
} }
} }
} /* klsi_105_shutdown */ } /* klsi_105_shutdown */
...@@ -355,7 +355,7 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -355,7 +355,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
static int klsi_105_open (struct usb_serial_port *port, struct file *filp) static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = (struct klsi_105_private *)port->private; struct klsi_105_private *priv = usb_get_serial_port_data(port);
int retval = 0; int retval = 0;
int rc; int rc;
int i; int i;
...@@ -436,8 +436,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -436,8 +436,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
static void klsi_105_close (struct usb_serial_port *port, struct file *filp) static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial; struct usb_serial *serial;
struct klsi_105_private *priv struct klsi_105_private *priv = usb_get_serial_port_data(port);
= (struct klsi_105_private *)port->private;
int rc; int rc;
dbg("%s port %d", __FUNCTION__, port->number); dbg("%s port %d", __FUNCTION__, port->number);
...@@ -481,8 +480,7 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user, ...@@ -481,8 +480,7 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = struct klsi_105_private *priv = usb_get_serial_port_data(port);
(struct klsi_105_private*) port->private;
int result, size; int result, size;
int bytes_sent=0; int bytes_sent=0;
...@@ -588,8 +586,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port) ...@@ -588,8 +586,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
int chars = 0; int chars = 0;
int i; int i;
unsigned long flags; unsigned long flags;
struct klsi_105_private *priv = struct klsi_105_private *priv = usb_get_serial_port_data(port);
(struct klsi_105_private*) port->private;
spin_lock_irqsave (&priv->write_urb_pool_lock, flags); spin_lock_irqsave (&priv->write_urb_pool_lock, flags);
...@@ -610,8 +607,7 @@ static int klsi_105_write_room (struct usb_serial_port *port) ...@@ -610,8 +607,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
unsigned long flags; unsigned long flags;
int i; int i;
int room = 0; int room = 0;
struct klsi_105_private *priv = struct klsi_105_private *priv = usb_get_serial_port_data(port);
(struct klsi_105_private*) port->private;
spin_lock_irqsave (&priv->write_urb_pool_lock, flags); spin_lock_irqsave (&priv->write_urb_pool_lock, flags);
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
...@@ -632,8 +628,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -632,8 +628,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = struct klsi_105_private *priv = usb_get_serial_port_data(port);
(struct klsi_105_private*) port->private;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int rc; int rc;
...@@ -715,7 +710,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port, ...@@ -715,7 +710,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
struct termios *old_termios) struct termios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = (struct klsi_105_private *)port->private; struct klsi_105_private *priv = usb_get_serial_port_data(port);
unsigned int iflag = port->tty->termios->c_iflag; unsigned int iflag = port->tty->termios->c_iflag;
unsigned int old_iflag = old_termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag;
unsigned int cflag = port->tty->termios->c_cflag; unsigned int cflag = port->tty->termios->c_cflag;
...@@ -869,7 +864,7 @@ static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file, ...@@ -869,7 +864,7 @@ static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = (struct klsi_105_private *)port->private; struct klsi_105_private *priv = usb_get_serial_port_data(port);
int mask; int mask;
dbg("%scmd=0x%x", __FUNCTION__, cmd); dbg("%scmd=0x%x", __FUNCTION__, cmd);
......
...@@ -136,12 +136,11 @@ static int kobil_startup (struct usb_serial *serial) ...@@ -136,12 +136,11 @@ static int kobil_startup (struct usb_serial *serial)
struct usb_host_interface *altsetting; struct usb_host_interface *altsetting;
struct usb_host_endpoint *endpoint; struct usb_host_endpoint *endpoint;
serial->port->private = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL);
if (!serial->port->private){ if (!priv){
return -1; return -ENOMEM;
} }
priv = (struct kobil_private *) serial->port->private;
priv->filled = 0; priv->filled = 0;
priv->cur_pos = 0; priv->cur_pos = 0;
priv->device_type = serial->product; priv->device_type = serial->product;
...@@ -158,6 +157,7 @@ static int kobil_startup (struct usb_serial *serial) ...@@ -158,6 +157,7 @@ static int kobil_startup (struct usb_serial *serial)
printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); printk(KERN_DEBUG "KOBIL USBTWIN detected\n");
break; break;
} }
usb_set_serial_port_data(serial->port, priv);
// search for the neccessary endpoints // search for the neccessary endpoints
pdev = serial->dev; pdev = serial->dev;
...@@ -192,9 +192,8 @@ static void kobil_shutdown (struct usb_serial *serial) ...@@ -192,9 +192,8 @@ static void kobil_shutdown (struct usb_serial *serial)
while (serial->port[i].open_count > 0) { while (serial->port[i].open_count > 0) {
kobil_close (&serial->port[i], NULL); kobil_close (&serial->port[i], NULL);
} }
if (serial->port[i].private) { kfree(usb_get_serial_port_data(&serial->port[i]));
kfree(serial->port[i].private); usb_set_serial_port_data(&serial->port[i], NULL);
}
} }
} }
...@@ -208,7 +207,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) ...@@ -208,7 +207,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
int write_urb_transfer_buffer_length = 8; int write_urb_transfer_buffer_length = 8;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
priv = (struct kobil_private *) port->private; priv = usb_get_serial_port_data(port);
priv->line_state = 0; priv->line_state = 0;
if (port_paranoia_check (port, __FUNCTION__)) if (port_paranoia_check (port, __FUNCTION__))
...@@ -413,7 +412,7 @@ static int kobil_write (struct usb_serial_port *port, int from_user, ...@@ -413,7 +412,7 @@ static int kobil_write (struct usb_serial_port *port, int from_user,
return 0; return 0;
} }
priv = (struct kobil_private *) port->private; priv = usb_get_serial_port_data(port);
if (count > (KOBIL_BUF_LENGTH - priv->filled)) { if (count > (KOBIL_BUF_LENGTH - priv->filled)) {
dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number);
...@@ -513,7 +512,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, ...@@ -513,7 +512,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file,
int transfer_buffer_length = 8; int transfer_buffer_length = 8;
char *settings; char *settings;
priv = (struct kobil_private *) port->private; priv = usb_get_serial_port_data(port);
if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) { if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) {
// This device doesn't support ioctl calls // This device doesn't support ioctl calls
return 0; return 0;
......
...@@ -304,40 +304,40 @@ static int mct_u232_startup (struct usb_serial *serial) ...@@ -304,40 +304,40 @@ static int mct_u232_startup (struct usb_serial *serial)
struct mct_u232_private *priv; struct mct_u232_private *priv;
/* allocate the private data structure */ /* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct mct_u232_private), priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
GFP_KERNEL); if (!priv)
if (!serial->port->private)
return (-1); /* error */ return (-1); /* error */
priv = (struct mct_u232_private *)serial->port->private;
/* set initial values for control structures */ /* set initial values for control structures */
priv->control_state = 0; priv->control_state = 0;
priv->last_lsr = 0; priv->last_lsr = 0;
priv->last_msr = 0; priv->last_msr = 0;
usb_set_serial_port_data(serial->port, priv);
init_waitqueue_head(&serial->port->write_wait); init_waitqueue_head(&serial->port->write_wait);
return (0); return (0);
} /* mct_u232_startup */ } /* mct_u232_startup */
static void mct_u232_shutdown (struct usb_serial *serial) static void mct_u232_shutdown (struct usb_serial *serial)
{ {
struct mct_u232_private *priv;
int i; int i;
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */ /* My special items, the standard routines free my urbs */
if (serial->port[i].private) priv = usb_get_serial_port_data(&serial->port[i]);
kfree(serial->port[i].private); if (priv)
kfree(priv);
} }
} /* mct_u232_shutdown */ } /* mct_u232_shutdown */
static int mct_u232_open (struct usb_serial_port *port, struct file *filp) static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = usb_get_serial_port_data(port);
int retval = 0; int retval = 0;
dbg("%s port %d", __FUNCTION__, port->number); dbg("%s port %d", __FUNCTION__, port->number);
...@@ -375,7 +375,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) ...@@ -375,7 +375,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
struct usb_serial_port *rport; struct usb_serial_port *rport;
rport = &serial->port[1]; rport = &serial->port[1];
rport->tty = port->tty; rport->tty = port->tty;
rport->private = port->private; usb_set_serial_port_data(rport, usb_get_serial_port_data(port));
port->read_urb = rport->interrupt_in_urb; port->read_urb = rport->interrupt_in_urb;
} }
...@@ -518,7 +518,7 @@ static void mct_u232_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -518,7 +518,7 @@ static void mct_u232_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void mct_u232_read_int_callback (struct urb *urb, struct pt_regs *regs) static void mct_u232_read_int_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -609,7 +609,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, ...@@ -609,7 +609,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
struct termios *old_termios) struct termios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned int iflag = port->tty->termios->c_iflag; unsigned int iflag = port->tty->termios->c_iflag;
unsigned int old_iflag = old_termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag;
unsigned int cflag = port->tty->termios->c_cflag; unsigned int cflag = port->tty->termios->c_cflag;
...@@ -725,7 +725,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, ...@@ -725,7 +725,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned char lcr = priv->last_lcr; unsigned char lcr = priv->last_lcr;
dbg("%sstate=%d", __FUNCTION__, break_state); dbg("%sstate=%d", __FUNCTION__, break_state);
...@@ -741,7 +741,7 @@ static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, ...@@ -741,7 +741,7 @@ static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = usb_get_serial_port_data(port);
int mask; int mask;
dbg("%scmd=0x%x", __FUNCTION__, cmd); dbg("%scmd=0x%x", __FUNCTION__, cmd);
......
...@@ -168,7 +168,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) ...@@ -168,7 +168,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
return -ENOMEM; return -ENOMEM;
} }
port->private = od; usb_set_serial_port_data(port, od);
wport = &serial->port[1]; wport = &serial->port[1];
wport->tty = port->tty; wport->tty = port->tty;
...@@ -205,7 +205,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) ...@@ -205,7 +205,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
} }
od = (struct omninet_data *)port->private; od = usb_get_serial_port_data(port);
if (od) if (od)
kfree(od); kfree(od);
} }
...@@ -272,7 +272,7 @@ static int omninet_write (struct usb_serial_port *port, int from_user, const uns ...@@ -272,7 +272,7 @@ static int omninet_write (struct usb_serial_port *port, int from_user, const uns
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct usb_serial_port *wport = &serial->port[1]; struct usb_serial_port *wport = &serial->port[1];
struct omninet_data *od = (struct omninet_data *) port->private; struct omninet_data *od = usb_get_serial_port_data(port);
struct omninet_header *header = (struct omninet_header *) wport->write_urb->transfer_buffer; struct omninet_header *header = (struct omninet_header *) wport->write_urb->transfer_buffer;
int result; int result;
......
...@@ -163,7 +163,7 @@ static int pl2303_startup (struct usb_serial *serial) ...@@ -163,7 +163,7 @@ static int pl2303_startup (struct usb_serial *serial)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
memset (priv, 0x00, sizeof (struct pl2303_private)); memset (priv, 0x00, sizeof (struct pl2303_private));
serial->port[i].private = priv; usb_set_serial_port_data(&serial->port[i], priv);
} }
return 0; return 0;
} }
...@@ -204,7 +204,7 @@ static int pl2303_write (struct usb_serial_port *port, int from_user, const uns ...@@ -204,7 +204,7 @@ static int pl2303_write (struct usb_serial_port *port, int from_user, const uns
port->write_urb->dev = port->serial->dev; port->write_urb->dev = port->serial->dev;
result = usb_submit_urb (port->write_urb, GFP_ATOMIC); result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed submitting write urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result);
else else
result = count; result = count;
...@@ -216,24 +216,23 @@ static int pl2303_write (struct usb_serial_port *port, int from_user, const uns ...@@ -216,24 +216,23 @@ static int pl2303_write (struct usb_serial_port *port, int from_user, const uns
static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios) static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct pl2303_private *priv; struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int cflag; unsigned int cflag;
unsigned char *buf; unsigned char *buf;
int baud; int baud;
int i; int i;
dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number, dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number, priv->termios_initialized);
((struct pl2303_private *) port->private)->termios_initialized);
if ((!port->tty) || (!port->tty->termios)) { if ((!port->tty) || (!port->tty->termios)) {
dbg("%s - no tty structures", __FUNCTION__); dbg("%s - no tty structures", __FUNCTION__);
return; return;
} }
if (!(((struct pl2303_private *) port->private)->termios_initialized)) { if (!priv->termios_initialized) {
*(port->tty->termios) = tty_std_termios; *(port->tty->termios) = tty_std_termios;
port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
((struct pl2303_private *) port->private)->termios_initialized = 1; priv->termios_initialized = 1;
} }
cflag = port->tty->termios->c_cflag; cflag = port->tty->termios->c_cflag;
/* check that they really want us to change something */ /* check that they really want us to change something */
...@@ -247,7 +246,7 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol ...@@ -247,7 +246,7 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
buf = kmalloc (7, GFP_KERNEL); buf = kmalloc (7, GFP_KERNEL);
if (!buf) { if (!buf) {
err("%s - out of memory.", __FUNCTION__); dev_err(port->dev, "%s - out of memory.\n", __FUNCTION__);
return; return;
} }
memset (buf, 0x00, 0x07); memset (buf, 0x00, 0x07);
...@@ -295,7 +294,7 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol ...@@ -295,7 +294,7 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
case B230400: baud = 230400; break; case B230400: baud = 230400; break;
case B460800: baud = 460800; break; case B460800: baud = 460800; break;
default: default:
err ("pl2303 driver does not support the baudrate requested (fix it)"); dev_err(port->dev, "pl2303 driver does not support the baudrate requested (fix it)\n");
break; break;
} }
dbg("%s - baud = %d", __FUNCTION__, baud); dbg("%s - baud = %d", __FUNCTION__, baud);
...@@ -341,7 +340,6 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol ...@@ -341,7 +340,6 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
dbg ("0x21:0x20:0:0 %d", i); dbg ("0x21:0x20:0:0 %d", i);
if (cflag && CBAUD) { if (cflag && CBAUD) {
priv = port->private;
if ((cflag && CBAUD) == B0) if ((cflag && CBAUD) == B0)
priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
else else
...@@ -413,7 +411,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) ...@@ -413,7 +411,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
port->read_urb->dev = serial->dev; port->read_urb->dev = serial->dev;
result = usb_submit_urb (port->read_urb, GFP_KERNEL); result = usb_submit_urb (port->read_urb, GFP_KERNEL);
if (result) { if (result) {
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
pl2303_close (port, NULL); pl2303_close (port, NULL);
return -EPROTO; return -EPROTO;
} }
...@@ -422,7 +420,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) ...@@ -422,7 +420,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
port->interrupt_in_urb->dev = serial->dev; port->interrupt_in_urb->dev = serial->dev;
result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL); result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL);
if (result) { if (result) {
err("%s - failed submitting interrupt urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting interrupt urb, error %d\n", __FUNCTION__, result);
pl2303_close (port, NULL); pl2303_close (port, NULL);
return -EPROTO; return -EPROTO;
} }
...@@ -450,7 +448,7 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) ...@@ -450,7 +448,7 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
c_cflag = port->tty->termios->c_cflag; c_cflag = port->tty->termios->c_cflag;
if (c_cflag & HUPCL) { if (c_cflag & HUPCL) {
/* drop DTR and RTS */ /* drop DTR and RTS */
priv = port->private; priv = usb_get_serial_port_data(port);
priv->line_control = 0; priv->line_control = 0;
set_control_lines (port->serial->dev, set_control_lines (port->serial->dev,
priv->line_control); priv->line_control);
...@@ -481,7 +479,7 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) ...@@ -481,7 +479,7 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value) static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
{ {
struct pl2303_private *priv = port->private; struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int arg; unsigned int arg;
if (copy_from_user(&arg, value, sizeof(int))) if (copy_from_user(&arg, value, sizeof(int)))
...@@ -516,7 +514,7 @@ static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsig ...@@ -516,7 +514,7 @@ static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsig
static int get_modem_info (struct usb_serial_port *port, unsigned int *value) static int get_modem_info (struct usb_serial_port *port, unsigned int *value)
{ {
struct pl2303_private *priv = port->private; struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int mcr = priv->line_control; unsigned int mcr = priv->line_control;
unsigned int result; unsigned int result;
...@@ -583,8 +581,10 @@ static void pl2303_shutdown (struct usb_serial *serial) ...@@ -583,8 +581,10 @@ static void pl2303_shutdown (struct usb_serial *serial)
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
for (i = 0; i < serial->num_ports; ++i) for (i = 0; i < serial->num_ports; ++i) {
kfree (serial->port[i].private); kfree (usb_get_serial_port_data(&serial->port[i]));
usb_set_serial_port_data(&serial->port[i], NULL);
}
} }
...@@ -621,8 +621,8 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -621,8 +621,8 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs)
exit: exit:
status = usb_submit_urb (urb, GFP_ATOMIC); status = usb_submit_urb (urb, GFP_ATOMIC);
if (status) if (status)
err ("%s - usb_submit_urb failed with result %d", dev_err(urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
__FUNCTION__, status); __FUNCTION__, status);
} }
...@@ -658,7 +658,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -658,7 +658,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
urb->dev = serial->dev; urb->dev = serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
return; return;
} }
dbg("%s - unable to handle the error, exiting.", __FUNCTION__); dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
...@@ -683,7 +683,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -683,7 +683,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
urb->dev = serial->dev; urb->dev = serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
} }
return; return;
...@@ -712,7 +712,7 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -712,7 +712,7 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
port->write_urb->dev = port->serial->dev; port->write_urb->dev = port->serial->dev;
result = usb_submit_urb (port->write_urb, GFP_ATOMIC); result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting write urb, error %d", __FUNCTION__, result); dev_err(urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", __FUNCTION__, result);
return; return;
} }
......
...@@ -366,7 +366,7 @@ static struct usb_device_id generic_serial_ids[] = { ...@@ -366,7 +366,7 @@ static struct usb_device_id generic_serial_ids[] = {
/* Driver structure we register with the USB core */ /* Driver structure we register with the USB core */
static struct usb_driver usb_serial_driver = { static struct usb_driver usb_serial_driver = {
.name = "serial", .name = "usbserial",
.probe = usb_serial_probe, .probe = usb_serial_probe,
.disconnect = usb_serial_disconnect, .disconnect = usb_serial_disconnect,
#ifdef CONFIG_USB_SERIAL_GENERIC #ifdef CONFIG_USB_SERIAL_GENERIC
...@@ -841,7 +841,7 @@ static struct usb_serial * create_serial (struct usb_device *dev, ...@@ -841,7 +841,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
serial = kmalloc (sizeof (*serial), GFP_KERNEL); serial = kmalloc (sizeof (*serial), GFP_KERNEL);
if (!serial) { if (!serial) {
err ("%s - out of memory", __FUNCTION__); dev_err(dev->dev, "%s - out of memory\n", __FUNCTION__);
return NULL; return NULL;
} }
memset (serial, 0, sizeof(*serial)); memset (serial, 0, sizeof(*serial));
...@@ -899,14 +899,14 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -899,14 +899,14 @@ int usb_serial_probe(struct usb_interface *interface,
serial = create_serial (dev, interface, type); serial = create_serial (dev, interface, type);
if (!serial) { if (!serial) {
err ("%s - out of memory", __FUNCTION__); dev_err(interface->dev, "%s - out of memory\n", __FUNCTION__);
return -ENODEV; return -ENODEV;
} }
/* if this device type has a probe function, call it */ /* if this device type has a probe function, call it */
if (type->probe) { if (type->probe) {
if (!try_module_get(type->owner)) { if (!try_module_get(type->owner)) {
err ("module get failed, exiting"); dev_err(interface->dev, "module get failed, exiting\n");
kfree (serial); kfree (serial);
return -EIO; return -EIO;
} }
...@@ -980,7 +980,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -980,7 +980,7 @@ int usb_serial_probe(struct usb_interface *interface,
* properly during a later invocation of usb_serial_probe * properly during a later invocation of usb_serial_probe
*/ */
if (num_bulk_in == 0 || num_bulk_out == 0) { if (num_bulk_in == 0 || num_bulk_out == 0) {
info("PL-2303 hack: descriptors matched but endpoints did not"); dev_info(interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n");
kfree (serial); kfree (serial);
return -ENODEV; return -ENODEV;
} }
...@@ -989,13 +989,13 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -989,13 +989,13 @@ int usb_serial_probe(struct usb_interface *interface,
#endif #endif
/* found all that we need */ /* found all that we need */
info("%s converter detected", type->name); dev_info(interface->dev, "%s converter detected\n", type->name);
#ifdef CONFIG_USB_SERIAL_GENERIC #ifdef CONFIG_USB_SERIAL_GENERIC
if (type == &usb_serial_generic_device) { if (type == &usb_serial_generic_device) {
num_ports = num_bulk_out; num_ports = num_bulk_out;
if (num_ports == 0) { if (num_ports == 0) {
err("Generic device with no bulk out, not allowed."); dev_err(interface->dev, "Generic device with no bulk out, not allowed.\n");
kfree (serial); kfree (serial);
return -EIO; return -EIO;
} }
...@@ -1005,7 +1005,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1005,7 +1005,7 @@ int usb_serial_probe(struct usb_interface *interface,
/* if this device type has a calc_num_ports function, call it */ /* if this device type has a calc_num_ports function, call it */
if (type->calc_num_ports) { if (type->calc_num_ports) {
if (!try_module_get(type->owner)) { if (!try_module_get(type->owner)) {
err ("module get failed, exiting"); dev_err(interface->dev, "module get failed, exiting\n");
kfree (serial); kfree (serial);
return -EIO; return -EIO;
} }
...@@ -1017,7 +1017,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1017,7 +1017,7 @@ int usb_serial_probe(struct usb_interface *interface,
} }
if (get_free_serial (serial, num_ports, &minor) == NULL) { if (get_free_serial (serial, num_ports, &minor) == NULL) {
err("No more free serial devices"); dev_err(interface->dev, "No more free serial devices\n");
kfree (serial); kfree (serial);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1034,14 +1034,14 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1034,14 +1034,14 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i]; port = &serial->port[i];
port->read_urb = usb_alloc_urb (0, GFP_KERNEL); port->read_urb = usb_alloc_urb (0, GFP_KERNEL);
if (!port->read_urb) { if (!port->read_urb) {
err("No free urbs available"); dev_err(interface->dev, "No free urbs available\n");
goto probe_error; goto probe_error;
} }
buffer_size = endpoint->wMaxPacketSize; buffer_size = endpoint->wMaxPacketSize;
port->bulk_in_endpointAddress = endpoint->bEndpointAddress; port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!port->bulk_in_buffer) { if (!port->bulk_in_buffer) {
err("Couldn't allocate bulk_in_buffer"); dev_err(interface->dev, "Couldn't allocate bulk_in_buffer\n");
goto probe_error; goto probe_error;
} }
usb_fill_bulk_urb (port->read_urb, dev, usb_fill_bulk_urb (port->read_urb, dev,
...@@ -1059,7 +1059,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1059,7 +1059,7 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i]; port = &serial->port[i];
port->write_urb = usb_alloc_urb(0, GFP_KERNEL); port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->write_urb) { if (!port->write_urb) {
err("No free urbs available"); dev_err(interface->dev, "No free urbs available\n");
goto probe_error; goto probe_error;
} }
buffer_size = endpoint->wMaxPacketSize; buffer_size = endpoint->wMaxPacketSize;
...@@ -1067,7 +1067,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1067,7 +1067,7 @@ int usb_serial_probe(struct usb_interface *interface,
port->bulk_out_endpointAddress = endpoint->bEndpointAddress; port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL); port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!port->bulk_out_buffer) { if (!port->bulk_out_buffer) {
err("Couldn't allocate bulk_out_buffer"); dev_err(interface->dev, "Couldn't allocate bulk_out_buffer\n");
goto probe_error; goto probe_error;
} }
usb_fill_bulk_urb (port->write_urb, dev, usb_fill_bulk_urb (port->write_urb, dev,
...@@ -1085,14 +1085,14 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1085,14 +1085,14 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i]; port = &serial->port[i];
port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->interrupt_in_urb) { if (!port->interrupt_in_urb) {
err("No free urbs available"); dev_err(interface->dev, "No free urbs available\n");
goto probe_error; goto probe_error;
} }
buffer_size = endpoint->wMaxPacketSize; buffer_size = endpoint->wMaxPacketSize;
port->interrupt_in_endpointAddress = endpoint->bEndpointAddress; port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!port->interrupt_in_buffer) { if (!port->interrupt_in_buffer) {
err("Couldn't allocate interrupt_in_buffer"); dev_err(interface->dev, "Couldn't allocate interrupt_in_buffer\n");
goto probe_error; goto probe_error;
} }
usb_fill_int_urb (port->interrupt_in_urb, dev, usb_fill_int_urb (port->interrupt_in_urb, dev,
...@@ -1121,7 +1121,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1121,7 +1121,7 @@ int usb_serial_probe(struct usb_interface *interface,
/* if this device type has an attach function, call it */ /* if this device type has an attach function, call it */
if (type->attach) { if (type->attach) {
if (!try_module_get(type->owner)) { if (!try_module_get(type->owner)) {
err ("module get failed, exiting"); dev_err(interface->dev, "module get failed, exiting\n");
goto probe_error; goto probe_error;
} }
retval = type->attach (serial); retval = type->attach (serial);
...@@ -1190,6 +1190,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1190,6 +1190,7 @@ int usb_serial_probe(struct usb_interface *interface,
void usb_serial_disconnect(struct usb_interface *interface) void usb_serial_disconnect(struct usb_interface *interface)
{ {
struct usb_serial *serial = dev_get_drvdata (&interface->dev); struct usb_serial *serial = dev_get_drvdata (&interface->dev);
struct device *dev = &interface->dev;
struct usb_serial_port *port; struct usb_serial_port *port;
int i; int i;
...@@ -1252,14 +1253,13 @@ void usb_serial_disconnect(struct usb_interface *interface) ...@@ -1252,14 +1253,13 @@ void usb_serial_disconnect(struct usb_interface *interface)
/* free up any memory that we allocated */ /* free up any memory that we allocated */
kfree (serial); kfree (serial);
} }
info("device disconnected"); dev_info(*dev, "device disconnected\n");
} }
struct tty_driver usb_serial_tty_driver = { struct tty_driver usb_serial_tty_driver = {
.magic = TTY_DRIVER_MAGIC, .magic = TTY_DRIVER_MAGIC,
.driver_name = "usb-serial", .driver_name = "usbserial",
#ifndef CONFIG_DEVFS_FS #ifndef CONFIG_DEVFS_FS
.name = "ttyUSB", .name = "ttyUSB",
#else #else
......
...@@ -90,9 +90,6 @@ ...@@ -90,9 +90,6 @@
* @work: work queue entry for the line discipline waking up. * @work: work queue entry for the line discipline waking up.
* @open_count: number of times this port has been opened. * @open_count: number of times this port has been opened.
* @sem: struct semaphore used to lock this structure. * @sem: struct semaphore used to lock this structure.
* @private: place to put any driver specific information that is needed. The
* usb-serial driver is required to manage this data, the usb-serial core
* will not touch this.
* *
* This structure is used by the usb-serial core and drivers for the specific * This structure is used by the usb-serial core and drivers for the specific
* ports of a device. * ports of a device.
...@@ -120,11 +117,21 @@ struct usb_serial_port { ...@@ -120,11 +117,21 @@ struct usb_serial_port {
struct work_struct work; struct work_struct work;
int open_count; int open_count;
struct semaphore sem; struct semaphore sem;
void * private;
struct device dev; struct device dev;
}; };
#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) #define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
/* get and set the port private data pointer helper functions */
static inline void *usb_get_serial_port_data (struct usb_serial_port *port)
{
return dev_get_drvdata(&port->dev);
}
static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data)
{
dev_set_drvdata(&port->dev, data);
}
/** /**
* usb_serial - structure used by the usb-serial core for a device * usb_serial - structure used by the usb-serial core for a device
* @magic: magic number for internal validity of this pointer. * @magic: magic number for internal validity of this pointer.
...@@ -141,7 +148,8 @@ struct usb_serial_port { ...@@ -141,7 +148,8 @@ struct usb_serial_port {
* @port: array of struct usb_serial_port structures for the different ports. * @port: array of struct usb_serial_port structures for the different ports.
* @private: place to put any driver specific information that is needed. The * @private: place to put any driver specific information that is needed. The
* usb-serial driver is required to manage this data, the usb-serial core * usb-serial driver is required to manage this data, the usb-serial core
* will not touch this. * will not touch this. Use usb_get_serial_data() and
* usb_set_serial_data() to access this.
*/ */
struct usb_serial { struct usb_serial {
int magic; int magic;
...@@ -159,9 +167,18 @@ struct usb_serial { ...@@ -159,9 +167,18 @@ struct usb_serial {
void * private; void * private;
}; };
#define NUM_DONT_CARE (-1) #define NUM_DONT_CARE (-1)
/* get and set the serial private data pointer helper functions */
static inline void *usb_get_serial_data (struct usb_serial *serial)
{
return serial->private;
}
static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
{
serial->private = data;
}
/** /**
* usb_serial_device_type - a structure that defines a usb serial device * usb_serial_device_type - a structure that defines a usb serial device
......
...@@ -303,7 +303,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -303,7 +303,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
if (!port->read_urb) { if (!port->read_urb) {
/* this is needed for some brain dead Sony devices */ /* this is needed for some brain dead Sony devices */
err ("Device lied about number of ports, please use a lower one."); dev_err(port->dev, "Device lied about number of ports, please use a lower one.\n");
return -ENODEV; return -ENODEV;
} }
...@@ -327,8 +327,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -327,8 +327,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
visor_read_bulk_callback, port); visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) { if (result) {
err("%s - failed submitting read urb, error %d", dev_err(port->dev, "%s - failed submitting read urb, error %d\n",
__FUNCTION__, result); __FUNCTION__, result);
goto exit; goto exit;
} }
...@@ -336,8 +336,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -336,8 +336,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
dbg("%s - adding interrupt input for treo", __FUNCTION__); dbg("%s - adding interrupt input for treo", __FUNCTION__);
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (result) if (result)
err("%s - failed submitting interrupt urb, error %d", dev_err(port->dev, "%s - failed submitting interrupt urb, error %d\n",
__FUNCTION__, result); __FUNCTION__, result);
} }
exit: exit:
return result; return result;
...@@ -363,7 +363,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) ...@@ -363,7 +363,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
* device is still here */ * device is still here */
transfer_buffer = kmalloc (0x12, GFP_KERNEL); transfer_buffer = kmalloc (0x12, GFP_KERNEL);
if (!transfer_buffer) { if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, 0x12); dev_err(port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x12);
} else { } else {
/* send a shutdown message to the device */ /* send a shutdown message to the device */
usb_control_msg (serial->dev, usb_control_msg (serial->dev,
...@@ -380,7 +380,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) ...@@ -380,7 +380,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->interrupt_in_urb); usb_unlink_urb (port->interrupt_in_urb);
} }
/* Uncomment the following line if you want to see some statistics in your syslog */ /* Uncomment the following line if you want to see some statistics in your syslog */
/* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ /* dev_info (port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */
} }
...@@ -395,13 +395,13 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig ...@@ -395,13 +395,13 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig
buffer = kmalloc (count, GFP_ATOMIC); buffer = kmalloc (count, GFP_ATOMIC);
if (!buffer) { if (!buffer) {
err ("out of memory"); dev_err(port->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
} }
urb = usb_alloc_urb(0, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) { if (!urb) {
err ("no more free urbs"); dev_err(port->dev, "no more free urbs\n");
kfree (buffer); kfree (buffer);
return -ENOMEM; return -ENOMEM;
} }
...@@ -427,8 +427,8 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig ...@@ -427,8 +427,8 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig
/* send it down the pipe */ /* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC); status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) { if (status) {
err("%s - usb_submit_urb(write bulk) failed with status = %d", dev_err(port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
__FUNCTION__, status); __FUNCTION__, status);
count = status; count = status;
} else { } else {
bytes_out += count; bytes_out += count;
...@@ -539,7 +539,7 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -539,7 +539,7 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
visor_read_bulk_callback, port); visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
return; return;
} }
...@@ -577,8 +577,8 @@ static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -577,8 +577,8 @@ static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs)
exit: exit:
result = usb_submit_urb (urb, GFP_ATOMIC); result = usb_submit_urb (urb, GFP_ATOMIC);
if (result) if (result)
err("%s - Error %d submitting interrupt urb", dev_err(urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
__FUNCTION__, result); __FUNCTION__, result);
} }
static void visor_throttle (struct usb_serial_port *port) static void visor_throttle (struct usb_serial_port *port)
...@@ -597,18 +597,19 @@ static void visor_unthrottle (struct usb_serial_port *port) ...@@ -597,18 +597,19 @@ static void visor_unthrottle (struct usb_serial_port *port)
port->read_urb->dev = port->serial->dev; port->read_urb->dev = port->serial->dev;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
err("%s - failed submitting read urb, error %d", __FUNCTION__, result); dev_err(port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
} }
static int visor_probe (struct usb_serial *serial) static int visor_probe (struct usb_serial *serial)
{ {
struct device *dev = &serial->dev->dev;
int response; int response;
int i; int i;
int num_ports; int num_ports;
unsigned char *transfer_buffer = kmalloc (256, GFP_KERNEL); unsigned char *transfer_buffer = kmalloc (256, GFP_KERNEL);
if (!transfer_buffer) { if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, 256); dev_err(*dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 256);
return -ENOMEM; return -ENOMEM;
} }
...@@ -621,14 +622,14 @@ static int visor_probe (struct usb_serial *serial) ...@@ -621,14 +622,14 @@ static int visor_probe (struct usb_serial *serial)
response = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_GET_CONNECTION_INFORMATION, response = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_GET_CONNECTION_INFORMATION,
0xc2, 0x0000, 0x0000, transfer_buffer, 0x12, 300); 0xc2, 0x0000, 0x0000, transfer_buffer, 0x12, 300);
if (response < 0) { if (response < 0) {
err("%s - error getting connection information", __FUNCTION__); dev_err(*dev, "%s - error getting connection information\n", __FUNCTION__);
} else { } else {
struct visor_connection_info *connection_info = (struct visor_connection_info *)transfer_buffer; struct visor_connection_info *connection_info = (struct visor_connection_info *)transfer_buffer;
char *string; char *string;
le16_to_cpus(&connection_info->num_ports); le16_to_cpus(&connection_info->num_ports);
num_ports = connection_info->num_ports; num_ports = connection_info->num_ports;
info("%s: Number of ports: %d", serial->type->name, connection_info->num_ports); dev_info(*dev, "%s: Number of ports: %d\n", serial->type->name, connection_info->num_ports);
for (i = 0; i < num_ports; ++i) { for (i = 0; i < num_ports; ++i) {
switch (connection_info->connections[i].port_function_id) { switch (connection_info->connections[i].port_function_id) {
case VISOR_FUNCTION_GENERIC: case VISOR_FUNCTION_GENERIC:
...@@ -650,10 +651,10 @@ static int visor_probe (struct usb_serial *serial) ...@@ -650,10 +651,10 @@ static int visor_probe (struct usb_serial *serial)
string = "unknown"; string = "unknown";
break; break;
} }
info("%s: port %d, is for %s use", serial->type->name, dev_info(*dev, "%s: port %d, is for %s use\n", serial->type->name,
connection_info->connections[i].port, string); connection_info->connections[i].port, string);
/* save off our num_ports info so that we can use it in the calc_num_ports call */ /* save off our num_ports info so that we can use it in the calc_num_ports call */
serial->private = (void *)(long)num_ports; usb_set_serial_data(serial, (void *)(long)num_ports);
} }
} }
...@@ -666,7 +667,7 @@ static int visor_probe (struct usb_serial *serial) ...@@ -666,7 +667,7 @@ static int visor_probe (struct usb_serial *serial)
0xc2, 0x0000, 0x0000, transfer_buffer, 0xc2, 0x0000, 0x0000, transfer_buffer,
0x14, 300); 0x14, 300);
if (response < 0) { if (response < 0) {
err("%s - error getting first unknown palm command", __FUNCTION__); dev_err(*dev, "%s - error getting first unknown palm command\n", __FUNCTION__);
} else { } else {
usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer); usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer);
} }
...@@ -675,7 +676,7 @@ static int visor_probe (struct usb_serial *serial) ...@@ -675,7 +676,7 @@ static int visor_probe (struct usb_serial *serial)
0xc2, 0x0000, 0x0000, transfer_buffer, 0xc2, 0x0000, 0x0000, transfer_buffer,
0x14, 300); 0x14, 300);
if (response < 0) { if (response < 0) {
err("%s - error getting second unknown palm command", __FUNCTION__); dev_err(*dev, "%s - error getting second unknown palm command\n", __FUNCTION__);
} else { } else {
usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer); usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer);
} }
...@@ -685,7 +686,7 @@ static int visor_probe (struct usb_serial *serial) ...@@ -685,7 +686,7 @@ static int visor_probe (struct usb_serial *serial)
response = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_REQUEST_BYTES_AVAILABLE, response = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), VISOR_REQUEST_BYTES_AVAILABLE,
0xc2, 0x0000, 0x0005, transfer_buffer, 0x02, 300); 0xc2, 0x0000, 0x0005, transfer_buffer, 0x02, 300);
if (response < 0) { if (response < 0) {
err("%s - error getting bytes available request", __FUNCTION__); dev_err(*dev, "%s - error getting bytes available request\n", __FUNCTION__);
} }
kfree (transfer_buffer); kfree (transfer_buffer);
...@@ -696,17 +697,17 @@ static int visor_probe (struct usb_serial *serial) ...@@ -696,17 +697,17 @@ static int visor_probe (struct usb_serial *serial)
static int visor_calc_num_ports (struct usb_serial *serial) static int visor_calc_num_ports (struct usb_serial *serial)
{ {
int num_ports = 0; int num_ports = (int)(long)(usb_get_serial_data(serial));
if (num_ports)
usb_set_serial_data(serial, NULL);
if (serial->private) {
num_ports = (int)(long)serial->private;
serial->private = NULL;
}
return num_ports; return num_ports;
} }
static int clie_3_5_startup (struct usb_serial *serial) static int clie_3_5_startup (struct usb_serial *serial)
{ {
struct device *dev = &serial->dev->dev;
int result; int result;
u8 data; u8 data;
...@@ -721,11 +722,11 @@ static int clie_3_5_startup (struct usb_serial *serial) ...@@ -721,11 +722,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
USB_REQ_GET_CONFIGURATION, USB_DIR_IN, USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
0, 0, &data, 1, HZ * 3); 0, 0, &data, 1, HZ * 3);
if (result < 0) { if (result < 0) {
err("%s: get config number failed: %d", __FUNCTION__, result); dev_err(*dev, "%s: get config number failed: %d\n", __FUNCTION__, result);
return result; return result;
} }
if (result != 1) { if (result != 1) {
err("%s: get config number bad return length: %d", __FUNCTION__, result); dev_err(*dev, "%s: get config number bad return length: %d\n", __FUNCTION__, result);
return -EIO; return -EIO;
} }
...@@ -735,11 +736,11 @@ static int clie_3_5_startup (struct usb_serial *serial) ...@@ -735,11 +736,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
USB_DIR_IN | USB_RECIP_INTERFACE, USB_DIR_IN | USB_RECIP_INTERFACE,
0, 0, &data, 1, HZ * 3); 0, 0, &data, 1, HZ * 3);
if (result < 0) { if (result < 0) {
err("%s: get interface number failed: %d", __FUNCTION__, result); dev_err(*dev, "%s: get interface number failed: %d\n", __FUNCTION__, result);
return result; return result;
} }
if (result != 1) { if (result != 1) {
err("%s: get interface number bad return length: %d", __FUNCTION__, result); dev_err(*dev, "%s: get interface number bad return length: %d\n", __FUNCTION__, result);
return -EIO; return -EIO;
} }
......
...@@ -464,7 +464,7 @@ static int whiteheat_attach (struct usb_serial *serial) ...@@ -464,7 +464,7 @@ static int whiteheat_attach (struct usb_serial *serial)
list_add(&wrap->list, &info->tx_urbs_free); list_add(&wrap->list, &info->tx_urbs_free);
} }
port->private = info; usb_set_serial_port_data(port, info);
} }
command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL);
...@@ -476,7 +476,7 @@ static int whiteheat_attach (struct usb_serial *serial) ...@@ -476,7 +476,7 @@ static int whiteheat_attach (struct usb_serial *serial)
spin_lock_init(&command_info->lock); spin_lock_init(&command_info->lock);
command_info->port_running = 0; command_info->port_running = 0;
init_waitqueue_head(&command_info->wait_command); init_waitqueue_head(&command_info->wait_command);
command_port->private = command_info; usb_set_serial_port_data(command_port, command_info);
command_port->write_urb->complete = command_port_write_callback; command_port->write_urb->complete = command_port_write_callback;
command_port->read_urb->complete = command_port_read_callback; command_port->read_urb->complete = command_port_read_callback;
...@@ -492,7 +492,7 @@ static int whiteheat_attach (struct usb_serial *serial) ...@@ -492,7 +492,7 @@ static int whiteheat_attach (struct usb_serial *serial)
no_command_private: no_command_private:
for (i = serial->num_ports - 1; i >= 0; i--) { for (i = serial->num_ports - 1; i >= 0; i--) {
port = &serial->port[i]; port = &serial->port[i];
info = port->private; info = usb_get_serial_port_data(port);
for (j = urb_pool_size - 1; j >= 0; j--) { for (j = urb_pool_size - 1; j >= 0; j--) {
tmp = list_first(&info->tx_urbs_free); tmp = list_first(&info->tx_urbs_free);
list_del(tmp); list_del(tmp);
...@@ -539,11 +539,11 @@ static void whiteheat_shutdown (struct usb_serial *serial) ...@@ -539,11 +539,11 @@ static void whiteheat_shutdown (struct usb_serial *serial)
/* free up our private data for our command port */ /* free up our private data for our command port */
command_port = &serial->port[COMMAND_PORT]; command_port = &serial->port[COMMAND_PORT];
kfree (command_port->private); kfree (usb_get_serial_port_data(command_port));
for (i = 0; i < serial->num_ports; i++) { for (i = 0; i < serial->num_ports; i++) {
port = &serial->port[i]; port = &serial->port[i];
info = port->private; info = usb_get_serial_port_data(port);
list_for_each_safe(tmp, tmp2, &info->rx_urbs_free) { list_for_each_safe(tmp, tmp2, &info->rx_urbs_free) {
list_del(tmp); list_del(tmp);
wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
...@@ -620,7 +620,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -620,7 +620,7 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
static void whiteheat_close(struct usb_serial_port *port, struct file * filp) static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
{ {
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
struct urb *urb; struct urb *urb;
struct list_head *tmp; struct list_head *tmp;
...@@ -686,7 +686,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) ...@@ -686,7 +686,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
struct urb *urb; struct urb *urb;
int result; int result;
...@@ -749,7 +749,7 @@ static int whiteheat_write(struct usb_serial_port *port, int from_user, const un ...@@ -749,7 +749,7 @@ static int whiteheat_write(struct usb_serial_port *port, int from_user, const un
static int whiteheat_write_room(struct usb_serial_port *port) static int whiteheat_write_room(struct usb_serial_port *port)
{ {
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct list_head *tmp; struct list_head *tmp;
int room = 0; int room = 0;
unsigned long flags; unsigned long flags;
...@@ -769,7 +769,7 @@ static int whiteheat_write_room(struct usb_serial_port *port) ...@@ -769,7 +769,7 @@ static int whiteheat_write_room(struct usb_serial_port *port)
static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
{ {
struct whiteheat_private *info = (struct whiteheat_private *)port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
unsigned int modem_signals = 0; unsigned int modem_signals = 0;
struct serial_struct serstruct; struct serial_struct serstruct;
...@@ -903,7 +903,7 @@ static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) { ...@@ -903,7 +903,7 @@ static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) {
static int whiteheat_chars_in_buffer(struct usb_serial_port *port) static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
{ {
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct list_head *tmp; struct list_head *tmp;
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
int chars = 0; int chars = 0;
...@@ -925,7 +925,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port) ...@@ -925,7 +925,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
static void whiteheat_throttle (struct usb_serial_port *port) static void whiteheat_throttle (struct usb_serial_port *port)
{ {
struct whiteheat_private *info = (struct whiteheat_private *)port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -940,7 +940,7 @@ static void whiteheat_throttle (struct usb_serial_port *port) ...@@ -940,7 +940,7 @@ static void whiteheat_throttle (struct usb_serial_port *port)
static void whiteheat_unthrottle (struct usb_serial_port *port) static void whiteheat_unthrottle (struct usb_serial_port *port)
{ {
struct whiteheat_private *info = (struct whiteheat_private *)port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
int actually_throttled; int actually_throttled;
unsigned long flags; unsigned long flags;
...@@ -999,7 +999,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) ...@@ -999,7 +999,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
command_info = (struct whiteheat_command_private *)command_port->private; command_info = usb_get_serial_port_data(command_port);
if (!command_info) { if (!command_info) {
dbg ("%s - command_info is NULL, exiting.", __FUNCTION__); dbg ("%s - command_info is NULL, exiting.", __FUNCTION__);
return; return;
...@@ -1038,7 +1038,7 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1038,7 +1038,7 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs)
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
struct whiteheat_private *info = (struct whiteheat_private *)port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -1087,7 +1087,7 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1087,7 +1087,7 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -1135,7 +1135,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 * ...@@ -1135,7 +1135,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
dbg("%s - command %d", __FUNCTION__, command); dbg("%s - command %d", __FUNCTION__, command);
command_port = &port->serial->port[COMMAND_PORT]; command_port = &port->serial->port[COMMAND_PORT];
command_info = (struct whiteheat_command_private *)command_port->private; command_info = usb_get_serial_port_data(command_port);
spin_lock_irqsave(&command_info->lock, flags); spin_lock_irqsave(&command_info->lock, flags);
command_info->command_finished = FALSE; command_info->command_finished = FALSE;
...@@ -1175,7 +1175,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 * ...@@ -1175,7 +1175,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
dbg("%s - command completed.", __FUNCTION__); dbg("%s - command completed.", __FUNCTION__);
switch (command) { switch (command) {
case WHITEHEAT_GET_DTR_RTS: case WHITEHEAT_GET_DTR_RTS:
info = (struct whiteheat_private *)port->private; info = usb_get_serial_port_data(port);
memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info)); memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info));
break; break;
} }
...@@ -1339,7 +1339,7 @@ static int start_command_port(struct usb_serial *serial) ...@@ -1339,7 +1339,7 @@ static int start_command_port(struct usb_serial *serial)
int retval = 0; int retval = 0;
command_port = &serial->port[COMMAND_PORT]; command_port = &serial->port[COMMAND_PORT];
command_info = (struct whiteheat_command_private *)command_port->private; command_info = usb_get_serial_port_data(command_port);
spin_lock_irqsave(&command_info->lock, flags); spin_lock_irqsave(&command_info->lock, flags);
if (!command_info->port_running) { if (!command_info->port_running) {
/* Work around HCD bugs */ /* Work around HCD bugs */
...@@ -1367,7 +1367,7 @@ static void stop_command_port(struct usb_serial *serial) ...@@ -1367,7 +1367,7 @@ static void stop_command_port(struct usb_serial *serial)
unsigned long flags; unsigned long flags;
command_port = &serial->port[COMMAND_PORT]; command_port = &serial->port[COMMAND_PORT];
command_info = (struct whiteheat_command_private *)command_port->private; command_info = usb_get_serial_port_data(command_port);
spin_lock_irqsave(&command_info->lock, flags); spin_lock_irqsave(&command_info->lock, flags);
command_info->port_running--; command_info->port_running--;
if (!command_info->port_running) if (!command_info->port_running)
...@@ -1376,8 +1376,9 @@ static void stop_command_port(struct usb_serial *serial) ...@@ -1376,8 +1376,9 @@ static void stop_command_port(struct usb_serial *serial)
} }
static int start_port_read(struct usb_serial_port *port) { static int start_port_read(struct usb_serial_port *port)
struct whiteheat_private *info = port->private; {
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
struct urb *urb; struct urb *urb;
int retval = 0; int retval = 0;
...@@ -1413,7 +1414,8 @@ static int start_port_read(struct usb_serial_port *port) { ...@@ -1413,7 +1414,8 @@ static int start_port_read(struct usb_serial_port *port) {
} }
static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) { static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head)
{
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
struct list_head *tmp; struct list_head *tmp;
...@@ -1427,14 +1429,16 @@ static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head ...@@ -1427,14 +1429,16 @@ static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head
} }
static struct list_head *list_first(struct list_head *head) { static struct list_head *list_first(struct list_head *head)
{
return head->next; return head->next;
} }
static void rx_data_softint(void *private) { static void rx_data_softint(void *private)
{
struct usb_serial_port *port = (struct usb_serial_port *)private; struct usb_serial_port *port = (struct usb_serial_port *)private;
struct whiteheat_private *info = port->private; struct whiteheat_private *info = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->tty;
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
struct urb *urb; struct urb *urb;
......
...@@ -28,14 +28,6 @@ static __inline__ void wait_ms(unsigned int ms) ...@@ -28,14 +28,6 @@ static __inline__ void wait_ms(unsigned int ms)
mdelay(ms); mdelay(ms);
} }
/*
* USB device number allocation bitmap. There's one bitmap
* per USB tree.
*/
struct usb_devmap {
unsigned long devicemap[128 / (8*sizeof(unsigned long))];
};
struct usb_device; struct usb_device;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -119,12 +111,21 @@ struct usb_interface { ...@@ -119,12 +111,21 @@ struct usb_interface {
struct usb_driver *driver; /* driver */ struct usb_driver *driver; /* driver */
kdev_t kdev; /* node this interface is bound to */ kdev_t kdev; /* node this interface is bound to */
struct device dev; /* interface specific device info */ struct device dev; /* interface specific device info */
void *private_data;
}; };
#define to_usb_interface(d) container_of(d, struct usb_interface, dev) #define to_usb_interface(d) container_of(d, struct usb_interface, dev)
#define interface_to_usbdev(intf) \ #define interface_to_usbdev(intf) \
container_of(intf->dev.parent, struct usb_device, dev) container_of(intf->dev.parent, struct usb_device, dev)
static inline void *usb_get_intfdata (struct usb_interface *intf)
{
return dev_get_drvdata (&intf->dev);
}
static inline void usb_set_intfdata (struct usb_interface *intf, void *data)
{
return dev_set_drvdata (&intf->dev, data);
}
/* USB_DT_CONFIG: Configuration descriptor information. /* USB_DT_CONFIG: Configuration descriptor information.
* *
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
...@@ -159,10 +160,16 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, ...@@ -159,10 +160,16 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
struct usb_operations; struct usb_operations;
/* USB device number allocation bitmap */
struct usb_devmap {
unsigned long devicemap[128 / (8*sizeof(unsigned long))];
};
/* /*
* Allocated per bus we have * Allocated per bus (tree of devices) we have:
*/ */
struct usb_bus { struct usb_bus {
struct device *controller; /* host/master side hardware */
int busnum; /* Bus number (in order of reg) */ int busnum; /* Bus number (in order of reg) */
char *bus_name; /* stable id (PCI slot_name etc) */ char *bus_name; /* stable id (PCI slot_name etc) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment