Commit aa8485d6 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: davinci_vpfe: cleanup ipipe_[g|s]_config logic

Reduce one ident level inside those functions and use BIT()
macro.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent b2f92225
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/bitops.h>
#include "dm365_ipipe.h" #include "dm365_ipipe.h"
#include "dm365_ipipe_hw.h" #include "dm365_ipipe_hw.h"
...@@ -1255,17 +1256,19 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) ...@@ -1255,17 +1256,19 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
int rval = 0; int rval = 0;
for (i = 0; i < ARRAY_SIZE(ipipe_modules); i++) { for (i = 0; i < ARRAY_SIZE(ipipe_modules); i++) {
unsigned int bit = 1 << i; const struct ipipe_module_if *module_if;
if (cfg->flag & bit) {
const struct ipipe_module_if *module_if =
&ipipe_modules[i];
struct ipipe_module_params *params; struct ipipe_module_params *params;
void __user *from = *(void * __user *) void __user *from;
((void *)cfg + module_if->config_offset);
size_t size; size_t size;
void *to; void *to;
if (!(cfg->flag & BIT(i)))
continue;
module_if = &ipipe_modules[i];
from = *(void * __user *)
((void *)cfg + module_if->config_offset);
params = kmalloc(sizeof(struct ipipe_module_params), params = kmalloc(sizeof(struct ipipe_module_params),
GFP_KERNEL); GFP_KERNEL);
to = (void *)params + module_if->param_offset; to = (void *)params + module_if->param_offset;
...@@ -1286,7 +1289,6 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) ...@@ -1286,7 +1289,6 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
} }
kfree(params); kfree(params);
} }
}
error: error:
return rval; return rval;
} }
...@@ -1298,17 +1300,18 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) ...@@ -1298,17 +1300,18 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
int rval = 0; int rval = 0;
for (i = 1; i < ARRAY_SIZE(ipipe_modules); i++) { for (i = 1; i < ARRAY_SIZE(ipipe_modules); i++) {
unsigned int bit = 1 << i; const struct ipipe_module_if *module_if;
if (cfg->flag & bit) {
const struct ipipe_module_if *module_if =
&ipipe_modules[i];
struct ipipe_module_params *params; struct ipipe_module_params *params;
void __user *to = *(void * __user *) void __user *to;
((void *)cfg + module_if->config_offset);
size_t size; size_t size;
void *from; void *from;
if (!(cfg->flag & BIT(i)))
continue;
module_if = &ipipe_modules[i];
to = *(void * __user *)((void *)cfg + module_if->config_offset);
params = kmalloc(sizeof(struct ipipe_module_params), params = kmalloc(sizeof(struct ipipe_module_params),
GFP_KERNEL); GFP_KERNEL);
from = (void *)params + module_if->param_offset; from = (void *)params + module_if->param_offset;
...@@ -1325,7 +1328,6 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) ...@@ -1325,7 +1328,6 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
} }
kfree(params); kfree(params);
} }
}
error: error:
return rval; return rval;
} }
......
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