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

Commit 9aaf7960 authored by Rishabh Jain's avatar Rishabh Jain
Browse files

msm: camera: Fix cpas axi clk rate overflow



Change the clk variable type from int32_t to int64_t
to avoid integer overflow.

Change-Id: I4031b5389792d57b573f41ab9e3b2d9990640e5a
Signed-off-by: default avatarRishabh Jain <risjai@codeaurora.org>
parent 485b7a4b
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -568,7 +568,7 @@ static int cam_cpas_util_set_camnoc_axi_clk_rate(
		struct cam_cpas_axi_port *curr_axi_port = NULL;
		struct cam_cpas_axi_port *curr_axi_port = NULL;
		struct cam_cpas_axi_port *temp_axi_port = NULL;
		struct cam_cpas_axi_port *temp_axi_port = NULL;
		uint64_t required_camnoc_bw = 0;
		uint64_t required_camnoc_bw = 0;
		int32_t clk_rate = 0;
		int64_t clk_rate = 0;


		list_for_each_entry_safe(curr_axi_port, temp_axi_port,
		list_for_each_entry_safe(curr_axi_port, temp_axi_port,
			&cpas_core->axi_ports_list_head, sibling_port) {
			&cpas_core->axi_ports_list_head, sibling_port) {
@@ -596,13 +596,13 @@ static int cam_cpas_util_set_camnoc_axi_clk_rate(


		clk_rate = required_camnoc_bw / soc_private->camnoc_bus_width;
		clk_rate = required_camnoc_bw / soc_private->camnoc_bus_width;


		CAM_DBG(CAM_CPAS, "Setting camnoc axi clk rate : %llu %d",
		CAM_DBG(CAM_CPAS, "Setting camnoc axi clk rate : %llu %lld",
			required_camnoc_bw, clk_rate);
			required_camnoc_bw, clk_rate);


		rc = cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
		rc = cam_soc_util_set_src_clk_rate(soc_info, clk_rate);
		if (rc)
		if (rc)
			CAM_ERR(CAM_CPAS,
			CAM_ERR(CAM_CPAS,
				"Failed in setting camnoc axi clk %llu %d %d",
				"Failed in setting camnoc axi clk %llu %lld %d",
				required_camnoc_bw, clk_rate, rc);
				required_camnoc_bw, clk_rate, rc);
	}
	}


+6 −6
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ static char supported_clk_info[256];
static char debugfs_dir_name[64];
static char debugfs_dir_name[64];


static int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info,
static int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info,
	int32_t src_clk_idx, int32_t clk_rate)
	int32_t src_clk_idx, int64_t clk_rate)
{
{
	int i;
	int i;
	long clk_rate_round;
	long clk_rate_round;
@@ -38,7 +38,7 @@ static int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info,
	for (i = 0; i < CAM_MAX_VOTE; i++) {
	for (i = 0; i < CAM_MAX_VOTE; i++) {
		if (soc_info->clk_rate[i][src_clk_idx] >= clk_rate_round) {
		if (soc_info->clk_rate[i][src_clk_idx] >= clk_rate_round) {
			CAM_DBG(CAM_UTIL,
			CAM_DBG(CAM_UTIL,
				"soc = %d round rate = %ld actual = %d",
				"soc = %d round rate = %ld actual = %lld",
				soc_info->clk_rate[i][src_clk_idx],
				soc_info->clk_rate[i][src_clk_idx],
				clk_rate_round,	clk_rate);
				clk_rate_round,	clk_rate);
			return i;
			return i;
@@ -387,7 +387,7 @@ int cam_soc_util_set_clk_flags(struct cam_hw_soc_info *soc_info,
 * @return:         Success or failure
 * @return:         Success or failure
 */
 */
static int cam_soc_util_set_clk_rate(struct clk *clk, const char *clk_name,
static int cam_soc_util_set_clk_rate(struct clk *clk, const char *clk_name,
	int32_t clk_rate)
	int64_t clk_rate)
{
{
	int rc = 0;
	int rc = 0;
	long clk_rate_round;
	long clk_rate_round;
@@ -395,7 +395,7 @@ static int cam_soc_util_set_clk_rate(struct clk *clk, const char *clk_name,
	if (!clk || !clk_name)
	if (!clk || !clk_name)
		return -EINVAL;
		return -EINVAL;


	CAM_DBG(CAM_UTIL, "set %s, rate %d", clk_name, clk_rate);
	CAM_DBG(CAM_UTIL, "set %s, rate %lld", clk_name, clk_rate);
	if (clk_rate > 0) {
	if (clk_rate > 0) {
		clk_rate_round = clk_round_rate(clk, clk_rate);
		clk_rate_round = clk_round_rate(clk, clk_rate);
		CAM_DBG(CAM_UTIL, "new_rate %ld", clk_rate_round);
		CAM_DBG(CAM_UTIL, "new_rate %ld", clk_rate_round);
@@ -431,7 +431,7 @@ static int cam_soc_util_set_clk_rate(struct clk *clk, const char *clk_name,
}
}


int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
	int32_t clk_rate)
	int64_t clk_rate)
{
{
	int32_t src_clk_idx;
	int32_t src_clk_idx;
	struct clk *clk = NULL;
	struct clk *clk = NULL;
@@ -452,7 +452,7 @@ int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
	if (soc_info->cam_cx_ipeak_enable && clk_rate >= 0) {
	if (soc_info->cam_cx_ipeak_enable && clk_rate >= 0) {
		apply_level = cam_soc_util_get_clk_level(soc_info, src_clk_idx,
		apply_level = cam_soc_util_get_clk_level(soc_info, src_clk_idx,
				clk_rate);
				clk_rate);
		CAM_DBG(CAM_UTIL, "set %s, rate %d dev_name = %s\n"
		CAM_DBG(CAM_UTIL, "set %s, rate %lld dev_name = %s\n"
			"apply level = %d",
			"apply level = %d",
			soc_info->clk_name[src_clk_idx], clk_rate,
			soc_info->clk_name[src_clk_idx], clk_rate,
			soc_info->dev_name, apply_level);
			soc_info->dev_name, apply_level);
+1 −1
Original line number Original line Diff line number Diff line
@@ -390,7 +390,7 @@ int cam_soc_util_set_clk_flags(struct cam_hw_soc_info *soc_info,
 * @return:             success or failure
 * @return:             success or failure
 */
 */
int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
int cam_soc_util_set_src_clk_rate(struct cam_hw_soc_info *soc_info,
	int32_t clk_rate);
	int64_t clk_rate);


/**
/**
 * cam_soc_util_get_option_clk_by_name()
 * cam_soc_util_get_option_clk_by_name()