diff options
Diffstat (limited to 'drivers/staging/ced1401')
-rw-r--r-- | drivers/staging/ced1401/ced_ioc.c | 37 | ||||
-rw-r--r-- | drivers/staging/ced1401/usb1401.c | 36 | ||||
-rw-r--r-- | drivers/staging/ced1401/usb1401.h | 2 | ||||
-rw-r--r-- | drivers/staging/ced1401/userspace/use1401.c | 8 |
4 files changed, 31 insertions, 52 deletions
diff --git a/drivers/staging/ced1401/ced_ioc.c b/drivers/staging/ced1401/ced_ioc.c index c9492ed..d043471 100644 --- a/drivers/staging/ced1401/ced_ioc.c +++ b/drivers/staging/ced1401/ced_ioc.c @@ -341,7 +341,7 @@ bool Is1401(DEVICE_EXTENSION * pdx) } if (iReturn == 0) // if all is OK... - iReturn = state == 0; // then sucess is that the state is 0 + iReturn = state == 0; // then success is that the state is 0 } else iReturn = 0; // we failed pdx->bForceReset = false; // Clear forced reset flag now @@ -565,7 +565,7 @@ int LineCount(DEVICE_EXTENSION * pdx) if (dwIndex >= INBUF_SZ) // see if we fall off buff dwIndex = 0; } - while (dwIndex != dwEnd); // go to last avaliable + while (dwIndex != dwEnd); // go to last available } spin_unlock_irq(&pdx->charInLock); @@ -697,8 +697,7 @@ static int SetArea(DEVICE_EXTENSION * pdx, int nArea, char __user * puBuf, return -EFAULT; // ...then we are done // Now allocate space to hold the page pointer and virtual address pointer tables - pPages = - (struct page **)kmalloc(len * sizeof(struct page *), GFP_KERNEL); + pPages = kmalloc(len * sizeof(struct page *), GFP_KERNEL); if (!pPages) { iReturn = U14ERR_NOMEMORY; goto error; @@ -913,18 +912,24 @@ int GetTransfer(DEVICE_EXTENSION * pdx, TGET_TX_BLOCK __user * pTX) iReturn = U14ERR_BADAREA; else { // Return the best information we have - we don't have physical addresses - TGET_TX_BLOCK tx; - memset(&tx, 0, sizeof(tx)); // clean out local work structure - tx.size = pdx->rTransDef[dwIdent].dwLength; - tx.linear = (long long)((long)pdx->rTransDef[dwIdent].lpvBuff); - tx.avail = GET_TX_MAXENTRIES; // how many blocks we could return - tx.used = 1; // number we actually return - tx.entries[0].physical = - (long long)(tx.linear + pdx->StagedOffset); - tx.entries[0].size = tx.size; - - if (copy_to_user(pTX, &tx, sizeof(tx))) + TGET_TX_BLOCK *tx; + + tx = kzalloc(sizeof(*tx), GFP_KERNEL); + if (!tx) { + mutex_unlock(&pdx->io_mutex); + return -ENOMEM; + } + tx->size = pdx->rTransDef[dwIdent].dwLength; + tx->linear = (long long)((long)pdx->rTransDef[dwIdent].lpvBuff); + tx->avail = GET_TX_MAXENTRIES; // how many blocks we could return + tx->used = 1; // number we actually return + tx->entries[0].physical = + (long long)(tx->linear + pdx->StagedOffset); + tx->entries[0].size = tx->size; + + if (copy_to_user(pTX, tx, sizeof(*tx))) iReturn = -EFAULT; + kfree(tx); } mutex_unlock(&pdx->io_mutex); return iReturn; @@ -1508,7 +1513,7 @@ int FreeCircBlock(DEVICE_EXTENSION * pdx, TCIRCBLOCK __user * pCB) iReturn = U14ERR_BADAREA; if (copy_to_user(pCB, &cb, sizeof(cb))) - return -EFAULT; + iReturn = -EFAULT; mutex_unlock(&pdx->io_mutex); return iReturn; diff --git a/drivers/staging/ced1401/usb1401.c b/drivers/staging/ced1401/usb1401.c index 6ba0ef6..a27043a 100644 --- a/drivers/staging/ced1401/usb1401.c +++ b/drivers/staging/ced1401/usb1401.c @@ -89,14 +89,11 @@ synchronous non-Urb based transfers. #include <linux/mutex.h> #include <linux/mm.h> #include <linux/highmem.h> -#include <linux/version.h> -#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) ) #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/kref.h> #include <linux/uaccess.h> -#endif #include "usb1401.h" @@ -123,19 +120,6 @@ MODULE_DEVICE_TABLE(usb, ced_table); #define WRITES_IN_FLIGHT 8 /* arbitrarily chosen */ -/* -The cause for these errors is that the driver makes use of the functions usb_buffer_alloc() and usb_buffer_free() which got renamed in kernel 2.6.35. This is stated in the Changelog: USB: rename usb_buffer_alloc() and usb_buffer_free() users - For more clearance what the functions actually do, - usb_buffer_alloc() is renamed to usb_alloc_coherent() - usb_buffer_free() is renamed to usb_free_coherent() - This is needed on Debian 2.6.32-5-amd64 -*/ -#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) ) -#define usb_alloc_coherent usb_buffer_alloc -#define usb_free_coherent usb_buffer_free -#define noop_llseek NULL -#endif - static struct usb_driver ced_driver; static void ced_delete(struct kref *kref) @@ -927,9 +911,9 @@ static bool ReadWord(unsigned short *pWord, char *pBuf, unsigned int *pdDone, ** ReadHuff ** ** Reads a coded number in and returns it, Code is: -** If data is in range 0..127 we recieve 1 byte. If data in range 128-16383 -** we recieve two bytes, top bit of first indicates another on its way. If -** data in range 16383-4194303 we get three bytes, top two bits of first set +** If data is in range 0..127 we receive 1 byte. If data in range 128-16383 +** we receive two bytes, top bit of first indicates another on its way. If +** data in range 16384-4194303 we get three bytes, top two bits of first set ** to indicate three byte total. ** *****************************************************************************/ @@ -1252,12 +1236,7 @@ int Allowi(DEVICE_EXTENSION * pdx, bool bInCallback) ** ulArg The argument passed in. Note that long is 64-bits in 64-bit system, i.e. it is big ** enough for a 64-bit pointer. *****************************************************************************/ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) static long ced_ioctl(struct file *file, unsigned int cmd, unsigned long ulArg) -#else -static int ced_ioctl(struct inode *node, struct file *file, unsigned int cmd, - unsigned long ulArg) -#endif { int err = 0; DEVICE_EXTENSION *pdx = file->private_data; @@ -1388,11 +1367,7 @@ static const struct file_operations ced_fops = { .release = ced_release, .flush = ced_flush, .llseek = noop_llseek, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) .unlocked_ioctl = ced_ioctl, -#else - .ioctl = ced_ioctl, -#endif }; /* @@ -1537,7 +1512,7 @@ error: static void ced_disconnect(struct usb_interface *interface) { DEVICE_EXTENSION *pdx = usb_get_intfdata(interface); - int minor = interface->minor; // save for message at the end + int minor = interface->minor; int i; usb_set_intfdata(interface, NULL); // remove the pdx from the interface @@ -1572,8 +1547,7 @@ void ced_draw_down(DEVICE_EXTENSION * pdx) pdx->bInDrawDown = true; time = usb_wait_anchor_empty_timeout(&pdx->submitted, 3000); - if (!time) // if we timed out we kill the urbs - { + if (!time) { // if we timed out we kill the urbs usb_kill_anchored_urbs(&pdx->submitted); dev_err(&pdx->interface->dev, "%s timed out", __func__); } diff --git a/drivers/staging/ced1401/usb1401.h b/drivers/staging/ced1401/usb1401.h index 331ca98..adb5fa4 100644 --- a/drivers/staging/ced1401/usb1401.h +++ b/drivers/staging/ced1401/usb1401.h @@ -165,7 +165,7 @@ typedef struct _DEVICE_EXTENSION // Parameters relating to a block read\write that is in progress. Some of these values // are equivalent to values in rDMAInfo. The values here are those in use, while those - // in rDMAInfo are those recieved from the 1401 via an escape sequence. If another + // in rDMAInfo are those received from the 1401 via an escape sequence. If another // escape sequence arrives before the previous xfer ends, rDMAInfo values are updated while these // are used to finish off the current transfer. volatile short StagedId; // The transfer area id for this transfer diff --git a/drivers/staging/ced1401/userspace/use1401.c b/drivers/staging/ced1401/userspace/use1401.c index d4c6316..38e7c1c 100644 --- a/drivers/staging/ced1401/userspace/use1401.c +++ b/drivers/staging/ced1401/userspace/use1401.c @@ -145,7 +145,7 @@ ** You should add a new one of these to keep things tidy for applications. ** ** DRIVERET_MAX (below) specifies the maximum allowed type code from the -** 1401 driver; I have set this high to accomodate as yet undesigned 1401 +** 1401 driver; I have set this high to accommodate as yet undesigned 1401 ** types. Similarly, as long as the command file names follow the ARM, ** ARN, ARO sequence, these are calculated by the ExtForType function, so ** you don't need to do anything here either. @@ -160,7 +160,7 @@ ** have broken backwards compatibility. Minor number changes mean that we ** have added new functionality that does not break backwards compatibility. ** we starts at 0. Revision changes mean we have fixed something. Each index -** returns to 0 when a higer one changes. +** returns to 0 when a higher one changes. */ #define U14LIB_MAJOR 4 #define U14LIB_MINOR 0 @@ -211,7 +211,7 @@ /* ** These are the 1401 type codes returned by the driver, they are a slightly -** odd sequence & start for reasons of compatability with the DOS driver. +** odd sequence & start for reasons of compatibility with the DOS driver. ** The maximum code value is the upper limit of 1401 device types. */ #define DRIVRET_STD 4 // Codes for 1401 types matching driver values @@ -2327,7 +2327,7 @@ U14API(short) U14SetTransArea(short hand, WORD wArea, void *pvBuff, /**************************************************************************** ** U14SetTransferEvent Sets an event for notification of application -** wArea The tranfer area index, from 0 to MAXAREAS-1 +** wArea The transfer area index, from 0 to MAXAREAS-1 ** bEvent True to create an event, false to remove it ** bToHost Set 0 for notification on to1401 tranfers, 1 for ** notification of transfers to the host PC |