diff mbox series

[v2,2/5] media: vimc: cleanup code that assigns entity in entities array

Message ID 20191003104409.15756-3-dafna.hirschfeld@collabora.com (mailing list archive)
State New, archived
Headers show
Series media: vimc: bug fixes related to memory management | expand

Commit Message

Dafna Hirschfeld Oct. 3, 2019, 10:44 a.m. UTC
Since the add callback returns NULL on failure and the array
is initialized to NULLs, there is no need for the intermediate
assignment to local var.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/media/platform/vimc/vimc-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Helen Mae Koike Fornazier Oct. 3, 2019, 1:52 p.m. UTC | #1
On 10/3/19 7:44 AM, Dafna Hirschfeld wrote:
> Since the add callback returns NULL on failure and the array
> is initialized to NULLs, there is no need for the intermediate
> assignment to local var.
> 
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>

I would just rename the title to something like:
"media: vimc: remove unnecessary var when adding entities"

It makes clear what you are doing and where, what do you think?

With this:

Acked-by: Helen Koike <helen.koike@collabora.com>

> ---
>  drivers/media/platform/vimc/vimc-core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
> index b8add4087652..325f55d0d8b3 100644
> --- a/drivers/media/platform/vimc/vimc-core.c
> +++ b/drivers/media/platform/vimc/vimc-core.c
> @@ -160,19 +160,17 @@ static int vimc_create_links(struct vimc_device *vimc)
>  static int vimc_add_subdevs(struct vimc_device *vimc)
>  {
>  	unsigned int i;
> -	struct vimc_ent_device *ved;
>  
>  	for (i = 0; i < vimc->pipe_cfg->num_ents; i++) {
>  		dev_dbg(&vimc->pdev.dev, "new entity for %s\n",
>  			vimc->pipe_cfg->ents[i].name);
> -		ved = vimc->pipe_cfg->ents[i].add(vimc,
> +		vimc->ent_devs[i] = vimc->pipe_cfg->ents[i].add(vimc,
>  					vimc->pipe_cfg->ents[i].name);
> -		if (!ved) {
> +		if (!vimc->ent_devs[i]) {
>  			dev_err(&vimc->pdev.dev, "add new entity for %s\n",
>  				vimc->pipe_cfg->ents[i].name);
>  			return -EINVAL;
>  		}
> -		vimc->ent_devs[i] = ved;
>  	}
>  	return 0;
>  }
>
diff mbox series

Patch

diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
index b8add4087652..325f55d0d8b3 100644
--- a/drivers/media/platform/vimc/vimc-core.c
+++ b/drivers/media/platform/vimc/vimc-core.c
@@ -160,19 +160,17 @@  static int vimc_create_links(struct vimc_device *vimc)
 static int vimc_add_subdevs(struct vimc_device *vimc)
 {
 	unsigned int i;
-	struct vimc_ent_device *ved;
 
 	for (i = 0; i < vimc->pipe_cfg->num_ents; i++) {
 		dev_dbg(&vimc->pdev.dev, "new entity for %s\n",
 			vimc->pipe_cfg->ents[i].name);
-		ved = vimc->pipe_cfg->ents[i].add(vimc,
+		vimc->ent_devs[i] = vimc->pipe_cfg->ents[i].add(vimc,
 					vimc->pipe_cfg->ents[i].name);
-		if (!ved) {
+		if (!vimc->ent_devs[i]) {
 			dev_err(&vimc->pdev.dev, "add new entity for %s\n",
 				vimc->pipe_cfg->ents[i].name);
 			return -EINVAL;
 		}
-		vimc->ent_devs[i] = ved;
 	}
 	return 0;
 }