media: i2c: s5c73m3: make sure we destroy the mutex
Commit Message
From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Make sure to call mutex_destroy() in case of probe failure or module
unload.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
---
drivers/media/i2c/s5c73m3/s5c73m3-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On 03/02/2015 04:00 PM, Lad Prabhakar wrote:
> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
>
> Make sure to call mutex_destroy() in case of probe failure or module
> unload.
It's not actually necessary to destroy a mutex. Most drivers never do this.
It only helps a bit in debugging.
I'll delegate this patch to Kamil, and he can decide whether or not to apply
this.
Regards,
Hans
>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> ---
> drivers/media/i2c/s5c73m3/s5c73m3-core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index ee0f57e..da0b3a3 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -1658,7 +1658,6 @@ static int s5c73m3_probe(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> - mutex_init(&state->lock);
> sd = &state->sensor_sd;
> oif_sd = &state->oif_sd;
>
> @@ -1695,6 +1694,8 @@ static int s5c73m3_probe(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> + mutex_init(&state->lock);
> +
> ret = s5c73m3_configure_gpios(state);
> if (ret)
> goto out_err;
> @@ -1754,6 +1755,7 @@ out_err1:
> s5c73m3_unregister_spi_driver(state);
> out_err:
> media_entity_cleanup(&sd->entity);
> + mutex_destroy(&state->lock);
> return ret;
> }
>
> @@ -1772,6 +1774,7 @@ static int s5c73m3_remove(struct i2c_client *client)
> media_entity_cleanup(&sensor_sd->entity);
>
> s5c73m3_unregister_spi_driver(state);
> + mutex_destroy(&state->lock);
>
> return 0;
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Hans Verkuil [mailto:hverkuil@xs4all.nl]
Sent: Tuesday, March 03, 2015 10:09 AM
>
> On 03/02/2015 04:00 PM, Lad Prabhakar wrote:
> > From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
> >
> > Make sure to call mutex_destroy() in case of probe failure or module
> > unload.
>
> It's not actually necessary to destroy a mutex. Most drivers never do
> this.
> It only helps a bit in debugging.
>
> I'll delegate this patch to Kamil, and he can decide whether or not to
> apply this.
I agree with Hans here, the patch is not necessary.
>
> Regards,
>
> Hans
>
Best wishes,
@@ -1658,7 +1658,6 @@ static int s5c73m3_probe(struct i2c_client *client,
if (ret < 0)
return ret;
- mutex_init(&state->lock);
sd = &state->sensor_sd;
oif_sd = &state->oif_sd;
@@ -1695,6 +1694,8 @@ static int s5c73m3_probe(struct i2c_client *client,
if (ret < 0)
return ret;
+ mutex_init(&state->lock);
+
ret = s5c73m3_configure_gpios(state);
if (ret)
goto out_err;
@@ -1754,6 +1755,7 @@ out_err1:
s5c73m3_unregister_spi_driver(state);
out_err:
media_entity_cleanup(&sd->entity);
+ mutex_destroy(&state->lock);
return ret;
}
@@ -1772,6 +1774,7 @@ static int s5c73m3_remove(struct i2c_client *client)
media_entity_cleanup(&sensor_sd->entity);
s5c73m3_unregister_spi_driver(state);
+ mutex_destroy(&state->lock);
return 0;
}