[PATCH 07/20] staging: comedi: s626: cleanup ioremap()

H Hartley Sweeten hartleys at visionengravers.com
Mon Sep 24 20:23:22 UTC 2012


The local variable 'resourceStart' is only used in the ioremap()
to hold the PCI bar 0 base address. Just use the pci_resource_start()
directly in the ioremap().

Also, instead of assuming the resource size for the ioremap, use
pci_resource_len() to get the actual size.

Remove the kernel noise when the ioremap fails and change the error
code from -ENODEV to -ENOMEM.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/s626.c | 12 ++++--------
 drivers/staging/comedi/drivers/s626.h |  1 -
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 12709b0..6f6c808 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -2446,7 +2446,6 @@ static int s626_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
 /*   unsigned int data[16]; */
 	int i;
 	int ret;
-	resource_size_t resourceStart;
 	dma_addr_t appdma;
 	struct comedi_subdevice *s;
 
@@ -2461,13 +2460,10 @@ static int s626_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
 		return ret;
 	dev->iobase = 1;	/* detach needs this */
 
-	resourceStart = pci_resource_start(pcidev, 0);
-
-	devpriv->base_addr = ioremap(resourceStart, SIZEOF_ADDRESS_SPACE);
-	if (devpriv->base_addr == NULL) {
-		printk(KERN_ERR "s626_attach: IOREMAP failed\n");
-		return -ENODEV;
-	}
+	devpriv->base_addr = ioremap(pci_resource_start(pcidev, 0),
+				     pci_resource_len(pcidev, 0));
+	if (!devpriv->base_addr)
+		return -ENOMEM;
 
 	if (devpriv->base_addr) {
 		/* disable master interrupt */
diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h
index 8a8f196..ff4b3a5 100644
--- a/drivers/staging/comedi/drivers/s626.h
+++ b/drivers/staging/comedi/drivers/s626.h
@@ -73,7 +73,6 @@
 #include <linux/slab.h>
 
 #define S626_SIZE 0x0200
-#define SIZEOF_ADDRESS_SPACE		0x0200
 #define DMABUF_SIZE			4096	/*  4k pages */
 
 #define S626_ADC_CHANNELS       16
-- 
1.7.11




More information about the devel mailing list