2015-05-01 17:04:21

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 0/8] staging: comedi: mite: some clean-ups

1) staging: comedi: mite: move #include <linux/slab.h>
2) staging: comedi: mite.h: remove PCIMIO_COMPAT
3) staging: comedi: mite.c: remove commented out USE_KMALLOC
4) staging: comedi: mite.h: remove "../comedi_pci.h" and make
self-reliant
5) staging: comedi: mite.h: reformat some comments
6) staging: comedi: mite.c: reformat comments
7) staging: comedi: mite.h: whitespace changes in function declarations
8) staging: comedi: mite: use a better MODULE_DESCRIPTION()

TODO: document the exported functions in "mite.c".

drivers/staging/comedi/drivers/mite.c | 110 +++++++++++++++++-----------------
drivers/staging/comedi/drivers/mite.h | 88 ++++++++++++++-------------
2 files changed, 101 insertions(+), 97 deletions(-)


2015-05-01 17:04:24

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 1/8] staging: comedi: mite: move #include <linux/slab.h>

The Comedi driver modules build fine if the inclusion of <linux/slab.h>
is removed from "mite.h", so remove it. However, since "mite.c" calls
`kzalloc()`, include <linux/slab.h> there.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.c | 1 +
drivers/staging/comedi/drivers/mite.h | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index e43a0c8..e45ce00 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -47,6 +47,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
+#include <linux/slab.h>

#include "../comedi_pci.h"

diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index b3ca7fc..cf45f88 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -20,7 +20,6 @@
#define _MITE_H_

#include <linux/log2.h>
-#include <linux/slab.h>
#include "../comedi_pci.h"

#define PCIMIO_COMPAT
--
2.1.4

2015-05-01 17:06:27

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 2/8] staging: comedi: mite.h: remove PCIMIO_COMPAT

The macro `PCIMIO_COMPAT` is defined, but never used. Remove it.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.h | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index cf45f88..620de2e 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -22,8 +22,6 @@
#include <linux/log2.h>
#include "../comedi_pci.h"

-#define PCIMIO_COMPAT
-
#define MAX_MITE_DMA_CHANNELS 8

struct mite_dma_descriptor {
--
2.1.4

2015-05-01 17:04:27

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 3/8] staging: comedi: mite.c: remove commented out USE_KMALLOC

The definition of the macro `USE_KMALLOC` is commented out, and nothing
refers to it. Remove the commented out macro.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index e45ce00..66b2bec 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -42,8 +42,6 @@

*/

-/* #define USE_KMALLOC */
-
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
--
2.1.4

2015-05-01 17:06:10

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 4/8] staging: comedi: mite.h: remove "../comedi_pci.h" and make self-reliant

"mite.h" relies on a lot of things declared including "../comedi_pci.h",
but doesn't need anything in "../comedi_pci.h" itself. None of the
Comedi modules that include "mite.h" rely on it to include
"../comedi_pci.h" on their behalf.

Remove the inclusion of "../comedi_pci.h" from "mite.h", and add enough
other includes and (incomplete) `struct` declarations to make it compile
without warnings or errors even when included first in a .c file.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 620de2e..5aa4da9 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -19,11 +19,17 @@
#ifndef _MITE_H_
#define _MITE_H_

+#include <linux/io.h>
#include <linux/log2.h>
-#include "../comedi_pci.h"
+#include <linux/spinlock.h>

#define MAX_MITE_DMA_CHANNELS 8

+struct comedi_device;
+struct comedi_subdevice;
+struct device;
+struct pci_dev;
+
struct mite_dma_descriptor {
__le32 count;
__le32 addr;
--
2.1.4

2015-05-01 17:05:26

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 5/8] staging: comedi: mite.h: reformat some comments

Use the usual style for block comments. Squash double spaces after
comment opening sequences.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.h | 59 ++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 5aa4da9..0d178c1 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -1,20 +1,20 @@
/*
- module/mite.h
- Hardware driver for NI Mite PCI interface chip
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1999 David A. Schleef <[email protected]>
-
- 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.
-*/
+ * module/mite.h
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1999 David A. Schleef <[email protected]>
+ *
+ * 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.
+ */

#ifndef _MITE_H_
#define _MITE_H_
@@ -115,12 +115,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
struct comedi_subdevice *s);

enum mite_registers {
- /* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
- written and read back. The bits 0x1f always read as 1.
- The rest always read as zero. */
+ /*
+ * The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
+ * written and read back. The bits 0x1f always read as 1.
+ * The rest always read as zero.
+ */
MITE_UNKNOWN_DMA_BURST_REG = 0x28,
MITE_IODWBSR = 0xc0, /* IO Device Window Base Size Register */
- MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */
+ MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */
MITE_IODWCR_1 = 0xf4,
MITE_PCI_CONFIG_OFFSET = 0x300,
MITE_CSIGR = 0x460 /* chip signature */
@@ -146,7 +148,7 @@ enum mite_registers {
#define MITE_FCR(x) (0x40 + MITE_CHAN(x)) /* fifo count */

enum MITE_IODWBSR_bits {
- WENAB = 0x80, /* window enable */
+ WENAB = 0x80, /* window enable */
};

static inline unsigned MITE_IODWBSR_1_WSIZE_bits(unsigned size)
@@ -169,27 +171,27 @@ static inline int mite_csigr_version(u32 csigr_bits)
};

static inline int mite_csigr_type(u32 csigr_bits)
-{ /* original mite = 0, minimite = 1 */
+{ /* original mite = 0, minimite = 1 */
return (csigr_bits >> 4) & 0xf;
};

static inline int mite_csigr_mmode(u32 csigr_bits)
-{ /* mite mode, minimite = 1 */
+{ /* mite mode, minimite = 1 */
return (csigr_bits >> 8) & 0x3;
};

static inline int mite_csigr_imode(u32 csigr_bits)
-{ /* cpu port interface mode, pci = 0x3 */
+{ /* cpu port interface mode, pci = 0x3 */
return (csigr_bits >> 12) & 0x3;
};

static inline int mite_csigr_dmac(u32 csigr_bits)
-{ /* number of dma channels */
+{ /* number of dma channels */
return (csigr_bits >> 16) & 0xf;
};

static inline int mite_csigr_wpdep(u32 csigr_bits)
-{ /* write post fifo depth */
+{ /* write post fifo depth */
unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;

return (wpdep_bits) ? (1 << (wpdep_bits - 1)) : 0;
@@ -201,7 +203,7 @@ static inline int mite_csigr_wins(u32 csigr_bits)
};

static inline int mite_csigr_iowins(u32 csigr_bits)
-{ /* number of io windows */
+{ /* number of io windows */
return (csigr_bits >> 29) & 0x7;
};

@@ -290,8 +292,7 @@ static inline int CR_REQS(int source)

static inline int CR_REQSDRQ(unsigned drq_line)
{
- /* This also works on m-series when
- using channels (drq_line) 4 or 5. */
+ /* This also works on m-series when using channels (drq_line) 4 or 5. */
return CR_REQS((drq_line & 0x3) | 0x4);
}

--
2.1.4

2015-05-01 17:04:30

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 6/8] staging: comedi: mite.c: reformat comments

Use the usual style for block comments. Squash double spaces after
comment opening sequences.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.c | 105 +++++++++++++++++-----------------
1 file changed, 54 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index 66b2bec..b514ad1 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -1,46 +1,46 @@
/*
- comedi/drivers/mite.c
- Hardware driver for NI Mite PCI interface chip
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1997-2002 David A. Schleef <[email protected]>
-
- 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.
-*/
+ * comedi/drivers/mite.c
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1997-2002 David A. Schleef <[email protected]>
+ *
+ * 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.
+ */

/*
- The PCI-MIO E series driver was originally written by
- Tomasz Motylewski <...>, and ported to comedi by ds.
-
- References for specifications:
-
- 321747b.pdf Register Level Programmer Manual (obsolete)
- 321747c.pdf Register Level Programmer Manual (new)
- DAQ-STC reference manual
-
- Other possibly relevant info:
-
- 320517c.pdf User manual (obsolete)
- 320517f.pdf User manual (new)
- 320889a.pdf delete
- 320906c.pdf maximum signal ratings
- 321066a.pdf about 16x
- 321791a.pdf discontinuation of at-mio-16e-10 rev. c
- 321808a.pdf about at-mio-16e-10 rev P
- 321837a.pdf discontinuation of at-mio-16de-10 rev d
- 321838a.pdf about at-mio-16de-10 rev N
-
- ISSUES:
-
-*/
+ * The PCI-MIO E series driver was originally written by
+ * Tomasz Motylewski <...>, and ported to comedi by ds.
+ *
+ * References for specifications:
+ *
+ * 321747b.pdf Register Level Programmer Manual (obsolete)
+ * 321747c.pdf Register Level Programmer Manual (new)
+ * DAQ-STC reference manual
+ *
+ * Other possibly relevant info:
+ *
+ * 320517c.pdf User manual (obsolete)
+ * 320517f.pdf User manual (new)
+ * 320889a.pdf delete
+ * 320906c.pdf maximum signal ratings
+ * 321066a.pdf about 16x
+ * 321791a.pdf discontinuation of at-mio-16e-10 rev. c
+ * 321808a.pdf about at-mio-16e-10 rev P
+ * 321837a.pdf discontinuation of at-mio-16de-10 rev d
+ * 321838a.pdf about at-mio-16de-10 rev N
+ *
+ * ISSUES:
+ *
+ */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

@@ -131,7 +131,7 @@ int mite_setup2(struct comedi_device *dev,
mite->mite_io_addr + MITE_IODWBSR);
}
/*
- * make sure dma bursts work. I got this from running a bus analyzer
+ * Make sure dma bursts work. I got this from running a bus analyzer
* on a pxi-6281 and a pxi-6713. 6713 powered up with register value
* of 0x61f and bursts worked. 6281 powered up with register value of
* 0x1f and bursts didn't work. The NI windows driver reads the
@@ -223,7 +223,8 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
unsigned long flags;
struct mite_channel *channel = NULL;

- /* spin lock so mite_release_channel can be called safely
+ /*
+ * spin lock so mite_release_channel can be called safely
* from interrupts
*/
spin_lock_irqsave(&mite->lock, flags);
@@ -245,15 +246,15 @@ void mite_release_channel(struct mite_channel *mite_chan)
struct mite_struct *mite = mite_chan->mite;
unsigned long flags;

- /* spin lock to prevent races with mite_request_channel */
+ /* spin lock to prevent races with mite_request_channel */
spin_lock_irqsave(&mite->lock, flags);
if (mite->channel_allocated[mite_chan->channel]) {
mite_dma_disarm(mite_chan);
mite_dma_reset(mite_chan);
- /*
- * disable all channel's interrupts (do it after disarm/reset so
- * MITE_CHCR reg isn't changed while dma is still active!)
- */
+ /*
+ * disable all channel's interrupts (do it after disarm/reset so
+ * MITE_CHCR reg isn't changed while dma is still active!)
+ */
writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
@@ -285,7 +286,7 @@ void mite_dma_arm(struct mite_channel *mite_chan)
writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
mmiowb();
spin_unlock_irqrestore(&mite->lock, flags);
-/* mite_dma_tcr(mite, channel); */
+ /* mite_dma_tcr(mite, channel); */
}
EXPORT_SYMBOL_GPL(mite_dma_arm);

@@ -528,8 +529,10 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
}

count = nbytes - async->buf_write_count;
- /* it's possible count will be negative due to
- * conservative value returned by mite_bytes_written_to_memory_lb */
+ /*
+ * it's possible count will be negative due to conservative value
+ * returned by mite_bytes_written_to_memory_lb
+ */
if (count <= 0)
return 0;

@@ -550,7 +553,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
u32 nbytes_ub, nbytes_lb;
int count;

- /* read alloc as much as we can */
+ /* read alloc as much as we can */
comedi_buf_read_alloc(s, async->prealloc_bufsz);
nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
if (cmd->stop_src == TRIG_COUNT && (int)(nbytes_lb - stop_count) > 0)
--
2.1.4

2015-05-01 17:05:07

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 7/8] staging: comedi: mite.h: whitespace changes in function declarations

Reformat some function declarations to avoid bunching up near column 80.

Also add a blank line after a `struct` definition.

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.h | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 0d178c1..c32d4e4 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -77,16 +77,13 @@ static inline int mite_setup(struct comedi_device *dev,
void mite_detach(struct mite_struct *mite);
struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite);
void mite_free_ring(struct mite_dma_descriptor_ring *ring);
-struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
- struct
- mite_dma_descriptor_ring
- *ring, unsigned min_channel,
- unsigned max_channel);
-static inline struct mite_channel *mite_request_channel(struct mite_struct
- *mite,
- struct
- mite_dma_descriptor_ring
- *ring)
+struct mite_channel *
+mite_request_channel_in_range(struct mite_struct *mite,
+ struct mite_dma_descriptor_ring *ring,
+ unsigned min_channel, unsigned max_channel);
+static inline struct mite_channel *
+mite_request_channel(struct mite_struct *mite,
+ struct mite_dma_descriptor_ring *ring)
{
return mite_request_channel_in_range(mite, ring, 0,
mite->num_channels - 1);
@@ -285,6 +282,7 @@ enum ConfigRegister_bits {
CR_PORTMXI = (3 << 6),
CR_AMDEVICE = (1 << 0),
};
+
static inline int CR_REQS(int source)
{
return (source & 0x7) << 16;
--
2.1.4

2015-05-01 17:04:47

by Ian Abbott

[permalink] [raw]
Subject: [PATCH 8/8] staging: comedi: mite: use a better MODULE_DESCRIPTION()

Signed-off-by: Ian Abbott <[email protected]>
---
drivers/staging/comedi/drivers/mite.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index b514ad1..fa7ae2c 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -624,5 +624,5 @@ module_init(mite_module_init);
module_exit(mite_module_exit);

MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi helper for NI Mite PCI interface chip");
MODULE_LICENSE("GPL");
--
2.1.4

2015-05-01 20:39:43

by Hartley Sweeten

[permalink] [raw]
Subject: RE: [PATCH 0/8] staging: comedi: mite: some clean-ups

On Friday, May 01, 2015 10:04 AM, Ian Abbott wrote:
> 1) staging: comedi: mite: move #include <linux/slab.h>
> 2) staging: comedi: mite.h: remove PCIMIO_COMPAT
> 3) staging: comedi: mite.c: remove commented out USE_KMALLOC
> 4) staging: comedi: mite.h: remove "../comedi_pci.h" and make
> self-reliant
> 5) staging: comedi: mite.h: reformat some comments
> 6) staging: comedi: mite.c: reformat comments
> 7) staging: comedi: mite.h: whitespace changes in function declarations
> 8) staging: comedi: mite: use a better MODULE_DESCRIPTION()
>
> TODO: document the exported functions in "mite.c".
>
> drivers/staging/comedi/drivers/mite.c | 110 +++++++++++++++++-----------------
> drivers/staging/comedi/drivers/mite.h | 88 ++++++++++++++-------------
> 2 files changed, 101 insertions(+), 97 deletions(-)

Reviewed-by: H Hartley Sweeten <[email protected]>