@@ -214,11 +214,13 @@ static int cam_req_mgr_close(struct file *filep)
214214
215215 cam_req_mgr_rwsem_write_op (CAM_SUBDEV_LOCK );
216216
217+ mutex_lock (& g_dev .subdev_lock );
217218 mutex_lock (& g_dev .cam_lock );
218219
219220 if (g_dev .open_cnt <= 0 ) {
220221 CAM_WARN (CAM_CRM , "open_cnt <= 0 in close!" );
221222 mutex_unlock (& g_dev .cam_lock );
223+ mutex_unlock (& g_dev .subdev_lock );
222224 cam_req_mgr_rwsem_write_op (CAM_SUBDEV_UNLOCK );
223225 return - EINVAL ;
224226 }
@@ -255,6 +257,7 @@ static int cam_req_mgr_close(struct file *filep)
255257 cam_req_mgr_util_free_hdls ();
256258 cam_mem_mgr_deinit ();
257259 mutex_unlock (& g_dev .cam_lock );
260+ mutex_unlock (& g_dev .subdev_lock );
258261
259262 cam_req_mgr_rwsem_write_op (CAM_SUBDEV_UNLOCK );
260263
@@ -920,6 +923,7 @@ int cam_register_subdev(struct cam_subdev *csd)
920923 return - EINVAL ;
921924 }
922925
926+ mutex_lock (& g_dev .subdev_lock );
923927 mutex_lock (& g_dev .dev_lock );
924928
925929 sd = & csd -> sd ;
@@ -969,6 +973,7 @@ int cam_register_subdev(struct cam_subdev *csd)
969973reg_fail :
970974invalid_val_fail :
971975 mutex_unlock (& g_dev .dev_lock );
976+ mutex_unlock (& g_dev .subdev_lock );
972977 return rc ;
973978}
974979
@@ -979,10 +984,12 @@ int cam_unregister_subdev(struct cam_subdev *csd)
979984 return - ENODEV ;
980985 }
981986
987+ mutex_lock (& g_dev .subdev_lock );
982988 mutex_lock (& g_dev .dev_lock );
983989 v4l2_device_unregister_subdev (& csd -> sd );
984990 g_dev .count -- ;
985991 mutex_unlock (& g_dev .dev_lock );
992+ mutex_unlock (& g_dev .subdev_lock );
986993
987994 return 0 ;
988995}
@@ -1012,6 +1019,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
10121019
10131020 g_dev .open_cnt = 0 ;
10141021 g_dev .shutdown_state = false;
1022+ mutex_init (& g_dev .subdev_lock );
10151023 mutex_init (& g_dev .cam_lock );
10161024 spin_lock_init (& g_dev .cam_eventq_lock );
10171025 mutex_init (& g_dev .dev_lock );
@@ -1070,6 +1078,7 @@ static int cam_req_mgr_component_master_bind(struct device *dev)
10701078req_mgr_util_fail :
10711079 mutex_destroy (& g_dev .dev_lock );
10721080 mutex_destroy (& g_dev .cam_lock );
1081+ mutex_destroy (& g_dev .subdev_lock );
10731082 cam_video_device_cleanup ();
10741083video_setup_fail :
10751084 cam_media_device_cleanup ();
@@ -1093,6 +1102,7 @@ static void cam_req_mgr_component_master_unbind(struct device *dev)
10931102 cam_v4l2_device_cleanup ();
10941103 cam_req_mgr_destroy_timer_slab ();
10951104 mutex_destroy (& g_dev .dev_lock );
1105+ mutex_destroy (& g_dev .subdev_lock );
10961106 g_dev .state = false;
10971107}
10981108
0 commit comments