[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450741676-5865-82-git-send-email-viro@ZenIV.linux.org.uk>
Date: Mon, 21 Dec 2015 23:47:55 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: linux-kernel@...r.kernel.org
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [POC][PATCH 82/83] media/platform/omap: get rid of pointless casts
From: Al Viro <viro@...iv.linux.org.uk>
Keep ->smsshado_virt_addrp[] and ->buf_virt_addr[] as pointers.
Note that this stuff is 32bit-only, so both unsigned int and
unsigned long are pointer-sized...
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
drivers/media/platform/omap/omap_vout.c | 26 ++++++++++++++------------
drivers/media/platform/omap/omap_vout_vrfb.c | 6 +++---
drivers/media/platform/omap/omap_voutdef.h | 4 ++--
drivers/media/platform/omap/omap_voutlib.c | 15 +++++++--------
drivers/media/platform/omap/omap_voutlib.h | 4 ++--
5 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index 70c28d1..3e298d8 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -240,7 +240,7 @@ void omap_vout_free_buffers(struct omap_vout_device *vout)
omap_vout_free_buffer(vout->buf_virt_addr[i],
vout->buffer_size);
vout->buf_phy_addr[i] = 0;
- vout->buf_virt_addr[i] = 0;
+ vout->buf_virt_addr[i] = NULL;
}
}
@@ -656,7 +656,8 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
unsigned int *size)
{
int startindex = 0, i, j;
- u32 phy_addr = 0, virt_addr = 0;
+ u32 phy_addr = 0;
+ void *virt_addr = NULL;
struct omap_vout_device *vout = q->priv_data;
struct omapvideo_info *ovid = &vout->vid_info;
int vid_max_buf_size;
@@ -712,7 +713,7 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
omap_vout_free_buffer(
vout->smsshado_virt_addr[j],
vout->smsshado_size);
- vout->smsshado_virt_addr[j] = 0;
+ vout->smsshado_virt_addr[j] = NULL;
vout->smsshado_phy_addr[j] = 0;
}
}
@@ -741,7 +742,7 @@ static void omap_vout_free_extra_buffers(struct omap_vout_device *vout)
omap_vout_free_buffer(vout->buf_virt_addr[i],
vout->buffer_size);
- vout->buf_virt_addr[i] = 0;
+ vout->buf_virt_addr[i] = NULL;
vout->buf_phy_addr[i] = 0;
}
vout->buffer_allocated = num_buffers;
@@ -782,13 +783,14 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
if (ret < 0)
return ret;
} else {
- unsigned long addr, dma_addr;
+ void *addr;
+ unsigned long dma_addr;
unsigned long size;
- addr = (unsigned long) vout->buf_virt_addr[vb->i];
+ addr = vout->buf_virt_addr[vb->i];
size = (unsigned long) vb->size;
- dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr,
+ dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, addr,
size, DMA_TO_DEVICE);
if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single failed\n");
@@ -913,11 +915,11 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
vma->vm_ops = &omap_vout_vm_ops;
vma->vm_private_data = (void *) vout;
- pos = (void *)vout->buf_virt_addr[i];
- vma->vm_pgoff = virt_to_phys((void *)pos) >> PAGE_SHIFT;
+ pos = vout->buf_virt_addr[i];
+ vma->vm_pgoff = virt_to_phys(pos) >> PAGE_SHIFT;
while (size > 0) {
unsigned long pfn;
- pfn = virt_to_phys((void *) pos) >> PAGE_SHIFT;
+ pfn = virt_to_phys(pos) >> PAGE_SHIFT;
if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED))
return -EAGAIN;
start += PAGE_SIZE;
@@ -1501,7 +1503,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
for (i = num_buffers; i < vout->buffer_allocated; i++) {
omap_vout_free_buffer(vout->buf_virt_addr[i],
vout->buffer_size);
- vout->buf_virt_addr[i] = 0;
+ vout->buf_virt_addr[i] = NULL;
vout->buf_phy_addr[i] = 0;
}
vout->buffer_allocated = num_buffers;
@@ -1979,7 +1981,7 @@ free_buffers:
for (i = 0; i < numbuffers; i++) {
omap_vout_free_buffer(vout->buf_virt_addr[i],
vout->buffer_size);
- vout->buf_virt_addr[i] = 0;
+ vout->buf_virt_addr[i] = NULL;
vout->buf_phy_addr[i] = 0;
}
return ret;
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index c6e2527..1c89189 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -48,13 +48,13 @@ static int omap_vout_allocate_vrfb_buffers(struct omap_vout_device *vout,
omap_vout_free_buffer(
vout->smsshado_virt_addr[j],
vout->smsshado_size);
- vout->smsshado_virt_addr[j] = 0;
+ vout->smsshado_virt_addr[j] = NULL;
vout->smsshado_phy_addr[j] = 0;
}
*count = 0;
return -ENOMEM;
}
- memset((void *) vout->smsshado_virt_addr[i], 0,
+ memset(vout->smsshado_virt_addr[i], 0,
vout->smsshado_size);
}
return 0;
@@ -81,7 +81,7 @@ void omap_vout_free_vrfb_buffers(struct omap_vout_device *vout)
for (j = 0; j < VRFB_NUM_BUFS; j++) {
omap_vout_free_buffer(vout->smsshado_virt_addr[j],
vout->smsshado_size);
- vout->smsshado_virt_addr[j] = 0;
+ vout->smsshado_virt_addr[j] = NULL;
vout->smsshado_phy_addr[j] = 0;
}
}
diff --git a/drivers/media/platform/omap/omap_voutdef.h b/drivers/media/platform/omap/omap_voutdef.h
index 9ccfe1f..d298d1a 100644
--- a/drivers/media/platform/omap/omap_voutdef.h
+++ b/drivers/media/platform/omap/omap_voutdef.h
@@ -126,7 +126,7 @@ struct omap_vout_device {
/* allow to reuse previously allocated buffer which is big enough */
int buffer_size;
/* keep buffer info across opens */
- unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
+ void *buf_virt_addr[VIDEO_MAX_FRAME];
unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
enum omap_color_mode dss_mode;
@@ -161,7 +161,7 @@ struct omap_vout_device {
struct vid_vrfb_dma vrfb_dma_tx;
unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
- unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
+ void *smsshado_virt_addr[MAC_VRFB_CTXS];
struct vrfb vrfb_context[MAC_VRFB_CTXS];
bool vrfb_static_allocation;
unsigned int smsshado_size;
diff --git a/drivers/media/platform/omap/omap_voutlib.c b/drivers/media/platform/omap/omap_voutlib.c
index f8cf63a..afce476 100644
--- a/drivers/media/platform/omap/omap_voutlib.c
+++ b/drivers/media/platform/omap/omap_voutlib.c
@@ -298,15 +298,14 @@ EXPORT_SYMBOL_GPL(omap_vout_new_format);
/*
* Allocate buffers
*/
-unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
+void *omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
{
u32 order, size;
- unsigned long virt_addr, addr;
+ void *virt_addr, *addr;
size = PAGE_ALIGN(buf_size);
order = get_order(size);
- virt_addr = __get_free_pages(GFP_KERNEL, order);
- addr = virt_addr;
+ addr = virt_addr = get_free_pages(GFP_KERNEL, order);
if (virt_addr) {
while (size > 0) {
@@ -315,17 +314,17 @@ unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
size -= PAGE_SIZE;
}
}
- *phys_addr = (u32) virt_to_phys((void *) virt_addr);
+ *phys_addr = (u32) virt_to_phys(virt_addr);
return virt_addr;
}
/*
* Free buffers
*/
-void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size)
+void omap_vout_free_buffer(void *virtaddr, u32 buf_size)
{
u32 order, size;
- unsigned long addr = virtaddr;
+ void *addr = virtaddr;
size = PAGE_ALIGN(buf_size);
order = get_order(size);
@@ -335,7 +334,7 @@ void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size)
addr += PAGE_SIZE;
size -= PAGE_SIZE;
}
- free_pages((void *)virtaddr, order);
+ free_pages(virtaddr, order);
}
bool omap_vout_dss_omap24xx(void)
diff --git a/drivers/media/platform/omap/omap_voutlib.h b/drivers/media/platform/omap/omap_voutlib.h
index f9d1c07..c62894e 100644
--- a/drivers/media/platform/omap/omap_voutlib.h
+++ b/drivers/media/platform/omap/omap_voutlib.h
@@ -30,8 +30,8 @@ int omap_vout_new_window(struct v4l2_rect *crop,
void omap_vout_new_format(struct v4l2_pix_format *pix,
struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop,
struct v4l2_window *win);
-unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr);
-void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size);
+void *omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr);
+void omap_vout_free_buffer(void *virtaddr, u32 buf_size);
bool omap_vout_dss_omap24xx(void);
bool omap_vout_dss_omap34xx(void);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists