All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Cohen <david.a.cohen@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v2 7/9] soc-camera: Continue the power off sequence if one of the steps fails
Date: Tue, 17 Jul 2012 14:03:30 +0300	[thread overview]
Message-ID: <50054682.7070503@linux.intel.com> (raw)
In-Reply-To: <11676269.DxxC5Mj13x@avalon>

Hi Laurent,

On 07/17/2012 02:45 AM, Laurent Pinchart wrote:
> Hi David,
>
> Thank you for the review.

You're welcome.

>
> On Monday 16 July 2012 01:24:37 David Cohen wrote:
>> On 07/05/2012 11:38 PM, Laurent Pinchart wrote:
>>> Powering off a device is a "best effort" task: failure to execute one of
>>> the steps should not prevent the next steps to be executed. For
>>> instance, an I2C communication error when putting the chip in stand-by
>>> mode should not prevent the more agressive next step of turning the
>>> chip's power supply off.
>>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>
>>>    drivers/media/video/soc_camera.c |    9 +++------
>>>    1 files changed, 3 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/media/video/soc_camera.c
>>> b/drivers/media/video/soc_camera.c index 55b981f..bbd518f 100644
>>> --- a/drivers/media/video/soc_camera.c
>>> +++ b/drivers/media/video/soc_camera.c
>>> @@ -89,18 +89,15 @@ static int soc_camera_power_off(struct
>>> soc_camera_device *icd,>
>>>    				struct soc_camera_link *icl)
>>>    {
>>>    	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
>>> -	int ret = v4l2_subdev_call(sd, core, s_power, 0);
>>> +	int ret;
>>>
>>> -	if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
>>> -		return ret;
>>> +	v4l2_subdev_call(sd, core, s_power, 0);
>>
>> Fair enough. I agree we should not prevent power off because of failure
>> in this step. But IMO we should not silently bypass it too. How about
>> an error message?
>
> I'll add that.
>
>>>    	if (icl->power) {
>>>    	
>>>    		ret = icl->power(icd->control, 0);
>>>
>>> -		if (ret < 0) {
>>> +		if (ret < 0)
>>>
>>>    			dev_err(icd->pdev,
>>>    			
>>>    				"Platform failed to power-off the camera.\n");
>>>
>>> -			return ret;
>>> -		}
>>>
>>>    	}
>>>    	
>>>    	ret = regulator_bulk_disable(icl->num_regulators,
>>
>> One more comment. Should this function's return value being based fully
>> on last action? If any earlier error happened but this last step is
>> fine, IMO we should not return 0.
>
> Good point. What about this (on top of the current patch) ?

That sounds nice to me :)

Regards,

David Cohen

>
> diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
> index bbd518f..7bf21da 100644
> --- a/drivers/media/video/soc_camera.c
> +++ b/drivers/media/video/soc_camera.c
> @@ -89,21 +89,30 @@ static int soc_camera_power_off(struct soc_camera_device *icd,
>                                  struct soc_camera_link *icl)
>   {
>          struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
> -       int ret;
> +       int ret = 0;
> +       int err;
>
> -       v4l2_subdev_call(sd, core, s_power, 0);
> +       err = v4l2_subdev_call(sd, core, s_power, 0);
> +       if (err < 0 && err != -ENOIOCTLCMD && err != -ENODEV) {
> +               dev_err(icd->pdev, "Subdev failed to power-off the camera.\n");
> +               ret = err;
> +       }
>
>          if (icl->power) {
> -               ret = icl->power(icd->control, 0);
> -               if (ret < 0)
> +               err = icl->power(icd->control, 0);
> +               if (err < 0) {
>                          dev_err(icd->pdev,
>                                  "Platform failed to power-off the camera.\n");
> +                       ret = ret ? : err;
> +               }
>          }
>
> -       ret = regulator_bulk_disable(icl->num_regulators,
> +       err = regulator_bulk_disable(icl->num_regulators,
>                                       icl->regulators);
> -       if (ret < 0)
> +       if (err < 0) {
>                  dev_err(icd->pdev, "Cannot disable regulators\n");
> +               ret = ret ? : err;
> +       }
>
>          return ret;
>   }
>



  reply	other threads:[~2012-07-17 11:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05 20:38 [PATCH v2 0/9] Miscellaneous soc-camera patches Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 1/9] soc-camera: Don't fail at module init time if no device is present Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 2/9] soc-camera: Pass the physical device to the power operation Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 3/9] ov2640: Don't access the device in the g_mbus_fmt operation Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 4/9] ov772x: " Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 5/9] tw9910: " Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 6/9] soc_camera: Don't call .s_power() during probe Laurent Pinchart
2012-07-05 20:38 ` [PATCH v2 7/9] soc-camera: Continue the power off sequence if one of the steps fails Laurent Pinchart
2012-07-15 22:24   ` David Cohen
2012-07-16 23:45     ` Laurent Pinchart
2012-07-17 11:03       ` David Cohen [this message]
2012-07-05 20:38 ` [PATCH v2 8/9] soc-camera: Add and use soc_camera_power_[on|off]() helper functions Laurent Pinchart
2012-07-15 23:17   ` David Cohen
2012-07-15 23:25     ` David Cohen
2012-07-17  1:24     ` Laurent Pinchart
2012-07-17 10:40       ` David Cohen
2012-07-05 20:38 ` [PATCH v2 9/9] soc-camera: Push probe-time power management to drivers Laurent Pinchart
2012-07-10 12:06   ` Guennadi Liakhovetski
2012-07-15 13:31     ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50054682.7070503@linux.intel.com \
    --to=david.a.cohen@linux.intel.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.