Commit 44421870 authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

media: i2c: dw9714: fix optional regulator support

squash with Angus patch and describe optional regulator and suspend
handling
parent 5f57c075
Pipeline #73380 passed with stage
in 93 minutes and 17 seconds
......@@ -148,8 +148,7 @@ static int dw9714_probe(struct i2c_client *client)
dw9714_dev->vcc = devm_regulator_get(&client->dev, "vcc");
if (IS_ERR(dw9714_dev->vcc))
return dev_err_probe(&client->dev, PTR_ERR(dw9714_dev->vcc),
"failed to request regulator\n");
return PTR_ERR(dw9714_dev->vcc);
rval = regulator_enable(dw9714_dev->vcc);
if (rval < 0) {
......@@ -211,6 +210,9 @@ static int __maybe_unused dw9714_vcm_suspend(struct device *dev)
struct dw9714_device *dw9714_dev = sd_to_dw9714_vcm(sd);
int ret, val;
if (pm_runtime_suspended(&client->dev))
return 0;
for (val = dw9714_dev->current_val & ~(DW9714_CTRL_STEPS - 1);
val >= 0; val -= DW9714_CTRL_STEPS) {
ret = dw9714_i2c_write(client,
......@@ -222,9 +224,9 @@ static int __maybe_unused dw9714_vcm_suspend(struct device *dev)
ret = regulator_disable(dw9714_dev->vcc);
if (ret)
dev_warn(dev, "Failed to disable vcc: %d\n", ret);
dev_err(dev, "Failed to disable vcc: %d\n", ret);
return 0;
return ret;
}
/*
......@@ -240,12 +242,14 @@ static int __maybe_unused dw9714_vcm_resume(struct device *dev)
struct dw9714_device *dw9714_dev = sd_to_dw9714_vcm(sd);
int ret, val;
if (pm_runtime_suspended(&client->dev))
return 0;
ret = regulator_enable(dw9714_dev->vcc);
if (ret) {
dev_err(dev, "Failed to enable vcc: %d\n", ret);
return ret;
}
usleep_range(1000, 2000);
for (val = dw9714_dev->current_val % DW9714_CTRL_STEPS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment