[PATCH 0/3] Enable discard on Hyper-V

2014-07-24 Thread Sitsofe Wheeler
On Wed, Jul 23, 2014 at 09:13:41PM +0100, Sitsofe Wheeler wrote:
> On Wed, Jul 23, 2014 at 07:15:58AM -0700, Christoph Hellwig wrote:
> > On Wed, Jul 23, 2014 at 03:10:28PM +0100, Sitsofe Wheeler wrote:
> > > I'm not sure this alone will work - won't sdev_bflags/bflags have
> > > already been built at this point?
> > 
> > They've been built up, but we can still or new values into it.  It looks
> > fine to me from review, but if you can test it on an actualy hypverv
> > setup that would be valueable feedback.
> 
> The previous patches didn't work for me with a Windows 2012 R2 host with a
> 3.16.0-rc6.x86_64-00076-g2f7d2ec-dirty guest. After applying
> 
> > term project, this late in the 3.17 cycle I'd just like to merge
> > something that gets discards on hyperv to work.

OK how about the following patches:

Sitsofe Wheeler (3):
  [SCSI] Add quirk for forcing logical block provisioning tests
  [SCSI] storvsc: Add Hyper-V logical block provisioning quirk
  [SCSI] Make LBP quirk skip lbpme checks

 drivers/scsi/scsi_scan.c|  4 +++-
 drivers/scsi/sd.c   | 12 ++--
 drivers/scsi/storvsc_drv.c  |  6 ++
 include/scsi/scsi_device.h  |  1 +
 include/scsi/scsi_devinfo.h |  2 ++
 5 files changed, 22 insertions(+), 3 deletions(-)

-- 
1.9.3

-- 
Sitsofe | http://sucs.org/~sits/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] [SCSI] Add quirk for forcing logical block provisioning tests

2014-07-24 Thread Sitsofe Wheeler
Despite supporting modern SCSI features (such an UNMAP) some storage
devices continue to claim conformance to an older version of the SPC
spec for compatibility with legacy operating systems.

Linux by default will not attempt to read VPD pages on devices that
claim SPC-2 or older.

Introduce a blacklist flag that allows the forcing of the paths leading
to logical block provisioning tests.

See https://lkml.org/lkml/2014/7/13/59 for the previous version.

Reported-by: K. Y. Srinivasan 
Original-patch-by: Martin K. Petersen 
Signed-off-by: Sitsofe Wheeler 
---
 drivers/scsi/scsi_scan.c|  4 +++-
 drivers/scsi/sd.c   |  8 
 drivers/scsi/storvsc_drv.c  | 10 ++
 include/scsi/scsi_device.h  |  1 +
 include/scsi/scsi_devinfo.h |  2 ++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index e02b3aa..02ca1c2 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -950,7 +950,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned 
char *inq_result,
 
sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
 
-   if (*bflags & BLIST_SKIP_VPD_PAGES)
+   if (*bflags & BLIST_TRY_LBP)
+   sdev->try_lbp = 1;
+   else if (*bflags & BLIST_SKIP_VPD_PAGES)
sdev->skip_vpd_pages = 1;
 
transport_configure_device(&sdev->sdev_gendev);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6825eda..8249e51 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2109,6 +2109,8 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
return 1;
if (scsi_device_protection(sdp))
return 1;
+   if (sdp->try_lbp)
+   return 1;
return 0;
 }
 
@@ -2682,6 +2684,12 @@ static void sd_read_write_same(struct scsi_disk *sdkp, 
unsigned char *buffer)
 static int sd_try_extended_inquiry(struct scsi_device *sdp)
 {
/*
+* Attempt VPD inquiry if the device blacklist explicitly calls
+* for it.
+*/
+   if (sdp->try_lbp)
+   return 1;
+   /*
 * Although VPD inquiries can go to SCSI-2 type devices,
 * some USB ones crash on receiving them, and the pages
 * we currently ask for are for SPC-3 and beyond
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 9969fa1..5ad2810 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -326,6 +326,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size 
(bytes)");
  */
 static int storvsc_timeout = 180;
 
+static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
+
 #define STORVSC_MAX_IO_REQUESTS200
 
 static void storvsc_on_channel_callback(void *context);
@@ -1441,6 +1443,14 @@ static int storvsc_device_configure(struct scsi_device 
*sdevice)
 
sdevice->no_write_same = 1;
 
+   /*
+* Add blist flags to permit the reading of the VPD pages even when
+* the target may claim SPC-2 compliance. MSFT targets currently
+* claim SPC-2 compliance while they implement post SPC-2 features.
+* With this patch we can correctly handle WRITE_SAME_16 issues.
+*/
+   sdevice->sdev_bflags |= msft_blist_flags;
+
return 0;
 }
 
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 27ab310..0a5c6fa 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -155,6 +155,7 @@ struct scsi_device {
unsigned skip_ms_page_8:1;  /* do not use MODE SENSE page 0x08 */
unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
unsigned skip_vpd_pages:1;  /* do not read VPD pages */
+   unsigned try_lbp:1; /* Try LBP tests */
unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
unsigned no_start_on_add:1; /* do not issue start on add */
unsigned allow_restart:1; /* issue START_UNIT in error handler */
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 447d2d7..9d15d78 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -32,4 +32,6 @@
 #define BLIST_ATTACH_PQ3   0x100 /* Scan: Attach to PQ3 devices */
 #define BLIST_NO_DIF   0x200 /* Disable T10 PI (DIF) */
 #define BLIST_SKIP_VPD_PAGES   0x400 /* Ignore SBC-3 VPD pages */
+#define BLIST_TRY_LBP  0x1000 /* Check Logical Block Provisioning
+ even on < SPC-3 devices */
 #endif
-- 
1.9.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: lustre: obdclass: fix sparse warnings about static declaration

2014-07-24 Thread Andrey Skvortsov
Signed-off-by: Andrey Skvortsov 
---
 changes since v1:

 removed from patch  static declarations for functions obd_sysctl_init and
 obd_sysctl_clean to fix build issue.
 

.../lustre/lustre/obdclass/linux/linux-sysctl.c|   24 ++--
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c 
b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index a4cd46b..38a9b31 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -52,7 +52,7 @@
 #include "../../include/lprocfs_status.h"
 
 #ifdef CONFIG_SYSCTL
-struct ctl_table_header *obd_table_header = NULL;
+static struct ctl_table_header *obd_table_header;
 #endif
 
 
@@ -79,8 +79,8 @@ enum {
 };
 
 
-int proc_set_timeout(struct ctl_table *table, int write, void __user *buffer,
-size_t *lenp, loff_t *ppos)
+static int proc_set_timeout(struct ctl_table *table, int write,
+   void __user *buffer, size_t *lenp, loff_t *ppos)
 {
int rc;
 
@@ -90,8 +90,8 @@ int proc_set_timeout(struct ctl_table *table, int write, void 
__user *buffer,
return rc;
 }
 
-int proc_memory_alloc(struct ctl_table *table, int write, void __user *buffer,
- size_t *lenp, loff_t *ppos)
+static int proc_memory_alloc(struct ctl_table *table, int write,
+   void __user *buffer, size_t *lenp, loff_t *ppos)
 {
char buf[22];
int len;
@@ -114,8 +114,8 @@ int proc_memory_alloc(struct ctl_table *table, int write, 
void __user *buffer,
return 0;
 }
 
-int proc_pages_alloc(struct ctl_table *table, int write, void __user *buffer,
-size_t *lenp, loff_t *ppos)
+static int proc_pages_alloc(struct ctl_table *table, int write,
+   void __user *buffer, size_t *lenp, loff_t *ppos)
 {
char buf[22];
int len;
@@ -138,7 +138,7 @@ int proc_pages_alloc(struct ctl_table *table, int write, 
void __user *buffer,
return 0;
 }
 
-int proc_mem_max(struct ctl_table *table, int write, void __user *buffer,
+static int proc_mem_max(struct ctl_table *table, int write, void __user 
*buffer,
 size_t *lenp, loff_t *ppos)
 {
char buf[22];
@@ -162,8 +162,8 @@ int proc_mem_max(struct ctl_table *table, int write, void 
__user *buffer,
return 0;
 }
 
-int proc_pages_max(struct ctl_table *table, int write, void __user *buffer,
-  size_t *lenp, loff_t *ppos)
+static int proc_pages_max(struct ctl_table *table, int write,
+   void __user *buffer, size_t *lenp, loff_t *ppos)
 {
char buf[22];
int len;
@@ -186,7 +186,7 @@ int proc_pages_max(struct ctl_table *table, int write, void 
__user *buffer,
return 0;
 }
 
-int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
+static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
   void __user *buffer, size_t *lenp, loff_t *ppos)
 {
int rc = 0;
@@ -228,7 +228,7 @@ int proc_max_dirty_pages_in_mb(struct ctl_table *table, int 
write,
return rc;
 }
 
-int proc_alloc_fail_rate(struct ctl_table *table, int write,
+static int proc_alloc_fail_rate(struct ctl_table *table, int write,
 void __user *buffer, size_t *lenp, loff_t *ppos)
 {
int rc= 0;
-- 
1.7.10.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] [SCSI] storvsc: Add Hyper-V logical block provisioning tests

2014-07-24 Thread Sitsofe Wheeler
Microsoft Hyper-V targets currently only claim SPC-2 compliance / no
compliance indicated even though they implement post SPC-2 features
which means those features are not tested for. Add a blacklist flag to
Hyper-V devices that forces said testing.

See https://lkml.org/lkml/2014/7/21/627 for the previous version of this
patch and https://lkml.org/lkml/2014/7/23/615 for example devices.

Original-patch-by: K. Y. Srinivasan 
Signed-off-by: Sitsofe Wheeler 
---
 drivers/scsi/storvsc_drv.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 5ad2810..88b7173 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -326,8 +326,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size 
(bytes)");
  */
 static int storvsc_timeout = 180;
 
-static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
-
 #define STORVSC_MAX_IO_REQUESTS200
 
 static void storvsc_on_channel_callback(void *context);
@@ -1444,12 +1442,10 @@ static int storvsc_device_configure(struct scsi_device 
*sdevice)
sdevice->no_write_same = 1;
 
/*
-* Add blist flags to permit the reading of the VPD pages even when
-* the target may claim SPC-2 compliance. MSFT targets currently
-* claim SPC-2 compliance while they implement post SPC-2 features.
-* With this patch we can correctly handle WRITE_SAME_16 issues.
+* Forcefully enable logical block provisioning testing.
 */
-   sdevice->sdev_bflags |= msft_blist_flags;
+   sdevice->sdev_bflags |= BLIST_TRY_LBP;
+   sdevice->try_lbp = 1;
 
return 0;
 }
-- 
1.9.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Sitsofe Wheeler
Some block devices (such as Hyper-V passthrough SSDs) support logical
block provisioning (e.g. via UNMAP) but don't set lbpme thus disabling
discard. If the try_lbp quirk is in use skip lbpme checks that lead up
to the logical block provisioning tests.

Signed-off-by: Sitsofe Wheeler 
---
 drivers/scsi/sd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8249e51..8bf34bc 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2559,7 +2559,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
 
sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
 
-   if (!sdkp->lbpme)
+   if (!sdkp->lbpme && !sdkp->device->try_lbp)
goto out;
 
lba_count = get_unaligned_be32(&buffer[20]);
@@ -2633,7 +2633,7 @@ static void sd_read_block_provisioning(struct scsi_disk 
*sdkp)
unsigned char *buffer;
const int vpd_len = 8;
 
-   if (sdkp->lbpme == 0)
+   if (sdkp->lbpme == 0 && sdkp->device->test_lbp == 0)
return;
 
buffer = kmalloc(vpd_len, GFP_KERNEL);
-- 
1.9.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] staging: vme: removed useless breaks in vme_user.c

2014-07-24 Thread Martyn Welch

On 23/07/14 17:17, Tom Jorquera wrote:

vme_user.c contained unnecessary breaks after gotos, which increased
code size and caused code style warning. This is now fixed.

Signed-off-by: Tom Jorquera 


Acked-by: Martyn Welch 


---
  drivers/staging/vme/devices/vme_user.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_user.c 
b/drivers/staging/vme/devices/vme_user.c
index 2d84972..920e50a 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -433,7 +433,6 @@ static loff_t vme_user_llseek(struct file *file, loff_t 
off, int whence)
default:
mutex_unlock(&image[minor].mutex);
return -EINVAL;
-   break;
}

if ((absolute < 0) || (absolute >= image_size)) {
@@ -511,7 +510,6 @@ static int vme_user_ioctl(struct inode *inode, struct file 
*file,
}

return retval;
-   break;

case VME_SET_MASTER:

@@ -552,7 +550,6 @@ static int vme_user_ioctl(struct inode *inode, struct file 
*file,
}

return retval;
-   break;

case VME_SET_SLAVE:

@@ -806,7 +803,6 @@ static int vme_user_probe(struct vme_dev *vdev)
default:
err = -EINVAL;
goto err_sysfs;
-   break;
}

num = (type[i] == SLAVE_MINOR) ? i - (MASTER_MAX + 1) : i;



--
Martyn Welch (Lead Software Engineer)  | Registered in England and Wales
GE Intelligent Platforms   | (3828642) at 100 Barbirolli Square
T +44(0)1327322748 | Manchester, M2 3AB
E martyn.we...@ge.com  | VAT:GB 927559189
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: XVME 6300 with TSI148 bridge on 64 bit Debian (Linux 3.2.57) vme_user issue

2014-07-24 Thread Martyn Welch

On 23/07/14 03:09, Maurice Moss wrote:

Hi Martyn,

Thanks for your patience with me.  I have a couple of questions for you:

0. I put the SBC with the right settings for Geographical addressing.
I did 2 tests by setting the board in each of the 2 slots available on
my rack and the geo address was detected as 0 in both the cases.  This
means my backplane isn't working or that my SBC isn't talking to the
backplane.


What settings did you apply to "set" geographical addressing? Is this 
the drivers or something board specific?



1. Is there a way I can test whether the PCI bridge is working?


I assume you mean whether the PCI bridges are passing the PCI address 
ranges used by the VME windows through to the device?


It think "lspci -v" will show you what ranges the bridges have, you will 
probably need to stick some debug into vme_tsi148.c to get the pci_base 
address as allocated in tsi148_master_set().


This can be very board dependant, so I'm afraid I can't help much here.


2. I don't understand what should be the exact vme base address of my
slave board.  I am now using VDIS8004 set in slot 2,
(http://www.ifh.de/~wischnew/amanda/daq/ces_8004_v10_.pdf) set to VME
short A16 (The static rotatory switches set to 2 and 2).  Based on
this my address would be 0x2200?  Any clarification or pointing me in
the right direction would be sincerely appreciated :-/


There are limitations to the granularity of windows bases and lengths. 
This is especially acute when using the A16 address space.


To debug this, try mapping the entirety of the A16 address space using 
master_set. Then when calling read, read from offset 0x2200.



3. When I do reads with what I believe is the correct address, I get
back '0xff' characters all the time, and if I do it frequently enough
I manage to crash the computer (with no logs on the dmesg, and reboot
needed with a forced fsck).  I am now trying to probe the kernel
module adding print statements, and trying to build it out of tree.



There was a bug when err_chk was set a while back, if you are running an 
older kernel you may be hitting that. It stores errors, but in some 
situations doesn't read them and clear them in time leading to memory 
exhaustion...




Cheers,
Maurice

PS: Here is what I get when I do an 'lspci -v':

03:00.0 PCI bridge: PLX Technology, Inc. PEX 8114 PCI
Express-to-PCI/PCI-X Bridge (rev bd) (prog-if 00 [Normal decode])
 Physical Slot: 0
 Flags: bus master, fast devsel, latency 0
 Memory at d400 (32-bit, non-prefetchable) [size=8K]
 Bus: primary=03, secondary=04, subordinate=04, sec-latency=64
 Memory behind bridge: d000-d3ff
 Capabilities: 

04:04.0 Bridge: Tundra Semiconductor Corp. Tsi148 [Tempe] (rev 01)
 Subsystem: Tundra Semiconductor Corp. Device 
 Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 16
 Memory at d000 (64-bit, non-prefetchable) [size=4K]
 Capabilities: 
 Kernel driver in use: vme_tsi148



The reads don't occur through the PCI bars (nasty), so you will need to 
find out what PCI addresses the windows are being mapped to and confirm 
they are in the d000-d3ff window. Without knowing much more 
about your system (and I don't think you've even told me what SBC you 
are using) there's a limit to how much I can help I'm afraid.


Hope that helps,

Martyn


On Wed, Jul 16, 2014 at 12:47 AM, Martyn Welch  wrote:



On 14/07/14 19:29, Maurice Moss wrote:


Hi all,

I have updated my Linux Kernel to the latest.  I am on Debian 64bit
3.15.5.  I issue the following Kernel command line, and the vme_user
module seems to load correctly, however the vme bus is neither mounted
on /dev nor /proc.



Just to make sure, you're looking under /dev/bus/vme?



I was earlier using a 3.2 debian 32bit and managed to mount the vme
bus by following the exact same procedure of rebuilding the kernel
with vme_user module.  Any help is appreciated.  Here is what I see on
dmesg.

[0.00] Kernel command line:
BOOT_IMAGE=/boot/vmlinuz-3.15.5-vme
root=UUID=4cdc2e84-9fbc-471c-9eb4-fde8f0b1ce96 ro vme_user.bus=0
vme_tsi148.err_chk=1 quiet
[1.754278] vme_user: VME User Space Access Driver
[1.754695] vme_tsi148 :04:04.0: Board is the VME system controller
[1.754700] vme_tsi148 :04:04.0: VME geographical address is 0
[1.754704] vme_tsi148 :04:04.0: VME Write and flush and error
check is enabled
[1.754942] vme_tsi148 :04:04.0: CR/CSR Offset: 0
[1.754948] vme_tsi148 :04:04.0: Enabling CR/CSR space

Cheers!



It's unfortunately going to take me a while to get everything together to
take a look, some of my old installs I've been eeking along for a while to
do adhoc VME tests are now broken :-(

Martyn



On Thu, Jul 3, 2014 at 8:18 AM, Maurice Moss 
wrote:


Martyn,

OK.  I feel like I am not clear.  The kernel command line has a space,
but the line here in the email doesn't (I don't know how that
happe

[PATCH 1/2] staging: et131x: Fix typo in et131x

2014-07-24 Thread Masanari Iida
This patch fix spelling typos in comments and printk
within et131x.

Signed-off-by: Masanari Iida 
---
 drivers/staging/et131x/et131x.c | 8 
 drivers/staging/et131x/et131x.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index ada0243..8bf1eb4 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -285,7 +285,7 @@ struct fbr_lookup {
dma_addr_t   buffsize;
 };
 
-/* struct rx_ring is the sructure representing the adaptor's local
+/* struct rx_ring is the structure representing the adaptor's local
  * reference(s) to the rings
  */
 struct rx_ring {
@@ -1941,7 +1941,7 @@ static void et131x_disable_interrupts(struct 
et131x_adapter *adapter)
 /* et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 */
 static void et131x_tx_dma_disable(struct et131x_adapter *adapter)
 {
-   /* Setup the tramsmit dma configuration register */
+   /* Setup the transmit dma configuration register */
writel(ET_TXDMA_CSR_HALT | ET_TXDMA_SNGL_EPKT,
&adapter->regs->txdma.csr);
 }
@@ -4023,7 +4023,7 @@ static void et131x_isr_handler(struct work_struct *work)
if (status & ET_INTR_RXDMA_STAT_LOW) {
/* Same idea as with the two Free Buffer Rings. Packets going
 * from the network to the host each consume a free buffer
-* resource and a packet status resource. These resoures are
+* resource and a packet status resource. These resources are
 * passed to the OS. When the OS is done with the resources,
 * they need to be returned to the ET1310. This is one method
 * of returning the resources.
@@ -4631,7 +4631,7 @@ static int et131x_pci_setup(struct pci_dev *pdev,
/* Allocate DMA memory */
rc = et131x_adapter_memory_alloc(adapter);
if (rc < 0) {
-   dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
+   dev_err(&pdev->dev, "Could not alloc adapter memory (DMA)\n");
goto err_iounmap;
}
 
diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h
index 2ac6e99..3c0c497 100644
--- a/drivers/staging/et131x/et131x.h
+++ b/drivers/staging/et131x/et131x.h
@@ -755,7 +755,7 @@ struct txmac_regs { /* Location: */
  */
 
 /*
- * structure for Unicast Paket Filter Address 1 reg in rxmac address map
+ * structure for Unicast Packet Filter Address 1 reg in rxmac address map
  * located at address 0x4068
  *
  * 31-24: addr1_3
@@ -769,7 +769,7 @@ struct txmac_regs { /* Location: */
 #define ET_RX_UNI_PF_ADDR1_5_SHIFT 8
 
 /*
- * structure for Unicast Paket Filter Address 2 reg in rxmac address map
+ * structure for Unicast Packet Filter Address 2 reg in rxmac address map
  * located at address 0x406C
  *
  * 31-24: addr2_3
@@ -783,7 +783,7 @@ struct txmac_regs { /* Location: */
 #define ET_RX_UNI_PF_ADDR2_5_SHIFT 8
 
 /*
- * structure for Unicast Paket Filter Address 1 & 2 reg in rxmac address map
+ * structure for Unicast Packet Filter Address 1 & 2 reg in rxmac address map
  * located at address 0x4070
  *
  * 31-24: addr2_1
-- 
2.0.1.537.g81e776d

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: et131x: Remove trailing semicolon from macros in et131x.h

2014-07-24 Thread Masanari Iida
This patch removes trailing semicolon from macros within et131x.h

Signed-off-by: Masanari Iida 
---
 drivers/staging/et131x/et131x.h | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h
index 3c0c497..1318439 100644
--- a/drivers/staging/et131x/et131x.h
+++ b/drivers/staging/et131x/et131x.h
@@ -145,7 +145,7 @@
  *31:  selfclr_disable
  */
 
-#define ET_RESET_ALL   0x007F;
+#define ET_RESET_ALL   0x007F
 
 /*
  * SLV Timer reg at address 0x002C (low 24 bits)
@@ -394,7 +394,7 @@ struct txdma_regs { /* Location: */
  * 11-0: psr ndes
  */
 
-#define ET_RXDMA_PSR_NUM_DES_MASK  0xFFF;
+#define ET_RXDMA_PSR_NUM_DES_MASK  0xFFF
 
 /*
  * structure for packet status ring available offset reg in rxdma address map
@@ -815,11 +815,11 @@ struct txmac_regs {   /* Location: */
  * 0: filter_broad_en
  */
 
-#define ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT  16;
-#define ET_RX_PFCTRL_FRAG_FILTER_ENABLE0x0008;
-#define ET_RX_PFCTRL_UNICST_FILTER_ENABLE  0x0004;
-#define ET_RX_PFCTRL_MLTCST_FILTER_ENABLE  0x0002;
-#define ET_RX_PFCTRL_BRDCST_FILTER_ENABLE  0x0001;
+#define ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT  16
+#define ET_RX_PFCTRL_FRAG_FILTER_ENABLE0x0008
+#define ET_RX_PFCTRL_UNICST_FILTER_ENABLE  0x0004
+#define ET_RX_PFCTRL_MLTCST_FILTER_ENABLE  0x0002
+#define ET_RX_PFCTRL_BRDCST_FILTER_ENABLE  0x0001
 
 /*
  * structure for Memory Controller Interface Control Max Segment reg in rxmac
@@ -831,9 +831,9 @@ struct txmac_regs { /* Location: */
  * 0: seg_en
  */
 
-#define ET_RX_MCIF_CTRL_MAX_SEG_SIZE_SHIFT 2;
-#define ET_RX_MCIF_CTRL_MAX_SEG_FC_ENABLE  0x0002;
-#define ET_RX_MCIF_CTRL_MAX_SEG_ENABLE 0x0001;
+#define ET_RX_MCIF_CTRL_MAX_SEG_SIZE_SHIFT 2
+#define ET_RX_MCIF_CTRL_MAX_SEG_FC_ENABLE  0x0002
+#define ET_RX_MCIF_CTRL_MAX_SEG_ENABLE 0x0001
 
 /*
  * structure for Memory Controller Interface Water Mark reg in rxmac address
@@ -987,15 +987,15 @@ struct rxmac_regs {   
/* Location: */
  * 0: full duplex
  */
 
-#define ET_MAC_CFG2_PREAMBLE_SHIFT 12;
-#define ET_MAC_CFG2_IFMODE_MASK0x0300;
-#define ET_MAC_CFG2_IFMODE_10000x0200;
-#define ET_MAC_CFG2_IFMODE_100 0x0100;
-#define ET_MAC_CFG2_IFMODE_HUGE_FRAME  0x0020;
-#define ET_MAC_CFG2_IFMODE_LEN_CHECK   0x0010;
-#define ET_MAC_CFG2_IFMODE_PAD_CRC 0x0004;
-#define ET_MAC_CFG2_IFMODE_CRC_ENABLE  0x0002;
-#define ET_MAC_CFG2_IFMODE_FULL_DPLX   0x0001;
+#define ET_MAC_CFG2_PREAMBLE_SHIFT 12
+#define ET_MAC_CFG2_IFMODE_MASK0x0300
+#define ET_MAC_CFG2_IFMODE_10000x0200
+#define ET_MAC_CFG2_IFMODE_100 0x0100
+#define ET_MAC_CFG2_IFMODE_HUGE_FRAME  0x0020
+#define ET_MAC_CFG2_IFMODE_LEN_CHECK   0x0010
+#define ET_MAC_CFG2_IFMODE_PAD_CRC 0x0004
+#define ET_MAC_CFG2_IFMODE_CRC_ENABLE  0x0002
+#define ET_MAC_CFG2_IFMODE_FULL_DPLX   0x0001
 
 /*
  * structure for Interpacket gap reg in mac address map.
@@ -1084,7 +1084,7 @@ struct rxmac_regs {   
/* Location: */
  * 15-0: phy control
  */
 
-#define ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK 0x;
+#define ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK 0x
 
 /*
  * structure for MII Management Indicators reg in mac address map.
-- 
2.0.1.537.g81e776d

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Sitsofe Wheeler
v1 -> v2: Fix incorrectly named variable.

Some block devices (such as Hyper-V passthrough SSDs) support logical
block provisioning (e.g. via UNMAP) but don't set lbpme thus disabling
discard. If the try_lbp quirk is in use skip lbpme checks that lead up
to the logical block provisioning tests.

Signed-off-by: Sitsofe Wheeler 
---
 drivers/scsi/sd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8249e51..8bf34bc 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2559,7 +2559,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
 
sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
 
-   if (!sdkp->lbpme)
+   if (!sdkp->lbpme && !sdkp->device->try_lbp)
goto out;
 
lba_count = get_unaligned_be32(&buffer[20]);
@@ -2633,7 +2633,7 @@ static void sd_read_block_provisioning(struct scsi_disk 
*sdkp)
unsigned char *buffer;
const int vpd_len = 8;
 
-   if (sdkp->lbpme == 0)
+   if (sdkp->lbpme == 0 && sdkp->device->try_lbp == 0)
return;
 
buffer = kmalloc(vpd_len, GFP_KERNEL);
-- 
1.9.3
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/3] Enable discard on Hyper-V

2014-07-24 Thread Sitsofe Wheeler
On Thu, Jul 24, 2014 at 08:47:39AM +0100, Sitsofe Wheeler wrote:
> On Wed, Jul 23, 2014 at 09:13:41PM +0100, Sitsofe Wheeler wrote:
> > On Wed, Jul 23, 2014 at 07:15:58AM -0700, Christoph Hellwig wrote:
> > > On Wed, Jul 23, 2014 at 03:10:28PM +0100, Sitsofe Wheeler wrote:
> > > > I'm not sure this alone will work - won't sdev_bflags/bflags have
> > > > already been built at this point?
> > > 
> > > They've been built up, but we can still or new values into it.  It looks
> > > fine to me from review, but if you can test it on an actualy hypverv
> > > setup that would be valueable feedback.
> > 
> > The previous patches didn't work for me with a Windows 2012 R2 host with a
> > 3.16.0-rc6.x86_64-00076-g2f7d2ec-dirty guest. After applying
> > 
> > > term project, this late in the 3.17 cycle I'd just like to merge
> > > something that gets discards on hyperv to work.
> 
> OK how about the following patches:
> 
> Sitsofe Wheeler (3):
>   [SCSI] Add quirk for forcing logical block provisioning tests
>   [SCSI] storvsc: Add Hyper-V logical block provisioning quirk
>   [SCSI] Make LBP quirk skip lbpme checks

With the updated "Make LBP quirk skip lbpme checks" the above patches
enable discard on all Hyper-V disks (both VHDXs and passthrough SSDs) on
Windows 2012 R2 running a Linux 3.16.0-rc6.x86_64-00076-g2f7d2ec-dirty
guest.

Adding back the debugging and looking at just the discard messages shows
this:

sd 0:0:0:0: [sda] Discard mode: 2
sd 0:0:0:0: [sda] Entering discard switch via LBP VPD
sd 0:0:0:0: [sda] Discard mode: 1
sd 0:0:0:0: [sda] Discard mode: 2
sd 0:0:0:0: [sda] Entering discard switch via LBP VPD
sd 0:0:0:0: [sda] Discard mode: 1
sd 0:0:0:0: [sda] Discard mode: 2
sd 0:0:0:0: [sda] Entering discard switch via LBP VPD
sd 0:0:0:0: [sda] Discard mode: 1
sd 1:0:0:3: [sdd] Discard mode: 2
sd 1:0:0:1: [sdc] Entering discard switch with NO LBP VPD
sd 1:0:0:1: [sdc] Discard mode: 1
sd 1:0:0:3: [sdd] Entering discard switch via LBP VPD
sd 1:0:0:3: [sdd] Discard mode: 1
sd 1:0:0:0: [sdb] Discard mode: 2
sd 1:0:0:3: [sdd] Discard mode: 2
sd 1:0:0:1: [sdc] Entering discard switch with NO LBP VPD
sd 1:0:0:1: [sdc] Discard mode: 1
sd 1:0:0:3: [sdd] Entering discard switch via LBP VPD
sd 1:0:0:3: [sdd] Discard mode: 1
sd 1:0:0:1: [sdc] Entering discard switch with NO LBP VPD
sd 1:0:0:1: [sdc] Discard mode: 1
sd 1:0:0:0: [sdb] Entering discard switch via LBP VPD
sd 1:0:0:0: [sdb] Discard mode: 1
sd 1:0:0:3: [sdd] Discard mode: 2
sd 1:0:0:0: [sdb] Discard mode: 2
sd 1:0:0:0: [sdb] Entering discard switch via LBP VPD
sd 1:0:0:0: [sdb] Discard mode: 1
sd 1:0:0:0: [sdb] Discard mode: 2
sd 1:0:0:0: [sdb] Entering discard switch via LBP VPD
sd 1:0:0:0: [sdb] Discard mode: 1
sd 1:0:0:3: [sdd] Entering discard switch via LBP VPD
sd 1:0:0:3: [sdd] Discard mode: 1

All devices eventually end up using discard mode 1 (SD_LBP_UNMAP) but
it's a bit strange the VHDX devices (which set lbpme) flip back and
forth between discard mode 1 and discard mode 2 (SD_LBP_WS16)...

-- 
Sitsofe | http://sucs.org/~sits/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging:bcm:DDRinit.c:coding style:line over 80 char

2014-07-24 Thread Sudip Mukherjee
---
 drivers/staging/bcm/DDRInit.c | 59 ---
 1 file changed, 39 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c
index 4564f40..4226c93 100644
--- a/drivers/staging/bcm/DDRInit.c
+++ b/drivers/staging/bcm/DDRInit.c
@@ -7,7 +7,8 @@
 
 /* DDR INIT-133Mhz */
 #define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = {
+   /* DPLL Clock Setting */
{0x0F000800, 0x7212},
{0x0f000820, 0x07F13FFF},
{0x0f000810, 0x0F95},
@@ -65,7 +66,8 @@ static struct bcm_ddr_setting asT3_DDRSetting133MHz[] = {  /* 
DPLL Clock Setting
 };
 /* 80Mhz */
 #define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000810, 0x0F95},
{0x0f000820, 0x07f1},
{0x0f000860, 0x},
@@ -117,7 +119,8 @@ static struct bcm_ddr_setting asT3_DDRSetting80MHz[] = {  
/* DPLL Clock Setting
 };
 /* 100Mhz */
 #define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3_DDRSetting100MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3_DDRSetting100MHz[] = {
+  /* DPLL Clock Setting */
{0x0F000800, 0x7008},
{0x0f000810, 0x0F95},
{0x0f000820, 0x07F13E3F},
@@ -189,7 +192,8 @@ static struct bcm_ddr_setting asDPLL_266MHZ[] = {
 };
 
 #define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000810, 0x0F95},
{0x0f000810, 0x0F95},
{0x0f000810, 0x0F95},
@@ -247,7 +251,8 @@ static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {  
/* DPLL Clock Settin
};
 
 #define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000810, 0x0F95},
{0x0f000820, 0x07F13FFF},
{0x0f000840, 0x0FFF1F00},
@@ -301,7 +306,8 @@ static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {  
/* DPLL Clock Setting
 
 /* 100Mhz */
 #define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000810, 0x0F95},
{0x0f000820, 0x07F1369B},
{0x0f000840, 0x0FFF0800},
@@ -356,7 +362,8 @@ static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {  
/* DPLL Clock Settin
 
 
 #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000820, 0x03F1365B},
{0x0f000810, 0x2F95},
{0x0f000880, 0x03DD},
@@ -416,7 +423,8 @@ static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[] = { 
 /* DPLL Clock Setti
 };
 
 #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000810, 0x2F95},
{0x0f000820, 0x03F1369B},
{0x0f000840, 0x0fff},
@@ -476,7 +484,8 @@ static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[] = { 
 /* DPLL Clock Setti
 };
 
 #define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000820, 0x07F13FFF},
{0x0f000810, 0x2F95},
{0x0f000860, 0x},
@@ -536,7 +545,8 @@ static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[] = {  
/* DPLL Clock Settin
 /* T3 LP-B (UMA-B) */
 
 #define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7  /* index for 0x0F007000 */
-static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = {  /* DPLL Clock 
Setting */
+static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = {
+  /* DPLL Clock Setting */
{0x0f000820, 0x03F137DB},
{0x0f000810, 0x01842795},
{0x0f000860, 0x},
@@ -544,7 +554,8 @@ static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[] = 
{  /* DPLL Clock S

Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Martin K. Petersen
> "Sitsofe" == Sitsofe Wheeler  writes:

Sitsofe> Fix incorrectly named variable.  Some block devices (such as
Sitsofe> Hyper-V passthrough SSDs) support logical block provisioning
Sitsofe> (e.g. via UNMAP) but don't set lbpme thus disabling discard. 

The fix for an SSD that is known to support LBP but which does not claim
support for it is to use:

echo unmap > /sys/class/scsi_disk/foo/provisioning_mode

I'm very much against short-circuiting the LBP logic in a passthrough
driver because then we might end up in the exact situation we were
trying to avoid with this patch series. Namely sending down commands
unsupported by the target device.

This kind of thing really needs to be a sysadmin decision and can be
handled with a udev rule.

-- 
Martin K. Petersen  Oracle Linux Engineering
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] [SCSI] storvsc: Add Hyper-V logical block provisioning tests

2014-07-24 Thread James Bottomley
On Thu, 2014-07-24 at 08:56 +0100, Sitsofe Wheeler wrote:
> Microsoft Hyper-V targets currently only claim SPC-2 compliance / no
> compliance indicated even though they implement post SPC-2 features
> which means those features are not tested for. Add a blacklist flag to
> Hyper-V devices that forces said testing.

This description is misleading: you don't force the test now, you force
the driver to send unmap commands down to the device.

> See https://lkml.org/lkml/2014/7/21/627 for the previous version of this
> patch and https://lkml.org/lkml/2014/7/23/615 for example devices.
> 
> Original-patch-by: K. Y. Srinivasan 
> Signed-off-by: Sitsofe Wheeler 
> ---
>  drivers/scsi/storvsc_drv.c | 10 +++---
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 5ad2810..88b7173 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -326,8 +326,6 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer 
> size (bytes)");
>   */
>  static int storvsc_timeout = 180;
>  
> -static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
> -
>  #define STORVSC_MAX_IO_REQUESTS  200
>  
>  static void storvsc_on_channel_callback(void *context);
> @@ -1444,12 +1442,10 @@ static int storvsc_device_configure(struct 
> scsi_device *sdevice)
>   sdevice->no_write_same = 1;
>  
>   /*
> -  * Add blist flags to permit the reading of the VPD pages even when
> -  * the target may claim SPC-2 compliance. MSFT targets currently
> -  * claim SPC-2 compliance while they implement post SPC-2 features.
> -  * With this patch we can correctly handle WRITE_SAME_16 issues.
> +  * Forcefully enable logical block provisioning testing.
>*/
> - sdevice->sdev_bflags |= msft_blist_flags;
> + sdevice->sdev_bflags |= BLIST_TRY_LBP;
> + sdevice->try_lbp = 1;

Really no way to this one.  You're forcing unmap support on every
hyper-v device; including spinning rust pass through ones which won't
support it.  The hyper-v storage interface has proven to be somewhat
fragile, so it may explode when the device tries to send illegal command
sense back.

If you have a specific IDENTITY string for a faulty SSD that fails to
report unmap support correctly, then we could quirk for that, but not
everything attached to the hyper-v driver.

James

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Steven Rostedt
On Wed, Jul 23, 2014 at 07:03:01PM -0400, Nicholas Krause wrote:
> This changes the call to kzalloc to kcalloc in ion_dummy_driver
> for allocating the heap.
> 
> Signed-off-by: Nicholas Krause 
> ---
>  drivers/staging/android/ion/ion_dummy_driver.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion_dummy_driver.c 
> b/drivers/staging/android/ion/ion_dummy_driver.c
> index 3a45e79..8883432 100644
> --- a/drivers/staging/android/ion/ion_dummy_driver.c
> +++ b/drivers/staging/android/ion/ion_dummy_driver.c
> @@ -67,9 +67,8 @@ static int __init ion_dummy_init(void)
>  {
>   int i, err;
>  
>   idev = ion_device_create(NULL);
> - heaps = kzalloc(sizeof(struct ion_heap *) * dummy_ion_pdata.nr,
> - GFP_KERNEL);
> + heaps = kcalloc(*dummy_ion_pdata.nr , sizeof((struct ion_heap *) 
> *dummy_ion_pdata.nr) , GFP_KERNEL);
>   if (!heaps)
>   return -ENOMEM;
>  

Hi Nick,

Look, I know you are really enthusiastic, and want to help out. I get it.
But this patch is proof that you are not yet ready to work on a complex
project such as the Linux kernel. Maybe you want to try something
a bit easier. Like, say, systemd?

First of all, there was really nothing wrong with this code in the first
place. It is fine to use kzalloc. But lets just say you want to convert
it to kcalloc. The proper answer would have been:

heaps = kcalloc(dummy_ion_pdata.nr, sizeof(struct ion_heap *), 
GFP_KERNEL);

That's rather simple. Just look at the prototype of kcalloc():

void *kcalloc(size_t n, size_t size, gfp_t flags)

The three parameters are the number of elements, the size of each individual
element, and then finally the flags used on how to allocate that memory.
I have to say, you did get the flags part correct.

Now lets look at what you did. For the size you had:

  *dummy_ion_ptr.nr

Do you have any idea of what that is? You just dereferenced the count.
That is, you didn't use the count, but you used the memory that is at
some location from address 0 + dummy_ion_ptr.nr. Now this probably wont
compile. At least not on 64 bit boxes as that nr field is only 32 bits
and a pointer would need to be 64 bits. It could possibly compile on
32 bit boxes, but it would definitely give you a warning about that.

Now lets look at the second parameter you used.

  sizeof((struct ion_heap *) *dummy_ion_pdata.nr)

This one takes a bit of thinking about. I'm actually confused at what
you were even trying to do. What the compiler would try to do is to
break it up. First you again dereference the dummy_ion_pdata.nr with

   *dummy_ion_pdata.nr

And then you convert the answer to that into the type "struct ion_heap *"

   (struct ion_heap *) *dummy_ion_pdata.nr

Finally, you take the sizeof of that answer. As you converted the type
into "struct ion_heap *", I think it would give you the size of that
pointer, that is, if it would compile in the first place.

Congrats! that is actually what we want the second parameter to be!
Although I doubt that you meant to do it that way. No one would mean
to do it that way unless they had no idea of what they were doing.


Basically what this patch tells me is that you do not have enough basic
knowledge of the C language to be programming in the kernel. Maybe you
want to be a BIOS programmer?

My advice to you is to find another project (Gnome?) and work with them
until you have a strong concept of C coding and then, and only then,
come back to working on the kernel. Kernel development is no place for
novice programmers. Sorry, but that's true. It will only give you a
bad reputation, and nasty comments from the real kernel developers.

Cheers!

-- Steve

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Steven Rostedt
On Thu, 24 Jul 2014 10:47:25 -0400
Steven Rostedt  wrote:

 
> The three parameters are the number of elements, the size of each individual
> element, and then finally the flags used on how to allocate that memory.
> I have to say, you did get the flags part correct.
> 
> Now lets look at what you did. For the size you had:

That should have read "For the count you had:"

Oh well, you get my point anyway.

-- Steve

> 
>   *dummy_ion_ptr.nr
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: dgnc: Fix space required after that ','

2014-07-24 Thread Seunghun Lee
This patch fixes checkpatch errors:
"space required after that ','"

Signed-off-by: Seunghun Lee 
---
 drivers/staging/dgnc/dgnc_driver.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index f7730a1..b68246a 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -219,8 +219,8 @@
  * Makes spotting lock/unlock locations easier.
  */
 # define DGNC_SPINLOCK_INIT(x) spin_lock_init(&(x))
-# define DGNC_LOCK(x,y)spin_lock_irqsave(&(x), y)
-# define DGNC_UNLOCK(x,y)  spin_unlock_irqrestore(&(x), y)
+# define DGNC_LOCK(x, y)   spin_lock_irqsave(&(x), y)
+# define DGNC_UNLOCK(x, y) spin_unlock_irqrestore(&(x), y)
 
 /*
  * All the possible states the driver can be while being loaded.
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: dgng: Fix Macros with complex values should be enclosed in parenthesis

2014-07-24 Thread Seunghun Lee
This patch fixes a checkpatch errors
"Macros with complex values should be enclosed in parenthesis"

Signed-off-by: Seunghun Lee 
---
 drivers/staging/dgnc/dgnc_driver.h |   40 
 drivers/staging/dgnc/digi.h|   60 ++--
 drivers/staging/dgnc/dpacompat.h   |   12 
 3 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index fe5ea90..f7730a1 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -111,32 +111,32 @@
 #endif
 
 #if defined TRC_TO_KMEM
-#define PRINTF_TO_KMEM(args) dgnc_tracef args
+#define PRINTF_TO_KMEM(args) do { dgnc_tracef args } while (0)
 #else /* !defined TRC_TO_KMEM */
 #define PRINTF_TO_KMEM(args)
 #endif
 
 #defineTRC(args)   { PRINTF_TO_KMEM(args); PRINTF_TO_CONSOLE(args) 
}
 
-# define DPR_INIT(ARGS)if (DBG_INIT) TRC(ARGS)
-# define DPR_BASIC(ARGS)   if (DBG_BASIC) TRC(ARGS)
-# define DPR_CORE(ARGS)if (DBG_CORE) TRC(ARGS)
-# define DPR_OPEN(ARGS)if (DBG_OPEN)  TRC(ARGS)
-# define DPR_CLOSE(ARGS)   if (DBG_CLOSE)  TRC(ARGS)
-# define DPR_READ(ARGS)if (DBG_READ)  TRC(ARGS)
-# define DPR_WRITE(ARGS)   if (DBG_WRITE) TRC(ARGS)
-# define DPR_IOCTL(ARGS)   if (DBG_IOCTL) TRC(ARGS)
-# define DPR_PROC(ARGS)if (DBG_PROC)  TRC(ARGS)
-# define DPR_PARAM(ARGS)   if (DBG_PARAM)  TRC(ARGS)
-# define DPR_PSCAN(ARGS)   if (DBG_PSCAN)  TRC(ARGS)
-# define DPR_EVENT(ARGS)   if (DBG_EVENT)  TRC(ARGS)
-# define DPR_DRAIN(ARGS)   if (DBG_DRAIN)  TRC(ARGS)
-# define DPR_CARR(ARGS)if (DBG_CARR)  TRC(ARGS)
-# define DPR_MGMT(ARGS)if (DBG_MGMT)  TRC(ARGS)
-# define DPR_INTR(ARGS)if (DBG_INTR)  TRC(ARGS)
-# define DPR_MSIGS(ARGS)   if (DBG_MSIGS)  TRC(ARGS)
-
-# define DPR(ARGS) if (dgnc_debug) TRC(ARGS)
+# define DPR_INIT(ARGS)do { if (DBG_INIT) TRC(ARGS) } while (0)
+# define DPR_BASIC(ARGS)   do { if (DBG_BASIC) TRC(ARGS) } while (0)
+# define DPR_CORE(ARGS)do { if (DBG_CORE) TRC(ARGS) } while (0)
+# define DPR_OPEN(ARGS)do { if (DBG_OPEN)  TRC(ARGS) } while 
(0)
+# define DPR_CLOSE(ARGS)   do { if (DBG_CLOSE)  TRC(ARGS) } while (0)
+# define DPR_READ(ARGS)do { if (DBG_READ)  TRC(ARGS) } while 
(0)
+# define DPR_WRITE(ARGS)   do { if (DBG_WRITE) TRC(ARGS) } while (0)
+# define DPR_IOCTL(ARGS)   do { if (DBG_IOCTL) TRC(ARGS) } while (0)
+# define DPR_PROC(ARGS)do { if (DBG_PROC)  TRC(ARGS) } while 
(0)
+# define DPR_PARAM(ARGS)   do { if (DBG_PARAM)  TRC(ARGS) } while (0)
+# define DPR_PSCAN(ARGS)   do { if (DBG_PSCAN)  TRC(ARGS) } while (0)
+# define DPR_EVENT(ARGS)   do { if (DBG_EVENT)  TRC(ARGS) } while (0)
+# define DPR_DRAIN(ARGS)   do { if (DBG_DRAIN)  TRC(ARGS) } while (0)
+# define DPR_CARR(ARGS)do { if (DBG_CARR)  TRC(ARGS) } while 
(0)
+# define DPR_MGMT(ARGS)do { if (DBG_MGMT)  TRC(ARGS) } while 
(0)
+# define DPR_INTR(ARGS)do { if (DBG_INTR)  TRC(ARGS) } while 
(0)
+# define DPR_MSIGS(ARGS)   do { if (DBG_MSIGS)  TRC(ARGS) } while (0)
+
+# define DPR(ARGS) do { if (dgnc_debug) TRC(ARGS) } while (0)
 # define P(X)  dgnc_tracef(#X "=%p\n", X)
 # define X(X)  dgnc_tracef(#X "=%x\n", X)
 
diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h
index 282908f..086cd9a 100644
--- a/drivers/staging/dgnc/digi.h
+++ b/drivers/staging/dgnc/digi.h
@@ -38,8 +38,8 @@
 
 #if !defined(TIOCMODG)
 
-#defineTIOCMODG('d'<<8) | 250  /* get modem ctrl state 
*/
-#defineTIOCMODS('d'<<8) | 251  /* set modem ctrl state 
*/
+#defineTIOCMODG(('d'<<8) | 250)/* get modem ctrl state 
*/
+#defineTIOCMODS(('d'<<8) | 251)/* set modem ctrl state 
*/
 
 #ifndef TIOCM_LE
 #defineTIOCM_LE0x01/* line enable  
*/
@@ -58,44 +58,44 @@
 #endif
 
 #if !defined(TIOCMSET)
-#defineTIOCMSET('d'<<8) | 252  /* set modem ctrl state 
*/
-#defineTIOCMGET('d'<<8) | 253  /* set modem ctrl state 
*/
+#defineTIOCMSET(('d'<<8) | 252)/* set modem ctrl state 
*/
+#defineTIOCMGET(('d'<<8) | 253)/* set modem ctrl state 
*/
 #endif
 
 #if !defined(TIOCMBIC)
-#defineTIOCMBIC('d'<<8) | 254  /* set modem ctrl state 
*/
-#defineTIOCMBIS('d'<<8) | 255  /* set modem ctrl state 
*/
+#defineTIOCMBIC(('d'<<8) | 254)/* set modem ctrl state 
*/
+#defineTIOCMBIS(('d'<<8) | 255)/* set modem ctrl state 
*/
 #endif
 
 
 #if !defined(TIOCSDTR)
-#define  

[PATCH 2/3] staging: dgnc: Fix do not initialise statics to 0 or NULL

2014-07-24 Thread Seunghun Lee
This patch fixes checkpatch errors
"do not initialise statics to 0 or NULL"

Signed-off-by: Seunghun Lee 
---
 drivers/staging/dgnc/dgnc_trace.c |2 +-
 drivers/staging/dgnc/dgnc_tty.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_trace.c 
b/drivers/staging/dgnc/dgnc_trace.c
index 2f62f2a..9be4715 100644
--- a/drivers/staging/dgnc/dgnc_trace.c
+++ b/drivers/staging/dgnc/dgnc_trace.c
@@ -43,7 +43,7 @@
 static char *dgnc_trcbuf;  /* the ringbuffer */
 
 #if defined(TRC_TO_KMEM)
-static int dgnc_trcbufi = 0;   /* index of the tilde at the end of */
+static int dgnc_trcbufi;   /* index of the tilde at the end of */
 #endif
 
 #if defined(TRC_TO_KMEM)
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 714a069..919abda 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -67,7 +67,7 @@
  * internal variables
  */
 static struct dgnc_board   *dgnc_BoardsByMajor[256];
-static uchar   *dgnc_TmpWriteBuf = NULL;
+static uchar   *dgnc_TmpWriteBuf;
 static DECLARE_MUTEX(dgnc_TmpWriteSem);
 
 /*
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Christoph Hellwig
On Thu, Jul 24, 2014 at 09:54:24AM -0400, Martin K. Petersen wrote:
> I'm very much against short-circuiting the LBP logic in a passthrough
> driver because then we might end up in the exact situation we were
> trying to avoid with this patch series. Namely sending down commands
> unsupported by the target device.
> 
> This kind of thing really needs to be a sysadmin decision and can be
> handled with a udev rule.

I agree - I'd like to pull in KY's simple fix as soon as I get a second
review for it.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Christoph Hellwig
On Thu, Jul 24, 2014 at 08:34:19AM -0700, Christoph Hellwig wrote:
> I agree - I'd like to pull in KY's simple fix as soon as I get a second
> review for it.

Ok, looks like I just got that from Hannes.  Let's see if there's more
to be done for the pass through case, but I'd rather wait for the next
window for that.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Sitsofe Wheeler
On Thu, Jul 24, 2014 at 09:54:24AM -0400, Martin K. Petersen wrote:
> > "Sitsofe" == Sitsofe Wheeler  writes:
> 
> Sitsofe> Fix incorrectly named variable.  Some block devices (such as
> Sitsofe> Hyper-V passthrough SSDs) support logical block provisioning
> Sitsofe> (e.g. via UNMAP) but don't set lbpme thus disabling discard. 
> 
> The fix for an SSD that is known to support LBP but which does not claim
> support for it is to use:
> 
> echo unmap > /sys/class/scsi_disk/foo/provisioning_mode
> 
> I'm very much against short-circuiting the LBP logic in a passthrough
> driver because then we might end up in the exact situation we were
> trying to avoid with this patch series. Namely sending down commands
> unsupported by the target device.
> 
> This kind of thing really needs to be a sysadmin decision and can be
> handled with a udev rule.

The problem is that the SSD _does_ claim to support it. Here are the
results of booting Linux directly on the host hardware and looking at
the device directly with a 3.10.35 kernel:

root@sysresccd /root % uname -a
Linux sysresccd 3.10.35-std420-amd64 #2 SMP Wed Apr 2 18:31:51 UTC 2014 x86_64 
Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz GenuineIntel GNU/Linux
root@sysresccd /root % sg_vpd -p lbpv /dev/sdb
root@sysresccd /root % sg_inq /dev/sdb   
standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  version=0x05  [SPC-3]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  Linked=0  [TranDis=0]  CmdQue=0
  [SPI: Clocking=0x0  QAS=0  IUS=0]
length=96 (0x60)   Peripheral device type: disk
 Vendor identification: ATA 
 Product identification: ADATA SSD S510 1
 Product revision level: 5.2.
 Unit serial number: 0320511550032076
root@sysresccd /root % sg_readcap -l /dev/sdb
Read Capacity results:
   Protection: prot_en=0, p_type=0, p_i_exponent=0
   Logical block provisioning: lbpme=1, lbprz=0
   Last logical block address=234441647 (0xdf94baf), Number of logical 
blocks=234441648
   Logical block length=512 bytes
   Logical blocks per physical block exponent=0
   Lowest aligned logical block address=0
Hence:
   Device size: 120034123776 bytes, 114473.5 MiB, 120.03 GB
Logical block provisioning VPD page (SBC):
  Unmap command supported (LBPU): 0
  Write same (16) with unmap bit supported (LBWS): 1
  Write same (10) with unmap bit supported (LBWS10): 0
  Logical block provisioning read zeros (LBPRZ): 0
  Anchored LBAs supported (ANC_SUP): 0
  Threshold exponent: 0
  Descriptor present (DP): 0
  Provisioning type: 0
root@sysresccd /root % sg_vpd -p bl /dev/sdb
Block limits VPD page (SBC):
  Write same no zero (WSNZ): 0
  Maximum compare and write length: 0 blocks
  Optimal transfer length granularity: 1 blocks
  Maximum transfer length: 0 blocks
  Optimal transfer length: 0 blocks
  Maximum prefetch length: 0 blocks
  Maximum unmap LBA count: 0
  Maximum unmap block descriptor count: 0
  Optimal unmap granularity: 1
  Unmap granularity alignment valid: 0
  Unmap granularity alignment: 0
  Maximum write same length: 0x3fffc0 blocks
root@sysresccd /root % grep . /sys/block/sdb/device/scsi_disk/1:0:0:0/* 
   
/sys/block/sdb/device/scsi_disk/1:0:0:0/allow_restart:1
/sys/block/sdb/device/scsi_disk/1:0:0:0/app_tag_own:0
/sys/block/sdb/device/scsi_disk/1:0:0:0/cache_type:write back
grep: /sys/block/sdb/device/scsi_disk/1:0:0:0/device: Is a directory
/sys/block/sdb/device/scsi_disk/1:0:0:0/FUA:0
/sys/block/sdb/device/scsi_disk/1:0:0:0/manage_start_stop:1
/sys/block/sdb/device/scsi_disk/1:0:0:0/max_medium_access_timeouts:2
/sys/block/sdb/device/scsi_disk/1:0:0:0/max_write_same_blocks:0
grep: /sys/block/sdb/device/scsi_disk/1:0:0:0/power: Is a directory
/sys/block/sdb/device/scsi_disk/1:0:0:0/protection_mode:none
/sys/block/sdb/device/scsi_disk/1:0:0:0/protection_type:0
/sys/block/sdb/device/scsi_disk/1:0:0:0/provisioning_mode:writesame_16
grep: /sys/block/sdb/device/scsi_disk/1:0:0:0/subsystem: Is a directory
/sys/block/sdb/device/scsi_disk/1:0:0:0/thin_provisioning:1

So we can see it is really a SATA device that announces discard
correctly and supports discard through WRITE_SAME(16). It is the act of
passing it through Hyper-V that turned it into a SCSI device that supports
UNMAP (but not WRITE_SAME(16)), doesn't announce its SCSI conformance number
and doesn't correctly announce which features it supports. Surely in
this case it's reasonable to quirk our way around the problem?

-- 
Sitsofe | http://sucs.org/~sits/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Martin K. Petersen
> "Sitsofe" == Sitsofe Wheeler  writes:

Sitsofe> So we can see it is really a SATA device that announces discard
Sitsofe> correctly and supports discard through WRITE_SAME(16).

No, that's the SATA device that announces support for DSM TRIM, and as a
result the Linux SATL reports support for WRITE SAME(16) w. the UNMAP
bit set and LBPME.

Sitsofe> It is the act of passing it through Hyper-V that turned it into
Sitsofe> a SCSI device that supports UNMAP (but not WRITE_SAME(16)),
Sitsofe> doesn't announce its SCSI conformance number and doesn't
Sitsofe> correctly announce which features it supports. Surely in this
Sitsofe> case it's reasonable to quirk our way around the problem?

No. That's an issue in Hyper-V that'll you'll have to take up with
Microsoft. I don't know what their passthrough limitations are for
SCSI-ATA translation. Maybe K. Y. has some insight into this?

There must be a reason why the VPD page was added and yet the device not
flagged as LBPME=1.

Many vendors do not support UNMAP/WRITE SAME to DSM TRIM translation.
Additionally, many vendors explicitly only whitelist drives that are
known to be working correctly. Your drive is an ADATA and therefore very
likely to be blacklisted by default by a vendor SATL.

-- 
Martin K. Petersen  Oracle Linux Engineering
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:bcm:DDRinit.c:coding style:line over 80 char

2014-07-24 Thread Greg KH
On Thu, Jul 24, 2014 at 06:19:46PM +0530, Sudip Mukherjee wrote:
> ---
>  drivers/staging/bcm/DDRInit.c | 59 
> ---
>  1 file changed, 39 insertions(+), 20 deletions(-)
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/SubmittingPatches and resend it after
  adding that line.  Note, the line needs to be in the body of the
  email, before the patch, not at the bottom of the patch or in the
  email signature.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Måns Rullgård
Steven Rostedt  writes:

> On Thu, 24 Jul 2014 10:47:25 -0400
> Steven Rostedt  wrote:
>
>> The three parameters are the number of elements, the size of each individual
>> element, and then finally the flags used on how to allocate that memory.
>> I have to say, you did get the flags part correct.
>> 
>> Now lets look at what you did. For the size you had:
>
> That should have read "For the count you had:"
>
> Oh well, you get my point anyway.

I have some doubts about the last bit.

-- 
Måns Rullgård
m...@mansr.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/3] [SCSI] Make LBP quirk skip lbpme checks tests

2014-07-24 Thread Sitsofe Wheeler
On Thu, Jul 24, 2014 at 08:35:13AM -0700, Christoph Hellwig wrote:
> On Thu, Jul 24, 2014 at 08:34:19AM -0700, Christoph Hellwig wrote:
> > I agree - I'd like to pull in KY's simple fix as soon as I get a second
> > review for it.
> 
> Ok, looks like I just got that from Hannes.  Let's see if there's more
> to be done for the pass through case, but I'd rather wait for the next
> window for that.

There's nothing Linux can do for today's Hyper-V passthrough wrt to
automatically turning on discard on my SATA SSD.

Martin explained that vendors often disable UNMAP/WRITE SAME to DSM TRIM
translation on purpose and/or have explicit device whitelists/blacklists
for those devices they want to support. It could be that Microsoft are
doing something similar (although it might be interesting to know how a
Windows 2012 guest on Hyper-V handles things).

-- 
Sitsofe | http://sucs.org/~sits/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 12:15 PM, Måns Rullgård  wrote:
> Steven Rostedt  writes:
>
>> On Thu, 24 Jul 2014 10:47:25 -0400
>> Steven Rostedt  wrote:
>>
>>> The three parameters are the number of elements, the size of each individual
>>> element, and then finally the flags used on how to allocate that memory.
>>> I have to say, you did get the flags part correct.
>>>
>>> Now lets look at what you did. For the size you had:
>>
>> That should have read "For the count you had:"
>>
>> Oh well, you get my point anyway.
>
> I have some doubts about the last bit.
>
> --
> Måns Rullgård
> m...@mansr.com


I am have this discussion with other kernel developers and just
because I send out
one patch as a newbie like this doesn't mean I don't known C.
Cheers Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Måns Rullgård
Nick Krause  writes:

> On Thu, Jul 24, 2014 at 12:15 PM, Måns Rullgård  wrote:
>> Steven Rostedt  writes:
>>
>>> On Thu, 24 Jul 2014 10:47:25 -0400
>>> Steven Rostedt  wrote:
>>>
 The three parameters are the number of elements, the size of each 
 individual
 element, and then finally the flags used on how to allocate that memory.
 I have to say, you did get the flags part correct.

 Now lets look at what you did. For the size you had:
>>>
>>> That should have read "For the count you had:"
>>>
>>> Oh well, you get my point anyway.
>>
>> I have some doubts about the last bit.
>
> I am have this discussion with other kernel developers and just
> because I send out one patch as a newbie like this doesn't mean I
> don't known C.

Now I no longer have doubts; I know for certain that the point didn't
get across.

-- 
Måns Rullgård
m...@mansr.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 12:34 PM, Måns Rullgård  wrote:
> Nick Krause  writes:
>
>> On Thu, Jul 24, 2014 at 12:15 PM, Måns Rullgård  wrote:
>>> Steven Rostedt  writes:
>>>
 On Thu, 24 Jul 2014 10:47:25 -0400
 Steven Rostedt  wrote:

> The three parameters are the number of elements, the size of each 
> individual
> element, and then finally the flags used on how to allocate that memory.
> I have to say, you did get the flags part correct.
>
> Now lets look at what you did. For the size you had:

 That should have read "For the count you had:"

 Oh well, you get my point anyway.
>>>
>>> I have some doubts about the last bit.
>>
>> I am have this discussion with other kernel developers and just
>> because I send out one patch as a newbie like this doesn't mean I
>> don't known C.
>
> Now I no longer have doubts; I know for certain that the point didn't
> get across.
>
> --
> Måns Rullgård
> m...@mansr.com

I get your point try other things but I talked to other kernel developers and
most of them seemed to get this feedback to when they started.
Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: dgnc: Fix do not initialise statics to 0 or NULL

2014-07-24 Thread Paul Bolle
Seunghun Lee schreef op vr 25-07-2014 om 00:26 [+0900]:
> This patch fixes checkpatch errors
> "do not initialise statics to 0 or NULL"
> 
> Signed-off-by: Seunghun Lee 
> ---
>  drivers/staging/dgnc/dgnc_trace.c |2 +-
>  drivers/staging/dgnc/dgnc_tty.c   |2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_trace.c 
> b/drivers/staging/dgnc/dgnc_trace.c
> index 2f62f2a..9be4715 100644
> --- a/drivers/staging/dgnc/dgnc_trace.c
> +++ b/drivers/staging/dgnc/dgnc_trace.c
> @@ -43,7 +43,7 @@
>  static char *dgnc_trcbuf;/* the ringbuffer */
>  
>  #if defined(TRC_TO_KMEM)
> -static int dgnc_trcbufi = 0; /* index of the tilde at the end of */
> +static int dgnc_trcbufi; /* index of the tilde at the end of */
>  #endif

I don't think TRC_TO_KMEM is defined anywhere. If that's correct, the
proper, well, fix for this checkpatch warning would be to remove all
code currently hidden behind the tests for that macro.

>  #if defined(TRC_TO_KMEM)


Paul Bolle

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Måns Rullgård
Nick Krause  writes:

> On Thu, Jul 24, 2014 at 12:34 PM, Måns Rullgård  wrote:
>> Nick Krause  writes:
>>
>>> On Thu, Jul 24, 2014 at 12:15 PM, Måns Rullgård  wrote:
 Steven Rostedt  writes:

> On Thu, 24 Jul 2014 10:47:25 -0400
> Steven Rostedt  wrote:
>
>> The three parameters are the number of elements, the size of each 
>> individual
>> element, and then finally the flags used on how to allocate that memory.
>> I have to say, you did get the flags part correct.
>>
>> Now lets look at what you did. For the size you had:
>
> That should have read "For the count you had:"
>
> Oh well, you get my point anyway.

 I have some doubts about the last bit.
>>>
>>> I am have this discussion with other kernel developers and just
>>> because I send out one patch as a newbie like this doesn't mean I
>>> don't known C.
>>
>> Now I no longer have doubts; I know for certain that the point didn't
>> get across.
>
> I get your point try other things but I talked to other kernel
> developers and most of them seemed to get this feedback to when they
> started.

Most kernel devs most certainly did NOT get started by spamming lkml
with unnecessary and incorrect patches despite being repeatedly told to
go away and stop wasting everybody's time.

-- 
Måns Rullgård
m...@mansr.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 12:47 PM, Måns Rullgård  wrote:
> Nick Krause  writes:
>
>> On Thu, Jul 24, 2014 at 12:34 PM, Måns Rullgård  wrote:
>>> Nick Krause  writes:
>>>
 On Thu, Jul 24, 2014 at 12:15 PM, Måns Rullgård  wrote:
> Steven Rostedt  writes:
>
>> On Thu, 24 Jul 2014 10:47:25 -0400
>> Steven Rostedt  wrote:
>>
>>> The three parameters are the number of elements, the size of each 
>>> individual
>>> element, and then finally the flags used on how to allocate that memory.
>>> I have to say, you did get the flags part correct.
>>>
>>> Now lets look at what you did. For the size you had:
>>
>> That should have read "For the count you had:"
>>
>> Oh well, you get my point anyway.
>
> I have some doubts about the last bit.

 I am have this discussion with other kernel developers and just
 because I send out one patch as a newbie like this doesn't mean I
 don't known C.
>>>
>>> Now I no longer have doubts; I know for certain that the point didn't
>>> get across.
>>
>> I get your point try other things but I talked to other kernel
>> developers and most of them seemed to get this feedback to when they
>> started.
>
> Most kernel devs most certainly did NOT get started by spamming lkml
> with unnecessary and incorrect patches despite being repeatedly told to
> go away and stop wasting everybody's time.
>
> --
> Måns Rullgård
> m...@mansr.com



FIne , I give up. You want me to leave this then I wiil.
Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/40] staging: comedi: ni_tio: convert global static const variables to defines

2014-07-24 Thread H Hartley Sweeten
For aesthetics, convert the global static const varaibles into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 92 -
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 247e3da..9b5ab0b 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -119,10 +119,10 @@ enum ni_660x_clock_source {
NI_660x_Timebase_3_Clock = 0x1e,/* 80MHz */
NI_660x_Logic_Low_Clock = 0x1f,
 };
-static const unsigned ni_660x_max_rtsi_channel = 6;
+#define NI_660X_MAX_RTSI_CHAN  6
 #define NI_660X_RTSI_CLK(x)(0xb + (x))
 
-static const unsigned ni_660x_max_source_pin = 7;
+#define NI_660X_MAX_SRC_PIN7
 #define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
 
 /* clock sources for ni e and m series boards, get bits with 
Gi_Source_Select_Bits() */
@@ -137,10 +137,10 @@ enum ni_m_series_clock_source {
NI_M_Series_Analog_Trigger_Out_Clock = 0x1e,/* when 
Gi_Src_SubSelect = 1 */
NI_M_Series_Logic_Low_Clock = 0x1f,
 };
-static const unsigned ni_m_series_max_pfi_channel = 15;
+#define NI_M_MAX_PFI_CHAN  15
 #define NI_M_PFI_CLK(x)(((x) < 10) ? (1 + (x)) : (0xb 
+ (x)))
 
-static const unsigned ni_m_series_max_rtsi_channel = 7;
+#define NI_M_MAX_RTSI_CHAN 7
 #define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
 
 enum ni_660x_gate_select {
@@ -150,7 +150,7 @@ enum ni_660x_gate_select {
NI_660x_Next_Out_Gate_Select = 0x14,
NI_660x_Logic_Low_Gate_Select = 0x1f,
 };
-static const unsigned ni_660x_max_gate_pin = 7;
+#define NI_660X_MAX_GATE_PIN   7
 #define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
 #define NI_660X_RTSI_GATE_SEL(x)   (0xb + (x))
 
@@ -185,7 +185,7 @@ enum ni_660x_second_gate_select {
NI_660x_Selected_Gate_Second_Gate_Select = 0x1e,
NI_660x_Logic_Low_Second_Gate_Select = 0x1f,
 };
-static const unsigned ni_660x_max_up_down_pin = 7;
+#define NI_660X_MAX_UP_DOWN_PIN7
 #define NI_660X_UD_PIN_GATE2_SEL(x)(0x2 + (x))
 #define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
 
@@ -512,22 +512,22 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
ni_660x_clock = NI_660x_Next_TC_Clock;
break;
default:
-   for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
+   for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
ni_660x_clock = NI_660X_RTSI_CLK(i);
break;
}
}
-   if (i <= ni_660x_max_rtsi_channel)
+   if (i <= NI_660X_MAX_RTSI_CHAN)
break;
-   for (i = 0; i <= ni_660x_max_source_pin; ++i) {
+   for (i = 0; i <= NI_660X_MAX_SRC_PIN; ++i) {
if (clock_select_bits ==
NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
ni_660x_clock = NI_660X_SRC_PIN_CLK(i);
break;
}
}
-   if (i <= ni_660x_max_source_pin)
+   if (i <= NI_660X_MAX_SRC_PIN)
break;
ni_660x_clock = 0;
BUG();
@@ -571,21 +571,21 @@ static unsigned ni_m_series_source_select_bits(unsigned 
int clock_source)
ni_m_series_clock = NI_M_Series_Analog_Trigger_Out_Clock;
break;
default:
-   for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
+   for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) {
if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
ni_m_series_clock = NI_M_RTSI_CLK(i);
break;
}
}
-   if (i <= ni_m_series_max_rtsi_channel)
+   if (i <= NI_M_MAX_RTSI_CHAN)
break;
-   for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
+   for (i = 0; i <= NI_M_MAX_PFI_CHAN; ++i) {
if (clock_select_bits == NI_GPCT_PFI_CLOCK_SRC_BITS(i)) 
{
ni_m_series_clock = NI_M_PFI_CLK(i);
break;
}
}
-   if (i <= ni_m_series_max_pfi_channel)
+   if (i <= NI_M_MAX_PFI_CHAN)
break;
printk(KERN_ERR "invalid clock source 0x%lx\n",
   (unsigned long)clock_source);
@@ -741,21 +741,21 @@ static unsigned ni_m_series_clock_src_select(co

[PATCH 00/40] staging: comedi: ni_tio: clean up driver

2014-07-24 Thread H Hartley Sweeten
Start cleaning up this driver by:
  1) fix all the checkpatch.pl warnings
 WARNING: line over 80 characters
 WARNING: Unnecessary space before function pointer arguments
 WARNING: Prefer [foo]_err to printk(KERN_ERR ...
  2) remove a bunch of unreachable BUG() code
  3) tidy up some of the CamelCase issues
  4) remove need for all the forward declarations
  5) general cleanup

H Hartley Sweeten (40):
  staging: comedi: ni_tio: fix ni_tio_insn_read()
  staging: comedi: ni_tio: fix > 80 char comments
  staging: comedi: ni_tio: tidy up some function declarations
  staging: comedi: ni_tio: remove unnecessary ni_gpct_variant BUG() cases
  staging: comedi: ni_tio: tidy up ni_660x_set_second_gate()
  staging: comedi: ni_tio: tidy up ni_m_series_set_first_gate()
  staging: comedi: ni_tio: tidy up ni_660x_set_first_gate()
  staging: comedi: ni_tio: convert NI_M_Series_RTSI_Clock() to a macro
  staging: comedi: ni_tio: convert NI_M_Series_PFI_Clock() to a macro
  staging: comedi: ni_tio: convert NI_660x_Gate_Pin_Gate_Select() to a macro
  staging: comedi: ni_tio: convert NI_660x_RTSI_Gate_Select() to a macro
  staging: comedi: ni_tio: convert NI_M_Series_RTSI_Gate_Select() to a macro
  staging: comedi: ni_tio: convert NI_M_Series_PFI_Gate_Select() to a macro
  staging: comedi: ni_tio: convert NI_660x_Source_Pin_Clock() to a macro
  staging: comedi: ni_tio: convert NI_660x_RTSI_Clock() to a macro
  staging: comedi: ni_tio: convert NI_660x_RTSI_Second_Gate_Select() to a macro
  staging: comedi: ni_tio: convert NI_660x_Up_Down_Pin_Second_Gate_Select() to 
a macro
  staging: comedi: ni_tio: convert global static const variables to defines
  staging: comedi: ni_tio: remove counter_status_mask
  staging: comedi: ni_tio: tidy up enum ni_660x_second_gate_select
  staging: comedi: ni_tio: tidy up enum ni_m_series_gate_select
  staging: comedi: ni_tio: tidy up enum ni_660x_gate_select
  staging: comedi: ni_tio: tidy up enum ni_m_series_clock_source
  staging: comedi: ni_tio: tidy up enum ni_660x_clock_source
  staging: comedi: ni_tio: move defines to head of file
  staging: comedi: ni_tio: tidy up ni_gpct_device_{construct,destroy)()
  staging: comedi: ni_tio: tidy up ni_tio_init_counter()
  staging: comedi: ni_tio: rename ni_tio_second_gate_registers_present()
  staging: comedi: ni_tio: tidy up ni_m_series_source_select_bits()
  staging: comedi: ni_tio: tidy up ni_660x_source_select_bits()
  staging: comedi: ni_tio: tidy up ni_tio_set_sync_mode()
  staging: comedi: ni_tio: absorb ni_tio_counter_status()
  staging: comedi: ni_tio: tidy up ni_tio_get_gate_src() and helpers
  staging: comedi: ni_tio: tidy up ni_tio_set_other_src()
  staging: comedi: ni_tio: tidy up ni_tio_set_gate_src() and helpers
  staging: comedi: ni_tio: absorb ni_tio_set_first_gate_modifiers()
  staging: comedi: ni_tio: tidy up ni_tio_get_clock_src()
  staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers
  staging: comedi: ni_tio: remove forward declarations
  staging: comedi: ni_tio: convert printk to pr_err

 drivers/staging/comedi/drivers/ni_tio.c | 1609 ++-
 1 file changed, 736 insertions(+), 873 deletions(-)

-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/40] staging: comedi: ni_tio: convert NI_660x_Gate_Pin_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index e6b8134..818519a 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -159,11 +159,7 @@ enum ni_660x_gate_select {
NI_660x_Logic_Low_Gate_Select = 0x1f,
 };
 static const unsigned ni_660x_max_gate_pin = 7;
-static inline unsigned NI_660x_Gate_Pin_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_gate_pin);
-   return 0x2 + n;
-}
+#define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
 
 static inline unsigned NI_660x_RTSI_Gate_Select(unsigned n)
 {
@@ -1225,8 +1221,7 @@ ni_660x_first_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
if (i <= ni_660x_max_rtsi_channel)
break;
for (i = 0; i <= ni_660x_max_gate_pin; ++i) {
-   if (ni_660x_gate_select ==
-   NI_660x_Gate_Pin_Gate_Select(i))
+   if (ni_660x_gate_select == NI_660X_PIN_GATE_SEL(i))
return NI_GPCT_GATE_PIN_GATE_SELECT(i);
}
if (i <= ni_660x_max_gate_pin)
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/40] staging: comedi: ni_tio: tidy up some function declarations

2014-07-24 Thread H Hartley Sweeten
Fix the whitespace in some of the function declarations to avoid
the ugly line breaks and fix a couple checkpatch.pl issues:

WARNING: line over 80 characters
WARNING: Unnecessary space before function pointer arguments

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 64 ++---
 1 file changed, 27 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 8b56397..49ffb50 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -53,9 +53,8 @@ static uint64_t ni_tio_clock_period_ps(const struct ni_gpct 
*counter,
   unsigned generic_clock_source);
 static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter);
 
-static inline enum Gi_Counting_Mode_Reg_Bits Gi_Alternate_Sync_Bit(enum
-  
ni_gpct_variant
-  variant)
+static inline enum Gi_Counting_Mode_Reg_Bits
+Gi_Alternate_Sync_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
@@ -71,9 +70,8 @@ static inline enum Gi_Counting_Mode_Reg_Bits 
Gi_Alternate_Sync_Bit(enum
return 0;
 }
 
-static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X2_Bit(enum
-   ni_gpct_variant
-   variant)
+static inline enum Gi_Counting_Mode_Reg_Bits
+Gi_Prescale_X2_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
@@ -89,9 +87,8 @@ static inline enum Gi_Counting_Mode_Reg_Bits 
Gi_Prescale_X2_Bit(enum
return 0;
 }
 
-static inline enum Gi_Counting_Mode_Reg_Bits Gi_Prescale_X8_Bit(enum
-   ni_gpct_variant
-   variant)
+static inline enum Gi_Counting_Mode_Reg_Bits
+Gi_Prescale_X8_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
@@ -107,9 +104,8 @@ static inline enum Gi_Counting_Mode_Reg_Bits 
Gi_Prescale_X8_Bit(enum
return 0;
 }
 
-static inline enum Gi_Counting_Mode_Reg_Bits Gi_HW_Arm_Select_Mask(enum
-  
ni_gpct_variant
-  variant)
+static inline enum Gi_Counting_Mode_Reg_Bits
+Gi_HW_Arm_Select_Mask(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
@@ -257,21 +253,15 @@ static inline unsigned 
NI_660x_RTSI_Second_Gate_Select(unsigned n)
 static const unsigned int counter_status_mask =
COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
 
-struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device *dev,
-   void (*write_register) (struct
-   ni_gpct
-   *
-   counter,
-   unsigned
-   bits,
-   enum
-   
ni_gpct_register
-   reg),
-   unsigned (*read_register)
-   (struct ni_gpct *counter,
-enum ni_gpct_register reg),
-   enum ni_gpct_variant variant,
-   unsigned num_counters)
+struct ni_gpct_device *
+ni_gpct_device_construct(struct comedi_device *dev,
+void (*write_register)(struct ni_gpct *counter,
+   unsigned bits,
+   enum ni_gpct_register reg),
+unsigned (*read_register)(struct ni_gpct *counter,
+  enum ni_gpct_register reg),
+enum ni_gpct_variant variant,
+unsigned num_counters)
 {
unsigned i;
 
@@ -309,8 +299,8 @@ void ni_gpct_device_destroy(struct ni_gpct_device 
*counter_dev)
 }
 EXPORT_SYMBOL_GPL(ni_gpct_device_destroy);
 
-static int ni_tio_second_gate_registers_present(const struct ni_gpct_device
- 

[PATCH 16/40] staging: comedi: ni_tio: convert NI_660x_RTSI_Second_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 422052f..2347612 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -192,11 +192,7 @@ static inline unsigned 
NI_660x_Up_Down_Pin_Second_Gate_Select(unsigned n)
return 0x2 + n;
 }
 
-static inline unsigned NI_660x_RTSI_Second_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_rtsi_channel);
-   return 0xb + n;
-}
+#define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
 
 static const unsigned int counter_status_mask =
COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
@@ -1267,10 +1263,8 @@ ni_660x_second_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-   if (ni_660x_gate_select ==
-   NI_660x_RTSI_Second_Gate_Select(i)) {
+   if (ni_660x_gate_select == NI_660X_RTSI_GATE2_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
-   }
}
if (i <= ni_660x_max_rtsi_channel)
break;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 28/40] staging: comedi: ni_tio: rename ni_tio_second_gate_registers_present()

2014-07-24 Thread H Hartley Sweeten
For aesthetics, rename this function to shorten some of the long lines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 0cecc60..b2ed3d8 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -186,8 +186,7 @@ static inline unsigned Gi_Gate_Select_Bits(unsigned 
gate_select)
return (gate_select << Gi_Gate_Select_Shift) & Gi_Gate_Select_Mask;
 }
 
-static int
-ni_tio_second_gate_registers_present(const struct ni_gpct_device *counter_dev)
+static int ni_tio_has_gate2_registers(const struct ni_gpct_device *counter_dev)
 {
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
@@ -996,8 +995,9 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned 
gate_index,
}
break;
case 1:
-   if (ni_tio_second_gate_registers_present(counter_dev) == 0)
+   if (!ni_tio_has_gate2_registers(counter_dev))
return -EINVAL;
+
if (CR_CHAN(gate_source) == NI_GPCT_DISABLED_GATE_SELECT) {
counter_dev->regs[second_gate_reg] &=
~Gi_Second_Gate_Mode_Bit;
@@ -1459,7 +1459,7 @@ void ni_tio_init_counter(struct ni_gpct *counter)
if (ni_tio_counting_mode_registers_present(counter_dev))
ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx), ~0, 0);
 
-   if (ni_tio_second_gate_registers_present(counter_dev)) {
+   if (ni_tio_has_gate2_registers(counter_dev)) {
counter_dev->regs[NITIO_GATE2_REG(cidx)] = 0x0;
write_register(counter, 0x0, NITIO_GATE2_REG(cidx));
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 31/40] staging: comedi: ni_tio: tidy up ni_tio_set_sync_mode()

2014-07-24 Thread H Hartley Sweeten
Fix the > 80 char line issues in this function.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 55485c2..d099f54 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -226,14 +226,13 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, 
int force_alt_sync)
unsigned cidx = counter->counter_index;
const unsigned counting_mode_reg = NITIO_CNT_MODE_REG(cidx);
static const uint64_t min_normal_sync_period_ps = 25000;
-   const uint64_t clock_period_ps = ni_tio_clock_period_ps(counter,
-   
ni_tio_generic_clock_src_select
-   (counter));
+   uint64_t clock_period_ps;
 
if (ni_tio_counting_mode_registers_present(counter_dev) == 0)
return;
 
-   switch (ni_tio_get_soft_copy(counter, counting_mode_reg) & 
Gi_Counting_Mode_Mask) {
+   switch (ni_tio_get_soft_copy(counter, counting_mode_reg) &
+   Gi_Counting_Mode_Mask) {
case Gi_Counting_Mode_QuadratureX1_Bits:
case Gi_Counting_Mode_QuadratureX2_Bits:
case Gi_Counting_Mode_QuadratureX4_Bits:
@@ -243,6 +242,10 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, 
int force_alt_sync)
default:
break;
}
+
+   clock_period_ps = ni_tio_clock_period_ps(counter,
+   ni_tio_generic_clock_src_select(counter));
+
/*
 * It's not clear what we should do if clock_period is unknown, so we
 * are not using the alt sync bit in that case, but allow the caller
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 32/40] staging: comedi: ni_tio: absorb ni_tio_counter_status()

2014-07-24 Thread H Hartley Sweeten
This function is only called to handle the INSN_CONFIG_GET_COUNTER_STATUS
instruction. For aesthetics, absorb the code into ni_tio_insn_config().

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index d099f54..f057848 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -205,21 +205,6 @@ static void ni_tio_reset_count_and_disarm(struct ni_gpct 
*counter)
write_register(counter, Gi_Reset_Bit(cidx), NITIO_RESET_REG(cidx));
 }
 
-static unsigned int ni_tio_counter_status(struct ni_gpct *counter)
-{
-   unsigned cidx = counter->counter_index;
-   const unsigned bits = read_register(counter,
-   NITIO_SHARED_STATUS_REG(cidx));
-   unsigned int status = 0;
-
-   if (bits & Gi_Armed_Bit(cidx)) {
-   status |= COMEDI_COUNTER_ARMED;
-   if (bits & Gi_Counting_Bit(cidx))
-   status |= COMEDI_COUNTER_COUNTING;
-   }
-   return status;
-}
-
 static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync)
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
@@ -1282,6 +1267,8 @@ int ni_tio_insn_config(struct comedi_device *dev,
   unsigned int *data)
 {
struct ni_gpct *counter = s->private;
+   unsigned cidx = counter->counter_index;
+   unsigned status;
 
switch (data[0]) {
case INSN_CONFIG_SET_COUNTER_MODE:
@@ -1292,7 +1279,13 @@ int ni_tio_insn_config(struct comedi_device *dev,
ni_tio_arm(counter, 0, 0);
return 0;
case INSN_CONFIG_GET_COUNTER_STATUS:
-   data[1] = ni_tio_counter_status(counter);
+   data[1] = 0;
+   status = read_register(counter, NITIO_SHARED_STATUS_REG(cidx));
+   if (status & Gi_Armed_Bit(cidx)) {
+   data[1] |= COMEDI_COUNTER_ARMED;
+   if (status & Gi_Counting_Bit(cidx))
+   data[1] |= COMEDI_COUNTER_COUNTING;
+   }
data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
return 0;
case INSN_CONFIG_SET_CLOCK_SRC:
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/40] staging: comedi: ni_tio: convert NI_M_Series_PFI_Clock() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index e1d7d4e..e6b8134 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -146,12 +146,7 @@ enum ni_m_series_clock_source {
NI_M_Series_Logic_Low_Clock = 0x1f,
 };
 static const unsigned ni_m_series_max_pfi_channel = 15;
-static inline unsigned NI_M_Series_PFI_Clock(unsigned n)
-{
-   BUG_ON(n > ni_m_series_max_pfi_channel);
-
-   return (n < 10) ? (1 + n) : (0xb + n);
-}
+#define NI_M_PFI_CLK(x)(((x) < 10) ? (1 + (x)) : (0xb 
+ (x)))
 
 static const unsigned ni_m_series_max_rtsi_channel = 7;
 #define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
@@ -625,7 +620,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int 
clock_source)
break;
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
if (clock_select_bits == NI_GPCT_PFI_CLOCK_SRC_BITS(i)) 
{
-   ni_m_series_clock = NI_M_Series_PFI_Clock(i);
+   ni_m_series_clock = NI_M_PFI_CLK(i);
break;
}
}
@@ -794,7 +789,7 @@ static unsigned ni_m_series_clock_src_select(const struct 
ni_gpct *counter)
if (i <= ni_m_series_max_rtsi_channel)
break;
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
-   if (input_select == NI_M_Series_PFI_Clock(i)) {
+   if (input_select == NI_M_PFI_CLK(i)) {
clock_source = NI_GPCT_PFI_CLOCK_SRC_BITS(i);
break;
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 29/40] staging: comedi: ni_tio: tidy up ni_m_series_source_select_bits()

2014-07-24 Thread H Hartley Sweeten
Rename a local variable to fix the > 80 char line issues.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index b2ed3d8..404a14f 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -442,11 +442,11 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
 
 static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
 {
+   unsigned clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
unsigned ni_m_series_clock;
unsigned i;
-   const unsigned clock_select_bits =
-   clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
-   switch (clock_select_bits) {
+
+   switch (clk_src) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
ni_m_series_clock = NI_M_TIMEBASE_1_CLK;
break;
@@ -476,7 +476,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int 
clock_source)
break;
default:
for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) {
-   if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
+   if (clk_src == NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
ni_m_series_clock = NI_M_RTSI_CLK(i);
break;
}
@@ -484,7 +484,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int 
clock_source)
if (i <= NI_M_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_M_MAX_PFI_CHAN; ++i) {
-   if (clock_select_bits == NI_GPCT_PFI_CLOCK_SRC_BITS(i)) 
{
+   if (clk_src == NI_GPCT_PFI_CLOCK_SRC_BITS(i)) {
ni_m_series_clock = NI_M_PFI_CLK(i);
break;
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 36/40] staging: comedi: ni_tio: absorb ni_tio_set_first_gate_modifiers()

2014-07-24 Thread H Hartley Sweeten
This function is only called by ni_tio_set_gate_src(). For aesthetics,
absorb the code into that function..

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index eb54582..33ffd17 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -776,23 +776,6 @@ static void ni_tio_get_clock_src(struct ni_gpct *counter,
*period_ns = temp64;
 }
 
-static void ni_tio_set_first_gate_modifiers(struct ni_gpct *counter,
-   unsigned int gate_source)
-{
-   const unsigned mode_mask = Gi_Gate_Polarity_Bit | Gi_Gating_Mode_Mask;
-   unsigned cidx = counter->counter_index;
-   unsigned mode_values = 0;
-
-   if (gate_source & CR_INVERT)
-   mode_values |= Gi_Gate_Polarity_Bit;
-   if (gate_source & CR_EDGE)
-   mode_values |= Gi_Rising_Edge_Gating_Bits;
-   else
-   mode_values |= Gi_Level_Gating_Bits;
-   ni_tio_set_bits(counter, NITIO_MODE_REG(cidx),
-   mode_mask, mode_values);
-}
-
 static int ni_660x_set_gate(struct ni_gpct *counter, unsigned int gate_source)
 {
unsigned int chan = CR_CHAN(gate_source);
@@ -953,6 +936,7 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned 
gate_index,
unsigned cidx = counter->counter_index;
unsigned int chan = CR_CHAN(gate_source);
unsigned gate2_reg = NITIO_GATE2_REG(cidx);
+   unsigned mode = 0;
 
switch (gate_index) {
case 0:
@@ -962,7 +946,15 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned 
gate_index,
Gi_Gating_Disabled_Bits);
return 0;
}
-   ni_tio_set_first_gate_modifiers(counter, gate_source);
+   if (gate_source & CR_INVERT)
+   mode |= Gi_Gate_Polarity_Bit;
+   if (gate_source & CR_EDGE)
+   mode |= Gi_Rising_Edge_Gating_Bits;
+   else
+   mode |= Gi_Level_Gating_Bits;
+   ni_tio_set_bits(counter, NITIO_MODE_REG(cidx),
+   Gi_Gate_Polarity_Bit | Gi_Gating_Mode_Mask,
+   mode);
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/40] staging: comedi: ni_tio: convert NI_660x_RTSI_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 818519a..1fb9a5c 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -160,12 +160,7 @@ enum ni_660x_gate_select {
 };
 static const unsigned ni_660x_max_gate_pin = 7;
 #define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
-
-static inline unsigned NI_660x_RTSI_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_rtsi_channel);
-   return 0xb + n;
-}
+#define NI_660X_RTSI_GATE_SEL(x)   (0xb + (x))
 
 enum ni_m_series_gate_select {
NI_M_Series_Timestamp_Mux_Gate_Select = 0x0,
@@ -1215,7 +1210,7 @@ ni_660x_first_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-   if (ni_660x_gate_select == NI_660x_RTSI_Gate_Select(i))
+   if (ni_660x_gate_select == NI_660X_RTSI_GATE_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
}
if (i <= ni_660x_max_rtsi_channel)
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/40] staging: comedi: ni_tio: convert NI_660x_Up_Down_Pin_Second_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 2347612..247e3da 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -186,12 +186,7 @@ enum ni_660x_second_gate_select {
NI_660x_Logic_Low_Second_Gate_Select = 0x1f,
 };
 static const unsigned ni_660x_max_up_down_pin = 7;
-static inline unsigned NI_660x_Up_Down_Pin_Second_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_up_down_pin);
-   return 0x2 + n;
-}
-
+#define NI_660X_UD_PIN_GATE2_SEL(x)(0x2 + (x))
 #define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
 
 static const unsigned int counter_status_mask =
@@ -1269,10 +1264,8 @@ ni_660x_second_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
if (i <= ni_660x_max_rtsi_channel)
break;
for (i = 0; i <= ni_660x_max_up_down_pin; ++i) {
-   if (ni_660x_gate_select ==
-   NI_660x_Up_Down_Pin_Second_Gate_Select(i)) {
+   if (ni_660x_gate_select == NI_660X_UD_PIN_GATE2_SEL(i))
return NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i);
-   }
}
if (i <= ni_660x_max_up_down_pin)
break;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/40] staging: comedi: ni_tio: convert NI_660x_Source_Pin_Clock() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index ee9c853..a7cd59b 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -127,11 +127,7 @@ static inline unsigned NI_660x_RTSI_Clock(unsigned n)
 }
 
 static const unsigned ni_660x_max_source_pin = 7;
-static inline unsigned NI_660x_Source_Pin_Clock(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_source_pin);
-   return 0x2 + n;
-}
+#define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
 
 /* clock sources for ni e and m series boards, get bits with 
Gi_Source_Select_Bits() */
 enum ni_m_series_clock_source {
@@ -540,7 +536,7 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
for (i = 0; i <= ni_660x_max_source_pin; ++i) {
if (clock_select_bits ==
NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
-   ni_660x_clock = NI_660x_Source_Pin_Clock(i);
+   ni_660x_clock = NI_660X_SRC_PIN_CLK(i);
break;
}
}
@@ -822,7 +818,7 @@ static unsigned ni_660x_clock_src_select(const struct 
ni_gpct *counter)
if (i <= ni_660x_max_rtsi_channel)
break;
for (i = 0; i <= ni_660x_max_source_pin; ++i) {
-   if (input_select == NI_660x_Source_Pin_Clock(i)) {
+   if (input_select == NI_660X_SRC_PIN_CLK(i)) {
clock_source =
NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i);
break;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 26/40] staging: comedi: ni_tio: tidy up ni_gpct_device_{construct, destroy)()

2014-07-24 Thread H Hartley Sweeten
For aesthetics, move these exported functions to the end of the file.

Tidy up the functions a bit and remove the BUG_ON when (num_counters == 0).

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 101 +---
 1 file changed, 55 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index e49c71c..a65b55d 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -186,52 +186,6 @@ static inline unsigned Gi_Gate_Select_Bits(unsigned 
gate_select)
return (gate_select << Gi_Gate_Select_Shift) & Gi_Gate_Select_Mask;
 }
 
-struct ni_gpct_device *
-ni_gpct_device_construct(struct comedi_device *dev,
-void (*write_register)(struct ni_gpct *counter,
-   unsigned bits,
-   enum ni_gpct_register reg),
-unsigned (*read_register)(struct ni_gpct *counter,
-  enum ni_gpct_register reg),
-enum ni_gpct_variant variant,
-unsigned num_counters)
-{
-   unsigned i;
-
-   struct ni_gpct_device *counter_dev =
-   kzalloc(sizeof(struct ni_gpct_device), GFP_KERNEL);
-   if (counter_dev == NULL)
-   return NULL;
-   counter_dev->dev = dev;
-   counter_dev->write_register = write_register;
-   counter_dev->read_register = read_register;
-   counter_dev->variant = variant;
-   spin_lock_init(&counter_dev->regs_lock);
-   BUG_ON(num_counters == 0);
-   counter_dev->counters =
-   kzalloc(sizeof(struct ni_gpct) * num_counters, GFP_KERNEL);
-   if (counter_dev->counters == NULL) {
-   kfree(counter_dev);
-   return NULL;
-   }
-   for (i = 0; i < num_counters; ++i) {
-   counter_dev->counters[i].counter_dev = counter_dev;
-   spin_lock_init(&counter_dev->counters[i].lock);
-   }
-   counter_dev->num_counters = num_counters;
-   return counter_dev;
-}
-EXPORT_SYMBOL_GPL(ni_gpct_device_construct);
-
-void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev)
-{
-   if (counter_dev->counters == NULL)
-   return;
-   kfree(counter_dev->counters);
-   kfree(counter_dev);
-}
-EXPORT_SYMBOL_GPL(ni_gpct_device_destroy);
-
 static int
 ni_tio_second_gate_registers_present(const struct ni_gpct_device *counter_dev)
 {
@@ -1521,6 +1475,61 @@ int ni_tio_insn_write(struct comedi_device *dev,
 }
 EXPORT_SYMBOL_GPL(ni_tio_insn_write);
 
+struct ni_gpct_device *
+ni_gpct_device_construct(struct comedi_device *dev,
+void (*write_register)(struct ni_gpct *counter,
+   unsigned bits,
+   enum ni_gpct_register reg),
+unsigned (*read_register)(struct ni_gpct *counter,
+  enum ni_gpct_register reg),
+enum ni_gpct_variant variant,
+unsigned num_counters)
+{
+   struct ni_gpct_device *counter_dev;
+   struct ni_gpct *counter;
+   unsigned i;
+
+   if (num_counters == 0)
+   return NULL;
+
+   counter_dev = kzalloc(sizeof(*counter_dev), GFP_KERNEL);
+   if (!counter_dev)
+   return NULL;
+
+   counter_dev->dev = dev;
+   counter_dev->write_register = write_register;
+   counter_dev->read_register = read_register;
+   counter_dev->variant = variant;
+
+   spin_lock_init(&counter_dev->regs_lock);
+
+   counter_dev->counters = kcalloc(num_counters, sizeof(*counter),
+   GFP_KERNEL);
+   if (!counter_dev->counters) {
+   kfree(counter_dev);
+   return NULL;
+   }
+
+   for (i = 0; i < num_counters; ++i) {
+   counter = &counter_dev->counters[i];
+   counter->counter_dev = counter_dev;
+   spin_lock_init(&counter->lock);
+   }
+   counter_dev->num_counters = num_counters;
+
+   return counter_dev;
+}
+EXPORT_SYMBOL_GPL(ni_gpct_device_construct);
+
+void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev)
+{
+   if (!counter_dev->counters)
+   return;
+   kfree(counter_dev->counters);
+   kfree(counter_dev);
+}
+EXPORT_SYMBOL_GPL(ni_gpct_device_destroy);
+
 static int __init ni_tio_init_module(void)
 {
return 0;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/40] staging: comedi: ni_tio: fix ni_tio_insn_read()

2014-07-24 Thread H Hartley Sweeten
The comedi core expects the (*insn_read) operations to read insn->n
values and return the number of values read.

Fix this function to work line the core expects.

For aesthetics, factor out the code that reads the SM_Save_Reg.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 80 +++--
 1 file changed, 47 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 694bd51..da66023 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1512,6 +1512,38 @@ int ni_tio_insn_config(struct comedi_device *dev,
 }
 EXPORT_SYMBOL_GPL(ni_tio_insn_config);
 
+static unsigned int ni_tio_read_sw_save_reg(struct comedi_device *dev,
+   struct comedi_subdevice *s)
+{
+   struct ni_gpct *counter = s->private;
+   unsigned cidx = counter->counter_index;
+   unsigned int first_read;
+   unsigned int second_read;
+   unsigned int correct_read;
+
+   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), Gi_Save_Trace_Bit, 0);
+   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx),
+   Gi_Save_Trace_Bit, Gi_Save_Trace_Bit);
+
+   /*
+* The count doesn't get latched until the next clock edge, so it is
+* possible the count may change (once) while we are reading. Since
+* the read of the SW_Save_Reg isn't atomic (apparently even when it's
+* a 32 bit register according to 660x docs), we need to read twice
+* and make sure the reading hasn't changed. If it has, a third read
+* will be correct since the count value will definitely have latched
+* by then.
+*/
+   first_read = read_register(counter, NITIO_SW_SAVE_REG(cidx));
+   second_read = read_register(counter, NITIO_SW_SAVE_REG(cidx));
+   if (first_read != second_read)
+   correct_read = read_register(counter, NITIO_SW_SAVE_REG(cidx));
+   else
+   correct_read = first_read;
+
+   return correct_read;
+}
+
 int ni_tio_insn_read(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
@@ -1519,42 +1551,24 @@ int ni_tio_insn_read(struct comedi_device *dev,
 {
struct ni_gpct *counter = s->private;
struct ni_gpct_device *counter_dev = counter->counter_dev;
-   const unsigned channel = CR_CHAN(insn->chanspec);
+   unsigned int channel = CR_CHAN(insn->chanspec);
unsigned cidx = counter->counter_index;
-   unsigned first_read;
-   unsigned second_read;
-   unsigned correct_read;
+   int i;
 
-   if (insn->n < 1)
-   return 0;
-   switch (channel) {
-   case 0:
-   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx),
-   Gi_Save_Trace_Bit, 0);
-   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx),
-   Gi_Save_Trace_Bit, Gi_Save_Trace_Bit);
-   /* The count doesn't get latched until the next clock edge, so 
it is possible the count
-  may change (once) while we are reading.  Since the read of 
the SW_Save_Reg isn't
-  atomic (apparently even when it's a 32 bit register 
according to 660x docs),
-  we need to read twice and make sure the reading hasn't 
changed.  If it has,
-  a third read will be correct since the count value will 
definitely have latched by then. */
-   first_read = read_register(counter, NITIO_SW_SAVE_REG(cidx));
-   second_read = read_register(counter, NITIO_SW_SAVE_REG(cidx));
-   if (first_read != second_read)
-   correct_read =
-   read_register(counter, NITIO_SW_SAVE_REG(cidx));
-   else
-   correct_read = first_read;
-   data[0] = correct_read;
-   return 0;
-   case 1:
-   data[0] = counter_dev->regs[NITIO_LOADA_REG(cidx)];
-   break;
-   case 2:
-   data[0] = counter_dev->regs[NITIO_LOADB_REG(cidx)];
-   break;
+   for (i = 0; i < insn->n; i++) {
+   switch (channel) {
+   case 0:
+   data[i] = ni_tio_read_sw_save_reg(dev, s);
+   break;
+   case 1:
+   data[i] = counter_dev->regs[NITIO_LOADA_REG(cidx)];
+   break;
+   case 2:
+   data[i] = counter_dev->regs[NITIO_LOADB_REG(cidx)];
+   break;
+   }
}
-   return 0;
+   return insn->n;
 }
 EXPORT_SYMBOL_GPL(ni_tio_insn_read);
 
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.

[PATCH 06/40] staging: comedi: ni_tio: tidy up ni_m_series_set_first_gate()

2014-07-24 Thread H Hartley Sweeten
Rename some of the local vars and tidy up this function to fix to
fix a couple > 80 char line issues.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index d610902..fa1ca45 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1002,14 +1002,12 @@ static int ni_660x_set_first_gate(struct ni_gpct 
*counter,
 static int ni_m_series_set_first_gate(struct ni_gpct *counter,
  unsigned int gate_source)
 {
-   const unsigned selected_gate = CR_CHAN(gate_source);
+   unsigned int chan = CR_CHAN(gate_source);
unsigned cidx = counter->counter_index;
-   /* bits of selected_gate that may be meaningful to input select 
register */
-   const unsigned selected_gate_mask = 0x1f;
-   unsigned ni_m_series_gate_select;
+   unsigned gate_sel;
unsigned i;
 
-   switch (selected_gate) {
+   switch (chan) {
case NI_GPCT_TIMESTAMP_MUX_GATE_SELECT:
case NI_GPCT_AI_START2_GATE_SELECT:
case NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT:
@@ -1018,22 +1016,20 @@ static int ni_m_series_set_first_gate(struct ni_gpct 
*counter,
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
case NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT:
case NI_GPCT_LOGIC_LOW_GATE_SELECT:
-   ni_m_series_gate_select = selected_gate & selected_gate_mask;
+   gate_sel = chan & 0x1f;
break;
default:
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
-   if (selected_gate == NI_GPCT_RTSI_GATE_SELECT(i)) {
-   ni_m_series_gate_select =
-   selected_gate & selected_gate_mask;
+   if (chan == NI_GPCT_RTSI_GATE_SELECT(i)) {
+   gate_sel = chan & 0x1f;
break;
}
}
if (i <= ni_m_series_max_rtsi_channel)
break;
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
-   if (selected_gate == NI_GPCT_PFI_GATE_SELECT(i)) {
-   ni_m_series_gate_select =
-   selected_gate & selected_gate_mask;
+   if (chan == NI_GPCT_PFI_GATE_SELECT(i)) {
+   gate_sel = chan & 0x1f;
break;
}
}
@@ -1042,8 +1038,7 @@ static int ni_m_series_set_first_gate(struct ni_gpct 
*counter,
return -EINVAL;
}
ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx),
-   Gi_Gate_Select_Mask,
-   Gi_Gate_Select_Bits(ni_m_series_gate_select));
+   Gi_Gate_Select_Mask, Gi_Gate_Select_Bits(gate_sel));
return 0;
 }
 
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/40] staging: comedi: ni_tio: remove counter_status_mask

2014-07-24 Thread H Hartley Sweeten
For aesthetics, remove this global static const varaible.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 9b5ab0b..6da4ab5 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -189,9 +189,6 @@ enum ni_660x_second_gate_select {
 #define NI_660X_UD_PIN_GATE2_SEL(x)(0x2 + (x))
 #define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
 
-static const unsigned int counter_status_mask =
-   COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
-
 struct ni_gpct_device *
 ni_gpct_device_construct(struct comedi_device *dev,
 void (*write_register)(struct ni_gpct *counter,
@@ -1387,7 +1384,7 @@ int ni_tio_insn_config(struct comedi_device *dev,
return 0;
case INSN_CONFIG_GET_COUNTER_STATUS:
data[1] = ni_tio_counter_status(counter);
-   data[2] = counter_status_mask;
+   data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
return 0;
case INSN_CONFIG_SET_CLOCK_SRC:
return ni_tio_set_clock_src(counter, data[1], data[2]);
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 37/40] staging: comedi: ni_tio: tidy up ni_tio_get_clock_src()

2014-07-24 Thread H Hartley Sweeten
Remove the static const local variable and add a blank line after
the declarations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 33ffd17..2f7e841 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -768,11 +768,11 @@ static void ni_tio_get_clock_src(struct ni_gpct *counter,
 unsigned int *clock_source,
 unsigned int *period_ns)
 {
-   static const unsigned pico_per_nano = 1000;
uint64_t temp64;
+
*clock_source = ni_tio_generic_clock_src_select(counter);
temp64 = ni_tio_clock_period_ps(counter, *clock_source);
-   do_div(temp64, pico_per_nano);
+   do_div(temp64, 1000);   /* ps to ns */
*period_ns = temp64;
 }
 
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 21/40] staging: comedi: ni_tio: tidy up enum ni_m_series_gate_select

2014-07-24 Thread H Hartley Sweeten
These values are not used as an enum. For aesthetics, rename the
CamelCase values and convert them into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 37 -
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 6ef64a6..62a5cab 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -154,18 +154,17 @@ enum ni_660x_gate_select {
 #define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
 #define NI_660X_RTSI_GATE_SEL(x)   (0xb + (x))
 
-enum ni_m_series_gate_select {
-   NI_M_Series_Timestamp_Mux_Gate_Select = 0x0,
-   NI_M_Series_AI_START2_Gate_Select = 0x12,
-   NI_M_Series_PXI_Star_Trigger_Gate_Select = 0x13,
-   NI_M_Series_Next_Out_Gate_Select = 0x14,
-   NI_M_Series_AI_START1_Gate_Select = 0x1c,
-   NI_M_Series_Next_SRC_Gate_Select = 0x1d,
-   NI_M_Series_Analog_Trigger_Out_Gate_Select = 0x1e,
-   NI_M_Series_Logic_Low_Gate_Select = 0x1f,
-};
-#define NI_M_RTSI_GATE_SEL(x)  (((x) == 7) ? 0x1b : (0xb + (x)))
+/* NI M SERIES gate_select */
+#define NI_M_TIMESTAMP_MUX_GATE_SEL0x0
 #define NI_M_PFI_GATE_SEL(x)   (((x) < 10) ? (1 + (x)) : (0xb + (x)))
+#define NI_M_RTSI_GATE_SEL(x)  (((x) == 7) ? 0x1b : (0xb + (x)))
+#define NI_M_AI_START2_GATE_SEL0x12
+#define NI_M_PXI_STAR_TRIGGER_GATE_SEL 0x13
+#define NI_M_NEXT_OUT_GATE_SEL 0x14
+#define NI_M_AI_START1_GATE_SEL0x1c
+#define NI_M_NEXT_SRC_GATE_SEL 0x1d
+#define NI_M_ANALOG_TRIG_OUT_GATE_SEL  0x1e
+#define NI_M_LOGIC_LOW_GATE_SEL0x1f
 
 static inline unsigned Gi_Source_Select_Bits(unsigned source)
 {
@@ -1199,21 +1198,21 @@ ni_m_series_first_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
unsigned i;
 
switch (ni_m_series_gate_select) {
-   case NI_M_Series_Timestamp_Mux_Gate_Select:
+   case NI_M_TIMESTAMP_MUX_GATE_SEL:
return NI_GPCT_TIMESTAMP_MUX_GATE_SELECT;
-   case NI_M_Series_AI_START2_Gate_Select:
+   case NI_M_AI_START2_GATE_SEL:
return NI_GPCT_AI_START2_GATE_SELECT;
-   case NI_M_Series_PXI_Star_Trigger_Gate_Select:
+   case NI_M_PXI_STAR_TRIGGER_GATE_SEL:
return NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT;
-   case NI_M_Series_Next_Out_Gate_Select:
+   case NI_M_NEXT_OUT_GATE_SEL:
return NI_GPCT_NEXT_OUT_GATE_SELECT;
-   case NI_M_Series_AI_START1_Gate_Select:
+   case NI_M_AI_START1_GATE_SEL:
return NI_GPCT_AI_START1_GATE_SELECT;
-   case NI_M_Series_Next_SRC_Gate_Select:
+   case NI_M_NEXT_SRC_GATE_SEL:
return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-   case NI_M_Series_Analog_Trigger_Out_Gate_Select:
+   case NI_M_ANALOG_TRIG_OUT_GATE_SEL:
return NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT;
-   case NI_M_Series_Logic_Low_Gate_Select:
+   case NI_M_LOGIC_LOW_GATE_SEL:
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) {
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 39/40] staging: comedi: ni_tio: remove forward declarations

2014-07-24 Thread H Hartley Sweeten
Move some of the functions to remove the need for the forward
declarations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 392 
 1 file changed, 194 insertions(+), 198 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index ebfc724..0367482 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -116,10 +116,6 @@ TODO:
 #define NI_660X_LOGIC_LOW_GATE2_SEL0x1f
 #define NI_660X_MAX_UP_DOWN_PIN7
 
-static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
-  unsigned generic_clock_source);
-static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter);
-
 static inline enum Gi_Counting_Mode_Reg_Bits
 Gi_Alternate_Sync_Bit(enum ni_gpct_variant variant)
 {
@@ -205,6 +201,200 @@ static void ni_tio_reset_count_and_disarm(struct ni_gpct 
*counter)
write_register(counter, Gi_Reset_Bit(cidx), NITIO_RESET_REG(cidx));
 }
 
+static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
+  unsigned generic_clock_source)
+{
+   uint64_t clock_period_ps;
+
+   switch (generic_clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK) {
+   case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
+   clock_period_ps = 5;
+   break;
+   case NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS:
+   clock_period_ps = 1000;
+   break;
+   case NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS:
+   clock_period_ps = 12500;
+   break;
+   case NI_GPCT_PXI10_CLOCK_SRC_BITS:
+   clock_period_ps = 10;
+   break;
+   default:
+   /*
+* clock period is specified by user with prescaling
+* already taken into account.
+*/
+   return counter->clock_period_ps;
+   }
+
+   switch (generic_clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK) {
+   case NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS:
+   break;
+   case NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS:
+   clock_period_ps *= 2;
+   break;
+   case NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS:
+   clock_period_ps *= 8;
+   break;
+   default:
+   BUG();
+   break;
+   }
+   return clock_period_ps;
+}
+
+static unsigned ni_tio_clock_src_modifiers(const struct ni_gpct *counter)
+{
+   struct ni_gpct_device *counter_dev = counter->counter_dev;
+   unsigned cidx = counter->counter_index;
+   const unsigned counting_mode_bits =
+   ni_tio_get_soft_copy(counter, NITIO_CNT_MODE_REG(cidx));
+   unsigned bits = 0;
+
+   if (ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx)) &
+   Gi_Source_Polarity_Bit)
+   bits |= NI_GPCT_INVERT_CLOCK_SRC_BIT;
+   if (counting_mode_bits & Gi_Prescale_X2_Bit(counter_dev->variant))
+   bits |= NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS;
+   if (counting_mode_bits & Gi_Prescale_X8_Bit(counter_dev->variant))
+   bits |= NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS;
+   return bits;
+}
+
+static unsigned ni_m_series_clock_src_select(const struct ni_gpct *counter)
+{
+   struct ni_gpct_device *counter_dev = counter->counter_dev;
+   unsigned cidx = counter->counter_index;
+   const unsigned second_gate_reg = NITIO_GATE2_REG(cidx);
+   unsigned clock_source = 0;
+   unsigned i;
+   const unsigned input_select =
+   (ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx)) &
+   Gi_Source_Select_Mask) >> Gi_Source_Select_Shift;
+
+   switch (input_select) {
+   case NI_M_TIMEBASE_1_CLK:
+   clock_source = NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS;
+   break;
+   case NI_M_TIMEBASE_2_CLK:
+   clock_source = NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS;
+   break;
+   case NI_M_TIMEBASE_3_CLK:
+   if (counter_dev->regs[second_gate_reg] &
+   Gi_Source_Subselect_Bit)
+   clock_source =
+   NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS;
+   else
+   clock_source = NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS;
+   break;
+   case NI_M_LOGIC_LOW_CLK:
+   clock_source = NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS;
+   break;
+   case NI_M_NEXT_GATE_CLK:
+   if (counter_dev->regs[second_gate_reg] &
+   Gi_Source_Subselect_Bit)
+   clock_source = NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS;
+   else
+   clock_source = NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS;
+   break;
+   case NI_M_PXI10_CLK:
+   clock_source = NI

[PATCH 20/40] staging: comedi: ni_tio: tidy up enum ni_660x_second_gate_select

2014-07-24 Thread H Hartley Sweeten
These values are not used as an enum. For aesthetics, rename the
CamelCase values and convert them into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 6da4ab5..6ef64a6 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -177,17 +177,16 @@ static inline unsigned Gi_Gate_Select_Bits(unsigned 
gate_select)
return (gate_select << Gi_Gate_Select_Shift) & Gi_Gate_Select_Mask;
 }
 
-enum ni_660x_second_gate_select {
-   NI_660x_Source_Pin_i_Second_Gate_Select = 0x0,
-   NI_660x_Up_Down_Pin_i_Second_Gate_Select = 0x1,
-   NI_660x_Next_SRC_Second_Gate_Select = 0xa,
-   NI_660x_Next_Out_Second_Gate_Select = 0x14,
-   NI_660x_Selected_Gate_Second_Gate_Select = 0x1e,
-   NI_660x_Logic_Low_Second_Gate_Select = 0x1f,
-};
-#define NI_660X_MAX_UP_DOWN_PIN7
+/* NI660X second gate select */
+#define NI_660X_SRC_PIN_I_GATE2_SEL0x0
+#define NI_660X_UD_PIN_I_GATE2_SEL 0x1
 #define NI_660X_UD_PIN_GATE2_SEL(x)(0x2 + (x))
+#define NI_660X_NEXT_SRC_GATE2_SEL 0xa
 #define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
+#define NI_660X_NEXT_OUT_GATE2_SEL 0x14
+#define NI_660X_SELECTED_GATE2_SEL 0x1e
+#define NI_660X_LOGIC_LOW_GATE2_SEL0x1f
+#define NI_660X_MAX_UP_DOWN_PIN7
 
 struct ni_gpct_device *
 ni_gpct_device_construct(struct comedi_device *dev,
@@ -1004,7 +1003,7 @@ static int ni_660x_set_second_gate(struct ni_gpct 
*counter,
gate2_sel = chan & 0x1f;
break;
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
-   gate2_sel = NI_660x_Next_SRC_Second_Gate_Select;
+   gate2_sel = NI_660X_NEXT_SRC_GATE2_SEL;
break;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
@@ -1241,17 +1240,17 @@ ni_660x_second_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
unsigned i;
 
switch (ni_660x_gate_select) {
-   case NI_660x_Source_Pin_i_Second_Gate_Select:
+   case NI_660X_SRC_PIN_I_GATE2_SEL:
return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
-   case NI_660x_Up_Down_Pin_i_Second_Gate_Select:
+   case NI_660X_UD_PIN_I_GATE2_SEL:
return NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT;
-   case NI_660x_Next_SRC_Second_Gate_Select:
+   case NI_660X_NEXT_SRC_GATE2_SEL:
return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-   case NI_660x_Next_Out_Second_Gate_Select:
+   case NI_660X_NEXT_OUT_GATE2_SEL:
return NI_GPCT_NEXT_OUT_GATE_SELECT;
-   case NI_660x_Selected_Gate_Second_Gate_Select:
+   case NI_660X_SELECTED_GATE2_SEL:
return NI_GPCT_SELECTED_GATE_GATE_SELECT;
-   case NI_660x_Logic_Low_Second_Gate_Select:
+   case NI_660X_LOGIC_LOW_GATE2_SEL:
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 34/40] staging: comedi: ni_tio: tidy up ni_tio_set_other_src()

2014-07-24 Thread H Hartley Sweeten
Invert the counter_dev->variant test to reduce the indent level of
this function.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 50 -
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index a149a73..1982a25 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1022,35 +1022,33 @@ static int ni_tio_set_other_src(struct ni_gpct 
*counter, unsigned index,
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
+   unsigned int abz_reg, shift, mask;
 
-   if (counter_dev->variant == ni_gpct_variant_m_series) {
-   unsigned int abz_reg, shift, mask;
+   if (counter_dev->variant != ni_gpct_variant_m_series)
+   return -EINVAL;
 
-   abz_reg = NITIO_ABZ_REG(cidx);
-   switch (index) {
-   case NI_GPCT_SOURCE_ENCODER_A:
-   shift = 10;
-   break;
-   case NI_GPCT_SOURCE_ENCODER_B:
-   shift = 5;
-   break;
-   case NI_GPCT_SOURCE_ENCODER_Z:
-   shift = 0;
-   break;
-   default:
-   return -EINVAL;
-   }
-   mask = 0x1f << shift;
-   if (source > 0x1f) {
-   /* Disable gate */
-   source = 0x1f;
-   }
-   counter_dev->regs[abz_reg] &= ~mask;
-   counter_dev->regs[abz_reg] |= (source << shift) & mask;
-   write_register(counter, counter_dev->regs[abz_reg], abz_reg);
-   return 0;
+   abz_reg = NITIO_ABZ_REG(cidx);
+   switch (index) {
+   case NI_GPCT_SOURCE_ENCODER_A:
+   shift = 10;
+   break;
+   case NI_GPCT_SOURCE_ENCODER_B:
+   shift = 5;
+   break;
+   case NI_GPCT_SOURCE_ENCODER_Z:
+   shift = 0;
+   break;
+   default:
+   return -EINVAL;
}
-   return -EINVAL;
+   mask = 0x1f << shift;
+   if (source > 0x1f)
+   source = 0x1f;  /* Disable gate */
+
+   counter_dev->regs[abz_reg] &= ~mask;
+   counter_dev->regs[abz_reg] |= (source << shift) & mask;
+   write_register(counter, counter_dev->regs[abz_reg], abz_reg);
+   return 0;
 }
 
 static unsigned ni_660x_gate_to_generic_gate(unsigned gate)
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/40] staging: comedi: ni_tio: convert NI_M_Series_PFI_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 60ec33f..ee9c853 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -173,14 +173,7 @@ enum ni_m_series_gate_select {
NI_M_Series_Logic_Low_Gate_Select = 0x1f,
 };
 #define NI_M_RTSI_GATE_SEL(x)  (((x) == 7) ? 0x1b : (0xb + (x)))
-
-static inline unsigned NI_M_Series_PFI_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_m_series_max_pfi_channel);
-   if (n < 10)
-   return 1 + n;
-   return 0xb + n;
-}
+#define NI_M_PFI_GATE_SEL(x)   (((x) < 10) ? (1 + (x)) : (0xb + (x)))
 
 static inline unsigned Gi_Source_Select_Bits(unsigned source)
 {
@@ -1251,10 +1244,8 @@ ni_m_series_first_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
if (i <= ni_m_series_max_rtsi_channel)
break;
for (i = 0; i <= ni_m_series_max_pfi_channel; ++i) {
-   if (ni_m_series_gate_select ==
-   NI_M_Series_PFI_Gate_Select(i)) {
+   if (ni_m_series_gate_select == NI_M_PFI_GATE_SEL(i))
return NI_GPCT_PFI_GATE_SELECT(i);
-   }
}
if (i <= ni_m_series_max_pfi_channel)
break;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/40] staging: comedi: ni_tio: fix > 80 char comments

2014-07-24 Thread H Hartley Sweeten
Tidy up some of the comments to fix some fo the the checkpatch.pl
warnings:

WARNING: line over 80 characters

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 44 -
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index da66023..8b56397 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -413,9 +413,11 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, 
int force_alt_sync)
default:
break;
}
-   /* It's not clear what we should do if clock_period is unknown, so we 
are not
-  using the alt sync bit in that case, but allow the caller to decide 
by using the
-  force_alt_sync parameter. */
+   /*
+* It's not clear what we should do if clock_period is unknown, so we
+* are not using the alt sync bit in that case, but allow the caller
+* to decide by using the force_alt_sync parameter.
+*/
if (force_alt_sync ||
(clock_period_ps && clock_period_ps < min_normal_sync_period_ps)) {
ni_tio_set_bits(counter, counting_mode_reg,
@@ -520,7 +522,11 @@ int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned 
start_trigger)
break;
default:
if (start_trigger & NI_GPCT_ARM_UNKNOWN) {
-   /* pass-through the least significant 
bits so we can figure out what select later */
+   /*
+* pass-through the least significant
+* bits so we can figure out what
+* select later
+*/
unsigned hw_arm_select_bits =
(start_trigger <<
 Gi_HW_Arm_Select_Shift) &
@@ -924,7 +930,10 @@ static uint64_t ni_tio_clock_period_ps(const struct 
ni_gpct *counter,
clock_period_ps = 10;
break;
default:
-   /* clock period is specified by user with prescaling already 
taken into account. */
+   /*
+* clock period is specified by user with prescaling
+* already taken into account.
+*/
return counter->clock_period_ps;
}
 
@@ -1137,8 +1146,10 @@ static int ni_m_series_set_second_gate(struct ni_gpct 
*counter,
static const unsigned selected_second_gate_mask = 0x1f;
unsigned ni_m_series_second_gate_select;
 
-   /* FIXME: We don't know what the m-series second gate codes are, so 
we'll just pass
-  the bits through for now. */
+   /*
+* FIXME: We don't know what the m-series second gate codes are,
+* so we'll just pass the bits through for now.
+*/
switch (selected_second_gate) {
default:
ni_m_series_second_gate_select =
@@ -1378,8 +1389,10 @@ static unsigned 
ni_660x_second_gate_to_generic_gate_source(unsigned
 static unsigned ni_m_series_second_gate_to_generic_gate_source(unsigned
   
ni_m_series_gate_select)
 {
-   /*FIXME: the second gate sources for the m series are undocumented, so 
we just return
-* the raw bits for now. */
+   /*
+* FIXME: the second gate sources for the m series are undocumented,
+* so we just return the raw bits for now.
+*/
switch (ni_m_series_gate_select) {
default:
return ni_m_series_gate_select;
@@ -1598,13 +1611,20 @@ int ni_tio_insn_write(struct comedi_device *dev,
return 0;
switch (channel) {
case 0:
-   /* Unsafe if counter is armed.  Should probably check status 
and return -EBUSY if armed. */
-   /* Don't disturb load source select, just use whichever load 
register is already selected. */
+   /*
+* Unsafe if counter is armed.
+* Should probably check status and return -EBUSY if armed.
+*/
+
+   /*
+* Don't disturb load source select, just use whichever
+* load register is already selected.
+*/
load_reg = ni_tio_next_load_register(counter);
write_register(counter, data[0], load_reg);
ni_tio_set_bits_transient(counter, NITIO_CMD_REG(cidx),
  0, 0, Gi_Load_Bit);
-   /* restore state of load reg to whatever the user set last set 
it to */
+   /* restore load reg */

[PATCH 33/40] staging: comedi: ni_tio: tidy up ni_tio_get_gate_src() and helpers

2014-07-24 Thread H Hartley Sweeten
Do some renaming of local vars, parameters, etc. to tidy up the ugly
line breaks to improve the readability of the code.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 90 ++---
 1 file changed, 37 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index f057848..a149a73 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1053,12 +1053,11 @@ static int ni_tio_set_other_src(struct ni_gpct 
*counter, unsigned index,
return -EINVAL;
 }
 
-static unsigned
-ni_660x_first_gate_to_generic_gate_source(unsigned ni_660x_gate_select)
+static unsigned ni_660x_gate_to_generic_gate(unsigned gate)
 {
unsigned i;
 
-   switch (ni_660x_gate_select) {
+   switch (gate) {
case NI_660X_SRC_PIN_I_GATE_SEL:
return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
case NI_660X_GATE_PIN_I_GATE_SEL:
@@ -1071,13 +1070,13 @@ ni_660x_first_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
-   if (ni_660x_gate_select == NI_660X_RTSI_GATE_SEL(i))
+   if (gate == NI_660X_RTSI_GATE_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
}
if (i <= NI_660X_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_660X_MAX_GATE_PIN; ++i) {
-   if (ni_660x_gate_select == NI_660X_PIN_GATE_SEL(i))
+   if (gate == NI_660X_PIN_GATE_SEL(i))
return NI_GPCT_GATE_PIN_GATE_SELECT(i);
}
if (i <= NI_660X_MAX_GATE_PIN)
@@ -1088,12 +1087,11 @@ ni_660x_first_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return 0;
 };
 
-static unsigned
-ni_m_series_first_gate_to_generic_gate_source(unsigned ni_m_series_gate_select)
+static unsigned ni_m_gate_to_generic_gate(unsigned gate)
 {
unsigned i;
 
-   switch (ni_m_series_gate_select) {
+   switch (gate) {
case NI_M_TIMESTAMP_MUX_GATE_SEL:
return NI_GPCT_TIMESTAMP_MUX_GATE_SELECT;
case NI_M_AI_START2_GATE_SEL:
@@ -1112,13 +1110,13 @@ ni_m_series_first_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) {
-   if (ni_m_series_gate_select == NI_M_RTSI_GATE_SEL(i))
+   if (gate == NI_M_RTSI_GATE_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
}
if (i <= NI_M_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_M_MAX_PFI_CHAN; ++i) {
-   if (ni_m_series_gate_select == NI_M_PFI_GATE_SEL(i))
+   if (gate == NI_M_PFI_GATE_SEL(i))
return NI_GPCT_PFI_GATE_SELECT(i);
}
if (i <= NI_M_MAX_PFI_CHAN)
@@ -1129,12 +1127,11 @@ ni_m_series_first_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
return 0;
 };
 
-static unsigned
-ni_660x_second_gate_to_generic_gate_source(unsigned ni_660x_gate_select)
+static unsigned ni_660x_gate2_to_generic_gate(unsigned gate)
 {
unsigned i;
 
-   switch (ni_660x_gate_select) {
+   switch (gate) {
case NI_660X_SRC_PIN_I_GATE2_SEL:
return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
case NI_660X_UD_PIN_I_GATE2_SEL:
@@ -1149,13 +1146,13 @@ ni_660x_second_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
-   if (ni_660x_gate_select == NI_660X_RTSI_GATE2_SEL(i))
+   if (gate == NI_660X_RTSI_GATE2_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
}
if (i <= NI_660X_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_660X_MAX_UP_DOWN_PIN; ++i) {
-   if (ni_660x_gate_select == NI_660X_UD_PIN_GATE2_SEL(i))
+   if (gate == NI_660X_UD_PIN_GATE2_SEL(i))
return NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i);
}
if (i <= NI_660X_MAX_UP_DOWN_PIN)
@@ -1166,16 +1163,15 @@ ni_660x_second_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
return 0;
 };
 
-static unsigned
-ni_m_series_second_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
+static unsigned ni_m_gate2_to_generic_gate(unsigned gate)
 {
/*
 * 

[PATCH 40/40] staging: comedi: ni_tio: convert printk to pr_err

2014-07-24 Thread H Hartley Sweeten
Convert the printk(KERN_ERR ...) in ni_m_clk_src() to a pr_err().

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 0367482..f9f6320 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -667,7 +667,7 @@ static unsigned ni_m_clk_src(unsigned int clock_source)
}
if (i <= NI_M_MAX_PFI_CHAN)
break;
-   printk(KERN_ERR "invalid clock source 0x%lx\n",
+   pr_err("invalid clock source 0x%lx\n",
   (unsigned long)clock_source);
BUG();
ni_m_series_clock = 0;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/40] staging: comedi: ni_tio: convert NI_M_Series_RTSI_Gate_Select() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 1fb9a5c..60ec33f 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -172,13 +172,7 @@ enum ni_m_series_gate_select {
NI_M_Series_Analog_Trigger_Out_Gate_Select = 0x1e,
NI_M_Series_Logic_Low_Gate_Select = 0x1f,
 };
-static inline unsigned NI_M_Series_RTSI_Gate_Select(unsigned n)
-{
-   BUG_ON(n > ni_m_series_max_rtsi_channel);
-   if (n == 7)
-   return 0x1b;
-   return 0xb + n;
-}
+#define NI_M_RTSI_GATE_SEL(x)  (((x) == 7) ? 0x1b : (0xb + (x)))
 
 static inline unsigned NI_M_Series_PFI_Gate_Select(unsigned n)
 {
@@ -1251,10 +1245,8 @@ ni_m_series_first_gate_to_generic_gate_source(unsigned 
ni_m_series_gate_select)
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
-   if (ni_m_series_gate_select ==
-   NI_M_Series_RTSI_Gate_Select(i)) {
+   if (ni_m_series_gate_select == NI_M_RTSI_GATE_SEL(i))
return NI_GPCT_RTSI_GATE_SELECT(i);
-   }
}
if (i <= ni_m_series_max_rtsi_channel)
break;
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 25/40] staging: comedi: ni_tio: move defines to head of file

2014-07-24 Thread H Hartley Sweeten
For aesthetics, move all the defines to the head of the file.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 131 
 1 file changed, 67 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index c187456..e49c71c 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -49,6 +49,73 @@ TODO:
 
 #include "ni_tio_internal.h"
 
+/*
+ * clock sources for ni e and m series boards,
+ * get bits with Gi_Source_Select_Bits()
+ */
+#define NI_M_TIMEBASE_1_CLK0x0 /* 20MHz */
+#define NI_M_PFI_CLK(x)(((x) < 10) ? (1 + (x)) : (0xb 
+ (x)))
+#define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
+#define NI_M_TIMEBASE_2_CLK0x12/* 100KHz */
+#define NI_M_NEXT_TC_CLK   0x13
+#define NI_M_NEXT_GATE_CLK 0x14/* Gi_Src_SubSelect=0 */
+#define NI_M_PXI_STAR_TRIGGER_CLK  0x14/* Gi_Src_SubSelect=1 */
+#define NI_M_PXI10_CLK 0x1d
+#define NI_M_TIMEBASE_3_CLK0x1e/* 80MHz, Gi_Src_SubSelect=0 */
+#define NI_M_ANALOG_TRIGGER_OUT_CLK0x1e/* Gi_Src_SubSelect=1 */
+#define NI_M_LOGIC_LOW_CLK 0x1f
+#define NI_M_MAX_PFI_CHAN  15
+#define NI_M_MAX_RTSI_CHAN 7
+
+/*
+ * clock sources for ni_660x boards,
+ * get bits with Gi_Source_Select_Bits()
+ */
+#define NI_660X_TIMEBASE_1_CLK 0x0 /* 20MHz */
+#define NI_660X_SRC_PIN_I_CLK  0x1
+#define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
+#define NI_660X_NEXT_GATE_CLK  0xa
+#define NI_660X_RTSI_CLK(x)(0xb + (x))
+#define NI_660X_TIMEBASE_2_CLK 0x12/* 100KHz */
+#define NI_660X_NEXT_TC_CLK0x13
+#define NI_660X_TIMEBASE_3_CLK 0x1e/* 80MHz */
+#define NI_660X_LOGIC_LOW_CLK  0x1f
+#define NI_660X_MAX_SRC_PIN7
+#define NI_660X_MAX_RTSI_CHAN  6
+
+/* ni m series gate_select */
+#define NI_M_TIMESTAMP_MUX_GATE_SEL0x0
+#define NI_M_PFI_GATE_SEL(x)   (((x) < 10) ? (1 + (x)) : (0xb + (x)))
+#define NI_M_RTSI_GATE_SEL(x)  (((x) == 7) ? 0x1b : (0xb + (x)))
+#define NI_M_AI_START2_GATE_SEL0x12
+#define NI_M_PXI_STAR_TRIGGER_GATE_SEL 0x13
+#define NI_M_NEXT_OUT_GATE_SEL 0x14
+#define NI_M_AI_START1_GATE_SEL0x1c
+#define NI_M_NEXT_SRC_GATE_SEL 0x1d
+#define NI_M_ANALOG_TRIG_OUT_GATE_SEL  0x1e
+#define NI_M_LOGIC_LOW_GATE_SEL0x1f
+
+/* ni_660x gate select */
+#define NI_660X_SRC_PIN_I_GATE_SEL 0x0
+#define NI_660X_GATE_PIN_I_GATE_SEL0x1
+#define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
+#define NI_660X_NEXT_SRC_GATE_SEL  0xa
+#define NI_660X_RTSI_GATE_SEL(x)   (0xb + (x))
+#define NI_660X_NEXT_OUT_GATE_SEL  0x14
+#define NI_660X_LOGIC_LOW_GATE_SEL 0x1f
+#define NI_660X_MAX_GATE_PIN   7
+
+/* ni_660x second gate select */
+#define NI_660X_SRC_PIN_I_GATE2_SEL0x0
+#define NI_660X_UD_PIN_I_GATE2_SEL 0x1
+#define NI_660X_UD_PIN_GATE2_SEL(x)(0x2 + (x))
+#define NI_660X_NEXT_SRC_GATE2_SEL 0xa
+#define NI_660X_RTSI_GATE2_SEL(x)  (0xb + (x))
+#define NI_660X_NEXT_OUT_GATE2_SEL 0x14
+#define NI_660X_SELECTED_GATE2_SEL 0x1e
+#define NI_660X_LOGIC_LOW_GATE2_SEL0x1f
+#define NI_660X_MAX_UP_DOWN_PIN7
+
 static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
   unsigned generic_clock_source);
 static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter);
@@ -109,59 +176,6 @@ Gi_HW_Arm_Select_Mask(enum ni_gpct_variant variant)
}
 }
 
-/* clock sources for ni_660x boards, get bits with Gi_Source_Select_Bits() */
-#define NI_660X_TIMEBASE_1_CLK 0x0 /* 20MHz */
-#define NI_660X_SRC_PIN_I_CLK  0x1
-#define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
-#define NI_660X_NEXT_GATE_CLK  0xa
-#define NI_660X_RTSI_CLK(x)(0xb + (x))
-#define NI_660X_TIMEBASE_2_CLK 0x12/* 100KHz */
-#define NI_660X_NEXT_TC_CLK0x13
-#define NI_660X_TIMEBASE_3_CLK 0x1e/* 80MHz */
-#define NI_660X_LOGIC_LOW_CLK  0x1f
-#define NI_660X_MAX_SRC_PIN7
-#define NI_660X_MAX_RTSI_CHAN  6
-
-/*
- * clock sources for ni e and m series boards,
- * get bits with Gi_Source_Select_Bits()
- */
-#define NI_M_TIMEBASE_1_CLK0x0 /* 20MHz */
-#define NI_M_PFI_CLK(x)(((x) < 10) ? (1 + (x)) : (0xb 
+ (x)))
-#define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
-#define NI_M_TIMEBASE_2_CLK0x12/* 100KHz */
-#define NI_M_NEXT_TC_CLK   0x13
-#define NI_M_NEXT_GATE_CLK 0x14/* Gi_Src_SubSelect=0 */
-#define NI_M_PXI_STAR_TRIGGER_CLK

[PATCH 07/40] staging: comedi: ni_tio: tidy up ni_660x_set_first_gate()

2014-07-24 Thread H Hartley Sweeten
Rename some of the local vars and tidy up this function to fix to
fix a couple > 80 char line issues.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index fa1ca45..e613353 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -955,37 +955,33 @@ static void ni_tio_set_first_gate_modifiers(struct 
ni_gpct *counter,
 static int ni_660x_set_first_gate(struct ni_gpct *counter,
  unsigned int gate_source)
 {
-   const unsigned selected_gate = CR_CHAN(gate_source);
+   unsigned int chan = CR_CHAN(gate_source);
unsigned cidx = counter->counter_index;
-   /* bits of selected_gate that may be meaningful to input select 
register */
-   const unsigned selected_gate_mask = 0x1f;
-   unsigned ni_660x_gate_select;
+   unsigned gate_sel;
unsigned i;
 
-   switch (selected_gate) {
+   switch (chan) {
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
-   ni_660x_gate_select = NI_660x_Next_SRC_Gate_Select;
+   gate_sel = NI_660x_Next_SRC_Gate_Select;
break;
case NI_GPCT_NEXT_OUT_GATE_SELECT:
case NI_GPCT_LOGIC_LOW_GATE_SELECT:
case NI_GPCT_SOURCE_PIN_i_GATE_SELECT:
case NI_GPCT_GATE_PIN_i_GATE_SELECT:
-   ni_660x_gate_select = selected_gate & selected_gate_mask;
+   gate_sel = chan & 0x1f;
break;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-   if (selected_gate == NI_GPCT_RTSI_GATE_SELECT(i)) {
-   ni_660x_gate_select =
-   selected_gate & selected_gate_mask;
+   if (chan == NI_GPCT_RTSI_GATE_SELECT(i)) {
+   gate_sel = chan & 0x1f;
break;
}
}
if (i <= ni_660x_max_rtsi_channel)
break;
for (i = 0; i <= ni_660x_max_gate_pin; ++i) {
-   if (selected_gate == NI_GPCT_GATE_PIN_GATE_SELECT(i)) {
-   ni_660x_gate_select =
-   selected_gate & selected_gate_mask;
+   if (chan == NI_GPCT_GATE_PIN_GATE_SELECT(i)) {
+   gate_sel = chan & 0x1f;
break;
}
}
@@ -994,8 +990,7 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter,
return -EINVAL;
}
ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx),
-   Gi_Gate_Select_Mask,
-   Gi_Gate_Select_Bits(ni_660x_gate_select));
+   Gi_Gate_Select_Mask, Gi_Gate_Select_Bits(gate_sel));
return 0;
 }
 
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 30/40] staging: comedi: ni_tio: tidy up ni_660x_source_select_bits()

2014-07-24 Thread H Hartley Sweeten
Rename a local variable to fix the > 80 char line issues.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 404a14f..55485c2 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -388,12 +388,11 @@ EXPORT_SYMBOL_GPL(ni_tio_arm);
 
 static unsigned ni_660x_source_select_bits(unsigned int clock_source)
 {
+   unsigned clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
unsigned ni_660x_clock;
unsigned i;
-   const unsigned clock_select_bits =
-   clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
 
-   switch (clock_select_bits) {
+   switch (clk_src) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
ni_660x_clock = NI_660X_TIMEBASE_1_CLK;
break;
@@ -417,7 +416,7 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
break;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
-   if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
+   if (clk_src == NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
ni_660x_clock = NI_660X_RTSI_CLK(i);
break;
}
@@ -425,8 +424,7 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
if (i <= NI_660X_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_660X_MAX_SRC_PIN; ++i) {
-   if (clock_select_bits ==
-   NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
+   if (clk_src == NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i)) {
ni_660x_clock = NI_660X_SRC_PIN_CLK(i);
break;
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/40] staging: comedi: ni_tio: convert NI_M_Series_RTSI_Clock() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index e613353..e1d7d4e 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -154,12 +154,7 @@ static inline unsigned NI_M_Series_PFI_Clock(unsigned n)
 }
 
 static const unsigned ni_m_series_max_rtsi_channel = 7;
-static inline unsigned NI_M_Series_RTSI_Clock(unsigned n)
-{
-   BUG_ON(n > ni_m_series_max_rtsi_channel);
-
-   return (n == 7) ? 0x1b : (0xb + n);
-}
+#define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
 
 enum ni_660x_gate_select {
NI_660x_Source_Pin_i_Gate_Select = 0x0,
@@ -622,7 +617,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int 
clock_source)
default:
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
-   ni_m_series_clock = NI_M_Series_RTSI_Clock(i);
+   ni_m_series_clock = NI_M_RTSI_CLK(i);
break;
}
}
@@ -791,7 +786,7 @@ static unsigned ni_m_series_clock_src_select(const struct 
ni_gpct *counter)
break;
default:
for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
-   if (input_select == NI_M_Series_RTSI_Clock(i)) {
+   if (input_select == NI_M_RTSI_CLK(i)) {
clock_source = NI_GPCT_RTSI_CLOCK_SRC_BITS(i);
break;
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/40] staging: comedi: ni_tio: remove unnecessary ni_gpct_variant BUG() cases

2014-07-24 Thread H Hartley Sweeten
The enum ni_gpct_variant is used to handle hardware variations in the
gpct timers handled by this driver. This enum is defined as:

enum ni_gpct_variant {
ni_gpct_variant_e_series,
ni_gpct_variant_m_series,
ni_gpct_variant_660x
};

For all the switch statements where all three enum values are handled,
remove the unreachable BUG(). Move the default case so it is handled
the same as ni_gpct_variant_e_series.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 46 +++--
 1 file changed, 10 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 49ffb50..c876273 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -58,16 +58,13 @@ Gi_Alternate_Sync_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
+   default:
return 0;
case ni_gpct_variant_m_series:
return Gi_M_Series_Alternate_Sync_Bit;
case ni_gpct_variant_660x:
return Gi_660x_Alternate_Sync_Bit;
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -75,16 +72,13 @@ Gi_Prescale_X2_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
+   default:
return 0;
case ni_gpct_variant_m_series:
return Gi_M_Series_Prescale_X2_Bit;
case ni_gpct_variant_660x:
return Gi_660x_Prescale_X2_Bit;
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -92,16 +86,13 @@ Gi_Prescale_X8_Bit(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
+   default:
return 0;
case ni_gpct_variant_m_series:
return Gi_M_Series_Prescale_X8_Bit;
case ni_gpct_variant_660x:
return Gi_660x_Prescale_X8_Bit;
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -109,16 +100,13 @@ Gi_HW_Arm_Select_Mask(enum ni_gpct_variant variant)
 {
switch (variant) {
case ni_gpct_variant_e_series:
+   default:
return 0;
case ni_gpct_variant_m_series:
return Gi_M_Series_HW_Arm_Select_Mask;
case ni_gpct_variant_660x:
return Gi_660x_HW_Arm_Select_Mask;
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 /* clock sources for ni_660x boards, get bits with Gi_Source_Select_Bits() */
@@ -304,15 +292,12 @@ ni_tio_second_gate_registers_present(const struct 
ni_gpct_device *counter_dev)
 {
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
+   default:
return 0;
case ni_gpct_variant_m_series:
case ni_gpct_variant_660x:
return 1;
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter)
@@ -704,12 +689,10 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
break;
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
+   default:
input_select_bits |=
ni_m_series_source_select_bits(clock_source);
break;
-   default:
-   BUG();
-   break;
}
if (clock_source & NI_GPCT_INVERT_CLOCK_SRC_BIT)
input_select_bits |= Gi_Source_Polarity_Bit;
@@ -891,14 +874,11 @@ static unsigned ni_tio_generic_clock_src_select(const 
struct ni_gpct *counter)
switch (counter->counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
+   default:
return ni_m_series_clock_src_select(counter);
case ni_gpct_variant_660x:
return ni_660x_clock_src_select(counter);
-   default:
-   BUG();
-   break;
}
-   return 0;
 }
 
 static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
@@ -1174,12 +1154,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, 
unsigned gate_index,
switch (counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
+   default:
return ni_m_series_set_first_gate(counter, gate_source);
case ni_gpct_variant_660x:
return ni_660x_set_first_gate(counter, gate_source);
-   default:
-   BUG();
-  

[PATCH 24/40] staging: comedi: ni_tio: tidy up enum ni_660x_clock_source

2014-07-24 Thread H Hartley Sweeten
These values are not used as an enum. For aesthetics, rename the
CamelCase values and convert them into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 49 -
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 757a7a5..c187456 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -110,20 +110,17 @@ Gi_HW_Arm_Select_Mask(enum ni_gpct_variant variant)
 }
 
 /* clock sources for ni_660x boards, get bits with Gi_Source_Select_Bits() */
-enum ni_660x_clock_source {
-   NI_660x_Timebase_1_Clock = 0x0, /* 20MHz */
-   NI_660x_Source_Pin_i_Clock = 0x1,
-   NI_660x_Next_Gate_Clock = 0xa,
-   NI_660x_Timebase_2_Clock = 0x12,/* 100KHz */
-   NI_660x_Next_TC_Clock = 0x13,
-   NI_660x_Timebase_3_Clock = 0x1e,/* 80MHz */
-   NI_660x_Logic_Low_Clock = 0x1f,
-};
-#define NI_660X_MAX_RTSI_CHAN  6
+#define NI_660X_TIMEBASE_1_CLK 0x0 /* 20MHz */
+#define NI_660X_SRC_PIN_I_CLK  0x1
+#define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
+#define NI_660X_NEXT_GATE_CLK  0xa
 #define NI_660X_RTSI_CLK(x)(0xb + (x))
-
+#define NI_660X_TIMEBASE_2_CLK 0x12/* 100KHz */
+#define NI_660X_NEXT_TC_CLK0x13
+#define NI_660X_TIMEBASE_3_CLK 0x1e/* 80MHz */
+#define NI_660X_LOGIC_LOW_CLK  0x1f
 #define NI_660X_MAX_SRC_PIN7
-#define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
+#define NI_660X_MAX_RTSI_CHAN  6
 
 /*
  * clock sources for ni e and m series boards,
@@ -485,25 +482,25 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
 
switch (clock_select_bits) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Timebase_1_Clock;
+   ni_660x_clock = NI_660X_TIMEBASE_1_CLK;
break;
case NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Timebase_2_Clock;
+   ni_660x_clock = NI_660X_TIMEBASE_2_CLK;
break;
case NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Timebase_3_Clock;
+   ni_660x_clock = NI_660X_TIMEBASE_3_CLK;
break;
case NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Logic_Low_Clock;
+   ni_660x_clock = NI_660X_LOGIC_LOW_CLK;
break;
case NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Source_Pin_i_Clock;
+   ni_660x_clock = NI_660X_SRC_PIN_I_CLK;
break;
case NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Next_Gate_Clock;
+   ni_660x_clock = NI_660X_NEXT_GATE_CLK;
break;
case NI_GPCT_NEXT_TC_CLOCK_SRC_BITS:
-   ni_660x_clock = NI_660x_Next_TC_Clock;
+   ni_660x_clock = NI_660X_NEXT_TC_CLK;
break;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
@@ -768,25 +765,25 @@ static unsigned ni_660x_clock_src_select(const struct 
ni_gpct *counter)
unsigned i;
 
switch (input_select) {
-   case NI_660x_Timebase_1_Clock:
+   case NI_660X_TIMEBASE_1_CLK:
clock_source = NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS;
break;
-   case NI_660x_Timebase_2_Clock:
+   case NI_660X_TIMEBASE_2_CLK:
clock_source = NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS;
break;
-   case NI_660x_Timebase_3_Clock:
+   case NI_660X_TIMEBASE_3_CLK:
clock_source = NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS;
break;
-   case NI_660x_Logic_Low_Clock:
+   case NI_660X_LOGIC_LOW_CLK:
clock_source = NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS;
break;
-   case NI_660x_Source_Pin_i_Clock:
+   case NI_660X_SRC_PIN_I_CLK:
clock_source = NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS;
break;
-   case NI_660x_Next_Gate_Clock:
+   case NI_660X_NEXT_GATE_CLK:
clock_source = NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS;
break;
-   case NI_660x_Next_TC_Clock:
+   case NI_660X_NEXT_TC_CLK:
clock_source = NI_GPCT_NEXT_TC_CLOCK_SRC_BITS;
break;
default:
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/40] staging: comedi: ni_tio: tidy up ni_660x_set_second_gate()

2014-07-24 Thread H Hartley Sweeten
Rename some of the local vars and tidy up this function to fix to
fix a couple > 80 char line issues.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 39 -
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index c876273..d610902 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1052,43 +1052,34 @@ static int ni_660x_set_second_gate(struct ni_gpct 
*counter,
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
-   const unsigned second_gate_reg = NITIO_GATE2_REG(cidx);
-   const unsigned selected_second_gate = CR_CHAN(gate_source);
-   /* bits of second_gate that may be meaningful to second gate register */
-   static const unsigned selected_second_gate_mask = 0x1f;
-   unsigned ni_660x_second_gate_select;
+   unsigned int chan = CR_CHAN(gate_source);
+   unsigned gate2_reg = NITIO_GATE2_REG(cidx);
+   unsigned gate2_sel;
unsigned i;
 
-   switch (selected_second_gate) {
+   switch (chan) {
case NI_GPCT_SOURCE_PIN_i_GATE_SELECT:
case NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT:
case NI_GPCT_SELECTED_GATE_GATE_SELECT:
case NI_GPCT_NEXT_OUT_GATE_SELECT:
case NI_GPCT_LOGIC_LOW_GATE_SELECT:
-   ni_660x_second_gate_select =
-   selected_second_gate & selected_second_gate_mask;
+   gate2_sel = chan & 0x1f;
break;
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
-   ni_660x_second_gate_select =
-   NI_660x_Next_SRC_Second_Gate_Select;
+   gate2_sel = NI_660x_Next_SRC_Second_Gate_Select;
break;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-   if (selected_second_gate == 
NI_GPCT_RTSI_GATE_SELECT(i)) {
-   ni_660x_second_gate_select =
-   selected_second_gate &
-   selected_second_gate_mask;
+   if (chan == NI_GPCT_RTSI_GATE_SELECT(i)) {
+   gate2_sel = chan & 0x1f;
break;
}
}
if (i <= ni_660x_max_rtsi_channel)
break;
for (i = 0; i <= ni_660x_max_up_down_pin; ++i) {
-   if (selected_second_gate ==
-   NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i)) {
-   ni_660x_second_gate_select =
-   selected_second_gate &
-   selected_second_gate_mask;
+   if (chan == NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i)) {
+   gate2_sel = chan & 0x1f;
break;
}
}
@@ -1096,12 +1087,10 @@ static int ni_660x_set_second_gate(struct ni_gpct 
*counter,
break;
return -EINVAL;
}
-   counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
-   counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
-   counter_dev->regs[second_gate_reg] |=
-   Gi_Second_Gate_Select_Bits(ni_660x_second_gate_select);
-   write_register(counter, counter_dev->regs[second_gate_reg],
-  second_gate_reg);
+   counter_dev->regs[gate2_reg] |= Gi_Second_Gate_Mode_Bit;
+   counter_dev->regs[gate2_reg] &= ~Gi_Second_Gate_Select_Mask;
+   counter_dev->regs[gate2_reg] |= Gi_Second_Gate_Select_Bits(gate2_sel);
+   write_register(counter, counter_dev->regs[gate2_reg], gate2_reg);
return 0;
 }
 
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/40] staging: comedi: ni_tio: convert NI_660x_RTSI_Clock() to a macro

2014-07-24 Thread H Hartley Sweeten
The BUG_ON() in this function can never happen.

For aesthetics, rename this CamelCase inline function and convert it into
a simple macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index a7cd59b..422052f 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -120,11 +120,7 @@ enum ni_660x_clock_source {
NI_660x_Logic_Low_Clock = 0x1f,
 };
 static const unsigned ni_660x_max_rtsi_channel = 6;
-static inline unsigned NI_660x_RTSI_Clock(unsigned n)
-{
-   BUG_ON(n > ni_660x_max_rtsi_channel);
-   return 0xb + n;
-}
+#define NI_660X_RTSI_CLK(x)(0xb + (x))
 
 static const unsigned ni_660x_max_source_pin = 7;
 #define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
@@ -527,7 +523,7 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
if (clock_select_bits == 
NI_GPCT_RTSI_CLOCK_SRC_BITS(i)) {
-   ni_660x_clock = NI_660x_RTSI_Clock(i);
+   ni_660x_clock = NI_660X_RTSI_CLK(i);
break;
}
}
@@ -810,7 +806,7 @@ static unsigned ni_660x_clock_src_select(const struct 
ni_gpct *counter)
break;
default:
for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-   if (input_select == NI_660x_RTSI_Clock(i)) {
+   if (input_select == NI_660X_RTSI_CLK(i)) {
clock_source = NI_GPCT_RTSI_CLOCK_SRC_BITS(i);
break;
}
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 38/40] staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers

2014-07-24 Thread H Hartley Sweeten
Do some renaming of local vars, etc. to tidy up the ugly line breaks
to improve the readability of the code.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 38 +
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 2f7e841..ebfc724 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -374,7 +374,7 @@ int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned 
start_trigger)
 }
 EXPORT_SYMBOL_GPL(ni_tio_arm);
 
-static unsigned ni_660x_source_select_bits(unsigned int clock_source)
+static unsigned ni_660x_clk_src(unsigned int clock_source)
 {
unsigned clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
unsigned ni_660x_clock;
@@ -426,7 +426,7 @@ static unsigned ni_660x_source_select_bits(unsigned int 
clock_source)
return Gi_Source_Select_Bits(ni_660x_clock);
 }
 
-static unsigned ni_m_series_source_select_bits(unsigned int clock_source)
+static unsigned ni_m_clk_src(unsigned int clock_source)
 {
unsigned clk_src = clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
unsigned ni_m_series_clock;
@@ -520,52 +520,44 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
-   unsigned input_select_bits = 0;
-   static const uint64_t pico_per_nano = 1000;
+   unsigned bits = 0;
 
-/*FIXME: validate clock source */
+   /* FIXME: validate clock source */
switch (counter_dev->variant) {
case ni_gpct_variant_660x:
-   input_select_bits |= ni_660x_source_select_bits(clock_source);
+   bits |= ni_660x_clk_src(clock_source);
break;
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
default:
-   input_select_bits |=
-   ni_m_series_source_select_bits(clock_source);
+   bits |= ni_m_clk_src(clock_source);
break;
}
if (clock_source & NI_GPCT_INVERT_CLOCK_SRC_BIT)
-   input_select_bits |= Gi_Source_Polarity_Bit;
+   bits |= Gi_Source_Polarity_Bit;
ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx),
-   Gi_Source_Select_Mask | Gi_Source_Polarity_Bit,
-   input_select_bits);
+   Gi_Source_Select_Mask | Gi_Source_Polarity_Bit, bits);
ni_tio_set_source_subselect(counter, clock_source);
-   if (ni_tio_counting_mode_registers_present(counter_dev)) {
-   const unsigned prescaling_mode =
-   clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK;
-   unsigned counting_mode_bits = 0;
 
-   switch (prescaling_mode) {
+   if (ni_tio_counting_mode_registers_present(counter_dev)) {
+   bits = 0;
+   switch (clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK) {
case NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS:
break;
case NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS:
-   counting_mode_bits |=
-   Gi_Prescale_X2_Bit(counter_dev->variant);
+   bits |= Gi_Prescale_X2_Bit(counter_dev->variant);
break;
case NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS:
-   counting_mode_bits |=
-   Gi_Prescale_X8_Bit(counter_dev->variant);
+   bits |= Gi_Prescale_X8_Bit(counter_dev->variant);
break;
default:
return -EINVAL;
}
ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx),
Gi_Prescale_X2_Bit(counter_dev->variant) |
-   Gi_Prescale_X8_Bit(counter_dev->variant),
-   counting_mode_bits);
+   Gi_Prescale_X8_Bit(counter_dev->variant), bits);
}
-   counter->clock_period_ps = pico_per_nano * period_ns;
+   counter->clock_period_ps = period_ns * 1000;
ni_tio_set_sync_mode(counter, 0);
return 0;
 }
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 23/40] staging: comedi: ni_tio: tidy up enum ni_m_series_clock_source

2014-07-24 Thread H Hartley Sweeten
These values are not used as an enum. For aesthetics, rename the
CamelCase values and convert them into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 62 -
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 39c7f50..757a7a5 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -125,23 +125,23 @@ enum ni_660x_clock_source {
 #define NI_660X_MAX_SRC_PIN7
 #define NI_660X_SRC_PIN_CLK(x) (0x2 + (x))
 
-/* clock sources for ni e and m series boards, get bits with 
Gi_Source_Select_Bits() */
-enum ni_m_series_clock_source {
-   NI_M_Series_Timebase_1_Clock = 0x0, /* 20MHz */
-   NI_M_Series_Timebase_2_Clock = 0x12,/* 100KHz */
-   NI_M_Series_Next_TC_Clock = 0x13,
-   NI_M_Series_Next_Gate_Clock = 0x14, /* when Gi_Src_SubSelect = 0 */
-   NI_M_Series_PXI_Star_Trigger_Clock = 0x14,  /* when 
Gi_Src_SubSelect = 1 */
-   NI_M_Series_PXI10_Clock = 0x1d,
-   NI_M_Series_Timebase_3_Clock = 0x1e,/* 80MHz, when Gi_Src_SubSelect 
= 0 */
-   NI_M_Series_Analog_Trigger_Out_Clock = 0x1e,/* when 
Gi_Src_SubSelect = 1 */
-   NI_M_Series_Logic_Low_Clock = 0x1f,
-};
-#define NI_M_MAX_PFI_CHAN  15
+/*
+ * clock sources for ni e and m series boards,
+ * get bits with Gi_Source_Select_Bits()
+ */
+#define NI_M_TIMEBASE_1_CLK0x0 /* 20MHz */
 #define NI_M_PFI_CLK(x)(((x) < 10) ? (1 + (x)) : (0xb 
+ (x)))
-
-#define NI_M_MAX_RTSI_CHAN 7
 #define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
+#define NI_M_TIMEBASE_2_CLK0x12/* 100KHz */
+#define NI_M_NEXT_TC_CLK   0x13
+#define NI_M_NEXT_GATE_CLK 0x14/* Gi_Src_SubSelect=0 */
+#define NI_M_PXI_STAR_TRIGGER_CLK  0x14/* Gi_Src_SubSelect=1 */
+#define NI_M_PXI10_CLK 0x1d
+#define NI_M_TIMEBASE_3_CLK0x1e/* 80MHz, Gi_Src_SubSelect=0 */
+#define NI_M_ANALOG_TRIGGER_OUT_CLK0x1e/* Gi_Src_SubSelect=1 */
+#define NI_M_LOGIC_LOW_CLK 0x1f
+#define NI_M_MAX_PFI_CHAN  15
+#define NI_M_MAX_RTSI_CHAN 7
 
 /* NI660X gate select */
 #define NI_660X_SRC_PIN_I_GATE_SEL 0x0
@@ -538,31 +538,31 @@ static unsigned ni_m_series_source_select_bits(unsigned 
int clock_source)
clock_source & NI_GPCT_CLOCK_SRC_SELECT_MASK;
switch (clock_select_bits) {
case NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Timebase_1_Clock;
+   ni_m_series_clock = NI_M_TIMEBASE_1_CLK;
break;
case NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Timebase_2_Clock;
+   ni_m_series_clock = NI_M_TIMEBASE_2_CLK;
break;
case NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Timebase_3_Clock;
+   ni_m_series_clock = NI_M_TIMEBASE_3_CLK;
break;
case NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Logic_Low_Clock;
+   ni_m_series_clock = NI_M_LOGIC_LOW_CLK;
break;
case NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Next_Gate_Clock;
+   ni_m_series_clock = NI_M_NEXT_GATE_CLK;
break;
case NI_GPCT_NEXT_TC_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Next_TC_Clock;
+   ni_m_series_clock = NI_M_NEXT_TC_CLK;
break;
case NI_GPCT_PXI10_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_PXI10_Clock;
+   ni_m_series_clock = NI_M_PXI10_CLK;
break;
case NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_PXI_Star_Trigger_Clock;
+   ni_m_series_clock = NI_M_PXI_STAR_TRIGGER_CLK;
break;
case NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS:
-   ni_m_series_clock = NI_M_Series_Analog_Trigger_Out_Clock;
+   ni_m_series_clock = NI_M_ANALOG_TRIGGER_OUT_CLK;
break;
default:
for (i = 0; i <= NI_M_MAX_RTSI_CHAN; ++i) {
@@ -704,13 +704,13 @@ static unsigned ni_m_series_clock_src_select(const struct 
ni_gpct *counter)
Gi_Source_Select_Mask) >> Gi_Source_Select_Shift;
 
switch (input_select) {
-   case NI_M_Series_Timebase_1_Clock:
+   case NI_M_TIMEBASE_1_CLK:
clock_source = NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS;
break;
-   case NI_M_Series_Timebase_2_Clock:
+   case NI_M_TIMEBASE_2_CLK:
clock_source = NI_GPCT_TIMEBASE_2_CLOC

[PATCH 27/40] staging: comedi: ni_tio: tidy up ni_tio_init_counter()

2014-07-24 Thread H Hartley Sweeten
This function is called to initialize/reset a gpct counter during a
comedi drivers (*attach).

For aesthetics, move this exported function toward the end of the file.

Tidy up the functions a bit by just open coding the '0x0' values used
to initialize some of the registers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 81 -
 1 file changed, 38 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index a65b55d..0cecc60 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -206,49 +206,6 @@ static void ni_tio_reset_count_and_disarm(struct ni_gpct 
*counter)
write_register(counter, Gi_Reset_Bit(cidx), NITIO_RESET_REG(cidx));
 }
 
-void ni_tio_init_counter(struct ni_gpct *counter)
-{
-   struct ni_gpct_device *counter_dev = counter->counter_dev;
-   unsigned cidx = counter->counter_index;
-
-   ni_tio_reset_count_and_disarm(counter);
-
-   /* initialize counter registers */
-   counter_dev->regs[NITIO_AUTO_INC_REG(cidx)] = 0x0;
-   write_register(counter, counter_dev->regs[NITIO_AUTO_INC_REG(cidx)],
-  NITIO_AUTO_INC_REG(cidx));
-
-   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx),
-   ~0, Gi_Synchronize_Gate_Bit);
-
-   ni_tio_set_bits(counter, NITIO_MODE_REG(cidx), ~0, 0);
-
-   counter_dev->regs[NITIO_LOADA_REG(cidx)] = 0x0;
-   write_register(counter, counter_dev->regs[NITIO_LOADA_REG(cidx)],
-  NITIO_LOADA_REG(cidx));
-
-   counter_dev->regs[NITIO_LOADB_REG(cidx)] = 0x0;
-   write_register(counter, counter_dev->regs[NITIO_LOADB_REG(cidx)],
-  NITIO_LOADB_REG(cidx));
-
-   ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx), ~0, 0);
-
-   if (ni_tio_counting_mode_registers_present(counter_dev))
-   ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx), ~0, 0);
-
-   if (ni_tio_second_gate_registers_present(counter_dev)) {
-   counter_dev->regs[NITIO_GATE2_REG(cidx)] = 0x0;
-   write_register(counter,
-  counter_dev->regs[NITIO_GATE2_REG(cidx)],
-  NITIO_GATE2_REG(cidx));
-   }
-
-   ni_tio_set_bits(counter, NITIO_DMA_CFG_REG(cidx), ~0, 0x0);
-
-   ni_tio_set_bits(counter, NITIO_INT_ENA_REG(cidx), ~0, 0x0);
-}
-EXPORT_SYMBOL_GPL(ni_tio_init_counter);
-
 static unsigned int ni_tio_counter_status(struct ni_gpct *counter)
 {
unsigned cidx = counter->counter_index;
@@ -1475,6 +1432,44 @@ int ni_tio_insn_write(struct comedi_device *dev,
 }
 EXPORT_SYMBOL_GPL(ni_tio_insn_write);
 
+void ni_tio_init_counter(struct ni_gpct *counter)
+{
+   struct ni_gpct_device *counter_dev = counter->counter_dev;
+   unsigned cidx = counter->counter_index;
+
+   ni_tio_reset_count_and_disarm(counter);
+
+   /* initialize counter registers */
+   counter_dev->regs[NITIO_AUTO_INC_REG(cidx)] = 0x0;
+   write_register(counter, 0x0, NITIO_AUTO_INC_REG(cidx));
+
+   ni_tio_set_bits(counter, NITIO_CMD_REG(cidx),
+   ~0, Gi_Synchronize_Gate_Bit);
+
+   ni_tio_set_bits(counter, NITIO_MODE_REG(cidx), ~0, 0);
+
+   counter_dev->regs[NITIO_LOADA_REG(cidx)] = 0x0;
+   write_register(counter, 0x0, NITIO_LOADA_REG(cidx));
+
+   counter_dev->regs[NITIO_LOADB_REG(cidx)] = 0x0;
+   write_register(counter, 0x0, NITIO_LOADB_REG(cidx));
+
+   ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx), ~0, 0);
+
+   if (ni_tio_counting_mode_registers_present(counter_dev))
+   ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx), ~0, 0);
+
+   if (ni_tio_second_gate_registers_present(counter_dev)) {
+   counter_dev->regs[NITIO_GATE2_REG(cidx)] = 0x0;
+   write_register(counter, 0x0, NITIO_GATE2_REG(cidx));
+   }
+
+   ni_tio_set_bits(counter, NITIO_DMA_CFG_REG(cidx), ~0, 0x0);
+
+   ni_tio_set_bits(counter, NITIO_INT_ENA_REG(cidx), ~0, 0x0);
+}
+EXPORT_SYMBOL_GPL(ni_tio_init_counter);
+
 struct ni_gpct_device *
 ni_gpct_device_construct(struct comedi_device *dev,
 void (*write_register)(struct ni_gpct *counter,
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/40] staging: comedi: ni_tio: tidy up enum ni_660x_gate_select

2014-07-24 Thread H Hartley Sweeten
These values are not used as an enum. For aesthetics, rename the
CamelCase values and convert them into defines.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 62a5cab..39c7f50 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -143,16 +143,15 @@ enum ni_m_series_clock_source {
 #define NI_M_MAX_RTSI_CHAN 7
 #define NI_M_RTSI_CLK(x)   (((x) == 7) ? 0x1b : (0xb + (x)))
 
-enum ni_660x_gate_select {
-   NI_660x_Source_Pin_i_Gate_Select = 0x0,
-   NI_660x_Gate_Pin_i_Gate_Select = 0x1,
-   NI_660x_Next_SRC_Gate_Select = 0xa,
-   NI_660x_Next_Out_Gate_Select = 0x14,
-   NI_660x_Logic_Low_Gate_Select = 0x1f,
-};
-#define NI_660X_MAX_GATE_PIN   7
+/* NI660X gate select */
+#define NI_660X_SRC_PIN_I_GATE_SEL 0x0
+#define NI_660X_GATE_PIN_I_GATE_SEL0x1
 #define NI_660X_PIN_GATE_SEL(x)(0x2 + (x))
+#define NI_660X_NEXT_SRC_GATE_SEL  0xa
 #define NI_660X_RTSI_GATE_SEL(x)   (0xb + (x))
+#define NI_660X_NEXT_OUT_GATE_SEL  0x14
+#define NI_660X_LOGIC_LOW_GATE_SEL 0x1f
+#define NI_660X_MAX_GATE_PIN   7
 
 /* NI M SERIES gate_select */
 #define NI_M_TIMESTAMP_MUX_GATE_SEL0x0
@@ -908,7 +907,7 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter,
 
switch (chan) {
case NI_GPCT_NEXT_SOURCE_GATE_SELECT:
-   gate_sel = NI_660x_Next_SRC_Gate_Select;
+   gate_sel = NI_660X_NEXT_SRC_GATE_SEL;
break;
case NI_GPCT_NEXT_OUT_GATE_SELECT:
case NI_GPCT_LOGIC_LOW_GATE_SELECT:
@@ -1163,15 +1162,15 @@ ni_660x_first_gate_to_generic_gate_source(unsigned 
ni_660x_gate_select)
unsigned i;
 
switch (ni_660x_gate_select) {
-   case NI_660x_Source_Pin_i_Gate_Select:
+   case NI_660X_SRC_PIN_I_GATE_SEL:
return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
-   case NI_660x_Gate_Pin_i_Gate_Select:
+   case NI_660X_GATE_PIN_I_GATE_SEL:
return NI_GPCT_GATE_PIN_i_GATE_SELECT;
-   case NI_660x_Next_SRC_Gate_Select:
+   case NI_660X_NEXT_SRC_GATE_SEL:
return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-   case NI_660x_Next_Out_Gate_Select:
+   case NI_660X_NEXT_OUT_GATE_SEL:
return NI_GPCT_NEXT_OUT_GATE_SELECT;
-   case NI_660x_Logic_Low_Gate_Select:
+   case NI_660X_LOGIC_LOW_GATE_SEL:
return NI_GPCT_LOGIC_LOW_GATE_SELECT;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
-- 
1.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 35/40] staging: comedi: ni_tio: tidy up ni_tio_set_gate_src() and helpers

2014-07-24 Thread H Hartley Sweeten
Do some renaming of local vars, parameters, etc. to tidy up the ugly
line breaks to improve the readability of the code.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_tio.c | 68 ++---
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 1982a25..eb54582 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -793,8 +793,7 @@ static void ni_tio_set_first_gate_modifiers(struct ni_gpct 
*counter,
mode_mask, mode_values);
 }
 
-static int ni_660x_set_first_gate(struct ni_gpct *counter,
- unsigned int gate_source)
+static int ni_660x_set_gate(struct ni_gpct *counter, unsigned int gate_source)
 {
unsigned int chan = CR_CHAN(gate_source);
unsigned cidx = counter->counter_index;
@@ -835,8 +834,7 @@ static int ni_660x_set_first_gate(struct ni_gpct *counter,
return 0;
 }
 
-static int ni_m_series_set_first_gate(struct ni_gpct *counter,
- unsigned int gate_source)
+static int ni_m_set_gate(struct ni_gpct *counter, unsigned int gate_source)
 {
unsigned int chan = CR_CHAN(gate_source);
unsigned cidx = counter->counter_index;
@@ -878,8 +876,7 @@ static int ni_m_series_set_first_gate(struct ni_gpct 
*counter,
return 0;
 }
 
-static int ni_660x_set_second_gate(struct ni_gpct *counter,
-  unsigned int gate_source)
+static int ni_660x_set_gate2(struct ni_gpct *counter, unsigned int gate_source)
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
@@ -925,33 +922,27 @@ static int ni_660x_set_second_gate(struct ni_gpct 
*counter,
return 0;
 }
 
-static int ni_m_series_set_second_gate(struct ni_gpct *counter,
-  unsigned int gate_source)
+static int ni_m_set_gate2(struct ni_gpct *counter, unsigned int gate_source)
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
-   const unsigned second_gate_reg = NITIO_GATE2_REG(cidx);
-   const unsigned selected_second_gate = CR_CHAN(gate_source);
-   /* bits of second_gate that may be meaningful to second gate register */
-   static const unsigned selected_second_gate_mask = 0x1f;
-   unsigned ni_m_series_second_gate_select;
+   unsigned int chan = CR_CHAN(gate_source);
+   unsigned gate2_reg = NITIO_GATE2_REG(cidx);
+   unsigned gate2_sel;
 
/*
 * FIXME: We don't know what the m-series second gate codes are,
 * so we'll just pass the bits through for now.
 */
-   switch (selected_second_gate) {
+   switch (chan) {
default:
-   ni_m_series_second_gate_select =
-   selected_second_gate & selected_second_gate_mask;
+   gate2_sel = chan & 0x1f;
break;
}
-   counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
-   counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
-   counter_dev->regs[second_gate_reg] |=
-   Gi_Second_Gate_Select_Bits(ni_m_series_second_gate_select);
-   write_register(counter, counter_dev->regs[second_gate_reg],
-  second_gate_reg);
+   counter_dev->regs[gate2_reg] |= Gi_Second_Gate_Mode_Bit;
+   counter_dev->regs[gate2_reg] &= ~Gi_Second_Gate_Select_Mask;
+   counter_dev->regs[gate2_reg] |= Gi_Second_Gate_Select_Bits(gate2_sel);
+   write_register(counter, counter_dev->regs[gate2_reg], gate2_reg);
return 0;
 }
 
@@ -960,11 +951,12 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned 
gate_index,
 {
struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index;
-   const unsigned second_gate_reg = NITIO_GATE2_REG(cidx);
+   unsigned int chan = CR_CHAN(gate_source);
+   unsigned gate2_reg = NITIO_GATE2_REG(cidx);
 
switch (gate_index) {
case 0:
-   if (CR_CHAN(gate_source) == NI_GPCT_DISABLED_GATE_SELECT) {
+   if (chan == NI_GPCT_DISABLED_GATE_SELECT) {
ni_tio_set_bits(counter, NITIO_MODE_REG(cidx),
Gi_Gating_Mode_Mask,
Gi_Gating_Disabled_Bits);
@@ -975,36 +967,34 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned 
gate_index,
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
default:
-   return ni_m_series_set_first_gate(counter, gate_source);
+   return ni_m_set_gate(counter, gate_source);
case ni_gpct_variant_660x:
- 

Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Steven Rostedt
On Thu, 24 Jul 2014 12:50:31 -0400
Nick Krause  wrote:

\
> > Most kernel devs most certainly did NOT get started by spamming lkml
> > with unnecessary and incorrect patches despite being repeatedly told to
> > go away and stop wasting everybody's time.

Mans, shut up! That is uncalled for.


> >
> > --
> > Måns Rullgård
> > m...@mansr.com
> 
> 
> 
> FIne , I give up. You want me to leave this then I wiil.

No, that's not what I said.

> I am have this discussion with other kernel developers and just
> because I send out one patch as a newbie like this doesn't mean I
> don't known C.  

It's not just one patch, and I didn't say you don't know C. I said you
don't understand C enough for kernel development.

Look, I really do like you enthusiasm, and I'm sorry that you are being
attacked the way you were. Some of the attacks are uncalled for, and I
even regret some of my own previous emails to you, as they too were
uncalled for. But I do not regret my reply in this thread.

I worked in various jobs for 6 years before touching the kernel. It was
2 years after that that I started doing trivial patches (fixing
off-by-one bugs and such). Then I started out doing real time
development outside of the mainline kernel for several more years
before I starting writing code for mainline.

That is, you don't just jump into kernel development before having a
solid foundation of programming skills.

The patch I replied to didn't just have a mistake. It really was wrong
on several levels that it couldn't be right. Getting such a simple patch
so wrong really shows that you need more experience.

Please, start working with some userspace projects first, where you can
easily walk through the code using gdb to understand how things work.
Spend a year or two doing that kind of work. There's even paying jobs
out there that require this. There's tons of opensource projects that
need help. The Linux kernel is really the biggest opensource project
and very intense. A "newbie" here means you haven't done much with the
kernel, but you have done a lot of coding in the past. It doesn't mean
"newbie" to development in general.

I've been told by my wife that I'm very blunt and say what's on my
mind. I'm not very tactful, as I hate beating around the bush. I hate
it when people beat around the bush with me, I usually just tell them to
"spit it out!" Thus, I treat people as I want to be treated, that is
"in-your-face truth".

Again, don't "go away" and never come back. "go away, learn a bit more,
then come back".

A lot of us are overworked and staring at code all day. We get grumpy,
and when someone comes along and starts spamming us with nonsense
changes, we sometimes bite back. Don't take it personally. I'm serious
when I say, just spend some time on userspace projects, then work you
way to some drivers, and then you can be more active, and more
importantly, more useful to the Linux kernel project :-)

-- Steve
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Harvey Harrison
On Thu, Jul 24, 2014 at 10:18 AM, Steven Rostedt  wrote:
> On Thu, 24 Jul 2014 12:50:31 -0400
> Nick Krause  wrote:

>
>> I am have this discussion with other kernel developers and just
>> because I send out one patch as a newbie like this doesn't mean I
>> don't known C.
>
> It's not just one patch, and I didn't say you don't know C. I said you
> don't understand C enough for kernel development.

And more importantly, stop guessing things are OK and selfishly asking
others to check
your work for you.

If you have not at least _built_ the kernel with your change, and not
_run_ it, and not made
sure that the changed code is being _run_...you are wasting other people's time.

Harvey
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Steven Rostedt
On Thu, 24 Jul 2014 10:30:51 -0700
Harvey Harrison  wrote:

> On Thu, Jul 24, 2014 at 10:18 AM, Steven Rostedt  wrote:
> > On Thu, 24 Jul 2014 12:50:31 -0400
> > Nick Krause  wrote:
> 
> >
> >> I am have this discussion with other kernel developers and just
> >> because I send out one patch as a newbie like this doesn't mean I
> >> don't known C.
> >
> > It's not just one patch, and I didn't say you don't know C. I said you
> > don't understand C enough for kernel development.
> 
> And more importantly, stop guessing things are OK and selfishly asking
> others to check
> your work for you.
> 
> If you have not at least _built_ the kernel with your change, and not
> _run_ it, and not made
> sure that the changed code is being _run_...you are wasting other people's 
> time.
> 

Nick,

Just to bring Harvey's email here in perspective. I mentioned in my
previous email that most of us are overworked. We don't have time to
teach you if your patches are correct or not. By saying, "I'll just
write the code and you tell me if it's correct, and test it for me" is
like telling someone "Here's a lawn mower, now go mow my lawn".

We like it if people put effort into their work and are confident
themselves that they have the right code or not. There's enough
reviewing of patches to do from people that put that effort in, that
there's no time to review patches from people that don't know if their
work or not.

Cheers,

-- Steve
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: dgng: Fix Macros with complex values should be enclosed in parenthesis

2014-07-24 Thread Joe Perches
On Fri, 2014-07-25 at 00:26 +0900, Seunghun Lee wrote:
> This patch fixes a checkpatch errors
> "Macros with complex values should be enclosed in parenthesis"
[]
> diff --git a/drivers/staging/dgnc/dgnc_driver.h 
> b/drivers/staging/dgnc/dgnc_driver.h

> @@ -111,32 +111,32 @@
>  #endif
>  
>  #if defined TRC_TO_KMEM
> -#define PRINTF_TO_KMEM(args) dgnc_tracef args
> +#define PRINTF_TO_KMEM(args) do { dgnc_tracef args } while (0)

All this _TO_KMEM code is #if 0 in dgnc_trace.h

It'd be good to change the dgnc_tracef prototype to use
__printf(1, 2)

and this code in drivers/staging/dgnc/dgnc_driver.h:

#if defined TRC_TO_CONSOLE
#define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; }
#else /* !defined TRACE_TO_CONSOLE */
#define PRINTF_TO_CONSOLE(args)
#endif

should really consolidate the printk to something like:

#define PRINTF_TO_CONSOLE(fmt, ...) \
printk(KERN_INFO DRVSTR ": " fmt, ##__VA_ARGS__)


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: phison: remove driver

2014-07-24 Thread Kristina Martšenko
The driver hasn't been cleaned up and it doesn't look like anyone is
working on it anymore (including the original author). So remove the
driver from the kernel. If someone wants to work on cleaning it up and
moving it out of staging, this commit can be reverted.

Signed-off-by: Kristina Martšenko 
Cc: Evan Ko 
---
 drivers/staging/Kconfig |  2 -
 drivers/staging/Makefile|  1 -
 drivers/staging/phison/Kconfig  |  5 ---
 drivers/staging/phison/Makefile |  1 -
 drivers/staging/phison/phison.c | 94 -
 5 files changed, 103 deletions(-)
 delete mode 100644 drivers/staging/phison/Kconfig
 delete mode 100644 drivers/staging/phison/Makefile
 delete mode 100644 drivers/staging/phison/phison.c

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 5b14f0d..be3f91c 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -54,8 +54,6 @@ source "drivers/staging/rtl8821ae/Kconfig"
 
 source "drivers/staging/rts5208/Kconfig"
 
-source "drivers/staging/phison/Kconfig"
-
 source "drivers/staging/line6/Kconfig"
 
 source "drivers/staging/octeon/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index d4536df..a4408a8 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_R8192EE) += rtl8192ee/
 obj-$(CONFIG_R8723AU)  += rtl8723au/
 obj-$(CONFIG_R8821AE)  += rtl8821ae/
 obj-$(CONFIG_RTS5208)  += rts5208/
-obj-$(CONFIG_IDE_PHISON)   += phison/
 obj-$(CONFIG_LINE6_USB)+= line6/
 obj-$(CONFIG_NETLOGIC_XLR_NET) += netlogic/
 obj-$(CONFIG_OCTEON_ETHERNET)  += octeon/
diff --git a/drivers/staging/phison/Kconfig b/drivers/staging/phison/Kconfig
deleted file mode 100644
index 1b56119..000
--- a/drivers/staging/phison/Kconfig
+++ /dev/null
@@ -1,5 +0,0 @@
-config IDE_PHISON
-   tristate "PCIE ATA PS5000 IDE support"
-   depends on PCI && ATA && ATA_SFF && ATA_BMDMA
-   ---help---
- This is an experimental driver for PS5000 IDE driver.
diff --git a/drivers/staging/phison/Makefile b/drivers/staging/phison/Makefile
deleted file mode 100644
index 7642a21..000
--- a/drivers/staging/phison/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_IDE_PHISON)   += phison.o
diff --git a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c
deleted file mode 100644
index 3826561..000
--- a/drivers/staging/phison/phison.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2006  Red Hat 
- *
- *  May be copied or modified under the terms of the GNU General Public License
- *
- *  [Modify History]
- *   #0001, Evan, 2008.10.22, V0.00, New release.
- *   #0002, Evan, 2008.11.01, V0.90, Test Work In Ubuntu Linux 8.04.
- *   #0003, Evan, 2008.01.08, V0.91, Change Name "PCIE-SSD" to "E-BOX".
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define PHISON_DEBUG
-
-#define DRV_NAME   "phison_e-box"  /* #0003 */
-#define DRV_VERSION"0.91"  /* #0003 */
-
-#define PCI_VENDOR_ID_PHISON   0x1987
-#define PCI_DEVICE_ID_PS5000   0x5000
-
-static int phison_pre_reset(struct ata_link *link, unsigned long deadline)
-{
-   int ret;
-   struct ata_port *ap = link->ap;
-
-   ap->cbl = ATA_CBL_NONE;
-   ret = ata_std_prereset(link, deadline);
-   dev_dbg(ap->dev, "phison_pre_reset(), ret = %x\n", ret);
-   return ret;
-}
-
-static struct scsi_host_template phison_sht = {
-   ATA_BMDMA_SHT(DRV_NAME),
-};
-
-static struct ata_port_operations phison_ops = {
-   .inherits   = &ata_bmdma_port_ops,
-   .prereset   = phison_pre_reset,
-};
-
-static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id 
*id)
-{
-   int ret;
-   struct ata_port_info info = {
-   .flags  = ATA_FLAG_NO_ATAPI,
-
-   .pio_mask   = 0x1f,
-   .mwdma_mask = 0x07,
-   .udma_mask  = ATA_UDMA5,
-
-   .port_ops   = &phison_ops,
-   };
-   const struct ata_port_info *ppi[] = { &info, NULL };
-
-   ret = ata_pci_bmdma_init_one(pdev, ppi, &phison_sht, NULL, 0);
-
-   dev_dbg(&pdev->dev, "phison_init_one(), ret = %x\n", ret);
-
-   return ret;
-}
-
-static const struct pci_device_id phison_pci_tbl[] = {
-   { PCI_DEVICE(PCI_VENDOR_ID_PHISON, PCI_DEVICE_ID_PS5000),
- PCI_CLASS_STORAGE_IDE << 8, 0x00, 0 },
-   { 0, },
-};
-MODULE_DEVICE_TABLE(pci, phison_pci_tbl);
-
-static struct pci_driver phison_pci_driver = {
-   .name   = DRV_NAME,
-   .id_table   = phison_pci_tbl,
-   .probe  = phison_init_one,
-   .remove = ata_pci_remove_one,
-#ifdef CONFIG_PM   /* haven't tested it. */
-   .suspend= ata_pci_device_suspend,
-   .resume = ata_pci_device_resume,
-#endif
-};
-
-module_pci_driver(phison_pc

Re: [PATCH 2/3] [SCSI] storvsc: Add Hyper-V logical block provisioning tests

2014-07-24 Thread Sitsofe Wheeler
On Thu, Jul 24, 2014 at 02:09:11PM +, James Bottomley wrote:
> On Thu, 2014-07-24 at 08:56 +0100, Sitsofe Wheeler wrote:
> > Microsoft Hyper-V targets currently only claim SPC-2 compliance / no
> > compliance indicated even though they implement post SPC-2 features
> > which means those features are not tested for. Add a blacklist flag to
> > Hyper-V devices that forces said testing.
> 
> This description is misleading: you don't force the test now, you force
> the driver to send unmap commands down to the device.

I disagree - UNMAP will only be used if the vpd pages say that UNMAP is
supported by the device. I've added two hard disks (one SATA, one on USB) to
the VM and here's the debug output with all three patches applied and some
extra logging:

sd 1:0:0:4: [sdc] Entered read_capacity_16
sd 1:0:0:4: [sdc] Past illegal req
sd 1:0:0:4: [sdc] Protection check
sd 1:0:0:4: [sdc] Got past protection check
sd 1:0:0:4: [sdc] Checking LBPME
sd 1:0:0:4: [sdc] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
sd 1:0:0:4: [sdc] 4096-byte physical blocks
sd 1:0:0:4: [sdc] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:4: [sdc] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:4: [sdc] Entered block limits
sd 1:0:0:4: [sdc] Started block limits
sd 1:0:0:4: [sdc] 0x3c...
sd 1:0:0:4: [sdc] Write Protect is off
sd 1:0:0:4: [sdc] Mode Sense: 0f 00 00 00
sd 1:0:0:2: [sdd] Entered read_capacity_16
sd 1:0:0:4: [sdc] Write cache: enabled, read cache: enabled, doesn't support 
DPO or FUA
sd 1:0:0:2: [sdd] 976773168 512-byte logical blocks: (500 GB/465 GiB)
sd 1:0:0:4: [sdc] Entered read_capacity_16
sd 1:0:0:2: [sdd] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:2: [sdd] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:4: [sdc] Past illegal req
sd 1:0:0:4: [sdc] Protection check
sd 1:0:0:4: [sdc] Got past protection check
sd 1:0:0:4: [sdc] Checking LBPME
sd 1:0:0:2: [sdd] Entered block limits
sd 1:0:0:4: [sdc] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:4: [sdc] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:4: [sdc] Entered block limits
sd 1:0:0:4: [sdc] Started block limits
sd 1:0:0:4: [sdc] 0x3c...
sd 1:0:0:2: [sdd] Write Protect is off
sd 1:0:0:2: [sdd] Mode Sense: 0f 00 00 00
sd 1:0:0:2: [sdd] Write cache: disabled, read cache: enabled, doesn't support 
DPO or FUA
sd 1:0:0:2: [sdd] Entered read_capacity_16
sd 1:0:0:2: [sdd] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:2: [sdd] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:2: [sdd] Entered block limits
 sdd: unknown partition table
sd 1:0:0:2: [sdd] Entered read_capacity_16
sd 1:0:0:2: [sdd] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:2: [sdd] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:2: [sdd] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:2: [sdd] Entered block limits
sd 1:0:0:2: [sdd] Attached SCSI disk
 sdc: sdc1 sdc2
sd 1:0:0:4: [sdc] Entered read_capacity_16
sd 1:0:0:4: [sdc] Past illegal req
sd 1:0:0:4: [sdc] Protection check
sd 1:0:0:4: [sdc] Got past protection check
sd 1:0:0:4: [sdc] Checking LBPME
sd 1:0:0:4: [sdc] sd_revalidate_disk: Extended inquiry check...
sd 1:0:0:4: [sdc] sd_revalidate_disk: Performing extended inquiries
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Entered, lbmpe: 0
sd 1:0:0:4: [sdc] sd_read_block_provisioning: Passed lbmpe test
sd 1:0:0:4: [sdc] Entered block limits
sd 1:0:0:4: [sdc] Started block limits
sd 1:0:0:4: [sdc] 0x3c...
sd 1:0:0:4: [sdc] Attached SCSI disk

Both
/sys/block/sdc/device/scsi_disk/1\:0\:0\:4/thin_provisioning
and
cat /sys/block/sdd/device/scsi_disk/1\:0\:0\:2/thin_provisioning
return 0.

A Hyper-V VHDX disk had output like this:
sd 0:0:0:0: [sda] Entered read_capacity_16
sd 0:0:0:0: [sda] Past illegal req
sd 0:0:0:0: [sda] Protection check
sd 0:0:0:0: [sda] Got past protection check
sd 0:0:0:0: [sda] Checking LBPME
sd 0:0:0:0: [sda] LBPME OK!
sd 0:0:0:0: [sda] Discard mode: 2
sd 0:0:0:0: [sda] 8388608 512-byte logical blocks: (4.29 GB/4.00 GiB)
sd 0:0:0:0: [sda] sd_revalidate_disk: Extended inquiry check...
sd 0:0:0:0: [sda] sd_revalidate_disk: Performing extended inquiries
sd 0:0:0:0: [sda] sd_read_block_provisioning: Entered, lbmpe: 1
sd 0:0:0:0: [sda] sd_read_block_provisioning: Passed lbmpe test
sd 0:0:0:0: [sda] sd_read_block_provisioning: Setting block provisioning
sd 0:0:0:0: [sda] Entered block limits
sd 0:0:0:0: [sda

Subject: [PATCH 6/6 v3] staging: unisys: ABI documentation for new sysfs entries

2014-07-24 Thread Benjamin Romer
This patch adds a documentation file for all of the interfaces that were moved
to sysfs by the other patches in this set.

Signed-off-by: Benjamin Romer 
---
v3: documentation was revised based on changes in earlier patches.
v2: whitespace errors were corrected.

 .../Documentation/ABI/sysfs-platform-visorchipset  | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 
drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset

diff --git 
a/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset 
b/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset
new file mode 100644
index 000..28f8f12
--- /dev/null
+++ b/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset
@@ -0,0 +1,101 @@
+What:  install/error
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to send the ID of a string that should be displayed on
+   s-Par's automatic installation progress screen when an error
+   is encountered during installation. This field has no effect
+   if not in installation mode.
+Users: sparmaintai...@unisys.com
+
+What:  install/remainingsteps
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to set the value of the progress bar on the s-Par automatic
+   installation progress screen. This field has no effect if not in
+   installation mode.
+Users: sparmaintai...@unisys.com
+
+What:  install/textid
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to send the ID of a string that should be displayed on
+   s-Par's automatic installation progress screen. Setting this
+   field when not in installation mode (boottotool was set on
+   the previous guest boot) has no effect.
+Users: sparmaintai...@unisys.com
+
+What:  install/boottotool
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   The boottotool flag controls s-Par behavior on the next boot of
+   this guest. Setting the flag will cause the guest to boot from
+   the utility and installation image, which will use the value in
+   the toolaction field to determine what operation is being
+   requested.
+Users: sparmaintai...@unisys.com
+
+What:  install/toolaction
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This field is used to tell s-Par which type of recovery tool
+   action to perform on the next guest boot-up. The meaning of the
+   value is dependent on the type of installation software used to
+   commission the guest.
+Users: sparmaintai...@unisys.com
+
+What:  guest/chipsetready
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by Unisys application software on the guest
+   to acknowledge completion of specific events for integration
+   purposes, but these acknowledgements are not required for the
+   guest to operate correctly. The interface accepts one of two
+   strings: MODULES_LOADED to indicate that the s-Par driver
+   modules have been loaded successfully, or CALLHOMEDISK_MOUNTED,
+   which indicates that the disk used to support call home services
+   has been successfully mounted.
+Users: sparmaintai...@unisys.com
+
+What:  parahotplug/deviceenabled
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by a Unisys support script installed on the
+   guest, and triggered by a udev event. The support script is
+   responsible for enabling and disabling SR-IOV devices when the
+   PF device is being recovered in another guest.
+
+   Some SR-IOV devices have problems when the PF is reset without
+   first disabling all VFs attached to that PF. s-Par handles this
+   situation by sending a message to guests using these VFs, and
+   the script will disable the device. When the PF is recovered,
+   another message is sent to the guests to re-enable the VFs.
+
+   The parahotplug/deviceenabled interface is used to acknowledge
+   the recovery message.
+Users: sparmaintai...@unisys.com
+
+What:  parahotplug/devicedisabled
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by a Unisys support script installed on the
+

[PATCH 3/6 v3] staging: unisys: clean up diagdump proc entry code

2014-07-24 Thread Benjamin Romer
Remove remnant code left over from the diagdump proc entry.

Signed-off-by: Benjamin Romer 
---
v3: patch locations changed due to prior patches being revised.
v2: patch locations changed due to prior patches being revised.

 drivers/staging/unisys/visorchipset/visorchipset_main.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 4211731..58a441d 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -126,9 +126,6 @@ InitPartitionProperties(void)
 
 static MYPROCTYPE *PartitionType;
 
-#define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
-static struct proc_dir_entry *diag_proc_dir;
-
 #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
 static struct proc_dir_entry *parahotplug_proc_dir;
 
@@ -2583,10 +2580,7 @@ visorchipset_exit(void)
visor_proc_DestroyType(PartitionType);
PartitionType = NULL;
}
-   if (diag_proc_dir) {
-   remove_proc_entry(VISORCHIPSET_DIAG_PROC_ENTRY_FN, ProcDir);
-   diag_proc_dir = NULL;
-   }
+
memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6 v3] staging: unisys: move installer to sysfs and split fields

2014-07-24 Thread Benjamin Romer
The installer entry in /proc/visorchipset/installer was composed of three
separate fields as one entry. This patch removes the proc entry and associated
functions, and creates new fields with distinct entries under sysfs in the
visorchipset/install directory. The fields are:

textid: used to send the ID of a string that should be displayed on
s-Par's automatic installation progress screen. Setting this
field when not in installation mode (boottotool was set on
the previous guest boot) has no effect.

remaining_steps: used to set the value of the progress bar on the
s-Par automatic installation progress screen. This field has
no effect if not in installation mode.

error: used to send the ID of a string that should be displayed on
s-Par's automatic installation progress screen when an error
is encountered during installation. This field has no effect
if not in installation mode.

Signed-off-by: Benjamin Romer 
---
v3: an errant tab was removed and the static keyword was added to the definition
of each sysfs attribute function.
v2: attribute creation was fixed and checks for controlvm_channel pointer were
removed.
 .../unisys/visorchipset/visorchipset_main.c| 233 ++---
 1 file changed, 106 insertions(+), 127 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 48db6ee..14eb0ab 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -144,16 +144,6 @@ static VISORCHANNEL *ControlVm_channel;
 static ssize_t visorchipset_proc_read_writeonly(struct file *file,
char __user *buf,
size_t len, loff_t *offset);
-static ssize_t proc_read_installer(struct file *file, char __user *buf,
-  size_t len, loff_t *offset);
-static ssize_t proc_write_installer(struct file *file,
-   const char __user *buffer,
-   size_t count, loff_t *ppos);
-
-static const struct file_operations proc_installer_fops = {
-   .read = proc_read_installer,
-   .write = proc_write_installer,
-};
 
 typedef struct {
U8 __iomem *ptr;/* pointer to base address of payload pool */
@@ -315,9 +305,30 @@ static ssize_t boottotool_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
 static DEVICE_ATTR_RW(boottotool);
 
+static ssize_t error_show(struct device *dev, struct device_attribute *attr,
+   char *buf);
+static ssize_t error_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count);
+static DEVICE_ATTR_RW(error);
+
+static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
+   char *buf);
+static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count);
+static DEVICE_ATTR_RW(textid);
+
+static ssize_t remaining_steps_show(struct device *dev,
+   struct device_attribute *attr, char *buf);
+static ssize_t remaining_steps_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_RW(remaining_steps);
+
 static struct attribute *visorchipset_install_attrs[] = {
&dev_attr_toolaction.attr,
&dev_attr_boottotool.attr,
+   &dev_attr_error.attr,
+   &dev_attr_textid.attr,
+   &dev_attr_remaining_steps.attr,
NULL
 };
 
@@ -407,6 +418,91 @@ ssize_t boottotool_store(struct device *dev, struct 
device_attribute *attr,
} else
return -EIO;
 }
+
+static ssize_t error_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   u32 error;
+
+   visorchannel_read(ControlVm_channel, offsetof(
+   ULTRA_CONTROLVM_CHANNEL_PROTOCOL, InstallationError),
+   &error, sizeof(u32));
+   return scnprintf(buf, PAGE_SIZE, "%i\n", error);
+}
+
+static ssize_t error_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   u32 error;
+
+   if (sscanf(buf, "%i\n", &error) == 1) {
+   if (visorchannel_write(ControlVm_channel,
+   offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+   InstallationError),
+   &error, sizeof(u32)) == 1) {
+   return count;
+   }
+   }
+   return -EIO;
+}
+
+static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   u32 textId;
+
+   visorchannel_read(ControlVm_channel, offsetof(
+   ULTRA_CONTROLVM_CHANNE

[PATCH 5/6 v3] staging: unisys: move parahotplug to sysfs

2014-07-24 Thread Benjamin Romer
Move the /proc/visorchipset/parahotplug interface to sysfs under
/sys/devices/platform/visorchipset/parahotplug/deviceenabled and
/sys/devices/platform/visorchipset/parahotplug/devicedisabled.

The parahotplug interface is used to deal with SR-IOV recovery situations on
s-Par guest partitions. The command service partition will send a message to a
guest when an SR-IOV device that guest is using needs to be temporarily removed.
The message triggers a udev event that will cause a recovery script to run.
When that script has completed its work, it will write to one of the
parahotplug interfaces to send a message back to Command, indicating that the
recovery action has completed.

When a guest that is sharing an SR-IOV device is restarted, that guest will
take down the PF driver on the device, but any guests with VFs will not know
that their device needs to be reset as well. The recovery script makes it so
the device will be shut down fully and then restarted after the sharing guest
comes back up, and ensures that the timing is correct.

Moving this interface to sysfs orphans the visorchipset_proc_read_writeonly()
function, so it is also removed.

Signed-off-by: Benjamin Romer 
---
v3: The interface was split in two, so only the ID need be passed as a parameter
to use the interfaces. Additional documentation was added.
v2: attribute creation was fixed and checks for controlvm_channel pointer were
removed.
 .../unisys/visorchipset/visorchipset_main.c| 99 +-
 1 file changed, 39 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 13f4da8..7a7f515 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -98,19 +98,11 @@ static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket;
 #define is_diagpool_channel(channel_type_guid) \
 (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0)
 
-#define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
-static struct proc_dir_entry *parahotplug_proc_dir;
-
 static LIST_HEAD(BusInfoList);
 static LIST_HEAD(DevInfoList);
 
-static struct proc_dir_entry *ProcDir;
 static VISORCHANNEL *ControlVm_channel;
 
-static ssize_t visorchipset_proc_read_writeonly(struct file *file,
-   char __user *buf,
-   size_t len, loff_t *offset);
-
 typedef struct {
U8 __iomem *ptr;/* pointer to base address of payload pool */
U64 offset; /* offset from beginning of controlvm
@@ -293,6 +285,14 @@ static ssize_t chipsetready_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
 static DEVICE_ATTR_WO(chipsetready);
 
+static ssize_t devicedisabled_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_WO(devicedisabled);
+
+static ssize_t deviceenabled_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_WO(deviceenabled);
+
 static struct attribute *visorchipset_install_attrs[] = {
&dev_attr_toolaction.attr,
&dev_attr_boottotool.attr,
@@ -317,9 +317,21 @@ static struct attribute_group visorchipset_guest_group = {
.attrs = visorchipset_guest_attrs
 };
 
+static struct attribute *visorchipset_parahotplug_attrs[] = {
+   &dev_attr_devicedisabled.attr,
+   &dev_attr_deviceenabled.attr,
+   NULL
+};
+
+static struct attribute_group visorchipset_parahotplug_group = {
+   .name = "parahotplug",
+   .attrs = visorchipset_parahotplug_attrs
+};
+
 static const struct attribute_group *visorchipset_dev_groups[] = {
&visorchipset_install_group,
&visorchipset_guest_group,
+   &visorchipset_parahotplug_group,
NULL
 };
 
@@ -1723,53 +1735,36 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
}
 }
 
-/*
- * Gets called when the udev script writes to
- * /proc/visorchipset/parahotplug.  Expects input in the form of "
- * " where  is the identifier passed to the script that
- * matches a request on the request list, and  is 0 or 1
- * indicating whether the device is now enabled or not.
+/* The parahotplug/devicedisabled interface gets called by our support script
+ * when an SR-IOV device has been shut down. The ID is passed to the script
+ * and then passed back when the device has been removed.
  */
-static ssize_t
-parahotplug_proc_write(struct file *file, const char __user *buffer,
-  size_t count, loff_t *ppos)
+ssize_t devicedisabled_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
 {
-   char buf[64];
uint id;
-   ushort active;
 
-   if (count > sizeof(buf) - 1) {
-

[PATCH 2/6 v3] staging: unisys: move chipsetready to sysfs

2014-07-24 Thread Benjamin Romer
Move the chipsetready proc entry to sysfs under a new directory guest. This
entry is used by Unisys application software on the guest to acknowledge
completion of specific events for integration purposes, but these
acknowledgements are not required for the guest to operate correctly.

The store function is simplified as well, to use scanf() instead of copying
the buffer and using strsep().

Signed-off-by: Benjamin Romer 
---
v3: The second parameter being passed in to the store function was found to be
unnecessary, and it was removed.
v2: attribute creation was fixed and checks for controlvm_channel pointer were
removed. The off-by-one error in the sscanf() was fixed. Error -1 that was 
being returned was changed to -EINVAL.

 .../unisys/visorchipset/visorchipset_main.c| 76 +++---
 1 file changed, 24 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 14eb0ab..4211731 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -129,9 +129,6 @@ static MYPROCTYPE *PartitionType;
 #define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
 static struct proc_dir_entry *diag_proc_dir;
 
-#define VISORCHIPSET_CHIPSET_PROC_ENTRY_FN "chipsetready"
-static struct proc_dir_entry *chipset_proc_dir;
-
 #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
 static struct proc_dir_entry *parahotplug_proc_dir;
 
@@ -323,6 +320,10 @@ static ssize_t remaining_steps_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
 static DEVICE_ATTR_RW(remaining_steps);
 
+static ssize_t chipsetready_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_WO(chipsetready);
+
 static struct attribute *visorchipset_install_attrs[] = {
&dev_attr_toolaction.attr,
&dev_attr_boottotool.attr,
@@ -337,8 +338,19 @@ static struct attribute_group visorchipset_install_group = 
{
.attrs = visorchipset_install_attrs
 };
 
+static struct attribute *visorchipset_guest_attrs[] = {
+   &dev_attr_chipsetready.attr,
+   NULL
+};
+
+static struct attribute_group visorchipset_guest_group = {
+   .name = "guest",
+   .attrs = visorchipset_guest_attrs
+};
+
 static const struct attribute_group *visorchipset_dev_groups[] = {
&visorchipset_install_group,
+   &visorchipset_guest_group,
NULL
 };
 
@@ -2369,49 +2381,21 @@ visorchipset_cache_free(struct kmem_cache *pool, void 
*p, char *fn, int ln)
kmem_cache_free(pool, p);
 }
 
-#define gettoken(bufp) strsep(bufp, " -\t\n")
-
-static ssize_t
-chipset_proc_write(struct file *file, const char __user *buffer,
-  size_t count, loff_t *ppos)
+static ssize_t chipsetready_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
 {
-   char buf[512];
-   char *token, *p;
+   char msgtype[64];
 
-   if (count > sizeof(buf) - 1) {
-   LOGERR("chipset_proc_write: count (%d) exceeds size of buffer 
(%d)",
-(int) count, (int) sizeof(buffer));
-   return -EINVAL;
-   }
-   if (copy_from_user(buf, buffer, count)) {
-   LOGERR("chipset_proc_write: copy_from_user failed");
-   return -EFAULT;
-   }
-   buf[count] = '\0';
-
-   p = buf;
-   token = gettoken(&p);
-
-   if (strcmp(token, "CALLHOMEDISK_MOUNTED") == 0) {
-   token = gettoken(&p);
-   /* The Call Home Disk has been mounted */
-   if (strcmp(token, "0") == 0)
+   if (sscanf(buf, "%63s", msgtype) == 1) {
+   if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0)
chipset_events[0] = 1;
-   } else if (strcmp(token, "MODULES_LOADED") == 0) {
-   token = gettoken(&p);
-   /* All modules for the partition have been loaded */
-   if (strcmp(token, "0") == 0)
+   else if (strcmp(msgtype, "MODULES_LOADED") == 0)
chipset_events[1] = 1;
-   } else if (token == NULL) {
-   /* No event specified */
-   LOGERR("No event was specified to send CHIPSET_READY response");
-   return -1;
+   else
+   return -EINVAL;
} else {
-   /* Unsupported event specified */
-   LOGERR("%s is an invalid event for sending CHIPSET_READY 
response",  token);
-   return -1;
+   return -EINVAL;
}
-
return count;
 }
 
@@ -2422,12 +2406,6 @@ visorchipset_proc_read_writeonly(struct file *file, char 
__user *buf,
return 0;
 }
 
-static const struct file_operations chipset_proc_fops = {
-   .owner = THIS_MODULE,
-   .read = visorchipset_proc_read_

[PATCH 4/6 v3] staging: unisys: remove partition information from proc

2014-07-24 Thread Benjamin Romer
Debugging information for the guest's channels was being exposed in proc.
Remove the code that creates these entries, which are no longer needed.

Signed-off-by: Benjamin Romer 
---
v3: patch location changed due to prior patches being revised.
v2: patch location changed due to prior patches being revised.

 Makefile   |  2 +-
 .../unisys/visorchipset/visorchipset_main.c| 99 --
 2 files changed, 1 insertion(+), 100 deletions(-)

diff --git a/Makefile b/Makefile
index f3c543d..a1c224f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 16
 SUBLEVEL = 0
-EXTRAVERSION = -rc5
+EXTRAVERSION = -bmr4
 NAME = Shuffling Zombie Juror
 
 # *DOCUMENTATION*
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 58a441d..13f4da8 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -98,34 +98,6 @@ static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket;
 #define is_diagpool_channel(channel_type_guid) \
 (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0)
 
-typedef enum {
-   PARTPROP_invalid,
-   PARTPROP_name,
-   PARTPROP_description,
-   PARTPROP_handle,
-   PARTPROP_busNumber,
-   /* add new properties above, but don't forget to change
-* InitPartitionProperties() and show_partition_property() also...
-*/
-   PARTPROP_last
-} PARTITION_property;
-static const char *PartitionTypeNames[] = { "partition", NULL };
-
-static char *PartitionPropertyNames[PARTPROP_last + 1];
-static void
-InitPartitionProperties(void)
-{
-   char **p = PartitionPropertyNames;
-   p[PARTPROP_invalid] = "";
-   p[PARTPROP_name] = "name";
-   p[PARTPROP_description] = "description";
-   p[PARTPROP_handle] = "handle";
-   p[PARTPROP_busNumber] = "busNumber";
-   p[PARTPROP_last] = NULL;
-}
-
-static MYPROCTYPE *PartitionType;
-
 #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
 static struct proc_dir_entry *parahotplug_proc_dir;
 
@@ -512,52 +484,6 @@ static ssize_t remaining_steps_store(struct device *dev,
return -EIO;
 }
 
-static void
-show_partition_property(struct seq_file *f, void *ctx, int property)
-{
-   VISORCHIPSET_BUS_INFO *info = (VISORCHIPSET_BUS_INFO *) (ctx);
-
-   switch (property) {
-   case PARTPROP_name:
-   seq_printf(f, "%s\n", NONULLSTR(info->name));
-   break;
-   case PARTPROP_description:
-   seq_printf(f, "%s\n", NONULLSTR(info->description));
-   break;
-   case PARTPROP_handle:
-   seq_printf(f, "0x%-16.16Lx\n", info->partitionHandle);
-   break;
-   case PARTPROP_busNumber:
-   seq_printf(f, "%d\n", info->busNo);
-   break;
-   default:
-   seq_printf(f, "(%d??)\n", property);
-   break;
-   }
-}
-
-static void
-proc_Init(void)
-{
-   if (ProcDir == NULL) {
-   ProcDir = proc_mkdir(MYDRVNAME, NULL);
-   if (ProcDir == NULL) {
-   LOGERR("failed to create /proc directory %s",
-  MYDRVNAME);
-   POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC,
-POSTCODE_SEVERITY_ERR);
-   }
-   }
-}
-
-static void
-proc_DeInit(void)
-{
-   if (ProcDir != NULL)
-   remove_proc_entry(MYDRVNAME, NULL);
-   ProcDir = NULL;
-}
-
 #if 0
 static void
 testUnicode(void)
@@ -1260,16 +1186,6 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT 
*parser_ctx)
pBusInfo->name = parser_string_get(parser_ctx);
 
visorchannel_uuid_id(&pBusInfo->partitionGuid, s);
-   pBusInfo->procObject =
-   visor_proc_CreateObject(PartitionType, s, (void *) (pBusInfo));
-   if (pBusInfo->procObject == NULL) {
-   LOGERR("CONTROLVM_BUS_CONFIGURE Failed: busNo=%lu failed to 
create /proc entry",
-busNo);
-   POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
-POSTCODE_SEVERITY_ERR);
-   rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
-   goto Away;
-   }
POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO);
 Away:
bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
@@ -2472,15 +2388,6 @@ visorchipset_init(void)
goto Away;
}
 
-   proc_Init();
-   memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames));
-   InitPartitionProperties();
-
-   PartitionType = visor_proc_CreateType(ProcDir, PartitionTypeNames,
- (const char **)
- PartitionPropertyNames,
-  

[PATCH 0/6 v3] staging: unisys: visorchipset proc fixes

2014-07-24 Thread Benjamin Romer
This patch set moves several interfaces in the visorchipset module from procfs
to sysfs, and removes the remaining proc interfaces from the module. It includes
documentation for the new interfaces in Documentation/ABI, and some code cleanup
in the new sysfs handler functions.

In version 3 of the set, an unused second parameter was removed from the
chipsetready attribute, and the parahotplug interface was split into two
separate attributes. Additional documentation has been added to the ABI doc
file to describe the use of these interfaces. Formatting mistakes were corrected
and sysfs attribute functions were made static to match their prototypes.

In version 2 of the set, extraneous checks for controlvm_channel pointer 
validity were removed, all newly created attributes use DEVICE_ATTR_RW or 
DEVICE_ATTR_WO, and logging was removed from the show and store functions to 
prevent creating a DOS attack possibility. 


Benjamin Romer (6):
  staging: unisys: move installer to sysfs and split fields
  staging: unisys: move chipsetready to sysfs
  staging: unisys: clean up diagdump proc entry code
  staging: unisys: remove partition information from proc
  staging: unisys: move parahotplug to sysfs
  staging: unisys: ABI documentation for new sysfs entries

 Makefile   |   2 +-
 .../Documentation/ABI/sysfs-platform-visorchipset  | 101 +
 .../unisys/visorchipset/visorchipset_main.c| 487 +++--
 3 files changed, 258 insertions(+), 332 deletions(-)
 create mode 100644 
drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6 v3] staging: unisys: ABI documentation for new sysfs entries

2014-07-24 Thread Benjamin Romer
This patch adds a documentation file for all of the interfaces that were moved
to sysfs by the other patches in this set.

Signed-off-by: Benjamin Romer 
---
v3: documentation was revised based on changes in earlier patches.
v2: whitespace errors were corrected.

 .../Documentation/ABI/sysfs-platform-visorchipset  | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 
drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset

diff --git 
a/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset 
b/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset
new file mode 100644
index 000..28f8f12
--- /dev/null
+++ b/drivers/staging/unisys/Documentation/ABI/sysfs-platform-visorchipset
@@ -0,0 +1,101 @@
+What:  install/error
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to send the ID of a string that should be displayed on
+   s-Par's automatic installation progress screen when an error
+   is encountered during installation. This field has no effect
+   if not in installation mode.
+Users: sparmaintai...@unisys.com
+
+What:  install/remainingsteps
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to set the value of the progress bar on the s-Par automatic
+   installation progress screen. This field has no effect if not in
+   installation mode.
+Users: sparmaintai...@unisys.com
+
+What:  install/textid
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   used to send the ID of a string that should be displayed on
+   s-Par's automatic installation progress screen. Setting this
+   field when not in installation mode (boottotool was set on
+   the previous guest boot) has no effect.
+Users: sparmaintai...@unisys.com
+
+What:  install/boottotool
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   The boottotool flag controls s-Par behavior on the next boot of
+   this guest. Setting the flag will cause the guest to boot from
+   the utility and installation image, which will use the value in
+   the toolaction field to determine what operation is being
+   requested.
+Users: sparmaintai...@unisys.com
+
+What:  install/toolaction
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This field is used to tell s-Par which type of recovery tool
+   action to perform on the next guest boot-up. The meaning of the
+   value is dependent on the type of installation software used to
+   commission the guest.
+Users: sparmaintai...@unisys.com
+
+What:  guest/chipsetready
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by Unisys application software on the guest
+   to acknowledge completion of specific events for integration
+   purposes, but these acknowledgements are not required for the
+   guest to operate correctly. The interface accepts one of two
+   strings: MODULES_LOADED to indicate that the s-Par driver
+   modules have been loaded successfully, or CALLHOMEDISK_MOUNTED,
+   which indicates that the disk used to support call home services
+   has been successfully mounted.
+Users: sparmaintai...@unisys.com
+
+What:  parahotplug/deviceenabled
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by a Unisys support script installed on the
+   guest, and triggered by a udev event. The support script is
+   responsible for enabling and disabling SR-IOV devices when the
+   PF device is being recovered in another guest.
+
+   Some SR-IOV devices have problems when the PF is reset without
+   first disabling all VFs attached to that PF. s-Par handles this
+   situation by sending a message to guests using these VFs, and
+   the script will disable the device. When the PF is recovered,
+   another message is sent to the guests to re-enable the VFs.
+
+   The parahotplug/deviceenabled interface is used to acknowledge
+   the recovery message.
+Users: sparmaintai...@unisys.com
+
+What:  parahotplug/devicedisabled
+Date:  7/18/2014
+KernelVersion: TBD
+Contact:   sparmaintai...@unisys.com
+Description:   This entry is used by a Unisys support script installed on the
+

Re: Subject: [PATCH 6/6 v3] staging: unisys: ABI documentation for new sysfs entries

2014-07-24 Thread Romer, Benjamin M
Please disregard this specific email - "Subject: [PATCH 6/6 v3] staging:
unisys: ABI documentation for new sysfs entries" - the subject was
corrected and this individual patch was resent.

Sorry for any confusion.

-- Ben
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: vt6655: remove redundant comments from baseband.h

2014-07-24 Thread Igor Bezukh
Removed redundant comments in baseband.h header file.

Signed-off-by: Igor Bezukh 
---
 drivers/staging/vt6655/baseband.h |   12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/staging/vt6655/baseband.h 
b/drivers/staging/vt6655/baseband.h
index e31bb76..d90c7f9 100644
--- a/drivers/staging/vt6655/baseband.h
+++ b/drivers/staging/vt6655/baseband.h
@@ -34,8 +34,6 @@
 #include "tether.h"
 #include "device.h"
 
-/*-  Export Definitions -*/
-
 //
 // Registers in the BASEBAND
 //
@@ -64,22 +62,12 @@
 #define TOP_RATE_2M 0x0020
 #define TOP_RATE_1M 0x0010
 
-/*-  Export Types  --*/
-
-/*-  Export Macros --*/
-
 #define BBvClearFOE(dwIoBase)  \
BBbWriteEmbedded(dwIoBase, 0xB1, 0)
 
 #define BBvSetFOE(dwIoBase)\
BBbWriteEmbedded(dwIoBase, 0xB1, 0x0C)
 
-/*-  Export Classes  */
-
-/*-  Export Variables  --*/
-
-/*-  Export Functions  --*/
-
 unsigned int
 BBuGetFrameTime(
unsigned char byPreambleType,
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 1:48 PM, Steven Rostedt  wrote:
> On Thu, 24 Jul 2014 10:30:51 -0700
> Harvey Harrison  wrote:
>
>> On Thu, Jul 24, 2014 at 10:18 AM, Steven Rostedt  wrote:
>> > On Thu, 24 Jul 2014 12:50:31 -0400
>> > Nick Krause  wrote:
>>
>> >
>> >> I am have this discussion with other kernel developers and just
>> >> because I send out one patch as a newbie like this doesn't mean I
>> >> don't known C.
>> >
>> > It's not just one patch, and I didn't say you don't know C. I said you
>> > don't understand C enough for kernel development.
>>
>> And more importantly, stop guessing things are OK and selfishly asking
>> others to check
>> your work for you.
>>
>> If you have not at least _built_ the kernel with your change, and not
>> _run_ it, and not made
>> sure that the changed code is being _run_...you are wasting other people's 
>> time.
>>
>
> Nick,
>
> Just to bring Harvey's email here in perspective. I mentioned in my
> previous email that most of us are overworked. We don't have time to
> teach you if your patches are correct or not. By saying, "I'll just
> write the code and you tell me if it's correct, and test it for me" is
> like telling someone "Here's a lawn mower, now go mow my lawn".
>
> We like it if people put effort into their work and are confident
> themselves that they have the right code or not. There's enough
> reviewing of patches to do from people that put that effort in, that
> there's no time to review patches from people that don't know if their
> work or not.
>
> Cheers,
>
> -- Steve

Steve,
I have programming a lot in other areas just not the kernel.
You are right through I need to test my code better through.
Cheers Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: vt6655: remove redundant comments from bssdb.h

2014-07-24 Thread Igor Bezukh
Removed redundant comments from bssdb.h header file.

Signed-off-by: Igor Bezukh 
---
 drivers/staging/vt6655/bssdb.h |   25 ++---
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h
index a0938b7..9337afe 100644
--- a/drivers/staging/vt6655/bssdb.h
+++ b/drivers/staging/vt6655/bssdb.h
@@ -35,8 +35,6 @@
 #include "80211mgr.h"
 #include "card.h"
 
-/*-  Export Definitions -*/
-
 #define MAX_NODE_NUM 64
 #define MAX_BSS_NUM  42
 #define LOST_BEACON_COUNT10   // 10 sec, XP defined
@@ -67,12 +65,6 @@
 
 #define MAX_WPA_IE_LEN  64
 
-/*-  Export Classes  */
-
-/*-  Export Variables  --*/
-
-/*-  Export Types  --*/
-
 //
 // IEEE 802.11 Structures and definitions
 //
@@ -99,7 +91,6 @@ typedef struct tagSRSNCapObject {
 // BSS info(AP)
 #pragma pack(1)
 typedef struct tagKnownBSS {
-   // BSS info
bool bActive;
unsigned char abyBSSID[WLAN_BSSID_LEN];
unsigned intuChannel;
@@ -116,10 +107,8 @@ typedef struct tagKnownBSS {
longldBmMAX;
longldBmAverage[RSSI_STAT_COUNT];
longldBmAverRange;
-   //For any BSSID selection improvment
bool bSelected;
 
-   //++ WPA informations
bool bWPAValid;
unsigned char byGKType;
unsigned char abyPKType[4];
@@ -128,9 +117,7 @@ typedef struct tagKnownBSS {
unsigned short wAuthCount;
unsigned char byDefaultK_as_PK;
unsigned char byReplayIdx;
-   //--
 
-   //++ WPA2 informations
bool bWPA2Valid;
unsigned char byCSSGK;
unsigned short wCSSPKCount;
@@ -138,28 +125,24 @@ typedef struct tagKnownBSS {
unsigned short wAKMSSAuthCount;
unsigned char abyAKMSSAuthType[4];
 
-   //++  wpactl
unsigned char byWPAIE[MAX_WPA_IE_LEN];
unsigned char byRSNIE[MAX_WPA_IE_LEN];
unsigned short wWPALen;
unsigned short wRSNLen;
 
-   // Clear count
unsigned intuClearCount;
unsigned intuIELength;
QWORD   qwBSSTimestamp;
-   QWORD   qwLocalTSF; // local TSF timer
+   QWORD   qwLocalTSF;
 
-//NDIS_802_11_NETWORK_TYPENetworkTypeInUse;
CARD_PHY_TYPE   eNetworkTypeInUse;
 
ERPObject   sERP;
SRSNCapObject   sRSNCapObj;
-   unsigned char abyIEs[1024];   // don't move this field !!
+   unsigned char abyIEs[1024];
 } __attribute__ ((__packed__))
 KnownBSS , *PKnownBSS;
 
-//2006-1116-01, by NomadZhao
 #pragma pack()
 
 typedef enum tagNODE_STATE {
@@ -172,7 +155,6 @@ typedef enum tagNODE_STATE {
 
 // STA node info
 typedef struct tagKnownNodeDB {
-   // STA info
bool bActive;
unsigned char abyMACAddr[WLAN_ADDR_LEN];
unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
@@ -211,7 +193,6 @@ typedef struct tagKnownNodeDB {
unsigned short wTSC15_0;
unsigned intuWepKeyLength;
unsigned char abyWepKey[WLAN_WEPMAX_KEYLEN];
-   //
// Auto rate fallback vars
bool bIsInFallback;
unsigned intuAverageRSSI;
@@ -228,8 +209,6 @@ typedef struct tagKnownNodeDB {
unsigned intuTimeCount;
 } KnownNodeDB, *PKnownNodeDB;
 
-/*-  Export Functions  --*/
-
 PKnownBSS
 BSSpSearchBSSList(
void *hDeviceContext,
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Richard Weinberger
On Thu, Jul 24, 2014 at 8:41 PM, Nick Krause  wrote:
> Steve,
> I have programming a lot in other areas just not the kernel.
> You are right through I need to test my code better through.

Nick,

let's make a deal.
Take the challenge at http://eudyptula-challenge.org. After you've solved all
tasks we'll accept patches from you.

-- 
Thanks,
//richard
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 2:49 PM, Richard Weinberger
 wrote:
> On Thu, Jul 24, 2014 at 8:41 PM, Nick Krause  wrote:
>> Steve,
>> I have programming a lot in other areas just not the kernel.
>> You are right through I need to test my code better through.
>
> Nick,
>
> let's make a deal.
> Take the challenge at http://eudyptula-challenge.org. After you've solved all
> tasks we'll accept patches from you.
>
> --
> Thanks,
> //richard
That's fine,
So Sorry :(.
Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: quickstart: remove driver

2014-07-24 Thread Kristina Martšenko
The driver hasn't been cleaned up and it doesn't look like anyone is
working on it anymore (including the original author). So remove the
driver from the kernel. If someone wants to work on cleaning it up and
moving it out of staging, this commit can be reverted.

Signed-off-by: Kristina Martšenko 
Cc: Angelo Arrifano 
---
To be applied after "staging: phison: remove driver".

 drivers/staging/Kconfig |   2 -
 drivers/staging/Makefile|   1 -
 drivers/staging/quickstart/Kconfig  |  10 -
 drivers/staging/quickstart/Makefile |   1 -
 drivers/staging/quickstart/quickstart.c | 458 
 5 files changed, 472 deletions(-)
 delete mode 100644 drivers/staging/quickstart/Kconfig
 delete mode 100644 drivers/staging/quickstart/Makefile
 delete mode 100644 drivers/staging/quickstart/quickstart.c

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index be3f91c..b08394c 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -70,8 +70,6 @@ source "drivers/staging/iio/Kconfig"
 
 source "drivers/staging/xgifb/Kconfig"
 
-source "drivers/staging/quickstart/Kconfig"
-
 source "drivers/staging/emxx_udc/Kconfig"
 
 source "drivers/staging/bcm/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index a4408a8..9623308 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -29,7 +29,6 @@ obj-$(CONFIG_VME_BUS) += vme/
 obj-$(CONFIG_DX_SEP)+= sep/
 obj-$(CONFIG_IIO)  += iio/
 obj-$(CONFIG_FB_XGI)   += xgifb/
-obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart/
 obj-$(CONFIG_USB_EMXX) += emxx_udc/
 obj-$(CONFIG_BCM_WIMAX)+= bcm/
 obj-$(CONFIG_FT1000)   += ft1000/
diff --git a/drivers/staging/quickstart/Kconfig 
b/drivers/staging/quickstart/Kconfig
deleted file mode 100644
index 5bea487..000
--- a/drivers/staging/quickstart/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-config ACPI_QUICKSTART
-   tristate "ACPI Quickstart key driver"
-   depends on ACPI && INPUT
-   help
- Say Y here if you have a platform that supports the ACPI
- quickstart key protocol.
-
- To compile this driver as a module, choose M here: the module will be
- called quickstart.
-
diff --git a/drivers/staging/quickstart/Makefile 
b/drivers/staging/quickstart/Makefile
deleted file mode 100644
index 290e0e4..000
--- a/drivers/staging/quickstart/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart.o
diff --git a/drivers/staging/quickstart/quickstart.c 
b/drivers/staging/quickstart/quickstart.c
deleted file mode 100644
index a85c3d6..000
--- a/drivers/staging/quickstart/quickstart.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- *  quickstart.c - ACPI Direct App Launch driver
- *
- *
- *  Copyright (C) 2007-2010 Angelo Arrifano 
- *
- *  Information gathered from disassembled dsdt and from here:
- *  
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#define QUICKSTART_VERSION "1.04"
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-MODULE_AUTHOR("Angelo Arrifano");
-MODULE_DESCRIPTION("ACPI Direct App Launch driver");
-MODULE_LICENSE("GPL");
-
-#define QUICKSTART_ACPI_DEVICE_NAME"quickstart"
-#define QUICKSTART_ACPI_CLASS  "quickstart"
-#define QUICKSTART_ACPI_HID"PNP0C32"
-
-#define QUICKSTART_PF_DRIVER_NAME  "quickstart"
-#define QUICKSTART_PF_DEVICE_NAME  "quickstart"
-
-/*
- * There will be two events:
- * 0x02 - A hot button was pressed while device was off/sleeping.
- * 0x80 - A hot button was pressed while device was up.
- */
-#define QUICKSTART_EVENT_WAKE  0x02
-#define QUICKSTART_EVENT_RUNTIME   0x80
-
-struct quickstart_button {
-   char *name;
-   unsigned int id;
-   struct list_head list;
-};
-
-struct quickstart_acpi {
-   struct acpi_device *device;
-   struct quickstart_button *button;
-};
-
-static LIST_HEAD(buttons);
-static struct quickstart_button *pressed;
-
-static struct input_dev *quickstart_input;
-
-/* Platform driver functions */
-static ssize_t buttons_show(struct

[PATCH] Staging: vt6655: remove redundant comments from card.h

2014-07-24 Thread Igor Bezukh
Removed redundant comments from card.h header file.

Signed-off-by: Igor Bezukh 
---
 drivers/staging/vt6655/80211hdr.h |7 ---
 drivers/staging/vt6655/80211mgr.h |   38 -
 drivers/staging/vt6655/aes_ccmp.h |9 -
 drivers/staging/vt6655/baseband.h |   12 
 drivers/staging/vt6655/bssdb.h|   25 ++--
 drivers/staging/vt6655/card.h |   10 +-
 6 files changed, 3 insertions(+), 98 deletions(-)

diff --git a/drivers/staging/vt6655/80211hdr.h 
b/drivers/staging/vt6655/80211hdr.h
index ba155cd..e05d135 100644
--- a/drivers/staging/vt6655/80211hdr.h
+++ b/drivers/staging/vt6655/80211hdr.h
@@ -33,7 +33,6 @@
 
 #include "ttype.h"
 
-/*-  Export Definitions -*/
 /* bit type */
 #define BIT0   0x0001
 #define BIT1   0x0002
@@ -315,10 +314,4 @@ typedef union tagUWLAN_80211HDR {
WLAN_80211HDR_A4sA4;
 } UWLAN_80211HDR, *PUWLAN_80211HDR;
 
-/*-  Export Classes  */
-
-/*-  Export Variables  --*/
-
-/*-  Export Functions  --*/
-
 #endif /* __80211HDR_H__ */
diff --git a/drivers/staging/vt6655/80211mgr.h 
b/drivers/staging/vt6655/80211mgr.h
index 065238b..8b126bb 100644
--- a/drivers/staging/vt6655/80211mgr.h
+++ b/drivers/staging/vt6655/80211mgr.h
@@ -34,8 +34,6 @@
 #include "ttype.h"
 #include "80211hdr.h"
 
-/*-  Export Definitions -*/
-
 #define WLAN_MIN_ARRAY  1
 
 /* Information Element ID value */
@@ -202,12 +200,6 @@
 #define MEASURE_MODE_INCAPABLE  0x02
 #define MEASURE_MODE_REFUSED0x04
 
-/*-  Export Classes  */
-
-/*-  Export Variables  --*/
-
-/*-  Export Types  --*/
-
 /* Information Element Types */
 
 #pragma pack(1)
@@ -472,14 +464,11 @@ typedef struct tagWLAN_FR_BEACON {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-   /* fixed fields */
PQWORD  pqwTimestamp;
unsigned short *pwBeaconInterval;
unsigned short *pwCapInfo;
-   /*-- info elements --*/
PWLAN_IE_SSID   pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
-/*  PWLAN_IE_FH_PARMS   pFHParms; */
PWLAN_IE_DS_PARMS   pDSParms;
PWLAN_IE_CF_PARMS   pCFParms;
PWLAN_IE_TIMpTIM;
@@ -501,10 +490,6 @@ typedef struct tagWLAN_FR_IBSSATIM {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-
-   /* fixed fields */
-   /* info elements */
-   /* this frame type has a null body */
 } WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM;
 
 /* Disassociation */
@@ -513,9 +498,7 @@ typedef struct tagWLAN_FR_DISASSOC {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-   /*-- fixed fields ---*/
unsigned short *pwReason;
-   /*-- info elements --*/
 } WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC;
 
 /* Association Request */
@@ -524,10 +507,8 @@ typedef struct tagWLAN_FR_ASSOCREQ {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-   /*-- fixed fields ---*/
unsigned short *pwCapInfo;
unsigned short *pwListenInterval;
-   /*-- info elements --*/
PWLAN_IE_SSID   pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_RSNpRSN;
@@ -543,11 +524,9 @@ typedef struct tagWLAN_FR_ASSOCRESP {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-   /*-- fixed fields ---*/
unsigned short *pwCapInfo;
unsigned short *pwStatus;
unsigned short *pwAid;
-   /*-- info elements --*/
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_SUPP_RATES pExtSuppRates;
 } WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP;
@@ -558,13 +537,9 @@ typedef struct tagWLAN_FR_REASSOCREQ {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-
-   /*-- fixed fields ---*/
unsigned short *pwCapInfo;
unsigned short *pwListenInterval;
PIEEE_ADDR  pAddrCurrAP;
-
-   /*-- info elements --*/
PWLAN_IE_SSID   pSSID;
PWLAN_IE_SUPP_RATES pSuppRates;
PWLAN_IE_RSNpRSN;
@@ -578,11 +553,9 @@ typedef struct tagWLAN_FR_REASSOCRESP {
unsigned intlen;
unsigned char *pBuf;
PUWLAN_80211HDR pHdr;
-   /*-- fixed fields ---*/
unsigned short *pwCapInfo;
unsigned short *pwStatus;
unsigned short *pwAid;
-   /*-- info elements ---

Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Nick Krause
On Thu, Jul 24, 2014 at 2:55 PM, Nick Krause  wrote:
> On Thu, Jul 24, 2014 at 2:49 PM, Richard Weinberger
>  wrote:
>> On Thu, Jul 24, 2014 at 8:41 PM, Nick Krause  wrote:
>>> Steve,
>>> I have programming a lot in other areas just not the kernel.
>>> You are right through I need to test my code better through.
>>
>> Nick,
>>
>> let's make a deal.
>> Take the challenge at http://eudyptula-challenge.org. After you've solved all
>> tasks we'll accept patches from you.
>>
>> --
>> Thanks,
>> //richard
> That's fine,
> So Sorry :(.
> Nick
I sent the challenge a email. Seems that there not replying.
Nick
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Change kzalloc to kcalloc

2014-07-24 Thread Richard Weinberger
Am 24.07.2014 21:05, schrieb Nick Krause:
> On Thu, Jul 24, 2014 at 2:55 PM, Nick Krause  wrote:
>> On Thu, Jul 24, 2014 at 2:49 PM, Richard Weinberger
>>  wrote:
>>> On Thu, Jul 24, 2014 at 8:41 PM, Nick Krause  wrote:
 Steve,
 I have programming a lot in other areas just not the kernel.
 You are right through I need to test my code better through.
>>>
>>> Nick,
>>>
>>> let's make a deal.
>>> Take the challenge at http://eudyptula-challenge.org. After you've solved 
>>> all
>>> tasks we'll accept patches from you.
>>>
>>> --
>>> Thanks,
>>> //richard
>> That's fine,
>> So Sorry :(.
>> Nick
> I sent the challenge a email. Seems that there not replying.

Patience is a virtue.

Thanks,
//richard
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1 linux-next] staging: ion: vm_insert_pfn and zap_page_range rely on CONFIG_MMU

2014-07-24 Thread Greg Kroah-Hartman
On Wed, Jul 23, 2014 at 09:04:38PM +0200, Fabian Frederick wrote:
> Fix following sh-allmodconfig errors reported on kisskb
> "
> drivers/built-in.o: In function `ion_vm_fault':
> ion.c:(.text+0x1f2d8f8): undefined reference to `vm_insert_pfn'
> drivers/built-in.o: In function `ion_buffer_sync_for_device':
> ion.c:(.text+0x1f316bc): undefined reference to `zap_page_range'
> make: *** [vmlinux] Error 1
> "
> 
> Signed-off-by: Fabian Frederick 
> ---
> 
> This is untested.

I'd like to see it tested before I apply it...
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/6 v3] staging: unisys: remove partition information from proc

2014-07-24 Thread Greg KH
On Thu, Jul 24, 2014 at 02:08:45PM -0400, Benjamin Romer wrote:
> Debugging information for the guest's channels was being exposed in proc.
> Remove the code that creates these entries, which are no longer needed.
> 
> Signed-off-by: Benjamin Romer 
> ---
> v3: patch location changed due to prior patches being revised.
> v2: patch location changed due to prior patches being revised.
> 
>  Makefile   |  2 +-
>  .../unisys/visorchipset/visorchipset_main.c| 99 
> --
>  2 files changed, 1 insertion(+), 100 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index f3c543d..a1c224f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1,7 +1,7 @@
>  VERSION = 3
>  PATCHLEVEL = 16
>  SUBLEVEL = 0
> -EXTRAVERSION = -rc5
> +EXTRAVERSION = -bmr4
>  NAME = Shuffling Zombie Juror
>  
>  # *DOCUMENTATION*


Really


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/6 v3] staging: unisys: visorchipset proc fixes

2014-07-24 Thread Greg KH
On Thu, Jul 24, 2014 at 02:08:41PM -0400, Benjamin Romer wrote:
> This patch set moves several interfaces in the visorchipset module from procfs
> to sysfs, and removes the remaining proc interfaces from the module. It 
> includes
> documentation for the new interfaces in Documentation/ABI, and some code 
> cleanup
> in the new sysfs handler functions.
> 
> In version 3 of the set, an unused second parameter was removed from the
> chipsetready attribute, and the parahotplug interface was split into two
> separate attributes. Additional documentation has been added to the ABI doc
> file to describe the use of these interfaces. Formatting mistakes were 
> corrected
> and sysfs attribute functions were made static to match their prototypes.
> 
> In version 2 of the set, extraneous checks for controlvm_channel pointer 
> validity were removed, all newly created attributes use DEVICE_ATTR_RW or 
> DEVICE_ATTR_WO, and logging was removed from the show and store functions to 
> prevent creating a DOS attack possibility. 

I did not apply patches 4 and 5 for the obvious reason that 4 is a crazy
patch...
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >