[RFC] staging:dgap: sparse errors/warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



checkpatch now gives 0 warnings or errors on both dgap.c and dgap.h
so I'm now looking at sparse errors/warnings. There are many and I'm
not really clear as to the best way to address them. This is my first 
exposure to sparse. A quick internet search reveals that using "__iomem"
in some way is the proper fix for most of what I see? 

Here is an initial sparse output showing only the first few:

  CHECK   drivers/staging/dgap/dgap.c
drivers/staging/dgap/dgap.c:652:28: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/dgap/dgap.c:652:28:    expected void volatile [noderef] <asn:2>*addr
drivers/staging/dgap/dgap.c:652:28:    got unsigned char *re_map_port
drivers/staging/dgap/dgap.c:658:28: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/dgap/dgap.c:658:28:    expected void volatile [noderef] <asn:2>*addr
drivers/staging/dgap/dgap.c:658:28:    got unsigned char *re_map_membase
drivers/staging/dgap/dgap.c:977:29: warning: incorrect type in assignment (different address spaces)
drivers/staging/dgap/dgap.c:977:29:    expected unsigned char *re_map_membase
drivers/staging/dgap/dgap.c:977:29:    got void [noderef] <asn:2>*
drivers/staging/dgap/dgap.c:984:26: warning: incorrect type in assignment (different address spaces)
drivers/staging/dgap/dgap.c:984:26:    expected unsigned char *re_map_port
drivers/staging/dgap/dgap.c:984:26:    got void [noderef] <asn:2>*
drivers/staging/dgap/dgap.c:988:28: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/dgap/dgap.c:988:28:    expected void volatile [noderef] <asn:2>*addr
drivers/staging/dgap/dgap.c:988:28:    got unsigned char *re_map_membase
drivers/staging/dgap/dgap.c:2057:32: warning: incorrect type in argument 1 (different address spaces)
drivers/staging/dgap/dgap.c:2057:32:    expected void const volatile [noderef] <asn:2>*addr
drivers/staging/dgap/dgap.c:2057:32:    got unsigned short *<noident>
drivers/staging/dgap/dgap.c:2058:32: warning: incorrect type in argument 2 (different address spaces)
drivers/staging/dgap/dgap.c:2058:32:    expected void volatile [noderef] <asn:2>*addr
drivers/staging/dgap/dgap.c:2058:32:    got unsigned short *<noident>

This patch seems to fix the first 5 but is it the correct way?

diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index e9ba2a4..07e12fd 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -574,8 +574,8 @@ struct board_t {
 	ulong		membase;	/* Start of base memory of the card */
 	ulong		membase_end;	/* End of base memory of the card */
 
-	uchar		*re_map_port;	/* Remapped io port of the card */
-	uchar		*re_map_membase;/* Remapped memory of the card */
+	void __iomem	*re_map_port;	/* Remapped io port of the card */
+	void __iomem	*re_map_membase;/* Remapped memory of the card */
 
 	uchar		runwait;	/* # Processes waiting for FEP  */
 	uchar		inhibit_poller; /* Tells the poller to leave us alone */

And then the last 2 warnings there seems to be a number of ways:

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 4bbedae..cd60d50 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -2054,8 +2054,8 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file)
 		/*
 		 * Flush input queue.
 		 */
-		head = readw(&(bs->rx_head));
-		writew(head, &(bs->rx_tail));
+		head = readw((void __iomem *)&bs->rx_head);
+		writew(head, (void __iomem *)&bs->rx_tail);
 
 		ch->ch_flags = 0;
 		ch->pscan_state = 0;

Or this, which actually causes other warnings

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 4bbedae..ceb82f1 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -1953,7 +1953,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file)
 	struct board_t	*brd;
 	struct channel_t *ch;
 	struct un_t	*un;
-	struct bs_t	*bs;
+	struct bs_t __iomem	*bs;
 	uint		major = 0;
 	uint		minor = 0;
 	int		rc = 0;

Thanks for any pointers
Mark
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux