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
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
PDAs running Windows CE 3.0 or PocketPC 2002 using a USB cable/cradle.
It's very likely that every device supported by ActiveSync USB works with this
driver. The driver supports the Compaq iPAQ, Jornada 548/568 and the Casio
EM500 out of the box. For others, please use module parameters to specify
the product and vendor id. e.g. modprobe ipaq vendor=0x3f0 product=0x1125
This driver can be used to connect to Compaq iPAQ, HP Jornada, Casio EM500
and other PDAs running Windows CE 3.0 or PocketPC 2002 using a USB
cable/cradle.
Most devices supported by ActiveSync are supported out of the box.
For others, please use module parameters to specify the product and vendor
id. e.g. modprobe ipaq vendor=0x3f0 product=0x1125
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
significant advantage of using USB is speed - you can get 73 to 113
kbytes/sec for download/upload to the iPAQ.
significant advantage of using USB is speed - I can get 73 to 113
kbytes/sec for download/upload to my iPAQ.
This driver is only one of a set of components required to utilize
the USB connection. Please visit http://synce.sourceforge.net which
contains the necessary packages and a simple step-by-step howto.
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
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
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.
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
Varadarajan <ganesh@veritas.com>
......
......@@ -152,7 +152,7 @@ static void led_blink(struct st5481_adapter *adapter)
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_b_out *b_out = &bcs->b_out;
......
......@@ -370,7 +370,7 @@ static void fifo_reseted(void *context)
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_d_out *d_out = &adapter->d_out;
......
......@@ -474,7 +474,7 @@ void st5481_release_isocpipes(struct urb* urb[2])
* called 50 times per second with 20 ISOC descriptors.
* 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;
unsigned char *ptr;
......
......@@ -24,11 +24,14 @@
/*
* DMA-Consistent Buffers
* DMA-Coherent Buffers
*/
/* FIXME tune these based on pool statistics ... */
static const size_t pool_max [HCD_BUFFER_POOLS] = {
/* platforms without dma-friendly caches might need to
* prevent cacheline sharing...
*/
32,
128,
512,
......@@ -133,98 +136,3 @@ void hcd_buffer_free (
}
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)
hcd->pdev = dev;
hcd->self.bus_name = dev->slot_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) {
clean_3:
......
......@@ -1031,19 +1031,19 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags)
/* lower level hcd code should use *_dma exclusively */
if (!(urb->transfer_flags & URB_NO_DMA_MAP)) {
if (usb_pipecontrol (urb->pipe))
urb->setup_dma = pci_map_single (
hcd->pdev,
urb->setup_dma = dma_map_single (
hcd->controller,
urb->setup_packet,
sizeof (struct usb_ctrlrequest),
PCI_DMA_TODEVICE);
DMA_TO_DEVICE);
if (urb->transfer_buffer_length != 0)
urb->transfer_dma = pci_map_single (
hcd->pdev,
urb->transfer_dma = dma_map_single (
hcd->controller,
urb->transfer_buffer,
urb->transfer_buffer_length,
usb_pipein (urb->pipe)
? PCI_DMA_FROMDEVICE
: PCI_DMA_TODEVICE);
? DMA_FROM_DEVICE
: DMA_TO_DEVICE);
}
status = hcd->driver->urb_enqueue (hcd, urb, mem_flags);
......@@ -1265,12 +1265,6 @@ struct usb_operations usb_hcd_operations = {
.deallocate = hcd_free_dev,
.buffer_alloc = hcd_buffer_alloc,
.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);
......
......@@ -145,26 +145,6 @@ struct usb_operations {
dma_addr_t *dma);
void (*buffer_free)(struct usb_bus *bus, size_t size,
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 */
......@@ -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 *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 */
extern struct usb_operations usb_hcd_operations;
extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);
......
......@@ -41,6 +41,11 @@
#endif
#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 "usb.h"
......@@ -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);
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
return;
iface->driver = NULL;
iface->private_data = NULL;
usb_set_intfdata(iface, NULL);
}
/**
......@@ -803,7 +808,7 @@ void usb_disconnect(struct usb_device **pdev)
*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 */
for (i = 0; i < USB_MAXCHILDREN; i++) {
......@@ -812,7 +817,7 @@ void usb_disconnect(struct usb_device **pdev)
usb_disconnect(child);
}
dbg ("unregistering interfaces on device %d", dev->devnum);
dev_dbg (dev->dev, "unregistering interfaces\n");
if (dev->actconfig) {
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
struct usb_interface *interface = &dev->actconfig->interface[i];
......@@ -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 */
if (dev->devnum > 0) {
clear_bit(dev->devnum, dev->bus->devmap.devicemap);
......@@ -980,6 +985,9 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
sprintf (&dev->dev.bus_id[0], "%d-%s",
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 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)
interface->dev.parent = &dev->dev;
interface->dev.driver = NULL;
interface->dev.bus = &usb_bus_type;
interface->dev.dma_mask = parent->dma_mask;
sprintf (&interface->dev.bus_id[0], "%d-%s:%d",
dev->bus->busnum, dev->devpath,
desc->bInterfaceNumber);
......@@ -1206,24 +1215,21 @@ void usb_buffer_free (
struct urb *usb_buffer_map (struct urb *urb)
{
struct usb_bus *bus;
struct usb_operations *op;
struct device *controller;
if (!urb
|| usb_pipecontrol (urb->pipe)
|| !urb->dev
|| !(bus = urb->dev->bus)
|| !(op = bus->op)
|| !op->buffer_map)
|| !(controller = bus->controller))
return 0;
if (op->buffer_map (bus,
urb->transfer_buffer,
&urb->transfer_dma,
urb->transfer_buffer_length,
urb->transfer_dma = dma_map_single (controller,
urb->transfer_buffer, urb->transfer_buffer_length,
usb_pipein (urb->pipe)
? USB_DIR_IN
: USB_DIR_OUT))
return 0;
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
// FIXME generic api broken like pci, can't report errors
// if (urb->transfer_dma == DMA_ADDR_INVALID) return 0;
urb->transfer_flags |= URB_NO_DMA_MAP;
return urb;
}
......@@ -1235,22 +1241,19 @@ struct urb *usb_buffer_map (struct urb *urb)
void usb_buffer_dmasync (struct urb *urb)
{
struct usb_bus *bus;
struct usb_operations *op;
struct device *controller;
if (!urb
|| !(urb->transfer_flags & URB_NO_DMA_MAP)
|| !urb->dev
|| !(bus = urb->dev->bus)
|| !(op = bus->op)
|| !op->buffer_dmasync)
|| !(controller = bus->controller))
return;
op->buffer_dmasync (bus,
urb->transfer_dma,
urb->transfer_buffer_length,
dma_sync_single (controller,
urb->transfer_dma, urb->transfer_buffer_length,
usb_pipein (urb->pipe)
? USB_DIR_IN
: USB_DIR_OUT);
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
/**
......@@ -1262,23 +1265,21 @@ void usb_buffer_dmasync (struct urb *urb)
void usb_buffer_unmap (struct urb *urb)
{
struct usb_bus *bus;
struct usb_operations *op;
struct device *controller;
if (!urb
|| !(urb->transfer_flags & URB_NO_DMA_MAP)
|| !urb->dev
|| !(bus = urb->dev->bus)
|| !(op = bus->op)
|| !op->buffer_unmap)
|| !(controller = bus->controller))
return;
op->buffer_unmap (bus,
urb->transfer_dma,
urb->transfer_buffer_length,
dma_unmap_single (controller,
urb->transfer_dma, urb->transfer_buffer_length,
usb_pipein (urb->pipe)
? USB_DIR_IN
: USB_DIR_OUT);
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
/**
* usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
* @dev: device to which the scatterlist will be mapped
......@@ -1297,6 +1298,7 @@ void usb_buffer_unmap (struct urb *urb)
* 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
* 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,
* 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,
struct scatterlist *sg, int nents)
{
struct usb_bus *bus;
struct usb_operations *op;
int n_hw_ents;
struct device *controller;
if (!dev
|| usb_pipecontrol (pipe)
|| !(bus = dev->bus)
|| !(op = bus->op)
|| !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))
|| !(controller = bus->controller))
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,
struct scatterlist *sg, int n_hw_ents)
{
struct usb_bus *bus;
struct usb_operations *op;
struct device *controller;
if (!dev
|| !(bus = dev->bus)
|| !(op = bus->op)
|| !op->buffer_dmasync_sg)
|| !(controller = bus->controller))
return;
op->buffer_dmasync_sg (bus,
sg,
n_hw_ents,
usb_pipein (pipe)
? USB_DIR_IN
: USB_DIR_OUT);
dma_sync_sg (controller, sg, n_hw_ents,
usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
/**
......@@ -1373,20 +1361,15 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents)
{
struct usb_bus *bus;
struct usb_operations *op;
struct device *controller;
if (!dev
|| !(bus = dev->bus)
|| !(op = bus->op)
|| !op->buffer_unmap_sg)
|| !(controller = bus->controller))
return;
op->buffer_unmap_sg (bus,
sg,
n_hw_ents,
usb_pipein (pipe)
? USB_DIR_IN
: USB_DIR_OUT);
dma_unmap_sg (controller, sg, n_hw_ents,
usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
......
......@@ -405,9 +405,10 @@ static int ehci_start (struct usb_hcd *hcd)
* streaming mappings for I/O buffers, like pci_map_single(),
* can return segments above 4GB, if the device allows.
*
* NOTE: layered drivers can't yet tell when we enable that,
* so they can't pass this info along (like NETIF_F_HIGHDMA)
* (or like Scsi_Host.highmem_io) ... usb_bus.flags?
* NOTE: the dma mask is visible through dma_supported(), so
* drivers can pass this info along ... like NETIF_F_HIGHDMA,
* Scsi_Host.highmem_io, and so forth. It's readonly to all
* host side drivers though.
*/
if (HCC_64BIT_ADDR (hcc_params)) {
writel (0, &ehci->regs->segment);
......
......@@ -176,7 +176,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver,
hcd->irq = dev->irq[1];
hcd->regs = dev->mapbase;
hcd->pdev = SA1111_FAKE_PCIDEV;
hcd->controller = &dev->dev;
hcd->self.controller = &dev->dev;
hcd->controller = hcd->self.controller;
retval = hcd_buffer_create (hcd);
if (retval != 0) {
......
......@@ -321,10 +321,13 @@
* "Jaeger, Gerhard" <gerhard@gjaeger.de>, Ira Childress
* <ichildress@mn.rr.com>, Till Kamppeter <till.kamppeter@gmx.net>,
* 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.
* - Accept scanners with only one bulk (in) endpoint (thanks to Sergey
* 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
* - Remove the 2/3 endpoint limitation
......@@ -858,7 +861,6 @@ probe_scanner(struct usb_interface *intf,
}
dbg("probe_scanner: USB dev address:%p", dev);
dbg("probe_scanner: ifnum:%u", ifnum);
/*
* 1. Check Vendor/Product
......@@ -907,13 +909,15 @@ probe_scanner(struct usb_interface *intf,
return -ENODEV;
}
if (dev->config[0].desc.bNumInterfaces != 1) {
info("probe_scanner: Only one device interface is supported.");
interface = intf->altsetting;
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;
}
interface = intf->altsetting;
/*
* Start checking for one or two bulk endpoints and an optional
* interrupt endpoint. If we have an interrupt endpoint go ahead and
......
......@@ -1317,6 +1317,9 @@ void hid_init_reports(struct hid_device *hid)
#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204
#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_DEVICE_ID_MGE_UPS 0xffff
#define USB_DEVICE_ID_MGE_UPS1 0x0001
......@@ -1355,6 +1358,7 @@ struct hid_blacklist {
{ 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_UPS1, HID_QUIRK_HIDDEV },
{ USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
{ 0, 0 }
};
......
......@@ -357,6 +357,11 @@ static void hidinput_configure_usage(struct hid_device *device, struct hid_field
int a = field->logical_minimum;
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->absmax[usage->code] = b;
input->absfuzz[usage->code] = (b - a) >> 8;
......
......@@ -206,6 +206,7 @@ struct hid_item {
#define HID_QUIRK_IGNORE 0x04
#define HID_QUIRK_NOGET 0x08
#define HID_QUIRK_HIDDEV 0x10
#define HID_QUIRK_BADPAD 0x12
/*
* 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)
/* Find field */
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);
if(!ret) {
printk("Couldn't set field\n");
......
/*
* USB NB Camera driver
*
* HISTORY:
* 25-Dec-2002 Dmitri Removed lighting, sharpness parameters, methods.
*/
#include <linux/kernel.h>
......@@ -34,12 +37,6 @@ static int flags = 0; /* FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */
static const int min_canvasWidth = 8;
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_MAX 6
static int framerate = -1;
......@@ -77,10 +74,6 @@ MODULE_PARM_DESC(flags,
"6=clean frames");
MODULE_PARM(framerate, "i");
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_DESC(init_brightness, "Brightness preconfiguration: 0-255 (default=128)");
......@@ -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()
*
......@@ -272,8 +247,6 @@ static void ultracam_reinit_iso(struct uvd *uvd, int do_stop)
static void ultracam_video_start(struct uvd *uvd)
{
ultracam_change_lighting_conditions(uvd);
ultracam_set_sharpness(uvd);
ultracam_reinit_iso(uvd, 0);
}
......
......@@ -978,7 +978,6 @@ static void usbtest_disconnect (struct usb_interface *intf)
dev_set_drvdata (&intf->dev, 0);
info ("unbound %s", dev->id);
kfree (intf->private_data);
}
/* Basic testing only needs a device that can source or sink bulk traffic.
......
......@@ -146,6 +146,11 @@
#endif
#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 */
#define CONFIG_USB_AN2720
......@@ -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);
// 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);
// possible with some EHCI controllers
if (dma_supported (&udev->dev, 0xffffffffffffffffULL))
net->features |= NETIF_F_HIGHDMA;
net->change_mtu = usbnet_change_mtu;
net->get_stats = usbnet_get_stats;
net->hard_start_xmit = usbnet_start_xmit;
......
......@@ -150,11 +150,11 @@ config USB_SERIAL_VISOR
module, say M here and read <file:Documentation/modules.txt>.
config USB_SERIAL_IPAQ
tristate "USB Compaq iPAQ / HP Jornada / Casio EM500 Driver"
tristate "USB PocketPC PDA Driver"
depends on USB_SERIAL
help
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,
read <file:Documentation/usb/usb-serial.txt>.
......
......@@ -171,10 +171,9 @@ static int belkin_sa_startup (struct usb_serial *serial)
struct belkin_sa_private *priv;
/* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
if (!serial->port->private)
priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
if (!priv)
return (-1); /* error */
priv = (struct belkin_sa_private *)serial->port->private;
/* set initial values for control structures */
priv->control_state = 0;
priv->last_lsr = 0;
......@@ -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);
init_waitqueue_head(&serial->port->write_wait);
usb_set_serial_port_data(serial->port, priv);
return (0);
}
......@@ -191,6 +191,7 @@ static int belkin_sa_startup (struct usb_serial *serial)
static void belkin_sa_shutdown (struct usb_serial *serial)
{
struct belkin_sa_private *priv;
int i;
dbg ("%s", __FUNCTION__);
......@@ -198,8 +199,9 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */
if (serial->port[i].private)
kfree(serial->port[i].private);
priv = usb_get_serial_port_data(&serial->port[i]);
if (priv)
kfree(priv);
}
}
......@@ -286,7 +288,7 @@ static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs)
/* Handle known interrupt data */
/* 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];
/* Record Control Line states */
......@@ -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)
{
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 cflag;
unsigned int old_iflag = 0;
......@@ -485,7 +487,7 @@ static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, un
{
struct usb_serial *serial = port->serial;
__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;
/* Based on code from acm.c and others */
......
......@@ -66,7 +66,7 @@ static int usb_serial_device_probe (struct device *dev)
driver = port->serial->type;
if (driver->port_probe) {
if (!try_module_get(driver->owner)) {
err ("module get failed, exiting");
dev_err(*dev, "module get failed, exiting\n");
retval = -EIO;
goto exit;
}
......@@ -79,8 +79,8 @@ static int usb_serial_device_probe (struct device *dev)
minor = port->number;
tty_register_devfs (&usb_serial_tty_driver, 0, minor);
info("%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)",
driver->name, minor, minor);
dev_info(*dev, "%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)\n",
driver->name, minor, minor);
exit:
return retval;
......@@ -101,7 +101,7 @@ static int usb_serial_device_remove (struct device *dev)
driver = port->serial->type;
if (driver->port_remove) {
if (!try_module_get(driver->owner)) {
err ("module get failed, exiting");
dev_err(*dev, "module get failed, exiting\n");
retval = -EIO;
goto exit;
}
......@@ -111,8 +111,8 @@ static int usb_serial_device_remove (struct device *dev)
exit:
minor = port->number;
tty_unregister_devfs (&usb_serial_tty_driver, minor);
info("%s converter now disconnected from ttyUSB%d",
driver->name, minor);
dev_info(*dev, "%s converter now disconnected from ttyUSB%d\n",
driver->name, minor);
return retval;
}
......
......@@ -114,15 +114,15 @@ static int cyberjack_startup (struct usb_serial *serial)
dbg("%s", __FUNCTION__);
/* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
if (!serial->port->private)
return (-1); /* error */
priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/* set initial values */
priv = (struct cyberjack_private *)serial->port->private;
priv->rdtodo = 0;
priv->wrfilled = 0;
priv->wrsent = 0;
usb_set_serial_port_data(serial->port, priv);
init_waitqueue_head(&serial->port->write_wait);
......@@ -137,8 +137,8 @@ static void cyberjack_shutdown (struct usb_serial *serial)
for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */
if (serial->port[i].private)
kfree(serial->port[i].private);
kfree(usb_get_serial_port_data(&serial->port[i]));
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)
*/
port->tty->low_latency = 1;
priv = (struct cyberjack_private *)port->private;
priv = usb_get_serial_port_data(port);
priv->rdtodo = 0;
priv->wrfilled = 0;
priv->wrsent = 0;
......@@ -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)
{
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 wrexpected;
......@@ -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 )
{
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;
unsigned char *data = urb->transfer_buffer;
......@@ -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)
{
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 tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
......@@ -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)
{
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__);
dbg("%s - port %d", __FUNCTION__, port->number);
......
......@@ -604,7 +604,7 @@ static void digi_wakeup_write_lock( struct usb_serial_port *port )
{
unsigned long flags;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
spin_lock_irqsave( &priv->dp_port_lock, flags );
......@@ -650,8 +650,8 @@ static int digi_write_oob_command( struct usb_serial_port *port,
int ret = 0;
int len;
struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)port->serial->private)->ds_oob_port;
struct digi_port *oob_priv = (struct digi_port *)oob_port->private;
struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
unsigned long flags = 0;
......@@ -719,7 +719,7 @@ static int digi_write_inb_command( struct usb_serial_port *port,
int ret = 0;
int len;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned char *data = port->write_urb->transfer_buffer;
unsigned long flags = 0;
......@@ -805,9 +805,9 @@ static int digi_set_modem_signals( struct usb_serial_port *port,
{
int ret;
struct digi_port *port_priv = (struct digi_port *)port->private;
struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)port->serial->private)->ds_oob_port;
struct digi_port *oob_priv = (struct digi_port *)oob_port->private;
struct digi_port *port_priv = usb_get_serial_port_data(port);
struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
unsigned char *data = oob_port->write_urb->transfer_buffer;
unsigned long flags = 0;
......@@ -884,7 +884,7 @@ static int digi_transmit_idle( struct usb_serial_port *port,
int ret;
unsigned char buf[2];
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned long flags = 0;
......@@ -924,7 +924,7 @@ static void digi_rx_throttle( struct usb_serial_port *port )
{
unsigned long flags;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
dbg( "digi_rx_throttle: TOP: port=%d", priv->dp_port_num );
......@@ -945,7 +945,7 @@ static void digi_rx_unthrottle( struct usb_serial_port *port )
int ret = 0;
int len;
unsigned long flags;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
......@@ -989,7 +989,7 @@ static void digi_set_termios( struct usb_serial_port *port,
struct termios *old_termios )
{
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned int iflag = port->tty->termios->c_iflag;
unsigned int cflag = port->tty->termios->c_cflag;
unsigned int old_iflag = old_termios->c_iflag;
......@@ -1213,7 +1213,7 @@ static int digi_ioctl( struct usb_serial_port *port, struct file *file,
unsigned int cmd, unsigned long arg )
{
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned int val;
unsigned long flags = 0;
......@@ -1265,7 +1265,7 @@ static int digi_write( struct usb_serial_port *port, int from_user,
{
int ret,data_len,new_len;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned char *data = port->write_urb->transfer_buffer;
unsigned char user_buf[64]; /* 64 bytes is max USB bulk packet */
unsigned long flags = 0;
......@@ -1353,26 +1353,26 @@ static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial;
struct digi_port *priv;
struct digi_serial *serial_priv;
int ret = 0;
dbg( "digi_write_bulk_callback: TOP, urb->status=%d", urb->status );
/* port and serial sanity check */
if( port == NULL || (priv=(struct digi_port *)(port->private)) == NULL ) {
if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) {
err("%s: port or port->private is NULL, status=%d", __FUNCTION__,
urb->status );
return;
}
serial = port->serial;
if( serial == NULL || serial->private == NULL ) {
if( serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL ) {
err("%s: serial or serial->private is NULL, status=%d", __FUNCTION__, urb->status );
return;
}
/* handle oob callback */
if( priv->dp_port_num
== ((struct digi_serial *)(serial->private))->ds_oob_port_num ) {
if( priv->dp_port_num == serial_priv->ds_oob_port_num ) {
dbg( "digi_write_bulk_callback: oob callback" );
spin_lock( &priv->dp_port_lock );
priv->dp_write_urb_in_use = 0;
......@@ -1432,7 +1432,7 @@ static int digi_write_room( struct usb_serial_port *port )
{
int room;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned long flags = 0;
......@@ -1455,7 +1455,7 @@ dbg( "digi_write_room: port=%d, room=%d", priv->dp_port_num, room );
static int digi_chars_in_buffer( struct usb_serial_port *port )
{
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
if( port->write_urb->status == -EINPROGRESS
......@@ -1476,7 +1476,7 @@ static int digi_open( struct usb_serial_port *port, struct file *filp )
int ret;
unsigned char buf[32];
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
struct termios not_termios;
unsigned long flags = 0;
......@@ -1542,7 +1542,7 @@ static void digi_close( struct usb_serial_port *port, struct file *filp )
int ret;
unsigned char buf[32];
struct tty_struct *tty = port->tty;
struct digi_port *priv = (struct digi_port *)port->private;
struct digi_port *priv = usb_get_serial_port_data(port);
unsigned long flags = 0;
......@@ -1641,7 +1641,7 @@ static int digi_startup_device( struct usb_serial *serial )
{
int i,ret = 0;
struct digi_serial *serial_priv = (struct digi_serial *)serial->private;
struct digi_serial *serial_priv = usb_get_serial_data(serial);
struct usb_serial_port *port;
......@@ -1690,12 +1690,11 @@ dbg( "digi_startup: TOP" );
for( i=0; i<serial->type->num_ports+1; i++ ) {
/* allocate port private structure */
priv = serial->port[i].private =
(struct digi_port *)kmalloc( sizeof(struct digi_port),
priv = (struct digi_port *)kmalloc( sizeof(struct digi_port),
GFP_KERNEL );
if( priv == (struct digi_port *)0 ) {
while( --i >= 0 )
kfree( serial->port[i].private );
kfree( usb_get_serial_port_data(&serial->port[i]) );
return( 1 ); /* error */
}
......@@ -1720,15 +1719,15 @@ dbg( "digi_startup: TOP" );
/* initialize write wait queue for this port */
init_waitqueue_head( &serial->port[i].write_wait );
usb_set_serial_port_data(&serial->port[i], priv);
}
/* allocate serial private structure */
serial_priv = serial->private =
(struct digi_serial *)kmalloc( sizeof(struct digi_serial),
serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial),
GFP_KERNEL );
if( serial_priv == (struct digi_serial *)0 ) {
for( i=0; i<serial->type->num_ports+1; i++ )
kfree( serial->port[i].private );
kfree( usb_get_serial_port_data(&serial->port[i]) );
return( 1 ); /* error */
}
......@@ -1737,6 +1736,7 @@ dbg( "digi_startup: TOP" );
serial_priv->ds_oob_port_num = serial->type->num_ports;
serial_priv->ds_oob_port = &serial->port[serial_priv->ds_oob_port_num];
serial_priv->ds_device_started = 0;
usb_set_serial_data(serial, serial_priv);
return( 0 );
......@@ -1760,9 +1760,8 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() );
/* free the private data structures for all ports */
/* number of regular ports + 1 for the out-of-band port */
for( i=0; i<serial->type->num_ports+1; i++ )
kfree( serial->port[i].private );
kfree( serial->private );
kfree( usb_get_serial_port_data(&serial->port[i]) );
kfree( usb_get_serial_data(serial) );
}
......@@ -1771,20 +1770,21 @@ static void digi_read_bulk_callback( struct urb *urb, struct pt_regs *regs )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct digi_port *priv;
struct digi_serial *serial_priv;
int ret;
dbg( "digi_read_bulk_callback: TOP" );
/* port sanity check, do not resubmit if port is not valid */
if( port == NULL || (priv=(struct digi_port *)(port->private)) == NULL ) {
if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) {
err("%s: port or port->private is NULL, status=%d", __FUNCTION__,
urb->status );
return;
}
if( port->serial == NULL
|| serial_paranoia_check( port->serial, __FUNCTION__ )
|| port->serial->private == NULL ) {
|| (serial_priv=usb_get_serial_data(port->serial)) == NULL ) {
err("%s: serial is bad or serial->private is NULL, status=%d", __FUNCTION__, urb->status );
return;
}
......@@ -1796,8 +1796,7 @@ dbg( "digi_read_bulk_callback: TOP" );
}
/* handle oob or inb callback, do not resubmit if error */
if( priv->dp_port_num
== ((struct digi_serial *)(port->serial->private))->ds_oob_port_num ) {
if( priv->dp_port_num == serial_priv->ds_oob_port_num ) {
if( digi_read_oob_callback( urb ) != 0 )
return;
} else {
......@@ -1830,7 +1829,7 @@ static int digi_read_inb_callback( struct urb *urb )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct tty_struct *tty = port->tty;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
int opcode = ((unsigned char *)urb->transfer_buffer)[0];
int len = ((unsigned char *)urb->transfer_buffer)[1];
int status = ((unsigned char *)urb->transfer_buffer)[2];
......@@ -1942,7 +1941,7 @@ static int digi_read_oob_callback( struct urb *urb )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = port->serial;
struct digi_port *priv = (struct digi_port *)(port->private);
struct digi_port *priv = usb_get_serial_port_data(port);
int opcode, line, status, val;
int i;
......@@ -1967,7 +1966,7 @@ opcode, line, status, val );
port = &serial->port[line];
if( port_paranoia_check( port, __FUNCTION__ )
|| (priv=port->private) == NULL )
|| (priv=usb_get_serial_port_data(port)) == NULL )
return( -1 );
if( opcode == DIGI_CMD_READ_INPUT_SIGNALS ) {
......
......@@ -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);
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;
}
......@@ -205,7 +205,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->read_urb);
}
/* 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
if (urb->transfer_buffer == NULL) {
urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
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;
}
}
......@@ -278,7 +278,7 @@ static int empeg_write (struct usb_serial_port *port, int from_user, const unsig
/* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC);
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;
break;
}
......@@ -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);
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;
......@@ -451,7 +451,7 @@ static void empeg_unthrottle (struct usb_serial_port *port)
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
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;
}
......
......@@ -41,7 +41,7 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
transfer_buffer = kmalloc (length, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, length);
dev_err(serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
return -ENOMEM;
}
memcpy (transfer_buffer, data, length);
......@@ -56,7 +56,7 @@ int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit)
dbg("%s - %d", __FUNCTION__, reset_bit);
response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0);
if (response < 0) {
err("%s- %d failed", __FUNCTION__, reset_bit);
dev_err(serial->dev->dev, "%s- %d failed\n", __FUNCTION__, reset_bit);
}
return response;
}
......
......@@ -267,7 +267,7 @@ static int ftdi_sio_startup (struct usb_serial *serial)
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){
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
return -ENOMEM;
......@@ -275,7 +275,8 @@ static int ftdi_sio_startup (struct usb_serial *serial)
priv->ftdi_type = sio;
priv->write_offset = 1;
usb_set_serial_port_data(serial->port, priv);
return (0);
}
......@@ -285,7 +286,7 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial)
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){
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
return -ENOMEM;
......@@ -293,17 +294,21 @@ static int ftdi_8U232AM_startup (struct usb_serial *serial)
priv->ftdi_type = F8U232AM;
priv->write_offset = 0;
usb_set_serial_port_data(serial->port, priv);
return (0);
}
static void ftdi_sio_shutdown (struct usb_serial *serial)
{
void *priv;
dbg("%s", __FUNCTION__);
if (serial->port[0].private){
kfree(serial->port[0].private);
serial->port[0].private = NULL;
priv = usb_get_serial_port_data(&serial->port[0]);
if (priv){
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,
const unsigned char *buf, int count)
{ /* ftdi_sio_write */
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;
int data_offset ;
int result;
......@@ -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 )
{
struct ftdi_private *priv = (struct ftdi_private *)port->private;
struct ftdi_private *priv = usb_get_serial_port_data(port);
int room;
if ( port->write_urb->status == -EINPROGRESS) {
......@@ -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 )
{
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;
char buf[1];
......@@ -709,7 +714,7 @@ static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios *
{ /* ftdi_sio_set_termios */
struct usb_serial *serial = port->serial;
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 */
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 *
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 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 */
char buf[2];
int ret, mask;
......
......@@ -106,7 +106,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
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;
......@@ -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 */
result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
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
result = count;
......@@ -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);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
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)
......
......@@ -572,7 +572,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
record = (struct edge_firmware_image_record *)firmware;
response = rom_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]);
if (response < 0) {
err("sram_write failed (%x, %x, %d)", record->ExtAddr, record->Addr, record->Len);
dev_err(edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len);
break;
}
firmware += sizeof (struct edge_firmware_image_record) + record->Len;
......@@ -818,7 +818,7 @@ static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
if (txCredits) {
port = &edge_serial->serial->port[portNumber];
if (port_paranoia_check (port, __FUNCTION__) == 0) {
edge_port = (struct edgeport_port *)port->private;
edge_port = usb_get_serial_port_data(port);
if (edge_port->open) {
edge_port->txCredits += txCredits;
dbg("%s - txcredits for port%d = %d", __FUNCTION__, portNumber, edge_port->txCredits);
......@@ -840,7 +840,7 @@ static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
exit:
result = usb_submit_urb (urb, GFP_ATOMIC);
if (result) {
err("%s - Error %d submitting control urb", __FUNCTION__, result);
dev_err(urb->dev->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, result);
}
}
......@@ -889,7 +889,7 @@ static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
edge_serial->read_urb->dev = edge_serial->serial->dev;
status = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
if (status) {
err("%s - usb_submit_urb(read bulk) failed, status = %d", __FUNCTION__, status);
dev_err(urb->dev->dev, "%s - usb_submit_urb(read bulk) failed, status = %d\n", __FUNCTION__, status);
}
}
}
......@@ -932,7 +932,7 @@ static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs)
edge_port->write_in_progress = FALSE;
// Check if more data needs to be sent
send_more_port_data((struct edgeport_serial *)(edge_port->port->serial->private), edge_port);
send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port);
}
......@@ -996,7 +996,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs)
*****************************************************************************/
static int edge_open (struct usb_serial_port *port, struct file * filp)
{
struct edgeport_port *edge_port = (struct edgeport_port *)port->private;
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct usb_serial *serial;
struct edgeport_serial *edge_serial;
int response;
......@@ -1019,7 +1019,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
/* see if we've set up our endpoint info yet (can't set it up in edge_startup
as the structures were not set up at that time.) */
serial = port->serial;
edge_serial = (struct edgeport_serial *)serial->private;
edge_serial = usb_get_serial_data(serial);
if (edge_serial == NULL) {
return -ENODEV;
}
......@@ -1057,7 +1057,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
* this interrupt will continue as long as the edgeport is connected */
response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL);
if (response) {
err("%s - Error %d submitting control urb", __FUNCTION__, response);
dev_err(port->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, response);
}
}
......@@ -1081,7 +1081,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0);
if (response < 0) {
err("%s - error sending open port command", __FUNCTION__);
dev_err(port->dev, "%s - error sending open port command\n", __FUNCTION__);
edge_port->openPending = FALSE;
return -ENODEV;
}
......@@ -1247,8 +1247,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if (!serial)
return;
edge_serial = (struct edgeport_serial *)serial->private;
edge_port = (struct edgeport_port *)port->private;
edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL))
return;
......@@ -1307,7 +1307,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
*****************************************************************************/
static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count)
{
struct edgeport_port *edge_port = (struct edgeport_port *)port->private;
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct TxFifo *fifo;
int copySize;
int bytesleft;
......@@ -1381,7 +1381,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
usb_serial_debug_data (__FILE__, __FUNCTION__, copySize, data);
}
send_more_port_data((struct edgeport_serial *)port->serial->private, edge_port);
send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count);
......@@ -1450,7 +1450,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
count = fifo->count;
buffer = kmalloc (count+2, GFP_ATOMIC);
if (buffer == NULL) {
err("%s - no more kernel memory...", __FUNCTION__);
dev_err(edge_serial->serial->dev->dev, "%s - no more kernel memory...\n", __FUNCTION__);
edge_port->write_in_progress = FALSE;
return;
}
......@@ -1508,7 +1508,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
*****************************************************************************/
static int edge_write_room (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int room;
dbg("%s", __FUNCTION__);
......@@ -1544,7 +1544,7 @@ static int edge_write_room (struct usb_serial_port *port)
*****************************************************************************/
static int edge_chars_in_buffer (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int num_chars;
dbg("%s", __FUNCTION__);
......@@ -1575,7 +1575,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
*****************************************************************************/
static void edge_throttle (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status;
......@@ -1624,7 +1624,7 @@ static void edge_throttle (struct usb_serial_port *port)
*****************************************************************************/
static void edge_unthrottle (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status;
......@@ -1672,7 +1672,7 @@ static void edge_unthrottle (struct usb_serial_port *port)
*****************************************************************************/
static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned int cflag;
......@@ -1862,7 +1862,7 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
*****************************************************************************/
static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct async_icount cnow;
struct async_icount cprev;
struct serial_icounter_struct icount;
......@@ -1953,7 +1953,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
*****************************************************************************/
static void edge_break (struct usb_serial_port *port, int break_state)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int status;
/* flush and chase */
......@@ -2086,7 +2086,7 @@ static int process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char
if (rxLen) {
port = &edge_serial->serial->port[edge_serial->rxPort];
if (port_paranoia_check (port, __FUNCTION__) == 0) {
edge_port = (struct edgeport_port *)port->private;
edge_port = usb_get_serial_port_data(port);
if (edge_port->open) {
tty = edge_port->port->tty;
if (tty) {
......@@ -2141,9 +2141,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
if (port_paranoia_check (port, __FUNCTION__)) {
return;
}
edge_port = (struct edgeport_port *)port->private;
edge_port = usb_get_serial_port_data(port);
if (edge_port == NULL) {
err("%s - edge_port == NULL for port %d", __FUNCTION__, edge_serial->rxPort);
dev_err(edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __FUNCTION__, edge_serial->rxPort);
return;
}
......@@ -2330,7 +2330,7 @@ static int sram_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u
transfer_buffer = kmalloc (64, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
dev_err(serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
return -ENOMEM;
}
......@@ -2375,7 +2375,7 @@ static int rom_write (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
transfer_buffer = kmalloc (64, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
dev_err(serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
return -ENOMEM;
}
......@@ -2420,7 +2420,7 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
transfer_buffer = kmalloc (64, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
dev_err(serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 64);
return -ENOMEM;
}
......@@ -2463,7 +2463,7 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
buffer = kmalloc (10, GFP_ATOMIC);
if (!buffer) {
err("%s - kmalloc(%d) failed.\n", __FUNCTION__, 10);
dev_err(edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 10);
return -ENOMEM;
}
......@@ -2489,7 +2489,7 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
*****************************************************************************/
static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length)
{
struct edgeport_serial *edge_serial = (struct edgeport_serial *)edge_port->port->serial->private;
struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
int status = 0;
struct urb *urb;
int timeout;
......@@ -2554,14 +2554,14 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
status = calc_baud_rate_divisor (baudRate, &divisor);
if (status) {
err("%s - bad baud rate", __FUNCTION__);
dev_err(edge_port->port->dev, "%s - bad baud rate\n", __FUNCTION__);
return status;
}
// Alloc memory for the string of commands.
cmdBuffer = kmalloc (0x100, GFP_ATOMIC);
if (!cmdBuffer) {
err("%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x100);
dev_err(edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x100);
return -ENOMEM;
}
currCmd = cmdBuffer;
......@@ -2838,7 +2838,7 @@ static void get_manufacturing_desc (struct edgeport_serial *edge_serial)
(__u8 *)(&edge_serial->manuf_descriptor));
if (response < 1) {
err("error in getting manufacturer descriptor");
dev_err(edge_serial->serial->dev->dev, "error in getting manufacturer descriptor\n");
} else {
char string[30];
dbg("**Manufacturer Descriptor");
......@@ -2877,7 +2877,7 @@ static void get_boot_desc (struct edgeport_serial *edge_serial)
(__u8 *)(&edge_serial->boot_descriptor));
if (response < 1) {
err("error in getting boot descriptor");
dev_err(edge_serial->serial->dev->dev, "error in getting boot descriptor\n");
} else {
dbg("**Boot Descriptor:");
dbg(" BootCodeLength: %d", edge_serial->boot_descriptor.BootCodeLength);
......@@ -2938,7 +2938,7 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)
record = (struct edge_firmware_image_record *)firmware;
response = sram_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]);
if (response < 0) {
err("sram_write failed (%x, %x, %d)", record->ExtAddr, record->Addr, record->Len);
dev_err(edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len);
break;
}
firmware += sizeof (struct edge_firmware_image_record) + record->Len;
......@@ -2974,12 +2974,12 @@ static int edge_startup (struct usb_serial *serial)
/* create our private serial structure */
edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
if (edge_serial == NULL) {
err("%s - Out of memory", __FUNCTION__);
dev_err(serial->dev->dev, "%s - Out of memory", __FUNCTION__);
return -ENOMEM;
}
memset (edge_serial, 0, sizeof(struct edgeport_serial));
edge_serial->serial = serial;
serial->private = edge_serial;
usb_set_serial_data(serial, edge_serial);
/* get the name for the device from the device */
if ( (i = get_string(dev, dev->descriptor.iManufacturer, &edge_serial->name[0])) != 0) {
......@@ -2988,7 +2988,7 @@ static int edge_startup (struct usb_serial *serial)
get_string(dev, dev->descriptor.iProduct, &edge_serial->name[i]);
info("%s detected", edge_serial->name);
dev_info(serial->dev->dev, "%s detected\n", edge_serial->name);
/* get the manufacturing descriptor for this device */
get_manufacturing_desc (edge_serial);
......@@ -3030,12 +3030,14 @@ static int edge_startup (struct usb_serial *serial)
for (i = 0; i < serial->num_ports; ++i) {
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
if (edge_port == NULL) {
err("%s - Out of memory", __FUNCTION__);
dev_err(serial->dev->dev, "%s - Out of memory", __FUNCTION__);
usb_set_serial_data(serial, NULL);
kfree(edge_serial);
return -ENOMEM;
}
memset (edge_port, 0, sizeof(struct edgeport_port));
edge_port->port = &serial->port[i];
serial->port[i].private = edge_port;
usb_set_serial_port_data(&serial->port[i], edge_port);
}
return 0;
......@@ -3055,11 +3057,11 @@ static void edge_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
kfree (serial->port[i].private);
serial->port[i].private = NULL;
kfree (usb_get_serial_port_data(&serial->port[i]));
usb_set_serial_port_data(&serial->port[i], NULL);
}
kfree (serial->private);
serial->private = NULL;
kfree (usb_get_serial_data(serial));
usb_set_serial_data(serial, NULL);
}
......
......@@ -473,7 +473,7 @@ static int TIIsTxActive (struct edgeport_port *port)
oedb = kmalloc (sizeof (* oedb), GFP_KERNEL);
if (!oedb) {
err ("%s - out of memory", __FUNCTION__);
dev_err (port->port->dev, "%s - out of memory\n", __FUNCTION__);
return -ENOMEM;
}
......@@ -592,7 +592,7 @@ static int TIChooseConfiguration (struct usb_device *dev)
dbg ("%s - MAX Power = %d", __FUNCTION__, dev->config->desc.bMaxPower*2);
if (dev->config->desc.bNumInterfaces != 1) {
err ("%s - bNumInterfaces is not 1, ERROR!", __FUNCTION__);
dev_err (dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __FUNCTION__);
return -ENODEV;
}
......@@ -684,6 +684,7 @@ static int ValidChecksum(struct ti_i2c_desc *rom_desc, __u8 *buffer)
/* Make sure that the I2C image is good */
static int TiValidateI2cImage (struct edgeport_serial *serial)
{
struct device *dev = &serial->serial->dev->dev;
int status = 0;
struct ti_i2c_desc *rom_desc;
int start_address = 2;
......@@ -691,12 +692,12 @@ static int TiValidateI2cImage (struct edgeport_serial *serial)
rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
if (!rom_desc) {
err ("%s - out of memory", __FUNCTION__);
dev_err (*dev, "%s - out of memory\n", __FUNCTION__);
return -ENOMEM;
}
buffer = kmalloc (TI_MAX_I2C_SIZE, GFP_KERNEL);
if (!buffer) {
err ("%s - out of memory when allocating buffer", __FUNCTION__);
dev_err (*dev, "%s - out of memory when allocating buffer\n", __FUNCTION__);
kfree (rom_desc);
return -ENOMEM;
}
......@@ -707,7 +708,7 @@ static int TiValidateI2cImage (struct edgeport_serial *serial)
goto ExitTiValidateI2cImage;
if (*buffer != 0x52) {
err ("%s - invalid buffer signature", __FUNCTION__);
dev_err (*dev, "%s - invalid buffer signature\n", __FUNCTION__);
status = -ENODEV;
goto ExitTiValidateI2cImage;
}
......@@ -765,7 +766,7 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer)
rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
if (!rom_desc) {
err ("%s - out of memory", __FUNCTION__);
dev_err (serial->serial->dev->dev, "%s - out of memory\n", __FUNCTION__);
return -ENOMEM;
}
start_address = TIGetDescriptorAddress (serial, I2C_DESC_TYPE_ION, rom_desc);
......@@ -800,7 +801,7 @@ static int TIReadManufDescriptor (struct edgeport_serial *serial, __u8 *buffer)
}
/* Build firmware header used for firmware update */
static int BuildI2CFirmwareHeader (__u8 *header)
static int BuildI2CFirmwareHeader (__u8 *header, struct device *dev)
{
__u8 *buffer;
int buffer_size;
......@@ -822,7 +823,7 @@ static int BuildI2CFirmwareHeader (__u8 *header)
buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) {
err ("%s - out of memory", __FUNCTION__);
dev_err (*dev, "%s - out of memory\n", __FUNCTION__);
return -ENOMEM;
}
......@@ -960,6 +961,7 @@ static int TIConfigureBootDevice (struct usb_device *dev)
*/
static int TIDownloadFirmware (struct edgeport_serial *serial)
{
struct device *dev = &serial->serial->dev->dev;
int status = 0;
int start_address;
struct edge_ti_manuf_descriptor *ti_manuf_desc;
......@@ -982,7 +984,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
interface = &serial->serial->dev->config->interface->altsetting->desc;
if (!interface) {
err ("%s - no interface set, error!", __FUNCTION__);
dev_err (serial->serial->dev->dev, "%s - no interface set, error!", __FUNCTION__);
return -ENODEV;
}
......@@ -1019,7 +1021,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
*/
ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL);
if (!ti_manuf_desc) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM;
}
status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc);
......@@ -1038,7 +1040,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
rom_desc = kmalloc (sizeof (*rom_desc), GFP_KERNEL);
if (!rom_desc) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
kfree (ti_manuf_desc);
return -ENOMEM;
}
......@@ -1052,7 +1054,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
firmware_version = kmalloc (sizeof (*firmware_version), GFP_KERNEL);
if (!firmware_version) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
kfree (rom_desc);
kfree (ti_manuf_desc);
return -ENOMEM;
......@@ -1129,7 +1131,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
}
if (record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
err ("%s - error resetting device", __FUNCTION__);
dev_err (*dev, "%s - error resetting device\n", __FUNCTION__);
kfree (firmware_version);
kfree (rom_desc);
kfree (ti_manuf_desc);
......@@ -1160,7 +1162,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
header = kmalloc (HEADER_SIZE, GFP_KERNEL);
if (!header) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
kfree (rom_desc);
kfree (ti_manuf_desc);
return -ENOMEM;
......@@ -1168,7 +1170,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
vheader = kmalloc (HEADER_SIZE, GFP_KERNEL);
if (!vheader) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
kfree (header);
kfree (rom_desc);
kfree (ti_manuf_desc);
......@@ -1183,7 +1185,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
// And finally when the device comes back up in download mode the driver will cause
// the new firmware to be copied from the UMP Ram to I2C and the firmware will update
// the record type from 0xf2 to 0x02.
status = BuildI2CFirmwareHeader(header);
status = BuildI2CFirmwareHeader(header, dev);
if (status) {
kfree (vheader);
kfree (header);
......@@ -1300,7 +1302,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
*/
ti_manuf_desc = kmalloc (sizeof (*ti_manuf_desc), GFP_KERNEL);
if (!ti_manuf_desc) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (*dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM;
}
status = TIReadManufDescriptor (serial, (__u8 *)ti_manuf_desc);
......@@ -1335,7 +1337,7 @@ static int TIDownloadFirmware (struct edgeport_serial *serial)
buffer_size = (((1024 * 16) - 512) + sizeof(struct ti_i2c_image_header));
buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) {
err ("%s - out of memory", __FUNCTION__);
dev_err (*dev, "%s - out of memory\n", __FUNCTION__);
return -ENOMEM;
}
......@@ -1616,7 +1618,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8
static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
{
struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context;
struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context;
struct usb_serial_port *port;
struct edgeport_port *edge_port;
unsigned char *data = urb->transfer_buffer;
......@@ -1670,7 +1672,7 @@ static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
__FUNCTION__);
return;
}
edge_port = port->private;
edge_port = usb_get_serial_port_data(port);
if (!edge_port) {
dbg ("%s - edge_port not found", __FUNCTION__);
return;
......@@ -1700,8 +1702,8 @@ static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
break;
default:
err ("%s - Unknown Interrupt code from UMP %x\n",
__FUNCTION__, data[1]);
dev_err (urb->dev->dev, "%s - Unknown Interrupt code from UMP %x\n",
__FUNCTION__, data[1]);
break;
}
......@@ -1709,8 +1711,8 @@ static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs)
exit:
status = usb_submit_urb (urb, GFP_ATOMIC);
if (status)
err ("%s - usb_submit_urb failed with result %d",
__FUNCTION__, status);
dev_err (urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
__FUNCTION__, status);
}
static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
......@@ -1777,8 +1779,8 @@ static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
/* continue always trying to read */
status = usb_submit_urb (urb, GFP_ATOMIC);
if (status)
err ("%s - usb_submit_urb failed with result %d",
__FUNCTION__, status);
dev_err (urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
__FUNCTION__, status);
}
static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs)
......@@ -1819,7 +1821,7 @@ static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs)
static int edge_open (struct usb_serial_port *port, struct file * filp)
{
struct edgeport_port *edge_port = (struct edgeport_port *)port->private;
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct edgeport_serial *edge_serial;
struct usb_device *dev;
struct urb *urb;
......@@ -1853,7 +1855,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
edge_port->dma_address = UMPD_OEDB2_ADDRESS;
break;
default:
err ("Unknown port number!!!");
dev_err (port->dev, "Unknown port number!!!\n");
return -ENODEV;
}
......@@ -1929,7 +1931,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
/* we are the first port to be opened, let's post the interrupt urb */
urb = edge_serial->serial->port[0].interrupt_in_urb;
if (!urb) {
err ("%s - no interrupt urb present, exiting", __FUNCTION__);
dev_err (port->dev, "%s - no interrupt urb present, exiting\n", __FUNCTION__);
return -EINVAL;
}
urb->complete = edge_interrupt_callback;
......@@ -1937,7 +1939,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
urb->dev = dev;
status = usb_submit_urb (urb, GFP_KERNEL);
if (status) {
err ("%s - usb_submit_urb failed with value %d", __FUNCTION__, status);
dev_err (port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status);
return status;
}
}
......@@ -1952,7 +1954,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
/* start up our bulk read urb */
urb = port->read_urb;
if (!urb) {
err ("%s - no read urb present, exiting", __FUNCTION__);
dev_err (port->dev, "%s - no read urb present, exiting\n", __FUNCTION__);
return -EINVAL;
}
urb->complete = edge_bulk_in_callback;
......@@ -1960,7 +1962,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
urb->dev = dev;
status = usb_submit_urb (urb, GFP_KERNEL);
if (status) {
err ("%s - read bulk usb_submit_urb failed with value %d", __FUNCTION__, status);
dev_err (port->dev, "%s - read bulk usb_submit_urb failed with value %d\n", __FUNCTION__, status);
return status;
}
......@@ -1988,8 +1990,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if (!serial)
return;
edge_serial = (struct edgeport_serial *)serial->private;
edge_port = (struct edgeport_port *)port->private;
edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL))
return;
......@@ -2028,7 +2030,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count)
{
struct usb_serial *serial = port->serial;
struct edgeport_port *edge_port = port->private;
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int result;
dbg("%s - port %d", __FUNCTION__, port->number);
......@@ -2070,7 +2072,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
/* send the data out the bulk port */
result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
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
result = count;
......@@ -2082,7 +2084,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
static int edge_write_room (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int room = 0;
dbg("%s", __FUNCTION__);
......@@ -2103,7 +2105,7 @@ static int edge_write_room (struct usb_serial_port *port)
static int edge_chars_in_buffer (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int chars = 0;
dbg("%s", __FUNCTION__);
......@@ -2124,7 +2126,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
static void edge_throttle (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status;
......@@ -2157,7 +2159,7 @@ static void edge_throttle (struct usb_serial_port *port)
static void edge_unthrottle (struct usb_serial_port *port)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status;
......@@ -2189,7 +2191,7 @@ static void edge_unthrottle (struct usb_serial_port *port)
port->read_urb->dev = port->serial->dev;
status = usb_submit_urb (port->read_urb, GFP_ATOMIC);
if (status) {
err ("%s - usb_submit_urb failed with value %d", __FUNCTION__, status);
dev_err (port->dev, "%s - usb_submit_urb failed with value %d\n", __FUNCTION__, status);
}
}
......@@ -2215,7 +2217,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio
config = kmalloc (sizeof (*config), GFP_KERNEL);
if (!config) {
err ("%s - out of memory", __FUNCTION__);
dev_err (edge_port->port->dev, "%s - out of memory\n", __FUNCTION__);
return;
}
......@@ -2348,7 +2350,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio
static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned int cflag;
......@@ -2482,7 +2484,7 @@ static int get_serial_info (struct edgeport_port *edge_port, struct serial_struc
static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct async_icount cnow;
struct async_icount cprev;
......@@ -2556,7 +2558,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
static void edge_break (struct usb_serial_port *port, int break_state)
{
struct edgeport_port *edge_port = (struct edgeport_port *)(port->private);
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int status;
dbg ("%s - state = %d", __FUNCTION__, break_state);
......@@ -2588,12 +2590,12 @@ static int edge_startup (struct usb_serial *serial)
/* create our private serial structure */
edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
if (edge_serial == NULL) {
err("%s - Out of memory", __FUNCTION__);
dev_err(serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
return -ENOMEM;
}
memset (edge_serial, 0, sizeof(struct edgeport_serial));
edge_serial->serial = serial;
serial->private = edge_serial;
usb_set_serial_data(serial, edge_serial);
status = TIDownloadFirmware (edge_serial);
if (status) {
......@@ -2605,13 +2607,13 @@ static int edge_startup (struct usb_serial *serial)
for (i = 0; i < serial->num_ports; ++i) {
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
if (edge_port == NULL) {
err("%s - Out of memory", __FUNCTION__);
dev_err(serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
return -ENOMEM;
}
memset (edge_port, 0, sizeof(struct edgeport_port));
edge_port->port = &serial->port[i];
edge_port->edge_serial = edge_serial;
serial->port[i].private = edge_port;
usb_set_serial_port_data(&serial->port[i], edge_port);
}
return 0;
......@@ -2624,11 +2626,11 @@ static void edge_shutdown (struct usb_serial *serial)
dbg ("%s", __FUNCTION__);
for (i=0; i < serial->num_ports; ++i) {
kfree (serial->port[i].private);
serial->port[i].private = NULL;
kfree (usb_get_serial_port_data(&serial->port[i]));
usb_set_serial_port_data(&serial->port[i], NULL);
}
kfree (serial->private);
serial->private = NULL;
kfree (usb_get_serial_data(serial));
usb_set_serial_data(serial, NULL);
}
......
......@@ -9,6 +9,10 @@
* the Free Software Foundation; either version 2 of the License, or
* (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
* Added insmod options to specify product and vendor id.
* Use modprobe ipaq vendor=0xfoo product=0xbar
......@@ -68,9 +72,9 @@
* Version Information
*/
#define DRIVER_VERSION "v0.4"
#define DRIVER_VERSION "v0.5"
#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;
......@@ -94,10 +98,36 @@ static void ipaq_destroy_lists(struct usb_serial_port *port);
static struct usb_device_id ipaq_id_table [] = {
/* The first entry is a placeholder for the insmod-specified device */
{ 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_0032_ID) },
{ USB_DEVICE(HP_VENDOR_ID, HP_JORNADA_548_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 */
};
......@@ -114,7 +144,7 @@ static struct usb_driver ipaq_driver = {
/* All of the device info needed for the Compaq iPAQ */
struct usb_serial_device_type ipaq_device = {
.owner = THIS_MODULE,
.name = "Compaq iPAQ",
.name = "PocketPC PDA",
.id_table = ipaq_id_table,
.num_interrupt_in = NUM_DONT_CARE,
.num_bulk_in = 1,
......@@ -156,7 +186,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
err("%s - Out of memory", __FUNCTION__);
return -ENOMEM;
}
port->private = (void *)priv;
usb_set_serial_port_data(port, priv);
priv->active = 0;
priv->queue_len = 0;
INIT_LIST_HEAD(&priv->queue);
......@@ -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)
{
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__)) {
return;
......@@ -271,7 +301,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
usb_unlink_urb(port->read_urb);
ipaq_destroy_lists(port);
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 */
/* 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
static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf,
int count)
{
struct ipaq_private *priv = port->private;
struct ipaq_private *priv = usb_get_serial_port_data(port);
struct ipaq_packet *pkt = NULL;
int result = 0;
unsigned long flags;
......@@ -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)
{
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;
int count, room;
struct ipaq_packet *pkt;
......@@ -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)
{
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;
int result;
......@@ -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)
{
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);
return priv->free_len;
......@@ -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)
{
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);
return priv->queue_len;
......@@ -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)
{
struct ipaq_private *priv = (struct ipaq_private *)port->private;
struct ipaq_private *priv = usb_get_serial_port_data(port);
struct list_head *tmp;
struct ipaq_packet *pkt;
......
......@@ -9,22 +9,66 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
*/
#ifndef __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_IPAQ_ID 0x0003
#define COMPAQ_0032_ID 0x0032
#define HP_VENDOR_ID 0x03f0
#define HP_JORNADA_548_ID 0x1016
#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 CASIO_EM500_ID 0x2002
#define LINKUP_VENDOR_ID 0x094b
#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
......@@ -41,8 +85,7 @@
*
* The value of PACKET_SIZE was empirically determined by
* 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
* supported by the iPAQ.
* URBDATA_QUEUE_MAX is set to 64K, which is the maximum TCP window size.
*/
struct ipaq_packet {
......
......@@ -243,7 +243,7 @@ static int ir_startup (struct usb_serial *serial)
irda_desc = irda_usb_find_class_desc (serial->dev, 0);
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;
}
......@@ -291,7 +291,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
/* override the default buffer sizes */
buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (port->dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM;
}
kfree (port->read_urb->transfer_buffer);
......@@ -300,7 +300,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
buffer = kmalloc (buffer_size, GFP_KERNEL);
if (!buffer) {
err ("%s - out of memory.", __FUNCTION__);
dev_err (port->dev, "%s - out of memory.\n", __FUNCTION__);
return -ENOMEM;
}
kfree (port->write_urb->transfer_buffer);
......@@ -320,7 +320,7 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
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;
}
......@@ -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);
if (!port->tty) {
err ("%s - no tty???", __FUNCTION__);
dev_err (port->dev, "%s - no tty???\n", __FUNCTION__);
return 0;
}
......@@ -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);
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
result = transfer_size;
......@@ -503,11 +503,9 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
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);
break ;
......@@ -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);
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;
}
......
......@@ -220,7 +220,7 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
dbg("%s", __FUNCTION__);
p_priv = (struct keyspan_port_private *)port->private;
p_priv = usb_get_serial_port_data(port);
if (break_state == -1)
p_priv->break_on = 1;
......@@ -241,7 +241,7 @@ static void keyspan_set_termios (struct usb_serial_port *port,
dbg("%s", __FUNCTION__);
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
cflag = port->tty->termios->c_cflag;
device_port = port->number - port->serial->minor;
......@@ -270,7 +270,7 @@ static int keyspan_ioctl(struct usb_serial_port *port, struct file *file,
unsigned int value, set;
struct keyspan_port_private *p_priv;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
switch (cmd) {
case TIOCMGET:
......@@ -321,7 +321,7 @@ static int keyspan_write(struct usb_serial_port *port, int from_user,
struct urb *this_urb;
int err;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
dbg("%s - for port %d (%d chars [%x]), flip=%d",
......@@ -444,7 +444,7 @@ static void usa2x_outdat_callback(struct urb *urb, struct pt_regs *regs)
struct keyspan_port_private *p_priv;
port = (struct usb_serial_port *) urb->context;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
dbg ("%s - urb %d", __FUNCTION__, urb == p_priv->out_urbs[1]);
if (port->open_count)
......@@ -463,7 +463,7 @@ static void usa26_outcont_callback(struct urb *urb, struct pt_regs *regs)
struct keyspan_port_private *p_priv;
port = (struct usb_serial_port *) urb->context;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
dbg ("%s - sending setup", __FUNCTION__);
......@@ -508,7 +508,7 @@ static void usa26_instat_callback(struct urb *urb, struct pt_regs *regs)
goto exit;
}
port = &serial->port[msg->port];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
......@@ -551,7 +551,7 @@ static void usa28_indat_callback(struct urb *urb, struct pt_regs *regs)
dbg ("%s", __FUNCTION__);
port = (struct usb_serial_port *) urb->context;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
data = urb->transfer_buffer;
if (urb != p_priv->in_urbs[p_priv->in_flip])
......@@ -565,7 +565,7 @@ static void usa28_indat_callback(struct urb *urb, struct pt_regs *regs)
}
port = (struct usb_serial_port *) urb->context;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
data = urb->transfer_buffer;
tty = port->tty;
......@@ -599,7 +599,7 @@ static void usa28_outcont_callback(struct urb *urb, struct pt_regs *regs)
struct keyspan_port_private *p_priv;
port = (struct usb_serial_port *) urb->context;
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
dbg ("%s - sending setup", __FUNCTION__);
......@@ -643,7 +643,7 @@ static void usa28_instat_callback(struct urb *urb, struct pt_regs *regs)
goto exit;
}
port = &serial->port[msg->port];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
......@@ -686,7 +686,7 @@ static void usa49_glocont_callback(struct urb *urb, struct pt_regs *regs)
serial = (struct usb_serial *) urb->context;
for (i = 0; i < serial->num_ports; ++i) {
port = &serial->port[i];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
dbg ("%s - sending setup", __FUNCTION__);
......@@ -735,7 +735,7 @@ static void usa49_instat_callback(struct urb *urb, struct pt_regs *regs)
goto exit;
}
port = &serial->port[msg->portNumber];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
......@@ -834,7 +834,7 @@ static int keyspan_write_room (struct usb_serial_port *port)
struct urb *this_urb;
dbg("%s", __FUNCTION__);
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
flip = p_priv->out_flip;
......@@ -867,14 +867,12 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
int i, err;
struct urb *urb;
s_priv = (struct keyspan_serial_private *)(serial->private);
p_priv = (struct keyspan_port_private *)(port->private);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details;
dbg("%s - port%d.", __FUNCTION__, port->number);
p_priv = (struct keyspan_port_private *)(port->private);
/* Set some sane defaults */
p_priv->rts_state = 1;
p_priv->dtr_state = 1;
......@@ -929,8 +927,8 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
return;
dbg("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
p_priv = (struct keyspan_port_private *)(port->private);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
p_priv->rts_state = 0;
p_priv->dtr_state = 0;
......@@ -1037,7 +1035,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
}
if (record == NULL) {
err("Required keyspan firmware image (%s) unavailable.", fw_name);
dev_err(serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name);
return(1);
}
......@@ -1051,10 +1049,10 @@ static int keyspan_fake_startup (struct usb_serial *serial)
(unsigned char *)record->data,
record->data_size, 0xa0);
if (response < 0) {
err("ezusb_writememory failed for Keyspan"
"firmware (%d %04X %p %d)",
response,
record->address, record->data, record->data_size);
dev_err(serial->dev->dev, "ezusb_writememory failed for Keyspan"
"firmware (%d %04X %p %d)\n",
response,
record->address, record->data, record->data_size);
break;
}
record++;
......@@ -1141,7 +1139,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details;
/* Setup values for the various callback routines */
......@@ -1162,7 +1160,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
/* Setup endpoints for each port specific thing */
for (i = 0; i < d_details->num_ports; i ++) {
port = &serial->port[i];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
/* Do indat endpoints first, once for each flip */
endp = d_details->indat_endpoints[i];
......@@ -1377,8 +1375,8 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
dbg ("%s reset=%d", __FUNCTION__, reset_port);
s_priv = (struct keyspan_serial_private *)(serial->private);
p_priv = (struct keyspan_port_private *)(port->private);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details;
device_port = port->number - port->serial->minor;
......@@ -1532,8 +1530,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
p_priv = (struct keyspan_port_private *)(port->private);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details;
device_port = port->number - port->serial->minor;
......@@ -1657,8 +1655,8 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
p_priv = (struct keyspan_port_private *)(port->private);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details;
glocont_urb = d_details->glocont_endpoint;
......@@ -1817,7 +1815,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details;
switch (d_details->msg_format) {
......@@ -1849,34 +1847,32 @@ static int keyspan_startup (struct usb_serial *serial)
if (d_details->product_id == serial->dev->descriptor.idProduct)
break;
if (d_details == NULL) {
err("%s - unknown product id %x", __FUNCTION__, serial->dev->descriptor.idProduct);
dev_err(serial->dev->dev, "%s - unknown product id %x\n", __FUNCTION__, serial->dev->descriptor.idProduct);
return 1;
}
/* Setup private data for serial driver */
serial->private = kmalloc(sizeof(struct keyspan_serial_private),
GFP_KERNEL);
if (!serial->private) {
s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
if (!s_priv) {
dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__);
return (1);
return -ENOMEM;
}
memset(serial->private, 0, sizeof(struct keyspan_serial_private));
memset(s_priv, 0, sizeof(struct keyspan_serial_private));
s_priv = (struct keyspan_serial_private *)(serial->private);
s_priv->device_details = d_details;
usb_set_serial_data(serial, s_priv);
/* Now setup per port private data */
for (i = 0; i < serial->num_ports; i++) {
port = &serial->port[i];
port->private = kmalloc(sizeof(struct keyspan_port_private),
GFP_KERNEL);
if (!port->private) {
p_priv = kmalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
if (!p_priv) {
dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i);
return (1);
}
memset(port->private, 0, sizeof(struct keyspan_port_private));
p_priv = (struct keyspan_port_private *)(port->private);
memset(p_priv, 0, sizeof(struct keyspan_port_private));
p_priv->device_details = d_details;
usb_set_serial_port_data(port, p_priv);
}
keyspan_setup_urbs(serial);
......@@ -1898,14 +1894,14 @@ static void keyspan_shutdown (struct usb_serial *serial)
dbg("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private);
s_priv = usb_get_serial_data(serial);
/* Stop reading/writing urbs */
stop_urb(s_priv->instat_urb);
stop_urb(s_priv->glocont_urb);
for (i = 0; i < serial->num_ports; ++i) {
port = &serial->port[i];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
stop_urb(p_priv->inack_urb);
stop_urb(p_priv->outcont_urb);
for (j = 0; j < 2; j++) {
......@@ -1921,7 +1917,7 @@ static void keyspan_shutdown (struct usb_serial *serial)
usb_free_urb(s_priv->glocont_urb);
for (i = 0; i < serial->num_ports; ++i) {
port = &serial->port[i];
p_priv = (struct keyspan_port_private *)(port->private);
p_priv = usb_get_serial_port_data(port);
if (p_priv->inack_urb)
usb_free_urb(p_priv->inack_urb);
if (p_priv->outcont_urb)
......@@ -1935,13 +1931,13 @@ static void keyspan_shutdown (struct usb_serial *serial)
}
/* dbg("Freeing serial->private."); */
kfree(serial->private);
kfree(s_priv);
/* dbg("Freeing port->private."); */
/* Now free per port private data */
for (i = 0; i < serial->num_ports; i++) {
port = &serial->port[i];
kfree(port->private);
kfree(usb_get_serial_port_data(port));
}
}
......
......@@ -231,7 +231,7 @@ static void keyspan_pda_rx_interrupt (struct urb *urb, struct pt_regs *regs)
int i;
int status;
struct keyspan_pda_private *priv;
priv = (struct keyspan_pda_private *)(port->private);
priv = usb_get_serial_port_data(port);
switch (urb->status) {
case 0:
......@@ -532,7 +532,7 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user,
int rc = 0;
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
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
......@@ -643,7 +643,7 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *re
struct usb_serial *serial;
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")) {
return;
......@@ -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)
{
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
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)
static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
{
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
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)
rc = -EIO;
goto error;
}
priv = (struct keyspan_pda_private *)(port->private);
priv = usb_get_serial_port_data(port);
priv->tx_room = room;
priv->tx_throttled = room ? 0 : 1;
......@@ -803,10 +805,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
/* allocate the private data structures for all ports. Well, for all
one ports. */
priv = serial->port[0].private
= kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
if (!priv)
return (1); /* error */
usb_set_serial_port_data(&serial->port[0], priv);
init_waitqueue_head(&serial->port[0].write_wait);
INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write,
(void *)(&serial->port[0]));
......@@ -820,7 +822,7 @@ static void keyspan_pda_shutdown (struct usb_serial *serial)
{
dbg("%s", __FUNCTION__);
kfree(serial->port[0].private);
kfree(usb_get_serial_port_data(&serial->port[0]));
}
#ifdef KEYSPAN
......
......@@ -265,13 +265,12 @@ static int klsi_105_startup (struct usb_serial *serial)
/* allocate the private data structure */
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);
if (!serial->port[i].private) {
if (!priv) {
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 */
priv->cfg.pktlen = 5;
priv->cfg.baudrate = kl5kusb105a_sio_b9600;
......@@ -283,6 +282,7 @@ static int klsi_105_startup (struct usb_serial *serial)
priv->bytes_in = 0;
priv->bytes_out = 0;
usb_set_serial_port_data(&serial->port[i], priv);
spin_lock_init (&priv->write_urb_pool_lock);
for (i=0; i<NUM_URBS; i++) {
......@@ -319,8 +319,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
struct klsi_105_private *priv =
(struct klsi_105_private*) serial->port[i].private;
struct klsi_105_private *priv = usb_get_serial_port_data(&serial->port[i]);
unsigned long flags;
if (priv) {
......@@ -347,7 +346,8 @@ static void klsi_105_shutdown (struct usb_serial *serial)
spin_unlock_irqrestore (&priv->write_urb_pool_lock,
flags);
kfree(serial->port[i].private);
kfree(priv);
usb_set_serial_port_data(&serial->port[i], NULL);
}
}
} /* klsi_105_shutdown */
......@@ -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)
{
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 rc;
int i;
......@@ -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)
{
struct usb_serial *serial;
struct klsi_105_private *priv
= (struct klsi_105_private *)port->private;
struct klsi_105_private *priv = usb_get_serial_port_data(port);
int rc;
dbg("%s port %d", __FUNCTION__, port->number);
......@@ -481,8 +480,7 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
const unsigned char *buf, int count)
{
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 result, size;
int bytes_sent=0;
......@@ -588,8 +586,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
int chars = 0;
int i;
unsigned long flags;
struct klsi_105_private *priv =
(struct klsi_105_private*) port->private;
struct klsi_105_private *priv = usb_get_serial_port_data(port);
spin_lock_irqsave (&priv->write_urb_pool_lock, flags);
......@@ -610,8 +607,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
unsigned long flags;
int i;
int room = 0;
struct klsi_105_private *priv =
(struct klsi_105_private*) port->private;
struct klsi_105_private *priv = usb_get_serial_port_data(port);
spin_lock_irqsave (&priv->write_urb_pool_lock, flags);
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)
{
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
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);
struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
int rc;
......@@ -715,7 +710,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
struct termios *old_termios)
{
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 old_iflag = old_termios->c_iflag;
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,
unsigned int cmd, unsigned long arg)
{
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;
dbg("%scmd=0x%x", __FUNCTION__, cmd);
......
......@@ -136,12 +136,11 @@ static int kobil_startup (struct usb_serial *serial)
struct usb_host_interface *altsetting;
struct usb_host_endpoint *endpoint;
serial->port->private = kmalloc(sizeof(struct kobil_private), GFP_KERNEL);
if (!serial->port->private){
return -1;
priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL);
if (!priv){
return -ENOMEM;
}
priv = (struct kobil_private *) serial->port->private;
priv->filled = 0;
priv->cur_pos = 0;
priv->device_type = serial->product;
......@@ -158,6 +157,7 @@ static int kobil_startup (struct usb_serial *serial)
printk(KERN_DEBUG "KOBIL USBTWIN detected\n");
break;
}
usb_set_serial_port_data(serial->port, priv);
// search for the neccessary endpoints
pdev = serial->dev;
......@@ -192,9 +192,8 @@ static void kobil_shutdown (struct usb_serial *serial)
while (serial->port[i].open_count > 0) {
kobil_close (&serial->port[i], NULL);
}
if (serial->port[i].private) {
kfree(serial->port[i].private);
}
kfree(usb_get_serial_port_data(&serial->port[i]));
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)
int write_urb_transfer_buffer_length = 8;
dbg("%s - port %d", __FUNCTION__, port->number);
priv = (struct kobil_private *) port->private;
priv = usb_get_serial_port_data(port);
priv->line_state = 0;
if (port_paranoia_check (port, __FUNCTION__))
......@@ -413,7 +412,7 @@ static int kobil_write (struct usb_serial_port *port, int from_user,
return 0;
}
priv = (struct kobil_private *) port->private;
priv = usb_get_serial_port_data(port);
if (count > (KOBIL_BUF_LENGTH - priv->filled)) {
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,
int transfer_buffer_length = 8;
char *settings;
priv = (struct kobil_private *) port->private;
priv = usb_get_serial_port_data(port);
if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) {
// This device doesn't support ioctl calls
return 0;
......
......@@ -304,40 +304,40 @@ static int mct_u232_startup (struct usb_serial *serial)
struct mct_u232_private *priv;
/* allocate the private data structure */
serial->port->private = kmalloc(sizeof(struct mct_u232_private),
GFP_KERNEL);
if (!serial->port->private)
priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
if (!priv)
return (-1); /* error */
priv = (struct mct_u232_private *)serial->port->private;
/* set initial values for control structures */
priv->control_state = 0;
priv->last_lsr = 0;
priv->last_msr = 0;
usb_set_serial_port_data(serial->port, priv);
init_waitqueue_head(&serial->port->write_wait);
return (0);
} /* mct_u232_startup */
static void mct_u232_shutdown (struct usb_serial *serial)
{
struct mct_u232_private *priv;
int i;
dbg("%s", __FUNCTION__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
/* My special items, the standard routines free my urbs */
if (serial->port[i].private)
kfree(serial->port[i].private);
priv = usb_get_serial_port_data(&serial->port[i]);
if (priv)
kfree(priv);
}
} /* mct_u232_shutdown */
static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
{
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;
dbg("%s port %d", __FUNCTION__, port->number);
......@@ -375,7 +375,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
struct usb_serial_port *rport;
rport = &serial->port[1];
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;
}
......@@ -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)
{
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 tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
......@@ -609,7 +609,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
struct termios *old_termios)
{
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 old_iflag = old_termios->c_iflag;
unsigned int cflag = port->tty->termios->c_cflag;
......@@ -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 )
{
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;
dbg("%sstate=%d", __FUNCTION__, break_state);
......@@ -741,7 +741,7 @@ static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
unsigned int cmd, unsigned long arg)
{
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;
dbg("%scmd=0x%x", __FUNCTION__, cmd);
......
......@@ -168,7 +168,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
return -ENOMEM;
}
port->private = od;
usb_set_serial_port_data(port, od);
wport = &serial->port[1];
wport->tty = port->tty;
......@@ -205,7 +205,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->read_urb);
}
od = (struct omninet_data *)port->private;
od = usb_get_serial_port_data(port);
if (od)
kfree(od);
}
......@@ -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_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;
int result;
......
......@@ -163,7 +163,7 @@ static int pl2303_startup (struct usb_serial *serial)
if (!priv)
return -ENOMEM;
memset (priv, 0x00, sizeof (struct pl2303_private));
serial->port[i].private = priv;
usb_set_serial_port_data(&serial->port[i], priv);
}
return 0;
}
......@@ -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;
result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
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
result = count;
......@@ -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)
{
struct usb_serial *serial = port->serial;
struct pl2303_private *priv;
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int cflag;
unsigned char *buf;
int baud;
int i;
dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number,
((struct pl2303_private *) port->private)->termios_initialized);
dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number, priv->termios_initialized);
if ((!port->tty) || (!port->tty->termios)) {
dbg("%s - no tty structures", __FUNCTION__);
return;
}
if (!(((struct pl2303_private *) port->private)->termios_initialized)) {
if (!priv->termios_initialized) {
*(port->tty->termios) = tty_std_termios;
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;
/* 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
buf = kmalloc (7, GFP_KERNEL);
if (!buf) {
err("%s - out of memory.", __FUNCTION__);
dev_err(port->dev, "%s - out of memory.\n", __FUNCTION__);
return;
}
memset (buf, 0x00, 0x07);
......@@ -295,7 +294,7 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
case B230400: baud = 230400; break;
case B460800: baud = 460800; break;
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;
}
dbg("%s - baud = %d", __FUNCTION__, baud);
......@@ -341,7 +340,6 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
dbg ("0x21:0x20:0:0 %d", i);
if (cflag && CBAUD) {
priv = port->private;
if ((cflag && CBAUD) == B0)
priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
else
......@@ -413,7 +411,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
port->read_urb->dev = serial->dev;
result = usb_submit_urb (port->read_urb, GFP_KERNEL);
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);
return -EPROTO;
}
......@@ -422,7 +420,7 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
port->interrupt_in_urb->dev = serial->dev;
result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL);
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);
return -EPROTO;
}
......@@ -450,7 +448,7 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
c_cflag = port->tty->termios->c_cflag;
if (c_cflag & HUPCL) {
/* drop DTR and RTS */
priv = port->private;
priv = usb_get_serial_port_data(port);
priv->line_control = 0;
set_control_lines (port->serial->dev,
priv->line_control);
......@@ -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)
{
struct pl2303_private *priv = port->private;
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int arg;
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
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 result;
......@@ -583,8 +581,10 @@ static void pl2303_shutdown (struct usb_serial *serial)
dbg("%s", __FUNCTION__);
for (i = 0; i < serial->num_ports; ++i)
kfree (serial->port[i].private);
for (i = 0; i < serial->num_ports; ++i) {
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)
exit:
status = usb_submit_urb (urb, GFP_ATOMIC);
if (status)
err ("%s - usb_submit_urb failed with result %d",
__FUNCTION__, status);
dev_err(urb->dev->dev, "%s - usb_submit_urb failed with result %d\n",
__FUNCTION__, status);
}
......@@ -658,7 +658,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
urb->dev = serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC);
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;
}
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)
urb->dev = serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC);
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;
......@@ -712,7 +712,7 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
port->write_urb->dev = port->serial->dev;
result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
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;
}
......
......@@ -366,7 +366,7 @@ static struct usb_device_id generic_serial_ids[] = {
/* Driver structure we register with the USB core */
static struct usb_driver usb_serial_driver = {
.name = "serial",
.name = "usbserial",
.probe = usb_serial_probe,
.disconnect = usb_serial_disconnect,
#ifdef CONFIG_USB_SERIAL_GENERIC
......@@ -841,7 +841,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
serial = kmalloc (sizeof (*serial), GFP_KERNEL);
if (!serial) {
err ("%s - out of memory", __FUNCTION__);
dev_err(dev->dev, "%s - out of memory\n", __FUNCTION__);
return NULL;
}
memset (serial, 0, sizeof(*serial));
......@@ -899,14 +899,14 @@ int usb_serial_probe(struct usb_interface *interface,
serial = create_serial (dev, interface, type);
if (!serial) {
err ("%s - out of memory", __FUNCTION__);
dev_err(interface->dev, "%s - out of memory\n", __FUNCTION__);
return -ENODEV;
}
/* if this device type has a probe function, call it */
if (type->probe) {
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
dev_err(interface->dev, "module get failed, exiting\n");
kfree (serial);
return -EIO;
}
......@@ -980,7 +980,7 @@ int usb_serial_probe(struct usb_interface *interface,
* properly during a later invocation of usb_serial_probe
*/
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);
return -ENODEV;
}
......@@ -989,13 +989,13 @@ int usb_serial_probe(struct usb_interface *interface,
#endif
/* 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
if (type == &usb_serial_generic_device) {
num_ports = num_bulk_out;
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);
return -EIO;
}
......@@ -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 (type->calc_num_ports) {
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
dev_err(interface->dev, "module get failed, exiting\n");
kfree (serial);
return -EIO;
}
......@@ -1017,7 +1017,7 @@ int usb_serial_probe(struct usb_interface *interface,
}
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);
return -ENOMEM;
}
......@@ -1034,14 +1034,14 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i];
port->read_urb = usb_alloc_urb (0, GFP_KERNEL);
if (!port->read_urb) {
err("No free urbs available");
dev_err(interface->dev, "No free urbs available\n");
goto probe_error;
}
buffer_size = endpoint->wMaxPacketSize;
port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
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;
}
usb_fill_bulk_urb (port->read_urb, dev,
......@@ -1059,7 +1059,7 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i];
port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->write_urb) {
err("No free urbs available");
dev_err(interface->dev, "No free urbs available\n");
goto probe_error;
}
buffer_size = endpoint->wMaxPacketSize;
......@@ -1067,7 +1067,7 @@ int usb_serial_probe(struct usb_interface *interface,
port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
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;
}
usb_fill_bulk_urb (port->write_urb, dev,
......@@ -1085,14 +1085,14 @@ int usb_serial_probe(struct usb_interface *interface,
port = &serial->port[i];
port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->interrupt_in_urb) {
err("No free urbs available");
dev_err(interface->dev, "No free urbs available\n");
goto probe_error;
}
buffer_size = endpoint->wMaxPacketSize;
port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
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;
}
usb_fill_int_urb (port->interrupt_in_urb, dev,
......@@ -1121,7 +1121,7 @@ int usb_serial_probe(struct usb_interface *interface,
/* if this device type has an attach function, call it */
if (type->attach) {
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
dev_err(interface->dev, "module get failed, exiting\n");
goto probe_error;
}
retval = type->attach (serial);
......@@ -1190,6 +1190,7 @@ int usb_serial_probe(struct usb_interface *interface,
void usb_serial_disconnect(struct usb_interface *interface)
{
struct usb_serial *serial = dev_get_drvdata (&interface->dev);
struct device *dev = &interface->dev;
struct usb_serial_port *port;
int i;
......@@ -1252,14 +1253,13 @@ void usb_serial_disconnect(struct usb_interface *interface)
/* free up any memory that we allocated */
kfree (serial);
}
info("device disconnected");
dev_info(*dev, "device disconnected\n");
}
struct tty_driver usb_serial_tty_driver = {
.magic = TTY_DRIVER_MAGIC,
.driver_name = "usb-serial",
.driver_name = "usbserial",
#ifndef CONFIG_DEVFS_FS
.name = "ttyUSB",
#else
......
......@@ -90,9 +90,6 @@
* @work: work queue entry for the line discipline waking up.
* @open_count: number of times this port has been opened.
* @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
* ports of a device.
......@@ -120,11 +117,21 @@ struct usb_serial_port {
struct work_struct work;
int open_count;
struct semaphore sem;
void * private;
struct device 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
* @magic: magic number for internal validity of this pointer.
......@@ -141,7 +148,8 @@ struct usb_serial_port {
* @port: array of struct usb_serial_port structures for the different ports.
* @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.
* will not touch this. Use usb_get_serial_data() and
* usb_set_serial_data() to access this.
*/
struct usb_serial {
int magic;
......@@ -159,9 +167,18 @@ struct usb_serial {
void * private;
};
#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
......
......@@ -303,7 +303,7 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
if (!port->read_urb) {
/* 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;
}
......@@ -327,8 +327,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_KERNEL);
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);
goto exit;
}
......@@ -336,8 +336,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
dbg("%s - adding interrupt input for treo", __FUNCTION__);
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
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);
}
exit:
return result;
......@@ -363,7 +363,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
* device is still here */
transfer_buffer = kmalloc (0x12, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, 0x12);
dev_err(port->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 0x12);
} else {
/* send a shutdown message to the device */
usb_control_msg (serial->dev,
......@@ -380,7 +380,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
usb_unlink_urb (port->interrupt_in_urb);
}
/* 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
buffer = kmalloc (count, GFP_ATOMIC);
if (!buffer) {
err ("out of memory");
dev_err(port->dev, "out of memory\n");
return -ENOMEM;
}
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
err ("no more free urbs");
dev_err(port->dev, "no more free urbs\n");
kfree (buffer);
return -ENOMEM;
}
......@@ -427,8 +427,8 @@ static int visor_write (struct usb_serial_port *port, int from_user, const unsig
/* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC);
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);
count = status;
} else {
bytes_out += count;
......@@ -539,7 +539,7 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
visor_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
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;
}
......@@ -577,8 +577,8 @@ static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs)
exit:
result = usb_submit_urb (urb, GFP_ATOMIC);
if (result)
err("%s - Error %d submitting interrupt urb",
__FUNCTION__, result);
dev_err(urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
__FUNCTION__, result);
}
static void visor_throttle (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;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
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)
{
struct device *dev = &serial->dev->dev;
int response;
int i;
int num_ports;
unsigned char *transfer_buffer = kmalloc (256, GFP_KERNEL);
if (!transfer_buffer) {
err("%s - kmalloc(%d) failed.", __FUNCTION__, 256);
dev_err(*dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, 256);
return -ENOMEM;
}
......@@ -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,
0xc2, 0x0000, 0x0000, transfer_buffer, 0x12, 300);
if (response < 0) {
err("%s - error getting connection information", __FUNCTION__);
dev_err(*dev, "%s - error getting connection information\n", __FUNCTION__);
} else {
struct visor_connection_info *connection_info = (struct visor_connection_info *)transfer_buffer;
char *string;
le16_to_cpus(&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) {
switch (connection_info->connections[i].port_function_id) {
case VISOR_FUNCTION_GENERIC:
......@@ -650,10 +651,10 @@ static int visor_probe (struct usb_serial *serial)
string = "unknown";
break;
}
info("%s: port %d, is for %s use", serial->type->name,
connection_info->connections[i].port, string);
dev_info(*dev, "%s: port %d, is for %s use\n", serial->type->name,
connection_info->connections[i].port, string);
/* 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)
0xc2, 0x0000, 0x0000, transfer_buffer,
0x14, 300);
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 {
usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer);
}
......@@ -675,7 +676,7 @@ static int visor_probe (struct usb_serial *serial)
0xc2, 0x0000, 0x0000, transfer_buffer,
0x14, 300);
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 {
usb_serial_debug_data (__FILE__, __FUNCTION__, 0x14, transfer_buffer);
}
......@@ -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,
0xc2, 0x0000, 0x0005, transfer_buffer, 0x02, 300);
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);
......@@ -696,17 +697,17 @@ static int visor_probe (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;
}
static int clie_3_5_startup (struct usb_serial *serial)
{
struct device *dev = &serial->dev->dev;
int result;
u8 data;
......@@ -721,11 +722,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
0, 0, &data, 1, HZ * 3);
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;
}
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;
}
......@@ -735,11 +736,11 @@ static int clie_3_5_startup (struct usb_serial *serial)
USB_DIR_IN | USB_RECIP_INTERFACE,
0, 0, &data, 1, HZ * 3);
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;
}
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;
}
......
......@@ -464,7 +464,7 @@ static int whiteheat_attach (struct usb_serial *serial)
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);
......@@ -476,7 +476,7 @@ static int whiteheat_attach (struct usb_serial *serial)
spin_lock_init(&command_info->lock);
command_info->port_running = 0;
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->read_urb->complete = command_port_read_callback;
......@@ -492,7 +492,7 @@ static int whiteheat_attach (struct usb_serial *serial)
no_command_private:
for (i = serial->num_ports - 1; i >= 0; i--) {
port = &serial->port[i];
info = port->private;
info = usb_get_serial_port_data(port);
for (j = urb_pool_size - 1; j >= 0; j--) {
tmp = list_first(&info->tx_urbs_free);
list_del(tmp);
......@@ -539,11 +539,11 @@ static void whiteheat_shutdown (struct usb_serial *serial)
/* free up our private data for our 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++) {
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_del(tmp);
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)
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 urb *urb;
struct list_head *tmp;
......@@ -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)
{
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 urb *urb;
int result;
......@@ -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)
{
struct whiteheat_private *info = port->private;
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct list_head *tmp;
int room = 0;
unsigned long flags;
......@@ -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)
{
struct whiteheat_private *info = (struct whiteheat_private *)port->private;
struct whiteheat_private *info = usb_get_serial_port_data(port);
unsigned int modem_signals = 0;
struct serial_struct serstruct;
......@@ -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)
{
struct whiteheat_private *info = port->private;
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct list_head *tmp;
struct whiteheat_urb_wrap *wrap;
int chars = 0;
......@@ -925,7 +925,7 @@ static int whiteheat_chars_in_buffer(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;
dbg("%s - port %d", __FUNCTION__, port->number);
......@@ -940,7 +940,7 @@ static void whiteheat_throttle (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;
unsigned long flags;
......@@ -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);
command_info = (struct whiteheat_command_private *)command_port->private;
command_info = usb_get_serial_port_data(command_port);
if (!command_info) {
dbg ("%s - command_info is NULL, exiting.", __FUNCTION__);
return;
......@@ -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 whiteheat_urb_wrap *wrap;
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);
......@@ -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 *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;
dbg("%s - port %d", __FUNCTION__, port->number);
......@@ -1135,7 +1135,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
dbg("%s - command %d", __FUNCTION__, command);
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);
command_info->command_finished = FALSE;
......@@ -1175,7 +1175,7 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
dbg("%s - command completed.", __FUNCTION__);
switch (command) {
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));
break;
}
......@@ -1339,7 +1339,7 @@ static int start_command_port(struct usb_serial *serial)
int retval = 0;
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);
if (!command_info->port_running) {
/* Work around HCD bugs */
......@@ -1367,7 +1367,7 @@ static void stop_command_port(struct usb_serial *serial)
unsigned long flags;
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);
command_info->port_running--;
if (!command_info->port_running)
......@@ -1376,8 +1376,9 @@ static void stop_command_port(struct usb_serial *serial)
}
static int start_port_read(struct usb_serial_port *port) {
struct whiteheat_private *info = port->private;
static int start_port_read(struct usb_serial_port *port)
{
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap;
struct urb *urb;
int retval = 0;
......@@ -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 list_head *tmp;
......@@ -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;
}
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 whiteheat_private *info = port->private;
struct whiteheat_private *info = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
struct whiteheat_urb_wrap *wrap;
struct urb *urb;
......
......@@ -28,14 +28,6 @@ static __inline__ void wait_ms(unsigned int 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;
/*-------------------------------------------------------------------------*/
......@@ -119,12 +111,21 @@ struct usb_interface {
struct usb_driver *driver; /* driver */
kdev_t kdev; /* node this interface is bound to */
struct device dev; /* interface specific device info */
void *private_data;
};
#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
#define interface_to_usbdev(intf) \
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_OTHER_SPEED_CONFIG is the same descriptor, except that the
......@@ -159,10 +160,16 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
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 device *controller; /* host/master side hardware */
int busnum; /* Bus number (in order of reg) */
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