Commit 309167b9 authored by Aishwarya Pant's avatar Aishwarya Pant Committed by Mauro Carvalho Chehab

media: staging: atomisp: cleanup out of memory messages

Logging of explicit out of memory messages is redundant since memory allocation
failures produce a backtrace.

Done with the help of the following cocci script:

@@
expression ex, ret;
statement s;
constant char[] c;
constant err;
identifier f, l;
@@

ex =
\(kmalloc\|kmalloc_array\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|devm_kzalloc\)(...)
... when != ex

if (
(
!ex
|
unlikely(!ex)
)
)
- {
- f(..., c, ...);
(
return ex;
|
return;
|
return err;
|
goto l;
)
- }
else s
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent eab638a8
...@@ -1153,10 +1153,8 @@ static int ap1302_probe(struct i2c_client *client, ...@@ -1153,10 +1153,8 @@ static int ap1302_probe(struct i2c_client *client,
/* allocate device & init sub device */ /* allocate device & init sub device */
dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "%s: out of memory\n", __func__);
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -1385,10 +1385,8 @@ static int gc0310_probe(struct i2c_client *client, ...@@ -1385,10 +1385,8 @@ static int gc0310_probe(struct i2c_client *client,
pr_info("%s S\n", __func__); pr_info("%s S\n", __func__);
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -1123,10 +1123,8 @@ static int gc2235_probe(struct i2c_client *client, ...@@ -1123,10 +1123,8 @@ static int gc2235_probe(struct i2c_client *client,
unsigned int i; unsigned int i;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -871,10 +871,8 @@ static int lm3554_probe(struct i2c_client *client, ...@@ -871,10 +871,8 @@ static int lm3554_probe(struct i2c_client *client,
int ret; int ret;
flash = kzalloc(sizeof(*flash), GFP_KERNEL); flash = kzalloc(sizeof(*flash), GFP_KERNEL);
if (!flash) { if (!flash)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
flash->pdata = client->dev.platform_data; flash->pdata = client->dev.platform_data;
......
...@@ -1863,10 +1863,8 @@ static int mt9m114_probe(struct i2c_client *client, ...@@ -1863,10 +1863,8 @@ static int mt9m114_probe(struct i2c_client *client,
/* Setup sensor configuration structure */ /* Setup sensor configuration structure */
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
v4l2_i2c_subdev_init(&dev->sd, client, &mt9m114_ops); v4l2_i2c_subdev_init(&dev->sd, client, &mt9m114_ops);
pdata = client->dev.platform_data; pdata = client->dev.platform_data;
......
...@@ -1447,10 +1447,8 @@ static int ov2680_probe(struct i2c_client *client, ...@@ -1447,10 +1447,8 @@ static int ov2680_probe(struct i2c_client *client,
unsigned int i; unsigned int i;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -1285,10 +1285,8 @@ static int ov2722_probe(struct i2c_client *client, ...@@ -1285,10 +1285,8 @@ static int ov2722_probe(struct i2c_client *client,
struct acpi_device *adev; struct acpi_device *adev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -2364,10 +2364,8 @@ static int imx_probe(struct i2c_client *client, ...@@ -2364,10 +2364,8 @@ static int imx_probe(struct i2c_client *client,
/* allocate sensor device & init sub device */ /* allocate sensor device & init sub device */
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
v4l2_err(client, "%s: out of memory\n", __func__);
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -1958,10 +1958,8 @@ static int ov5693_probe(struct i2c_client *client, ...@@ -1958,10 +1958,8 @@ static int ov5693_probe(struct i2c_client *client,
} }
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -480,8 +480,6 @@ static int ov8858_priv_int_data_init(struct v4l2_subdev *sd) ...@@ -480,8 +480,6 @@ static int ov8858_priv_int_data_init(struct v4l2_subdev *sd)
if (!dev->otp_data) { if (!dev->otp_data) {
dev->otp_data = devm_kzalloc(&client->dev, size, GFP_KERNEL); dev->otp_data = devm_kzalloc(&client->dev, size, GFP_KERNEL);
if (!dev->otp_data) { if (!dev->otp_data) {
dev_err(&client->dev, "%s: can't allocate memory",
__func__);
r = -ENOMEM; r = -ENOMEM;
goto error3; goto error3;
} }
...@@ -2094,10 +2092,8 @@ static int ov8858_probe(struct i2c_client *client, ...@@ -2094,10 +2092,8 @@ static int ov8858_probe(struct i2c_client *client,
/* allocate sensor device & init sub device */ /* allocate sensor device & init sub device */
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev)
dev_err(&client->dev, "%s: out of memory\n", __func__);
return -ENOMEM; return -ENOMEM;
}
mutex_init(&dev->input_lock); mutex_init(&dev->input_lock);
......
...@@ -1137,10 +1137,8 @@ static int remove_pad_from_frame(struct atomisp_device *isp, ...@@ -1137,10 +1137,8 @@ static int remove_pad_from_frame(struct atomisp_device *isp,
ia_css_ptr store = load; ia_css_ptr store = load;
buffer = kmalloc(width*sizeof(load), GFP_KERNEL); buffer = kmalloc(width*sizeof(load), GFP_KERNEL);
if (!buffer) { if (!buffer)
dev_err(isp->dev, "out of memory.\n");
return -ENOMEM; return -ENOMEM;
}
load += ISP_LEFT_PAD; load += ISP_LEFT_PAD;
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
......
...@@ -942,10 +942,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd, ...@@ -942,10 +942,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
dev_dbg(isp->dev, "allocating %d 3a buffers\n", count); dev_dbg(isp->dev, "allocating %d 3a buffers\n", count);
while (count--) { while (count--) {
s3a_buf = kzalloc(sizeof(struct atomisp_s3a_buf), GFP_KERNEL); s3a_buf = kzalloc(sizeof(struct atomisp_s3a_buf), GFP_KERNEL);
if (!s3a_buf) { if (!s3a_buf)
dev_err(isp->dev, "s3a stat buf alloc failed\n");
goto error; goto error;
}
if (atomisp_css_allocate_stat_buffers( if (atomisp_css_allocate_stat_buffers(
asd, stream_id, s3a_buf, NULL, NULL)) { asd, stream_id, s3a_buf, NULL, NULL)) {
...@@ -964,7 +962,6 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd, ...@@ -964,7 +962,6 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
while (count--) { while (count--) {
dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL); dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL);
if (!dis_buf) { if (!dis_buf) {
dev_err(isp->dev, "dis stat buf alloc failed\n");
kfree(s3a_buf); kfree(s3a_buf);
goto error; goto error;
} }
...@@ -989,10 +986,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd, ...@@ -989,10 +986,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
while (count--) { while (count--) {
md_buf = kzalloc(sizeof(struct atomisp_metadata_buf), md_buf = kzalloc(sizeof(struct atomisp_metadata_buf),
GFP_KERNEL); GFP_KERNEL);
if (!md_buf) { if (!md_buf)
dev_err(isp->dev, "metadata buf alloc failed\n");
goto error; goto error;
}
if (atomisp_css_allocate_stat_buffers( if (atomisp_css_allocate_stat_buffers(
asd, stream_id, NULL, NULL, md_buf)) { asd, stream_id, NULL, NULL, md_buf)) {
......
...@@ -365,10 +365,8 @@ ia_css_shading_table_alloc( ...@@ -365,10 +365,8 @@ ia_css_shading_table_alloc(
IA_CSS_ENTER(""); IA_CSS_ENTER("");
me = kmalloc(sizeof(*me), GFP_KERNEL); me = kmalloc(sizeof(*me), GFP_KERNEL);
if (!me) { if (!me)
IA_CSS_ERROR("out of memory");
return me; return me;
}
me->width = width; me->width = width;
me->height = height; me->height = height;
......
...@@ -727,10 +727,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, ...@@ -727,10 +727,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr, bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr,
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!bo->page_obj)) { if (unlikely(!bo->page_obj))
dev_err(atomisp_dev, "out of memory for bo->page_obj\n");
return -ENOMEM; return -ENOMEM;
}
i = 0; i = 0;
alloc_pgnr = 0; alloc_pgnr = 0;
...@@ -991,15 +989,12 @@ static int alloc_user_pages(struct hmm_buffer_object *bo, ...@@ -991,15 +989,12 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
struct page **pages; struct page **pages;
pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL); pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) { if (unlikely(!pages))
dev_err(atomisp_dev, "out of memory for pages...\n");
return -ENOMEM; return -ENOMEM;
}
bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr, bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr,
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!bo->page_obj)) { if (unlikely(!bo->page_obj)) {
dev_err(atomisp_dev, "out of memory for bo->page_obj...\n");
kfree(pages); kfree(pages);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1362,7 +1357,6 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) ...@@ -1362,7 +1357,6 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached)
pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL); pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) { if (unlikely(!pages)) {
mutex_unlock(&bo->mutex); mutex_unlock(&bo->mutex);
dev_err(atomisp_dev, "out of memory for pages...\n");
return NULL; return NULL;
} }
......
...@@ -116,8 +116,6 @@ static void free_pages_to_dynamic_pool(void *pool, ...@@ -116,8 +116,6 @@ static void free_pages_to_dynamic_pool(void *pool,
hmm_page = kmem_cache_zalloc(dypool_info->pgptr_cache, hmm_page = kmem_cache_zalloc(dypool_info->pgptr_cache,
GFP_KERNEL); GFP_KERNEL);
if (!hmm_page) { if (!hmm_page) {
dev_err(atomisp_dev, "out of memory for hmm_page.\n");
/* free page directly */ /* free page directly */
ret = set_pages_wb(page_obj->page, 1); ret = set_pages_wb(page_obj->page, 1);
if (ret) if (ret)
...@@ -151,10 +149,8 @@ static int hmm_dynamic_pool_init(void **pool, unsigned int pool_size) ...@@ -151,10 +149,8 @@ static int hmm_dynamic_pool_init(void **pool, unsigned int pool_size)
dypool_info = kmalloc(sizeof(struct hmm_dynamic_pool_info), dypool_info = kmalloc(sizeof(struct hmm_dynamic_pool_info),
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!dypool_info)) { if (unlikely(!dypool_info))
dev_err(atomisp_dev, "out of memory for repool_info.\n");
return -ENOMEM; return -ENOMEM;
}
dypool_info->pgptr_cache = kmem_cache_create("pgptr_cache", dypool_info->pgptr_cache = kmem_cache_create("pgptr_cache",
sizeof(struct hmm_page), 0, sizeof(struct hmm_page), 0,
......
...@@ -92,15 +92,12 @@ static int hmm_reserved_pool_setup(struct hmm_reserved_pool_info **repool_info, ...@@ -92,15 +92,12 @@ static int hmm_reserved_pool_setup(struct hmm_reserved_pool_info **repool_info,
pool_info = kmalloc(sizeof(struct hmm_reserved_pool_info), pool_info = kmalloc(sizeof(struct hmm_reserved_pool_info),
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!pool_info)) { if (unlikely(!pool_info))
dev_err(atomisp_dev, "out of memory for repool_info.\n");
return -ENOMEM; return -ENOMEM;
}
pool_info->pages = kmalloc(sizeof(struct page *) * pool_size, pool_info->pages = kmalloc(sizeof(struct page *) * pool_size,
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!pool_info->pages)) { if (unlikely(!pool_info->pages)) {
dev_err(atomisp_dev, "out of memory for repool_info->pages.\n");
kfree(pool_info); kfree(pool_info);
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -89,10 +89,8 @@ static struct hmm_vm_node *alloc_hmm_vm_node(unsigned int pgnr, ...@@ -89,10 +89,8 @@ static struct hmm_vm_node *alloc_hmm_vm_node(unsigned int pgnr,
struct hmm_vm_node *node; struct hmm_vm_node *node;
node = kmem_cache_alloc(vm->cache, GFP_KERNEL); node = kmem_cache_alloc(vm->cache, GFP_KERNEL);
if (!node) { if (!node)
dev_err(atomisp_dev, "out of memory.\n");
return NULL; return NULL;
}
INIT_LIST_HEAD(&node->list); INIT_LIST_HEAD(&node->list);
node->pgnr = pgnr; node->pgnr = pgnr;
......
...@@ -785,10 +785,8 @@ int camera_sensor_csi(struct v4l2_subdev *sd, u32 port, ...@@ -785,10 +785,8 @@ int camera_sensor_csi(struct v4l2_subdev *sd, u32 port,
if (flag) { if (flag) {
csi = kzalloc(sizeof(*csi), GFP_KERNEL); csi = kzalloc(sizeof(*csi), GFP_KERNEL);
if (!csi) { if (!csi)
dev_err(&client->dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
}
csi->port = port; csi->port = port;
csi->num_lanes = lanes; csi->num_lanes = lanes;
csi->input_format = format; csi->input_format = format;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment