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,
/* allocate device & init sub device */
dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "%s: out of memory\n", __func__);
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -1385,10 +1385,8 @@ static int gc0310_probe(struct i2c_client *client,
pr_info("%s S\n", __func__);
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -1123,10 +1123,8 @@ static int gc2235_probe(struct i2c_client *client,
unsigned int i;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -871,10 +871,8 @@ static int lm3554_probe(struct i2c_client *client,
int ret;
flash = kzalloc(sizeof(*flash), GFP_KERNEL);
if (!flash) {
dev_err(&client->dev, "out of memory\n");
if (!flash)
return -ENOMEM;
}
flash->pdata = client->dev.platform_data;
......
......@@ -1863,10 +1863,8 @@ static int mt9m114_probe(struct i2c_client *client,
/* Setup sensor configuration structure */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
v4l2_i2c_subdev_init(&dev->sd, client, &mt9m114_ops);
pdata = client->dev.platform_data;
......
......@@ -1447,10 +1447,8 @@ static int ov2680_probe(struct i2c_client *client,
unsigned int i;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -1285,10 +1285,8 @@ static int ov2722_probe(struct i2c_client *client,
struct acpi_device *adev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -2364,10 +2364,8 @@ static int imx_probe(struct i2c_client *client,
/* allocate sensor device & init sub device */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
v4l2_err(client, "%s: out of memory\n", __func__);
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -1958,10 +1958,8 @@ static int ov5693_probe(struct i2c_client *client,
}
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "out of memory\n");
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -480,8 +480,6 @@ static int ov8858_priv_int_data_init(struct v4l2_subdev *sd)
if (!dev->otp_data) {
dev->otp_data = devm_kzalloc(&client->dev, size, GFP_KERNEL);
if (!dev->otp_data) {
dev_err(&client->dev, "%s: can't allocate memory",
__func__);
r = -ENOMEM;
goto error3;
}
......@@ -2094,10 +2092,8 @@ static int ov8858_probe(struct i2c_client *client,
/* allocate sensor device & init sub device */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
dev_err(&client->dev, "%s: out of memory\n", __func__);
if (!dev)
return -ENOMEM;
}
mutex_init(&dev->input_lock);
......
......@@ -1137,10 +1137,8 @@ static int remove_pad_from_frame(struct atomisp_device *isp,
ia_css_ptr store = load;
buffer = kmalloc(width*sizeof(load), GFP_KERNEL);
if (!buffer) {
dev_err(isp->dev, "out of memory.\n");
if (!buffer)
return -ENOMEM;
}
load += ISP_LEFT_PAD;
for (i = 0; i < height; i++) {
......
......@@ -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);
while (count--) {
s3a_buf = kzalloc(sizeof(struct atomisp_s3a_buf), GFP_KERNEL);
if (!s3a_buf) {
dev_err(isp->dev, "s3a stat buf alloc failed\n");
if (!s3a_buf)
goto error;
}
if (atomisp_css_allocate_stat_buffers(
asd, stream_id, s3a_buf, NULL, NULL)) {
......@@ -964,7 +962,6 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
while (count--) {
dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL);
if (!dis_buf) {
dev_err(isp->dev, "dis stat buf alloc failed\n");
kfree(s3a_buf);
goto error;
}
......@@ -989,10 +986,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
while (count--) {
md_buf = kzalloc(sizeof(struct atomisp_metadata_buf),
GFP_KERNEL);
if (!md_buf) {
dev_err(isp->dev, "metadata buf alloc failed\n");
if (!md_buf)
goto error;
}
if (atomisp_css_allocate_stat_buffers(
asd, stream_id, NULL, NULL, md_buf)) {
......
......@@ -365,10 +365,8 @@ ia_css_shading_table_alloc(
IA_CSS_ENTER("");
me = kmalloc(sizeof(*me), GFP_KERNEL);
if (!me) {
IA_CSS_ERROR("out of memory");
if (!me)
return me;
}
me->width = width;
me->height = height;
......
......@@ -727,10 +727,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr,
GFP_KERNEL);
if (unlikely(!bo->page_obj)) {
dev_err(atomisp_dev, "out of memory for bo->page_obj\n");
if (unlikely(!bo->page_obj))
return -ENOMEM;
}
i = 0;
alloc_pgnr = 0;
......@@ -991,15 +989,12 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
struct page **pages;
pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) {
dev_err(atomisp_dev, "out of memory for pages...\n");
if (unlikely(!pages))
return -ENOMEM;
}
bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr,
GFP_KERNEL);
if (unlikely(!bo->page_obj)) {
dev_err(atomisp_dev, "out of memory for bo->page_obj...\n");
kfree(pages);
return -ENOMEM;
}
......@@ -1362,7 +1357,6 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached)
pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL);
if (unlikely(!pages)) {
mutex_unlock(&bo->mutex);
dev_err(atomisp_dev, "out of memory for pages...\n");
return NULL;
}
......
......@@ -116,8 +116,6 @@ static void free_pages_to_dynamic_pool(void *pool,
hmm_page = kmem_cache_zalloc(dypool_info->pgptr_cache,
GFP_KERNEL);
if (!hmm_page) {
dev_err(atomisp_dev, "out of memory for hmm_page.\n");
/* free page directly */
ret = set_pages_wb(page_obj->page, 1);
if (ret)
......@@ -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),
GFP_KERNEL);
if (unlikely(!dypool_info)) {
dev_err(atomisp_dev, "out of memory for repool_info.\n");
if (unlikely(!dypool_info))
return -ENOMEM;
}
dypool_info->pgptr_cache = kmem_cache_create("pgptr_cache",
sizeof(struct hmm_page), 0,
......
......@@ -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),
GFP_KERNEL);
if (unlikely(!pool_info)) {
dev_err(atomisp_dev, "out of memory for repool_info.\n");
if (unlikely(!pool_info))
return -ENOMEM;
}
pool_info->pages = kmalloc(sizeof(struct page *) * pool_size,
GFP_KERNEL);
if (unlikely(!pool_info->pages)) {
dev_err(atomisp_dev, "out of memory for repool_info->pages.\n");
kfree(pool_info);
return -ENOMEM;
}
......
......@@ -89,10 +89,8 @@ static struct hmm_vm_node *alloc_hmm_vm_node(unsigned int pgnr,
struct hmm_vm_node *node;
node = kmem_cache_alloc(vm->cache, GFP_KERNEL);
if (!node) {
dev_err(atomisp_dev, "out of memory.\n");
if (!node)
return NULL;
}
INIT_LIST_HEAD(&node->list);
node->pgnr = pgnr;
......
......@@ -785,10 +785,8 @@ int camera_sensor_csi(struct v4l2_subdev *sd, u32 port,
if (flag) {
csi = kzalloc(sizeof(*csi), GFP_KERNEL);
if (!csi) {
dev_err(&client->dev, "out of memory\n");
if (!csi)
return -ENOMEM;
}
csi->port = port;
csi->num_lanes = lanes;
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