aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2014-08-05 07:01:08 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-09-03 07:50:25 -0400
commit58e43d90b9cb75b4dd42ba1481d83011fa7412df (patch)
tree21c41543ca3c93b61e091eec2b09bb67b4eb3e0c
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
[media] smiapp: Fix power count handling
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>
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 1eaf975d3612..632bd9efdc97 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1282,19 +1282,12 @@ static int smiapp_set_power(struct v4l2_subdev *subdev, int on)
1282 1282
1283 mutex_lock(&sensor->power_mutex); 1283 mutex_lock(&sensor->power_mutex);
1284 1284
1285 /* 1285 if (on && !sensor->power_count) {
1286 * If the power count is modified from 0 to != 0 or from != 0
1287 * to 0, update the power state.
1288 */
1289 if (!sensor->power_count == !on)
1290 goto out;
1291
1292 if (on) {
1293 /* Power on and perform initialisation. */ 1286 /* Power on and perform initialisation. */
1294 ret = smiapp_power_on(sensor); 1287 ret = smiapp_power_on(sensor);
1295 if (ret < 0) 1288 if (ret < 0)
1296 goto out; 1289 goto out;
1297 } else { 1290 } else if (!on && sensor->power_count == 1) {
1298 smiapp_power_off(sensor); 1291 smiapp_power_off(sensor);
1299 } 1292 }
1300 1293