diff options
author | Javier Martinez Canillas <javierm@redhat.com> | 2018-09-01 08:46:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-17 15:19:40 -0400 |
commit | b7a417628abf49dae98cb80a272dc133b0e4d1a3 (patch) | |
tree | 8bac0b42bc69f01df3cbacde1a14a22733df9689 /drivers/media/i2c | |
parent | 75b090a5bc961e578e232269596ddd0486ec6fca (diff) | |
download | linux-stable-b7a417628abf49dae98cb80a272dc133b0e4d1a3.tar.gz linux-stable-b7a417628abf49dae98cb80a272dc133b0e4d1a3.tar.bz2 linux-stable-b7a417628abf49dae98cb80a272dc133b0e4d1a3.zip |
media: ov2680: don't register the v4l2 subdevice before checking chip ID
The driver registers the v4l2 subdevice before attempting to power on the
chip and checking its ID. This means that a media device driver that it's
waiting for this subdevice to be bound, will prematurely expose its media
device node to userspace because if something goes wrong the media entity
will be cleaned up again on the ov2680 probe function.
This also simplifies the probe function error path since no initialization
is made before attempting to enable the resources or checking the chip ID.
Fixes: 3ee47cad3e69 ("media: ov2680: Add Omnivision OV2680 sensor driver")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/ov2680.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index f753a1c333ef..3ccd584568fb 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -1088,26 +1088,20 @@ static int ov2680_probe(struct i2c_client *client) mutex_init(&sensor->lock); - ret = ov2680_v4l2_init(sensor); + ret = ov2680_check_id(sensor); if (ret < 0) goto lock_destroy; - ret = ov2680_check_id(sensor); + ret = ov2680_v4l2_init(sensor); if (ret < 0) - goto error_cleanup; + goto lock_destroy; dev_info(dev, "ov2680 init correctly\n"); return 0; -error_cleanup: - dev_err(dev, "ov2680 init fail: %d\n", ret); - - media_entity_cleanup(&sensor->sd.entity); - v4l2_async_unregister_subdev(&sensor->sd); - v4l2_ctrl_handler_free(&sensor->ctrls.handler); - lock_destroy: + dev_err(dev, "ov2680 init fail: %d\n", ret); mutex_destroy(&sensor->lock); return ret; |