Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f591118b authored by Prakasha Nayak's avatar Prakasha Nayak
Browse files

msm: camera: cpas: Check the HW state before accessing register



Check the hardware state before accessing registers and
add mutex lock to prevent unclocked access

Change-Id: I624614ea3b469c354dfbdc9ab6110c34664592b4
Signed-off-by: default avatarPrakasha Nayak <pnayak@codeaurora.org>
parent ed85a423
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -406,6 +406,12 @@ static void cam_cpastop_work(struct work_struct *work)
		return;
	}

	mutex_lock(&cpas_hw->hw_mutex);
	if (cpas_hw->hw_state == CAM_HW_STATE_POWER_DOWN) {
		CAM_ERR(CAM_CPAS, "CPAS CORE is off");
		mutex_unlock(&cpas_hw->hw_mutex);
		return;
	}
	for (i = 0; i < camnoc_info->irq_err_size; i++) {
		if ((payload->irq_status & camnoc_info->irq_err[i].sbm_port) &&
			(camnoc_info->irq_err[i].enable)) {
@@ -451,6 +457,7 @@ static void cam_cpastop_work(struct work_struct *work)
				~camnoc_info->irq_err[i].sbm_port;
		}
	}
	mutex_unlock(&cpas_hw->hw_mutex);
	atomic_dec(&cpas_core->irq_count);
	wake_up(&cpas_core->irq_count_wq);
	CAM_DBG(CAM_CPAS, "irq_count=%d\n", atomic_read(&cpas_core->irq_count));