mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 19:11:02 +07:00
V4L/DVB (10983): v4l2-common: add missing i2c_unregister_device.
If the i2c sub-device cannot be found, then we must unregister the i2c_client. Otherwise this will prevent a possible probe for a different device on that same address. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
2c79252326
commit
7c026c3511
@ -813,11 +813,11 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
|
||||
We need better support from the kernel so that we
|
||||
can easily wait for the load to finish. */
|
||||
if (client == NULL || client->driver == NULL)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
/* Lock the module so we can safely get the v4l2_subdev pointer */
|
||||
if (!try_module_get(client->driver->driver.owner))
|
||||
return NULL;
|
||||
goto error;
|
||||
sd = i2c_get_clientdata(client);
|
||||
|
||||
/* Register with the v4l2_device which increases the module's
|
||||
@ -826,8 +826,13 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
|
||||
sd = NULL;
|
||||
/* Decrease the module use count to match the first try_module_get. */
|
||||
module_put(client->driver->driver.owner);
|
||||
return sd;
|
||||
|
||||
error:
|
||||
/* If we have a client but no subdev, then something went wrong and
|
||||
we must unregister the client. */
|
||||
if (client && sd == NULL)
|
||||
i2c_unregister_device(client);
|
||||
return sd;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
|
||||
|
||||
@ -860,11 +865,11 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
|
||||
We need better support from the kernel so that we
|
||||
can easily wait for the load to finish. */
|
||||
if (client == NULL || client->driver == NULL)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
/* Lock the module so we can safely get the v4l2_subdev pointer */
|
||||
if (!try_module_get(client->driver->driver.owner))
|
||||
return NULL;
|
||||
goto error;
|
||||
sd = i2c_get_clientdata(client);
|
||||
|
||||
/* Register with the v4l2_device which increases the module's
|
||||
@ -873,6 +878,12 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
|
||||
sd = NULL;
|
||||
/* Decrease the module use count to match the first try_module_get. */
|
||||
module_put(client->driver->driver.owner);
|
||||
|
||||
error:
|
||||
/* If we have a client but no subdev, then something went wrong and
|
||||
we must unregister the client. */
|
||||
if (client && sd == NULL)
|
||||
i2c_unregister_device(client);
|
||||
return sd;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);
|
||||
|
Loading…
Reference in New Issue
Block a user