Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1461738

Re: [PATCH v3 02/14] media: mt9m111: prevent module removal while in use

From Hans Verkuil <hverkuil@xs4all.nl>
Newsgroups linux.kernel
Subject Re: [PATCH v3 02/14] media: mt9m111: prevent module removal while in use
Date 2016-08-14 11:10 +0200
Message-ID <s5ZAC-5TR-11@gated-at.bofh.it> (permalink)
References <s3YyZ-5Ay-7@gated-at.bofh.it> <s3Yz1-5Ay-85@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 08/08/2016 09:30 PM, Robert Jarzmik wrote:
> The mt9m111 can be a removable module : the only case where the module
> should be kept loaded is while it is used, ie. while an active
> transation is ongoing on it.
> 
> The notion of active transaction is mapped on the power state of the
> module : if powered on the removal is prohibited.

I don't really see the purpose of this patch: if this driver is loaded
by a platform driver (such as pxa_camera), then the module count should be
1 and it isn't possible to unload.

So you shouldn't need this patch. Am I missing something?

No other driver in drivers/media/i2c does something like this.

Regards,

	Hans

> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---
>  drivers/media/i2c/soc_camera/mt9m111.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
> index a7efaa5964d1..ea5b5e709402 100644
> --- a/drivers/media/i2c/soc_camera/mt9m111.c
> +++ b/drivers/media/i2c/soc_camera/mt9m111.c
> @@ -780,23 +780,33 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111)
>  	struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
>  	int ret;
>  
> +	if (!try_module_get(THIS_MODULE))
> +		return -ENXIO;
> +
>  	ret = v4l2_clk_enable(mt9m111->clk);
>  	if (ret < 0)
> -		return ret;
> +		goto out_module_put;
>  
>  	ret = mt9m111_resume(mt9m111);
>  	if (ret < 0) {
>  		dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret);
> -		v4l2_clk_disable(mt9m111->clk);
> +		goto out_clk_disable;
>  	}
>  
>  	return ret;
> +
> +out_clk_disable:
> +	v4l2_clk_disable(mt9m111->clk);
> +out_module_put:
> +	module_put(THIS_MODULE);
> +	return ret;
>  }
>  
>  static void mt9m111_power_off(struct mt9m111 *mt9m111)
>  {
>  	mt9m111_suspend(mt9m111);
>  	v4l2_clk_disable(mt9m111->clk);
> +	module_put(THIS_MODULE);
>  }
>  
>  static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
> 

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 02/14] media: mt9m111: prevent module removal while in  use Hans Verkuil <hverkuil@xs4all.nl> - 2016-08-14 11:10 +0200
  Re: [PATCH v3 02/14] media: mt9m111: prevent module removal while in use Robert Jarzmik <robert.jarzmik@free.fr> - 2016-08-14 21:40 +0200

csiph-web