mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
camera: rockchip: cif: fix fival_list alloc and free
fix fival_list alloc and free with API doesn't match Change-Id: I4d24a783cf8caaba3aa1575be26078cc7e1336fc Signed-off-by: Peng Zhou <benjo.zhou@rock-chips.com>
This commit is contained in:
@@ -260,8 +260,10 @@ static inline unsigned int read_grf_reg(unsigned int addr)
|
||||
* 1.cif uses dmabuf,in this case,vb->boff is buffer fd.
|
||||
*v0.5.0:
|
||||
* 1. Only register cif driver here.
|
||||
*v0.5.1:
|
||||
* 1. fix fival_list alloc and free with API does't match.
|
||||
*/
|
||||
#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 5, 0)
|
||||
#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 5, 1)
|
||||
static int version = RK_CAM_VERSION_CODE;
|
||||
module_param(version, int, S_IRUGO);
|
||||
|
||||
@@ -754,36 +756,44 @@ static int rk_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
|
||||
}
|
||||
|
||||
if (pcdev->camera_work == NULL) {
|
||||
pcdev->camera_work = wk = kzalloc(sizeof(struct rk_camera_work)*(*count), GFP_KERNEL);
|
||||
pcdev->camera_work = kzalloc(
|
||||
sizeof(struct rk_camera_work) * (*count),
|
||||
GFP_KERNEL);
|
||||
if (pcdev->camera_work == NULL) {
|
||||
RKCAMERA_TR("kmalloc failed\n");
|
||||
BUG();
|
||||
}
|
||||
INIT_LIST_HEAD(&pcdev->camera_work_queue);
|
||||
wk = pcdev->camera_work;
|
||||
INIT_LIST_HEAD(&pcdev->camera_work_queue);
|
||||
|
||||
for (i=0; i<(*count); i++) {
|
||||
wk->index = i;
|
||||
list_add_tail(&wk->queue, &pcdev->camera_work_queue);
|
||||
wk++;
|
||||
}
|
||||
for (i = 0; i < (*count); i++) {
|
||||
wk->index = i;
|
||||
list_add_tail(&wk->queue,
|
||||
&pcdev->camera_work_queue);
|
||||
wk++;
|
||||
}
|
||||
pcdev->camera_work_count = (*count);
|
||||
}
|
||||
#if CAMERA_VIDEOBUF_ARM_ACCESS
|
||||
if (pcdev->vbinfo && (pcdev->vbinfo_count != *count)) {
|
||||
kfree(pcdev->vbinfo);
|
||||
pcdev->vbinfo = NULL;
|
||||
pcdev->vbinfo_count = 0x00;
|
||||
}
|
||||
if (pcdev->vbinfo && (pcdev->vbinfo_count != *count)) {
|
||||
kfree(pcdev->vbinfo);
|
||||
pcdev->vbinfo = NULL;
|
||||
pcdev->vbinfo_count = 0x00;
|
||||
}
|
||||
|
||||
if (pcdev->vbinfo == NULL) {
|
||||
pcdev->vbinfo = kzalloc(sizeof(struct rk29_camera_vbinfo)*(*count), GFP_KERNEL);
|
||||
if (pcdev->vbinfo == NULL) {
|
||||
RKCAMERA_TR("vbinfo kmalloc fail\n");
|
||||
BUG();
|
||||
}
|
||||
memset(pcdev->vbinfo,0,sizeof(struct rk29_camera_vbinfo)*(*count));
|
||||
pcdev->vbinfo_count = *count;
|
||||
}
|
||||
if (!pcdev->vbinfo) {
|
||||
pcdev->vbinfo = kzalloc(
|
||||
sizeof(struct rk29_camera_vbinfo) * (*count),
|
||||
GFP_KERNEL);
|
||||
if (!pcdev->vbinfo) {
|
||||
RKCAMERA_TR("vbinfo kmalloc fail\n");
|
||||
WARN_ON(1);
|
||||
}
|
||||
memset(pcdev->vbinfo,
|
||||
0,
|
||||
sizeof(struct rk29_camera_vbinfo) * (*count));
|
||||
pcdev->vbinfo_count = *count;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef RK_CAMERA_MODE_DMA_SG
|
||||
@@ -3038,23 +3048,33 @@ static enum hrtimer_restart rk_camera_fps_func(struct hrtimer *timer)
|
||||
fival_nxt = fival_nxt->nxt;
|
||||
}
|
||||
|
||||
if ((rec_flag == 0) && fival_pre) {
|
||||
fival_pre->nxt = kzalloc(sizeof(struct rk_camera_frmivalenum), GFP_ATOMIC);
|
||||
if (fival_pre->nxt != NULL) {
|
||||
fival_pre->nxt->fival.index = fival_pre->fival.index++;
|
||||
fival_pre->nxt->fival.width = pcdev->icd->user_width;
|
||||
fival_pre->nxt->fival.height= pcdev->icd->user_height;
|
||||
fival_pre->nxt->fival.pixel_format = pcdev->pixfmt;
|
||||
if ((rec_flag == 0) && fival_pre) {
|
||||
fival_pre->nxt = kzalloc(
|
||||
sizeof(struct rk_camera_frmivalenum),
|
||||
GFP_ATOMIC);
|
||||
if (fival_pre->nxt) {
|
||||
fival_pre->nxt->fival.index =
|
||||
fival_pre->fival.index++;
|
||||
fival_pre->nxt->fival.width =
|
||||
pcdev->icd->user_width;
|
||||
fival_pre->nxt->fival.height =
|
||||
pcdev->icd->user_height;
|
||||
fival_pre->nxt->fival.pixel_format =
|
||||
pcdev->pixfmt;
|
||||
|
||||
fival_pre->nxt->fival.discrete.denominator = pcdev->frame_interval;
|
||||
fival_pre->nxt->fival.reserved[1] = (pcdev->icd_width<<16)
|
||||
|(pcdev->icd_height);
|
||||
fival_pre->nxt->fival.discrete.numerator = 1000000;
|
||||
fival_pre->nxt->fival.type = V4L2_FRMIVAL_TYPE_DISCRETE;
|
||||
rec_flag = 1;
|
||||
fival_rec = fival_pre->nxt;
|
||||
}
|
||||
}
|
||||
fival_pre->nxt->fival.discrete.denominator =
|
||||
pcdev->frame_interval;
|
||||
fival_pre->nxt->fival.reserved[1] =
|
||||
(pcdev->icd_width << 16) |
|
||||
(pcdev->icd_height);
|
||||
fival_pre->nxt->fival.discrete.numerator =
|
||||
1000000;
|
||||
fival_pre->nxt->fival.type =
|
||||
V4L2_FRMIVAL_TYPE_DISCRETE;
|
||||
rec_flag = 1;
|
||||
fival_rec = fival_pre->nxt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((pcdev->last_fps != pcdev->fps) && (pcdev->reinit_times)) /*ddl@rock-chips.com v0.3.0x13*/
|
||||
@@ -3715,9 +3735,8 @@ static int rk_camera_probe(struct platform_device *pdev)
|
||||
for (i = 0; i < 2; i++) {
|
||||
pcdev->icd_frmival[i].icd = NULL;
|
||||
pcdev->icd_frmival[i].fival_list =
|
||||
devm_kzalloc(&pdev->dev,
|
||||
sizeof(struct rk_camera_frmivalenum),
|
||||
GFP_KERNEL);
|
||||
kzalloc(sizeof(struct rk_camera_frmivalenum),
|
||||
GFP_KERNEL);
|
||||
if (IS_ERR_OR_NULL(pcdev->icd_frmival[i].fival_list)) {
|
||||
dev_err(&pdev->dev, "Couldn't allocate fival_list[%d]\n",
|
||||
i);
|
||||
@@ -3766,6 +3785,7 @@ exit_free_irq:
|
||||
fival_nxt = fival_list;
|
||||
while (fival_nxt) {
|
||||
fival_nxt = fival_list->nxt;
|
||||
kfree(fival_list);
|
||||
fival_list = fival_nxt;
|
||||
}
|
||||
}
|
||||
@@ -3796,6 +3816,7 @@ static int rk_camera_remove(struct platform_device *pdev)
|
||||
fival_nxt = fival_list;
|
||||
while (fival_nxt) {
|
||||
fival_nxt = fival_list->nxt;
|
||||
kfree(fival_list);
|
||||
fival_list = fival_nxt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user