Skip to content

Commit

Permalink
[media] smiapp: Fix power count handling
Browse files Browse the repository at this point in the history
The sensor may be powered by either one of its sub-devices being accessed
from the user space (an open file handle) or by its s_power() op being
called with non-zero on argument. The driver counts the users and if any
reason to keep the device powered exists it will be powered.

However, a faulty condition was used in recognising the need to power off
the sensor, leading it to be powered off every time any of its uses went
away.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
  • Loading branch information
Sakari Ailus authored and Mauro Carvalho Chehab committed Sep 3, 2014
1 parent 7d1311b commit 58e43d9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions drivers/media/i2c/smiapp/smiapp-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,19 +1282,12 @@ static int smiapp_set_power(struct v4l2_subdev *subdev, int on)

mutex_lock(&sensor->power_mutex);

/*
* If the power count is modified from 0 to != 0 or from != 0
* to 0, update the power state.
*/
if (!sensor->power_count == !on)
goto out;

if (on) {
if (on && !sensor->power_count) {
/* Power on and perform initialisation. */
ret = smiapp_power_on(sensor);
if (ret < 0)
goto out;
} else {
} else if (!on && sensor->power_count == 1) {
smiapp_power_off(sensor);
}

Expand Down

0 comments on commit 58e43d9

Please sign in to comment.