aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Senna Tschudin <peter.senna@gmail.com>2015-05-19 05:44:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-30 22:40:14 -0400
commit07d783fd830a49008f3b2764ae7b6033ee1bf329 (patch)
tree77d2042ff6626aa29cb047791a7d20f1ec23863c
parente97bc8b220c41cab2e84d7410ece70166bba9fe9 (diff)
staging: goldfish: Fix pointer cast for 32 bits
As the first argument of gf_write64() was of type unsigned long, and as some calls to gf_write64() were casting the first argument from void * to u64 the compiler and/or sparse were printing warnings for casts of wrong sizes when compiling for i386. This patch changes the type of the first argument of gf_write64() to const void *, and update calls to the function. This change fixed the warnings and allowed to remove casts from 3 calls to gf_write64(). In addition gf_write64() was renamed to gf_write_ptr() as the name was misleading because it only writes 32 bits on 32 bit systems. gf_write_dma_addr() was added to handle dma_addr_t values which is used at drivers/staging/goldfish/goldfish_audio.c. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/platform/goldfish/goldfish_pipe.c18
-rw-r--r--drivers/staging/goldfish/goldfish_audio.c2
-rw-r--r--drivers/staging/goldfish/goldfish_nand.c2
-rw-r--r--drivers/tty/goldfish.c4
-rw-r--r--include/linux/goldfish.h19
5 files changed, 28 insertions, 17 deletions
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index d9a09d9637d9..aad16bc9e630 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -158,8 +158,8 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd)
158 struct goldfish_pipe_dev *dev = pipe->dev; 158 struct goldfish_pipe_dev *dev = pipe->dev;
159 159
160 spin_lock_irqsave(&dev->lock, flags); 160 spin_lock_irqsave(&dev->lock, flags);
161 gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, 161 gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
162 dev->base + PIPE_REG_CHANNEL_HIGH); 162 dev->base + PIPE_REG_CHANNEL_HIGH);
163 writel(cmd, dev->base + PIPE_REG_COMMAND); 163 writel(cmd, dev->base + PIPE_REG_COMMAND);
164 status = readl(dev->base + PIPE_REG_STATUS); 164 status = readl(dev->base + PIPE_REG_STATUS);
165 spin_unlock_irqrestore(&dev->lock, flags); 165 spin_unlock_irqrestore(&dev->lock, flags);
@@ -172,8 +172,8 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd)
172 struct goldfish_pipe_dev *dev = pipe->dev; 172 struct goldfish_pipe_dev *dev = pipe->dev;
173 173
174 spin_lock_irqsave(&dev->lock, flags); 174 spin_lock_irqsave(&dev->lock, flags);
175 gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, 175 gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
176 dev->base + PIPE_REG_CHANNEL_HIGH); 176 dev->base + PIPE_REG_CHANNEL_HIGH);
177 writel(cmd, dev->base + PIPE_REG_COMMAND); 177 writel(cmd, dev->base + PIPE_REG_COMMAND);
178 spin_unlock_irqrestore(&dev->lock, flags); 178 spin_unlock_irqrestore(&dev->lock, flags);
179} 179}
@@ -327,12 +327,12 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
327 spin_lock_irqsave(&dev->lock, irq_flags); 327 spin_lock_irqsave(&dev->lock, irq_flags);
328 if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, 328 if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset,
329 address, avail, pipe, &status)) { 329 address, avail, pipe, &status)) {
330 gf_write64((u64)(unsigned long)pipe, 330 gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
331 dev->base + PIPE_REG_CHANNEL, 331 dev->base + PIPE_REG_CHANNEL_HIGH);
332 dev->base + PIPE_REG_CHANNEL_HIGH);
333 writel(avail, dev->base + PIPE_REG_SIZE); 332 writel(avail, dev->base + PIPE_REG_SIZE);
334 gf_write64(address, dev->base + PIPE_REG_ADDRESS, 333 gf_write_ptr((void *)address,
335 dev->base + PIPE_REG_ADDRESS_HIGH); 334 dev->base + PIPE_REG_ADDRESS,
335 dev->base + PIPE_REG_ADDRESS_HIGH);
336 writel(CMD_WRITE_BUFFER + cmd_offset, 336 writel(CMD_WRITE_BUFFER + cmd_offset,
337 dev->base + PIPE_REG_COMMAND); 337 dev->base + PIPE_REG_COMMAND);
338 status = readl(dev->base + PIPE_REG_STATUS); 338 status = readl(dev->base + PIPE_REG_STATUS);
diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c
index 702ae04df912..b0927e49d0a8 100644
--- a/drivers/staging/goldfish/goldfish_audio.c
+++ b/drivers/staging/goldfish/goldfish_audio.c
@@ -63,7 +63,7 @@ struct goldfish_audio {
63#define AUDIO_READ(data, addr) (readl(data->reg_base + addr)) 63#define AUDIO_READ(data, addr) (readl(data->reg_base + addr))
64#define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr)) 64#define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr))
65#define AUDIO_WRITE64(data, addr, addr2, x) \ 65#define AUDIO_WRITE64(data, addr, addr2, x) \
66 (gf_write64((u64)(x), data->reg_base + addr, data->reg_base+addr2)) 66 (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base+addr2))
67 67
68/* 68/*
69 * temporary variable used between goldfish_audio_probe() and 69 * temporary variable used between goldfish_audio_probe() and
diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c
index 213877a2c430..66ae48fcc2b2 100644
--- a/drivers/staging/goldfish/goldfish_nand.c
+++ b/drivers/staging/goldfish/goldfish_nand.c
@@ -87,7 +87,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
87 writel((u32)(addr >> 32), base + NAND_ADDR_HIGH); 87 writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
88 writel((u32)addr, base + NAND_ADDR_LOW); 88 writel((u32)addr, base + NAND_ADDR_LOW);
89 writel(len, base + NAND_TRANSFER_SIZE); 89 writel(len, base + NAND_TRANSFER_SIZE);
90 gf_write64((u64)ptr, base + NAND_DATA, base + NAND_DATA_HIGH); 90 gf_write_ptr(ptr, base + NAND_DATA, base + NAND_DATA_HIGH);
91 writel(cmd, base + NAND_COMMAND); 91 writel(cmd, base + NAND_COMMAND);
92 rv = readl(base + NAND_RESULT); 92 rv = readl(base + NAND_RESULT);
93 } 93 }
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 0655fecf8240..0f82c0b146f6 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -59,7 +59,7 @@ static void goldfish_tty_do_write(int line, const char *buf, unsigned count)
59 struct goldfish_tty *qtty = &goldfish_ttys[line]; 59 struct goldfish_tty *qtty = &goldfish_ttys[line];
60 void __iomem *base = qtty->base; 60 void __iomem *base = qtty->base;
61 spin_lock_irqsave(&qtty->lock, irq_flags); 61 spin_lock_irqsave(&qtty->lock, irq_flags);
62 gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, 62 gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR,
63 base + GOLDFISH_TTY_DATA_PTR_HIGH); 63 base + GOLDFISH_TTY_DATA_PTR_HIGH);
64 writel(count, base + GOLDFISH_TTY_DATA_LEN); 64 writel(count, base + GOLDFISH_TTY_DATA_LEN);
65 writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); 65 writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD);
@@ -81,7 +81,7 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
81 81
82 count = tty_prepare_flip_string(&qtty->port, &buf, count); 82 count = tty_prepare_flip_string(&qtty->port, &buf, count);
83 spin_lock_irqsave(&qtty->lock, irq_flags); 83 spin_lock_irqsave(&qtty->lock, irq_flags);
84 gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, 84 gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR,
85 base + GOLDFISH_TTY_DATA_PTR_HIGH); 85 base + GOLDFISH_TTY_DATA_PTR_HIGH);
86 writel(count, base + GOLDFISH_TTY_DATA_LEN); 86 writel(count, base + GOLDFISH_TTY_DATA_LEN);
87 writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); 87 writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD);
diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h
index 569236e6b2bc..93e080b39cf6 100644
--- a/include/linux/goldfish.h
+++ b/include/linux/goldfish.h
@@ -3,13 +3,24 @@
3 3
4/* Helpers for Goldfish virtual platform */ 4/* Helpers for Goldfish virtual platform */
5 5
6static inline void gf_write64(unsigned long data, 6static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
7 void __iomem *portl, void __iomem *porth) 7 void __iomem *porth)
8{ 8{
9 writel((u32)data, portl); 9 writel((u32)(unsigned long)ptr, portl);
10#ifdef CONFIG_64BIT 10#ifdef CONFIG_64BIT
11 writel(data>>32, porth); 11 writel((unsigned long)ptr >> 32, porth);
12#endif 12#endif
13} 13}
14 14
15static inline void gf_write_dma_addr(const dma_addr_t addr,
16 void __iomem *portl,
17 void __iomem *porth)
18{
19 writel((u32)addr, portl);
20#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
21 writel(addr >> 32, porth);
22#endif
23}
24
25
15#endif /* __LINUX_GOLDFISH_H */ 26#endif /* __LINUX_GOLDFISH_H */