Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273693
b: refs/heads/master
c: 3dcc731
h: refs/heads/master
i:
  273691: 25a58eb
v: v3
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Nov 3, 2011
1 parent 9157719 commit 1478df4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da83d9dc0ac18ffb07b5b344e237005a0ba08089
refs/heads/master: 3dcc731a93679d75a1f90a969b34aa9d7acd1cbf
65 changes: 34 additions & 31 deletions trunk/drivers/media/video/soc_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,49 +50,52 @@ static LIST_HEAD(hosts);
static LIST_HEAD(devices);
static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */

static int soc_camera_power_set(struct soc_camera_device *icd,
struct soc_camera_link *icl,
int power_on)
static int soc_camera_power_on(struct soc_camera_device *icd,
struct soc_camera_link *icl)
{
int ret;

if (power_on) {
ret = regulator_bulk_enable(icl->num_regulators,
icl->regulators);
if (ret < 0) {
dev_err(icd->pdev, "Cannot enable regulators\n");
return ret;
}
ret = regulator_bulk_enable(icl->num_regulators,
icl->regulators);
if (ret < 0) {
dev_err(icd->pdev, "Cannot enable regulators\n");
return ret;
}

if (icl->power)
ret = icl->power(icd->pdev, power_on);
if (icl->power) {
ret = icl->power(icd->pdev, 1);
if (ret < 0) {
dev_err(icd->pdev,
"Platform failed to power-on the camera.\n");

regulator_bulk_disable(icl->num_regulators,
icl->regulators);
return ret;
}
} else {
ret = 0;
if (icl->power)
ret = icl->power(icd->pdev, 0);
}

return ret;
}

static int soc_camera_power_off(struct soc_camera_device *icd,
struct soc_camera_link *icl)
{
int ret;

if (icl->power) {
ret = icl->power(icd->pdev, 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,
icl->regulators);
if (ret < 0) {
dev_err(icd->pdev, "Cannot disable regulators\n");
return ret;
}
}

return 0;
ret = regulator_bulk_disable(icl->num_regulators,
icl->regulators);
if (ret < 0)
dev_err(icd->pdev, "Cannot disable regulators\n");

return ret;
}

const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
Expand Down Expand Up @@ -502,7 +505,7 @@ static int soc_camera_open(struct file *file)
},
};

ret = soc_camera_power_set(icd, icl, 1);
ret = soc_camera_power_on(icd, icl);
if (ret < 0)
goto epower;

Expand Down Expand Up @@ -556,7 +559,7 @@ static int soc_camera_open(struct file *file)
eresume:
ici->ops->remove(icd);
eiciadd:
soc_camera_power_set(icd, icl, 0);
soc_camera_power_off(icd, icl);
epower:
icd->use_count--;
module_put(ici->ops->owner);
Expand All @@ -580,7 +583,7 @@ static int soc_camera_close(struct file *file)
if (ici->ops->init_videobuf2)
vb2_queue_release(&icd->vb2_vidq);

soc_camera_power_set(icd, icl, 0);
soc_camera_power_off(icd, icl);
}

if (icd->streamer == file)
Expand Down Expand Up @@ -1026,7 +1029,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)
if (ret < 0)
goto ereg;

ret = soc_camera_power_set(icd, icl, 1);
ret = soc_camera_power_on(icd, icl);
if (ret < 0)
goto epower;

Expand Down Expand Up @@ -1106,7 +1109,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)

ici->ops->remove(icd);

soc_camera_power_set(icd, icl, 0);
soc_camera_power_off(icd, icl);

mutex_unlock(&icd->video_lock);

Expand All @@ -1129,7 +1132,7 @@ static int soc_camera_probe(struct soc_camera_device *icd)
evdc:
ici->ops->remove(icd);
eadd:
soc_camera_power_set(icd, icl, 0);
soc_camera_power_off(icd, icl);
epower:
regulator_bulk_free(icl->num_regulators, icl->regulators);
ereg:
Expand Down

0 comments on commit 1478df4

Please sign in to comment.