public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: CodingStyle cleanups for drivers/adl_pci6208.c
@ 2009-09-28 22:00 Bruce Jones
  2009-10-02 22:13 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Bruce Jones @ 2009-09-28 22:00 UTC (permalink / raw)
  To: gregkh; +Cc: wfp5, devel, linux-kernel

Remove unused and commented-out code.  Address basic coding
style issues.  Re-factor a deeply nested routine to conform to
line length restrictions.

Signed-off-by: Bruce Jones <brucej@linux.com>
---
 drivers/staging/comedi/drivers/adl_pci6208.c |  123 ++++++++------------------
 1 files changed, 38 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index 8e1befc..1c25bc2 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -133,10 +133,6 @@ static int pci6208_ao_winsn(struct comedi_device *dev,
 static int pci6208_ao_rinsn(struct comedi_device *dev,
 			    struct comedi_subdevice *s,
 			    struct comedi_insn *insn, unsigned int *data);
-/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data); */
-/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data); */
 
 /*
  * Attach is called by the Comedi core to configure the driver
@@ -151,7 +147,7 @@ static int pci6208_attach(struct comedi_device *dev,
 	int retval;
 	unsigned long io_base;
 
-	printk("comedi%d: pci6208: ", dev->minor);
+	printk(KERN_INFO "comedi%d: pci6208: ", dev->minor);
 
 	retval = alloc_private(dev, sizeof(struct pci6208_private));
 	if (retval < 0)
@@ -210,12 +206,11 @@ static int pci6208_attach(struct comedi_device *dev,
  */
 static int pci6208_detach(struct comedi_device *dev)
 {
-	printk("comedi%d: pci6208: remove\n", dev->minor);
+	printk(KERN_INFO "comedi%d: pci6208: remove\n", dev->minor);
 
 	if (devpriv && devpriv->pci_dev) {
-		if (dev->iobase) {
+		if (dev->iobase)
 			comedi_pci_disable(devpriv->pci_dev);
-		}
 		pci_dev_put(devpriv->pci_dev);
 	}
 
@@ -261,91 +256,50 @@ static int pci6208_ao_rinsn(struct comedi_device *dev,
 	return i;
 }
 
-/* DIO devices are slightly special.  Although it is possible to
- * implement the insn_read/insn_write interface, it is much more
- * useful to applications if you implement the insn_bits interface.
- * This allows packed reading/writing of the DIO channels.  The
- * comedi core can convert between insn_bits and insn_read/write */
-/* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data) */
-/* { */
-/* if(insn->n!=2)return -EINVAL; */
-
-	/* The insn data is a mask in data[0] and the new data
-	 * in data[1], each channel cooresponding to a bit. */
-/* if(data[0]){ */
-/* s->state &= ~data[0]; */
-/* s->state |= data[0]&data[1]; */
-		/* Write out the new digital output lines */
-		/* outw(s->state,dev->iobase + SKEL_DIO); */
-/* } */
-
-	/* on return, data[1] contains the value of the digital
-	 * input and output lines. */
-	/* data[1]=inw(dev->iobase + SKEL_DIO); */
-	/* or we could just return the software copy of the output values if
-	 * it was a purely digital output subdevice */
-	/* data[1]=s->state; */
-
-/* return 2; */
-/* } */
-
-/* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data) */
-/* { */
-/* int chan=CR_CHAN(insn->chanspec); */
-
-	/* The input or output configuration of each digital line is
-	 * configured by a special insn_config instruction.  chanspec
-	 * contains the channel to be changed, and data[0] contains the
-	 * value COMEDI_INPUT or COMEDI_OUTPUT. */
-
-/* if(data[0]==COMEDI_OUTPUT){ */
-/* s->io_bits |= 1<<chan; */
-/* }else{ */
-/* s->io_bits &= ~(1<<chan); */
-/* } */
-	/* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
-
-/* return 1; */
-/* } */
+
+static int pci6208_scan_board(struct pci_dev *pci_dev,
+			      struct comedi_device *dev, int bus, int slot)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
+		if (pci6208_boards[i].dev_id == pci_dev->device) {
+			/*  was a particular bus/slot requested? */
+			if ((bus != 0) || (slot != 0)) {
+				/*  are we on the wrong bus/slot? */
+				if (pci_dev->bus->number != bus ||
+				    PCI_SLOT(pci_dev->devfn) != slot) {
+					continue;
+				}
+			}
+			return i;
+		}
+	}
+	return 0;
+}
 
 static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 {
 	struct pci_dev *pci_dev;
-	int i;
+	int bnum;
 
 	for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	     pci_dev != NULL;
 	     pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
 		if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
-			for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
-				if (pci6208_boards[i].dev_id == pci_dev->device) {
-					/*  was a particular bus/slot requested? */
-					if ((bus != 0) || (slot != 0)) {
-						/*  are we on the wrong bus/slot? */
-						if (pci_dev->bus->number
-						    != bus ||
-						    PCI_SLOT(pci_dev->devfn)
-						    != slot) {
-							continue;
-						}
-					}
-					dev->board_ptr = pci6208_boards + i;
-					goto found;
-				}
+			bnum = pci6208_scan_board(pci_dev, dev, bus, slot);
+			if (bnum)
+				dev->board_ptr = pci6208_boards + bnum;
+			else {
+				printk(KERN_INFO "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+				       dev->minor, bus, slot);
+				return -EIO;
 			}
 		}
 	}
-
-	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-	       dev->minor, bus, slot);
-	return -EIO;
-
-found:
-	printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
+	printk(KERN_INFO "comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
 	       dev->minor,
-	       pci6208_boards[i].name,
+	       pci6208_boards[bnum].name,
 	       pci_dev->bus->number,
 	       PCI_SLOT(pci_dev->devfn),
 	       PCI_FUNC(pci_dev->devfn), pci_dev->irq);
@@ -368,23 +322,22 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
 
 	/*  Enable PCI device and request regions */
 	if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
-		printk
-		    ("comedi%d: Failed to enable PCI device and request regions\n",
+		printk(KERN_INFO "comedi%d: Failed to enable PCI device and request regions\n",
 		     dev_minor);
 		return -EIO;
 	}
-	/*  Read local configuration register base address [PCI_BASE_ADDRESS #1]. */
+	/*  Read local config register base address [PCI_BASE_ADDRESS #1]. */
 	lcr_io_base = pci_resource_start(pci_dev, 1);
 	lcr_io_range = pci_resource_len(pci_dev, 1);
 
-	printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
+	printk(KERN_INFO "comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
 	       dev_minor, lcr_io_base, lcr_io_range);
 
 	/*  Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
 	io_base = pci_resource_start(pci_dev, 2);
 	io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
 
-	printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
+	printk(KERN_INFO "comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
 	       dev_minor, io_base, io_range);
 
 	*io_base_ptr = io_base;
-- 
1.6.5.rc2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: comedi: CodingStyle cleanups for drivers/adl_pci6208.c
  2009-09-28 22:00 [PATCH] staging: comedi: CodingStyle cleanups for drivers/adl_pci6208.c Bruce Jones
@ 2009-10-02 22:13 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2009-10-02 22:13 UTC (permalink / raw)
  To: Bruce Jones; +Cc: gregkh, wfp5, devel, linux-kernel

On Mon, Sep 28, 2009 at 03:00:02PM -0700, Bruce Jones wrote:
> Remove unused and commented-out code.  Address basic coding
> style issues.  Re-factor a deeply nested routine to conform to
> line length restrictions.

Someone already cleaned up this file for the simple fixes, so this
doesn't apply anymore.

sorry,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-02 23:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-28 22:00 [PATCH] staging: comedi: CodingStyle cleanups for drivers/adl_pci6208.c Bruce Jones
2009-10-02 22:13 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox