| 1 |
Description: Make variables containing positive offsets unsigned |
| 2 |
Author: Simon Richter <[email protected]> |
| 3 |
Last-Update: 2013-01-08 |
| 4 |
|
| 5 |
Index: langford-0.0.20130228/langford.c |
| 6 |
=================================================================== |
| 7 |
--- langford-0.0.20130228.orig/langford.c |
| 8 |
+++ langford-0.0.20130228/langford.c |
| 9 |
@@ -39,13 +39,13 @@ static DEFINE_MUTEX(cdev_open_close_mute |
| 10 |
|
| 11 |
static DEFINE_MUTEX(cdev_read_buff_mutex); /**< Read buffer mutex*/ |
| 12 |
static uint8_t *cdev_read_buff; /**< Read buffer*/ |
| 13 |
|
| 14 |
|
| 15 |
+static unsigned int cdev_read_buff_start; /**< Start pointer to read buffer*/ |
| 16 |
+static unsigned int cdev_read_buff_end; /**< End pointer to read buffer*/ |
| 17 |
|
| 18 |
static DEFINE_MUTEX(cdev_write_buff_mutex); /**< Write buffer mutex*/ |
| 19 |
static uint8_t *cdev_write_buff; /**< Write buffer*/ |
| 20 |
|
| 21 |
|
| 22 |
+static unsigned int cdev_write_buff_start; /**< Start pointer to write buffer*/ |
| 23 |
+static unsigned int cdev_write_buff_end; /**< End pointer to write buffer*/ |
| 24 |
|
| 25 |
/*DMA read and write threads*/ |
| 26 |
static struct task_struct *dev_read_thread; /**< Thread in charge of reading data from PCIe device*/ |
| 27 |
@@ -54,7 +54,7 @@ static struct task_struct *dev_write_thr |
| 28 |
|
| 29 |
/**Figures out elements are used in a circular buffer |
| 30 |
*/ |
| 31 |
|
| 32 |
+static unsigned int circ_buff_filled(unsigned int start, unsigned int end, unsigned int len) { |
| 33 |
int rc; |
| 34 |
|
| 35 |
rc = end - start; |
| 36 |
@@ -69,7 +69,7 @@ static int circ_buff_filled(int start, i |
| 37 |
|
| 38 |
/**Figures out how many elements of a circular buffer are available to be filled |
| 39 |
*/ |
| 40 |
|
| 41 |
+static unsigned int circ_buff_avail(unsigned int start, unsigned int end, unsigned int len) { |
| 42 |
return len - circ_buff_filled(start, end, len) - 1; |
| 43 |
}; |
| 44 |
|
| 45 |
@@ -84,9 +84,9 @@ This thread: |
| 46 |
static int dev_read_task(void *data) { |
| 47 |
int DescLevel; /*Descriptor FIFO level read from device*/ |
| 48 |
int DescActive, DescComp; /*Number of descriptors to be serviced and the number of completed descriptors*/ |
| 49 |
|
| 50 |
+ unsigned int BuffStart, BuffEnd; /*Indices to beginning and end of DMA buffers ring array (DevPrivData->RxDmaBuffsBusAddr)*/ |
| 51 |
int Ctr; |
| 52 |
|
| 53 |
+ unsigned int BuffsToWrite; |
| 54 |
uint32_t DescAddr; |
| 55 |
|
| 56 |
printk(KERN_DEBUG DRIVER_NAME " Read thread created\n"); |
| 57 |
@@ -225,9 +225,9 @@ This thread: |
| 58 |
static int dev_write_task(void *data) { |
| 59 |
int DescLevel; /*Descriptor FIFO level read from device*/ |
| 60 |
int DescActive, DescComp; /*Number of descriptors to be serviced and the number of completed descriptors*/ |
| 61 |
|
| 62 |
+ unsigned int BuffStart, BuffEnd; /*Indices to beginning and end of DMA buffers ring array (DevPrivData->TxDmaBuffsBusAddr)*/ |
| 63 |
int Ctr; |
| 64 |
|
| 65 |
+ unsigned int BuffsToWrite; |
| 66 |
uint32_t DescAddr; |
| 67 |
|
| 68 |
printk(KERN_DEBUG DRIVER_NAME " Write thread created\n"); |
| 69 |
@@ -402,7 +402,7 @@ static ssize_t cdev_read(struct file *fi |
| 70 |
/**Service user mode writes |
| 71 |
*/ |
| 72 |
static ssize_t cdev_write(struct file *file, const char __user *buf, size_t len, loff_t *ppos) { |
| 73 |
|
| 74 |
+ unsigned int cdev_buff_avail; |
| 75 |
|
| 76 |
#if VERBOSE_LOGGING_W |
| 77 |
printk(KERN_DEBUG DRIVER_NAME " User requested write of %zu bytes\n", len); |