Commit ac11da47 authored by Matt Ranostay's avatar Matt Ranostay Committed by Mauro Carvalho Chehab

media: video-i2c: check if chip struct has set_power function

Not all future supported video chips will always have power management
support, and so it is important to check before calling set_power() is
defined.
Signed-off-by: default avatarMatt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 69d2a734
...@@ -736,9 +736,11 @@ static int video_i2c_probe(struct i2c_client *client, ...@@ -736,9 +736,11 @@ static int video_i2c_probe(struct i2c_client *client,
video_set_drvdata(&data->vdev, data); video_set_drvdata(&data->vdev, data);
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
ret = data->chip->set_power(data, true); if (data->chip->set_power) {
if (ret) ret = data->chip->set_power(data, true);
goto error_unregister_device; if (ret)
goto error_unregister_device;
}
pm_runtime_get_noresume(&client->dev); pm_runtime_get_noresume(&client->dev);
pm_runtime_set_active(&client->dev); pm_runtime_set_active(&client->dev);
...@@ -767,7 +769,9 @@ static int video_i2c_probe(struct i2c_client *client, ...@@ -767,7 +769,9 @@ static int video_i2c_probe(struct i2c_client *client,
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev); pm_runtime_set_suspended(&client->dev);
pm_runtime_put_noidle(&client->dev); pm_runtime_put_noidle(&client->dev);
data->chip->set_power(data, false);
if (data->chip->set_power)
data->chip->set_power(data, false);
error_unregister_device: error_unregister_device:
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
...@@ -791,7 +795,9 @@ static int video_i2c_remove(struct i2c_client *client) ...@@ -791,7 +795,9 @@ static int video_i2c_remove(struct i2c_client *client)
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev); pm_runtime_set_suspended(&client->dev);
pm_runtime_put_noidle(&client->dev); pm_runtime_put_noidle(&client->dev);
data->chip->set_power(data, false);
if (data->chip->set_power)
data->chip->set_power(data, false);
video_unregister_device(&data->vdev); video_unregister_device(&data->vdev);
...@@ -804,6 +810,9 @@ static int video_i2c_pm_runtime_suspend(struct device *dev) ...@@ -804,6 +810,9 @@ static int video_i2c_pm_runtime_suspend(struct device *dev)
{ {
struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev)); struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev));
if (!data->chip->set_power)
return 0;
return data->chip->set_power(data, false); return data->chip->set_power(data, false);
} }
...@@ -811,6 +820,9 @@ static int video_i2c_pm_runtime_resume(struct device *dev) ...@@ -811,6 +820,9 @@ static int video_i2c_pm_runtime_resume(struct device *dev)
{ {
struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev)); struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev));
if (!data->chip->set_power)
return 0;
return data->chip->set_power(data, true); return data->chip->set_power(data, true);
} }
......
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