[PATCH] staging: media: atomisp: use kvmalloc/kvzalloc

2017-08-07 Thread Geliang Tang
Use kvmalloc()/kvzalloc() instead of atomisp_kernel_malloc()
/atomisp_kernel_zalloc().

Signed-off-by: Geliang Tang 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 31 +-
 .../media/atomisp/pci/atomisp2/atomisp_cmd.h   |  2 --
 .../atomisp/pci/atomisp2/atomisp_compat_css20.c|  4 +--
 .../media/atomisp/pci/atomisp2/atomisp_internal.h  |  2 --
 4 files changed, 3 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 7bf5dcd..f48bf45 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -83,35 +83,6 @@ union host {
 };
 
 /*
- * atomisp_kernel_malloc: chooses whether kmalloc() or vmalloc() is preferable.
- *
- * It is also a wrap functions to pass into css framework.
- */
-void *atomisp_kernel_malloc(size_t bytes)
-{
-   /* vmalloc() is preferable if allocating more than 1 page */
-   if (bytes > PAGE_SIZE)
-   return vmalloc(bytes);
-
-   return kmalloc(bytes, GFP_KERNEL);
-}
-
-/*
- * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory.
- *
- * It is also a wrap functions to pass into css framework.
- */
-void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
-{
-   void *ptr = atomisp_kernel_malloc(bytes);
-
-   if (ptr && zero_mem)
-   memset(ptr, 0, bytes);
-
-   return ptr;
-}
-
-/*
  * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field.
  * subdev->priv is set in mrst.c
  */
@@ -4316,7 +4287,7 @@ int atomisp_set_parameters(struct video_device *vdev,
 * are ready, the parameters will be set to CSS.
 * per-frame setting only works for the main output frame.
 */
-   param = atomisp_kernel_zalloc(sizeof(*param), true);
+   param = kvzalloc(sizeof(*param), GFP_KERNEL);
if (!param) {
dev_err(asd->isp->dev, "%s: failed to alloc params 
buffer\n",
__func__);
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
index 1ccd911..31ba4e6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
@@ -78,8 +78,6 @@ static inline void __iomem *atomisp_get_io_virt_addr(unsigned 
int address)
return ret;
 }
 */
-void *atomisp_kernel_malloc(size_t bytes);
-void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem);
 
 /*
  * Interrupt functions
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index 36f934d..05897b7 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -1671,9 +1671,9 @@ int atomisp_alloc_metadata_output_buf(struct 
atomisp_sub_device *asd)
/* We allocate the cpu-side buffer used for communication with user
 * space */
for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-   asd->params.metadata_user[i] = atomisp_kernel_malloc(
+   asd->params.metadata_user[i] = kvmalloc(
asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-   stream_info.metadata_info.size);
+   stream_info.metadata_info.size, GFP_KERNEL);
if (!asd->params.metadata_user[i]) {
while (--i >= 0) {
kvfree(asd->params.metadata_user[i]);
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
index 4b03f28..7542a72f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
@@ -301,8 +301,6 @@ struct atomisp_device {
 
 extern struct device *atomisp_dev;
 
-extern void *atomisp_kernel_malloc(size_t bytes);
-
 #define atomisp_is_wdt_running(a) timer_pending(&(a)->wdt)
 #ifdef ISP2401
 extern void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
-- 
2.9.3



[PATCH 09/12] [media] s5p-mfc: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index bb0a588..2c363aa 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1266,9 +1266,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
dev->hw_lock = 0;
INIT_WORK(&dev->watchdog_work, s5p_mfc_watchdog_worker);
atomic_set(&dev->watchdog_cnt, 0);
-   init_timer(&dev->watchdog_timer);
-   dev->watchdog_timer.data = (unsigned long)dev;
-   dev->watchdog_timer.function = s5p_mfc_watchdog;
+   setup_timer(&dev->watchdog_timer, s5p_mfc_watchdog,
+   (unsigned long)dev);
 
/* Initialize HW ops and commands based on MFC version */
s5p_mfc_init_hw_ops(dev);
-- 
2.9.3



[PATCH 06/12] [media] netup_unidvb: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 191bd82..983 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -663,9 +663,8 @@ static int netup_unidvb_dma_init(struct netup_unidvb_dev 
*ndev, int num)
spin_lock_init(&dma->lock);
INIT_WORK(&dma->work, netup_unidvb_dma_worker);
INIT_LIST_HEAD(&dma->free_buffers);
-   dma->timeout.function = netup_unidvb_dma_timeout;
-   dma->timeout.data = (unsigned long)dma;
-   init_timer(&dma->timeout);
+   setup_timer(&dma->timeout, netup_unidvb_dma_timeout,
+   (unsigned long)dma);
dma->ring_buffer_size = ndev->dma_size / 2;
dma->addr_virt = ndev->dma_virt + dma->ring_buffer_size * num;
dma->addr_phys = (dma_addr_t)((u64)ndev->dma_phys +
-- 
2.9.3



[PATCH 10/12] [media] c8sectpfe: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 7652ce2..59280ac 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -865,9 +865,8 @@ static int c8sectpfe_probe(struct platform_device *pdev)
}
 
/* Setup timer interrupt */
-   init_timer(&fei->timer);
-   fei->timer.function = c8sectpfe_timer_interrupt;
-   fei->timer.data = (unsigned long)fei;
+   setup_timer(&fei->timer, c8sectpfe_timer_interrupt,
+   (unsigned long)fei);
 
mutex_init(&fei->lock);
 
-- 
2.9.3



[PATCH 12/12] [media] imon: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/rc/imon.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 89823d2..3489010 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -2412,9 +2412,8 @@ static struct imon_context *imon_init_intf1(struct 
usb_interface *intf,
mutex_lock(&ictx->lock);
 
if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) {
-   init_timer(&ictx->ttimer);
-   ictx->ttimer.data = (unsigned long)ictx;
-   ictx->ttimer.function = imon_touch_display_timeout;
+   setup_timer(&ictx->ttimer, imon_touch_display_timeout,
+   (unsigned long)ictx);
}
 
ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf));
-- 
2.9.3



[PATCH 05/12] [media] ivtv: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ivtv/ivtv-driver.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c 
b/drivers/media/pci/ivtv/ivtv-driver.c
index a71a03e..e8fa99b 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -770,9 +770,8 @@ static int ivtv_init_struct1(struct ivtv *itv)
init_waitqueue_head(&itv->event_waitq);
init_waitqueue_head(&itv->vsync_waitq);
init_waitqueue_head(&itv->dma_waitq);
-   init_timer(&itv->dma_timer);
-   itv->dma_timer.function = ivtv_unfinished_dma;
-   itv->dma_timer.data = (unsigned long)itv;
+   setup_timer(&itv->dma_timer, ivtv_unfinished_dma,
+   (unsigned long)itv);
 
itv->cur_dma_stream = -1;
itv->cur_pio_stream = -1;
-- 
2.9.3



[PATCH 08/12] [media] fsl-viu: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/fsl-viu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index ae8c6b3..97e164b 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1466,9 +1466,8 @@ static int viu_of_probe(struct platform_device *op)
viu_dev->decoder = v4l2_i2c_new_subdev(&viu_dev->v4l2_dev, ad,
"saa7113", VIU_VIDEO_DECODER_ADDR, NULL);
 
-   viu_dev->vidq.timeout.function = viu_vid_timeout;
-   viu_dev->vidq.timeout.data = (unsigned long)viu_dev;
-   init_timer(&viu_dev->vidq.timeout);
+   setup_timer(&viu_dev->vidq.timeout, viu_vid_timeout,
+   (unsigned long)viu_dev);
viu_dev->std = V4L2_STD_NTSC_M;
viu_dev->first = 1;
 
-- 
2.9.3



[PATCH 07/12] [media] av7110: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ttpci/av7110_ir.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ttpci/av7110_ir.c 
b/drivers/media/pci/ttpci/av7110_ir.c
index 10e28f0..ca05198 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -333,9 +333,8 @@ int av7110_ir_init(struct av7110 *av7110)
av_list[av_cnt++] = av7110;
av7110_check_ir_config(av7110, true);
 
-   init_timer(&av7110->ir.keyup_timer);
-   av7110->ir.keyup_timer.function = av7110_emit_keyup;
-   av7110->ir.keyup_timer.data = (unsigned long) &av7110->ir;
+   setup_timer(&av7110->ir.keyup_timer, av7110_emit_keyup,
+   (unsigned long)&av7110->ir);
 
input_dev = input_allocate_device();
if (!input_dev)
-- 
2.9.3



[PATCH 04/12] [media] cx18: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/cx18/cx18-streams.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-streams.c 
b/drivers/media/pci/cx18/cx18-streams.c
index 7c93814..3c45e007 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -282,9 +282,7 @@ static void cx18_stream_init(struct cx18 *cx, int type)
INIT_WORK(&s->out_work_order, cx18_out_work_handler);
 
INIT_LIST_HEAD(&s->vb_capture);
-   s->vb_timeout.function = cx18_vb_timeout;
-   s->vb_timeout.data = (unsigned long)s;
-   init_timer(&s->vb_timeout);
+   setup_timer(&s->vb_timeout, cx18_vb_timeout, (unsigned long)s);
spin_lock_init(&s->vb_lock);
if (type == CX18_ENC_STREAM_TYPE_YUV) {
spin_lock_init(&s->vbuf_q_lock);
-- 
2.9.3



[PATCH 03/12] [media] bt8xx: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index fb4aefb..ed319f1 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4043,9 +4043,7 @@ static int bttv_probe(struct pci_dev *dev, const struct 
pci_device_id *pci_id)
INIT_LIST_HEAD(&btv->capture);
INIT_LIST_HEAD(&btv->vcapture);
 
-   init_timer(&btv->timeout);
-   btv->timeout.function = bttv_irq_timeout;
-   btv->timeout.data = (unsigned long)btv;
+   setup_timer(&btv->timeout, bttv_irq_timeout, (unsigned long)btv);
 
btv->i2c_rc = -1;
btv->tuner_type  = UNSET;
-- 
2.9.3



[PATCH 11/12] [media] wl128x: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/radio/wl128x/fmdrv_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 74a1b3e..588e2d6 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1550,9 +1550,8 @@ int fmc_prepare(struct fmdev *fmdev)
atomic_set(&fmdev->tx_cnt, 1);
fmdev->resp_comp = NULL;
 
-   init_timer(&fmdev->irq_info.timer);
-   fmdev->irq_info.timer.function = &int_timeout_handler;
-   fmdev->irq_info.timer.data = (unsigned long)fmdev;
+   setup_timer(&fmdev->irq_info.timer, &int_timeout_handler,
+   (unsigned long)fmdev);
/*TODO: add FM_STIC_EVENT later */
fmdev->irq_info.mask = FM_MAL_EVENT;
 
-- 
2.9.3



[PATCH 01/12] [media] saa7134: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/saa7134/saa7134-ts.c| 5 ++---
 drivers/media/pci/saa7134/saa7134-vbi.c   | 5 ++---
 drivers/media/pci/saa7134/saa7134-video.c | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-ts.c 
b/drivers/media/pci/saa7134/saa7134-ts.c
index 578e03f..7414878 100644
--- a/drivers/media/pci/saa7134/saa7134-ts.c
+++ b/drivers/media/pci/saa7134/saa7134-ts.c
@@ -223,9 +223,8 @@ int saa7134_ts_init1(struct saa7134_dev *dev)
dev->ts.nr_packets = ts_nr_packets;
 
INIT_LIST_HEAD(&dev->ts_q.queue);
-   init_timer(&dev->ts_q.timeout);
-   dev->ts_q.timeout.function = saa7134_buffer_timeout;
-   dev->ts_q.timeout.data = (unsigned long)(&dev->ts_q);
+   setup_timer(&dev->ts_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(&dev->ts_q));
dev->ts_q.dev  = dev;
dev->ts_q.need_two = 1;
dev->ts_started= 0;
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c 
b/drivers/media/pci/saa7134/saa7134-vbi.c
index 4619337..bcad9b2 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -181,9 +181,8 @@ struct vb2_ops saa7134_vbi_qops = {
 int saa7134_vbi_init1(struct saa7134_dev *dev)
 {
INIT_LIST_HEAD(&dev->vbi_q.queue);
-   init_timer(&dev->vbi_q.timeout);
-   dev->vbi_q.timeout.function = saa7134_buffer_timeout;
-   dev->vbi_q.timeout.data = (unsigned long)(&dev->vbi_q);
+   setup_timer(&dev->vbi_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(&dev->vbi_q));
dev->vbi_q.dev  = dev;
 
if (vbibufs < 2)
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 4b1c432..51d42bb 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2145,9 +2145,8 @@ int saa7134_video_init1(struct saa7134_dev *dev)
dev->automute   = 0;
 
INIT_LIST_HEAD(&dev->video_q.queue);
-   init_timer(&dev->video_q.timeout);
-   dev->video_q.timeout.function = saa7134_buffer_timeout;
-   dev->video_q.timeout.data = (unsigned long)(&dev->video_q);
+   setup_timer(&dev->video_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(&dev->video_q));
dev->video_q.dev  = dev;
dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
dev->width= 720;
-- 
2.9.3



[PATCH 02/12] [media] saa7146: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/common/saa7146/saa7146_vbi.c   | 5 ++---
 drivers/media/common/saa7146/saa7146_video.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_vbi.c 
b/drivers/media/common/saa7146/saa7146_vbi.c
index 4923751..3553ac4 100644
--- a/drivers/media/common/saa7146/saa7146_vbi.c
+++ b/drivers/media/common/saa7146/saa7146_vbi.c
@@ -365,9 +365,8 @@ static void vbi_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 
INIT_LIST_HEAD(&vv->vbi_dmaq.queue);
 
-   init_timer(&vv->vbi_dmaq.timeout);
-   vv->vbi_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->vbi_dmaq.timeout.data = (unsigned long)(&vv->vbi_dmaq);
+   setup_timer(&vv->vbi_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(&vv->vbi_dmaq));
vv->vbi_dmaq.dev  = dev;
 
init_waitqueue_head(&vv->vbi_wq);
diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index e034bcf..b3b29d4 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -1201,9 +1201,8 @@ static void video_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 {
INIT_LIST_HEAD(&vv->video_dmaq.queue);
 
-   init_timer(&vv->video_dmaq.timeout);
-   vv->video_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->video_dmaq.timeout.data = (unsigned long)(&vv->video_dmaq);
+   setup_timer(&vv->video_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(&vv->video_dmaq));
vv->video_dmaq.dev  = dev;
 
/* set some default values */
-- 
2.9.3



[PATCH] [media] ivtv: use for_each_sg

2017-03-24 Thread Geliang Tang
Use for_each_sg() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ivtv/ivtv-udma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ivtv/ivtv-udma.c 
b/drivers/media/pci/ivtv/ivtv-udma.c
index 2c9232e..3b33e87 100644
--- a/drivers/media/pci/ivtv/ivtv-udma.c
+++ b/drivers/media/pci/ivtv/ivtv-udma.c
@@ -76,7 +76,7 @@ void ivtv_udma_fill_sg_array (struct ivtv_user_dma *dma, u32 
buffer_offset, u32
int i;
struct scatterlist *sg;
 
-   for (i = 0, sg = dma->SGlist; i < dma->SG_length; i++, sg = 
sg_next(sg)) {
+   for_each_sg(dma->SGlist, sg, dma->SG_length, i) {
dma->SGarray[i].size = cpu_to_le32(sg_dma_len(sg));
dma->SGarray[i].src = cpu_to_le32(sg_dma_address(sg));
dma->SGarray[i].dst = cpu_to_le32(buffer_offset);
-- 
2.9.3



[PATCH] staging: media: atomisp: use kvmalloc and kvfree

2017-03-23 Thread Geliang Tang
Use kvmalloc() and kvfree() instead of open-coding.

Signed-off-by: Geliang Tang 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..c7b9320 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -90,10 +90,7 @@ union host {
 void *atomisp_kernel_malloc(size_t bytes)
 {
/* vmalloc() is preferable if allocating more than 1 page */
-   if (bytes > PAGE_SIZE)
-   return vmalloc(bytes);
-
-   return kmalloc(bytes, GFP_KERNEL);
+   return kvmalloc(bytes, GFP_KERNEL);
 }
 
 /*
@@ -118,10 +115,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
 void atomisp_kernel_free(void *ptr)
 {
/* Verify if buffer was allocated by vmalloc() or kmalloc() */
-   if (is_vmalloc_addr(ptr))
-   vfree(ptr);
-   else
-   kfree(ptr);
+   kvfree(ptr);
 }
 
 /*
-- 
2.9.3



[PATCH] staging: media: atomisp: fix build error

2017-03-23 Thread Geliang Tang
Fix the following build error:

  CC  drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
 error: excess elements in array initializer [-Werror]
  "i", /* ion */
  ^~~
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c:52:2:
 note: (near initialization for ‘hmm_bo_type_strings’)
cc1: all warnings being treated as errors
scripts/Makefile.build:294: recipe for target
'drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.o' failed

Signed-off-by: Geliang Tang 
---
 drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index a362b49..e78f02f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -49,7 +49,9 @@ const char *hmm_bo_type_strings[HMM_BO_LAST] = {
"p", /* private */
"s", /* shared */
"u", /* user */
+#ifdef CONFIG_ION
"i", /* ion */
+#endif
 };
 
 static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
-- 
2.9.3



[PATCH] [media] netup_unidvb: use module_pci_driver

2016-11-16 Thread Geliang Tang
Use module_pci_driver() helper to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index b078ac2..191bd82 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -1030,15 +1030,4 @@ static struct pci_driver netup_unidvb_pci_driver = {
.resume   = NULL,
 };
 
-static int __init netup_unidvb_init(void)
-{
-   return pci_register_driver(&netup_unidvb_pci_driver);
-}
-
-static void __exit netup_unidvb_fini(void)
-{
-   pci_unregister_driver(&netup_unidvb_pci_driver);
-}
-
-module_init(netup_unidvb_init);
-module_exit(netup_unidvb_fini);
+module_pci_driver(netup_unidvb_pci_driver);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] sh_mobile_ceu_camera: use module_platform_driver

2016-11-15 Thread Geliang Tang
Use module_platform_driver() helper to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index a15bfb5..96dc017 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -1801,18 +1801,7 @@ static struct platform_driver sh_mobile_ceu_driver = {
.remove = sh_mobile_ceu_remove,
 };
 
-static int __init sh_mobile_ceu_init(void)
-{
-   return platform_driver_register(&sh_mobile_ceu_driver);
-}
-
-static void __exit sh_mobile_ceu_exit(void)
-{
-   platform_driver_unregister(&sh_mobile_ceu_driver);
-}
-
-module_init(sh_mobile_ceu_init);
-module_exit(sh_mobile_ceu_exit);
+module_platform_driver(sh_mobile_ceu_driver);
 
 MODULE_DESCRIPTION("SuperH Mobile CEU driver");
 MODULE_AUTHOR("Magnus Damm");
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] sh_mobile_ceu_camera: use soc_camera_from_vb2q

2016-01-05 Thread Geliang Tang
Use soc_camera_from_vb2q() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c 
b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 90c87f2..b9f369c 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -213,8 +213,7 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue 
*vq,
unsigned int *count, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[])
 {
-   struct soc_camera_device *icd = container_of(vq,
-   struct soc_camera_device, vb2_vidq);
+   struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
 
@@ -361,8 +360,7 @@ static int sh_mobile_ceu_videobuf_prepare(struct vb2_buffer 
*vb)
 static void sh_mobile_ceu_videobuf_queue(struct vb2_buffer *vb)
 {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-   struct soc_camera_device *icd = container_of(vb->vb2_queue,
-   struct soc_camera_device, vb2_vidq);
+   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
@@ -413,8 +411,7 @@ error:
 static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
 {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-   struct soc_camera_device *icd = container_of(vb->vb2_queue,
-   struct soc_camera_device, vb2_vidq);
+   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
@@ -444,8 +441,7 @@ static void sh_mobile_ceu_videobuf_release(struct 
vb2_buffer *vb)
 static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb)
 {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-   struct soc_camera_device *icd = container_of(vb->vb2_queue,
-   struct soc_camera_device, vb2_vidq);
+   struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
 
@@ -460,7 +456,7 @@ static int sh_mobile_ceu_videobuf_init(struct vb2_buffer 
*vb)
 
 static void sh_mobile_ceu_stop_streaming(struct vb2_queue *q)
 {
-   struct soc_camera_device *icd = container_of(q, struct 
soc_camera_device, vb2_vidq);
+   struct soc_camera_device *icd = soc_camera_from_vb2q(q);
struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
struct list_head *buf_head, *tmp;
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] bttv-driver, usbvision-video: use to_video_device()

2015-12-22 Thread Geliang Tang
Use to_video_device() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/bt8xx/bttv-driver.c |  2 +-
 drivers/media/usb/usbvision/usbvision-video.c | 27 +--
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index 9400e99..a04329a 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -186,7 +186,7 @@ MODULE_VERSION(BTTV_VERSION);
 static ssize_t show_card(struct device *cd,
 struct device_attribute *attr, char *buf)
 {
-   struct video_device *vfd = container_of(cd, struct video_device, dev);
+   struct video_device *vfd = to_video_device(cd);
struct bttv *btv = video_get_drvdata(vfd);
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
 }
diff --git a/drivers/media/usb/usbvision/usbvision-video.c 
b/drivers/media/usb/usbvision/usbvision-video.c
index de9ff3b..7f5d6f1 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -162,8 +162,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
 
 static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
return video_get_drvdata(vdev);
 }
 
@@ -177,8 +176,7 @@ static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
 static ssize_t show_model(struct device *cd,
  struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%s\n",
   
usbvision_device_data[usbvision->dev_model].model_string);
@@ -188,8 +186,7 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
 static ssize_t show_hue(struct device *cd,
struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_HUE;
@@ -203,8 +200,7 @@ static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
 static ssize_t show_contrast(struct device *cd,
 struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_CONTRAST;
@@ -218,8 +214,7 @@ static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
 static ssize_t show_brightness(struct device *cd,
   struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -233,8 +228,7 @@ static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, 
NULL);
 static ssize_t show_saturation(struct device *cd,
   struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_SATURATION;
@@ -248,8 +242,7 @@ static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, 
NULL);
 static ssize_t show_streaming(struct device *cd,
  struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%s\n",
   YES_NO(usbvision->streaming == stream_on ? 1 : 0));
@@ -259,8 +252,7 @@ static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, 
NULL);
 static ssize_t show_compression(struct device *cd,
struct device_attribute *attr, char *buf)
 {
-   struct video_device *vdev =
-   container_of(cd, struct video_device, dev);
+   struct video_device *vdev = to_video_device(cd);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf

[PATCH 1/3] media: dvb-core: fix kernel-doc warnings in dvbdev.h

2015-09-17 Thread Geliang Tang
Fix the following 'make htmldocs' warnings:

  .//drivers/media/dvb-core/dvbdev.h:199: warning: Excess function parameter 
'device' description in 'dvb_register_device'
  .//drivers/media/dvb-core/dvbdev.h:199: warning: Excess function parameter 
'adapter_nums' description in 'dvb_register_device'

Signed-off-by: Geliang Tang 
---
 drivers/media/dvb-core/dvbdev.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index c61a4f0..1069a77 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -184,10 +184,6 @@ int dvb_unregister_adapter(struct dvb_adapter *adap);
  * @pdvbdev:   pointer to the place where the new struct dvb_device will be
  * stored
  * @template:  Template used to create &pdvbdev;
- * @device:pointer to struct device that corresponds to the device driver
- * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter;
- * to select among them. Typically, initialized with:
- * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums)
  * @priv:  private data
  * @type:  type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND,
  * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: fix kernel-doc warnings in v4l2-dv-timings.h

2015-09-15 Thread Geliang Tang
Fix the following 'make htmldocs' warnings:

  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'frame_height'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'hfreq'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'vsync'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'active_width'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'polarities'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'interlaced'
  .//include/media/v4l2-dv-timings.h:147: warning: No description found for 
parameter 'fmt'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'frame_height'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'hfreq'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'vsync'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'polarities'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'interlaced'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'aspect'
  .//include/media/v4l2-dv-timings.h:171: warning: No description found for 
parameter 'fmt'
  .//include/media/v4l2-dv-timings.h:184: warning: No description found for 
parameter 'hor_landscape'
  .//include/media/v4l2-dv-timings.h:184: warning: No description found for 
parameter 'vert_portrait'

Signed-off-by: Geliang Tang 
---
 include/media/v4l2-dv-timings.h | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index b6130b5..9c7147b 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -127,16 +127,16 @@ void v4l2_print_dv_timings(const char *dev_prefix, const 
char *prefix,
 /**
  * v4l2_detect_cvt - detect if the given timings follow the CVT standard
  *
- * @frame_height - the total height of the frame (including blanking) in lines.
- * @hfreq - the horizontal frequency in Hz.
- * @vsync - the height of the vertical sync in lines.
- * @active_width - active width of image (does not include blanking). This
+ * @frame_height: the total height of the frame (including blanking) in lines.
+ * @hfreq: the horizontal frequency in Hz.
+ * @vsync: the height of the vertical sync in lines.
+ * @active_width: active width of image (does not include blanking). This
  * information is needed only in case of version 2 of reduced blanking.
  * In other cases, this parameter does not have any effect on timings.
- * @polarities - the horizontal and vertical polarities (same as struct
+ * @polarities: the horizontal and vertical polarities (same as struct
  * v4l2_bt_timings polarities).
- * @interlaced - if this flag is true, it indicates interlaced format
- * @fmt - the resulting timings.
+ * @interlaced: if this flag is true, it indicates interlaced format
+ * @fmt: the resulting timings.
  *
  * This function will attempt to detect if the given values correspond to a
  * valid CVT format. If so, then it will return true, and fmt will be filled
@@ -149,18 +149,18 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned 
hfreq, unsigned vsync,
 /**
  * v4l2_detect_gtf - detect if the given timings follow the GTF standard
  *
- * @frame_height - the total height of the frame (including blanking) in lines.
- * @hfreq - the horizontal frequency in Hz.
- * @vsync - the height of the vertical sync in lines.
- * @polarities - the horizontal and vertical polarities (same as struct
+ * @frame_height: the total height of the frame (including blanking) in lines.
+ * @hfreq: the horizontal frequency in Hz.
+ * @vsync: the height of the vertical sync in lines.
+ * @polarities: the horizontal and vertical polarities (same as struct
  * v4l2_bt_timings polarities).
- * @interlaced - if this flag is true, it indicates interlaced format
- * @aspect - preferred aspect ratio. GTF has no method of determining the
+ * @interlaced: if this flag is true, it indicates interlaced format
+ * @aspect: preferred aspect ratio. GTF has no method of determining the
  * aspect ratio in order to derive the image width from the
  * image height, so it has to be passed explicitly. Usually
  * the native screen aspect ratio is used for this. If it
  * is not filled in correctly, then 16:9 will be assumed.
- * @fmt - the resulting timings.
+ * @fmt: the resulting timings.
  *
  * This function will attempt to detect if the given values correspond to a
  *