mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-22 16:46:30 -04:00
media: dw9714: move power sequences to dedicated functions
Move the power-up and power-down sequences to their own functions. This is a preparation for the upcoming powerdown pin support. Signed-off-by: Matthias Fend <matthias.fend@emfend.at> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
This commit is contained in:
committed by
Hans Verkuil
parent
feec4b07c8
commit
1eefe42e9d
@@ -137,6 +137,24 @@ static int dw9714_init_controls(struct dw9714_device *dev_vcm)
|
||||
return hdl->error;
|
||||
}
|
||||
|
||||
static int dw9714_power_up(struct dw9714_device *dw9714_dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = regulator_enable(dw9714_dev->vcc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dw9714_power_down(struct dw9714_device *dw9714_dev)
|
||||
{
|
||||
return regulator_disable(dw9714_dev->vcc);
|
||||
}
|
||||
|
||||
static int dw9714_probe(struct i2c_client *client)
|
||||
{
|
||||
struct dw9714_device *dw9714_dev;
|
||||
@@ -151,13 +169,10 @@ static int dw9714_probe(struct i2c_client *client)
|
||||
if (IS_ERR(dw9714_dev->vcc))
|
||||
return PTR_ERR(dw9714_dev->vcc);
|
||||
|
||||
rval = regulator_enable(dw9714_dev->vcc);
|
||||
if (rval < 0) {
|
||||
dev_err(&client->dev, "failed to enable vcc: %d\n", rval);
|
||||
return rval;
|
||||
}
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
rval = dw9714_power_up(dw9714_dev);
|
||||
if (rval)
|
||||
return dev_err_probe(&client->dev, rval,
|
||||
"failed to power up: %d\n", rval);
|
||||
|
||||
v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops);
|
||||
dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
|
||||
@@ -185,7 +200,7 @@ static int dw9714_probe(struct i2c_client *client)
|
||||
return 0;
|
||||
|
||||
err_cleanup:
|
||||
regulator_disable(dw9714_dev->vcc);
|
||||
dw9714_power_down(dw9714_dev);
|
||||
v4l2_ctrl_handler_free(&dw9714_dev->ctrls_vcm);
|
||||
media_entity_cleanup(&dw9714_dev->sd.entity);
|
||||
|
||||
@@ -200,10 +215,10 @@ static void dw9714_remove(struct i2c_client *client)
|
||||
|
||||
pm_runtime_disable(&client->dev);
|
||||
if (!pm_runtime_status_suspended(&client->dev)) {
|
||||
ret = regulator_disable(dw9714_dev->vcc);
|
||||
ret = dw9714_power_down(dw9714_dev);
|
||||
if (ret) {
|
||||
dev_err(&client->dev,
|
||||
"Failed to disable vcc: %d\n", ret);
|
||||
"Failed to power down: %d\n", ret);
|
||||
}
|
||||
}
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
@@ -234,9 +249,9 @@ static int __maybe_unused dw9714_vcm_suspend(struct device *dev)
|
||||
usleep_range(DW9714_CTRL_DELAY_US, DW9714_CTRL_DELAY_US + 10);
|
||||
}
|
||||
|
||||
ret = regulator_disable(dw9714_dev->vcc);
|
||||
ret = dw9714_power_down(dw9714_dev);
|
||||
if (ret)
|
||||
dev_err(dev, "Failed to disable vcc: %d\n", ret);
|
||||
dev_err(dev, "Failed to power down: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -257,12 +272,11 @@ static int __maybe_unused dw9714_vcm_resume(struct device *dev)
|
||||
if (pm_runtime_suspended(&client->dev))
|
||||
return 0;
|
||||
|
||||
ret = regulator_enable(dw9714_dev->vcc);
|
||||
ret = dw9714_power_up(dw9714_dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to enable vcc: %d\n", ret);
|
||||
dev_err(dev, "Failed to power up: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
usleep_range(1000, 2000);
|
||||
|
||||
for (val = dw9714_dev->current_val % DW9714_CTRL_STEPS;
|
||||
val < dw9714_dev->current_val + DW9714_CTRL_STEPS - 1;
|
||||
|
||||
Reference in New Issue
Block a user