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

Commit cfdf33da authored by David Collins's avatar David Collins
Browse files

regulator: cpr3-regulator: remove memory allocation failure messages



Remove all error messages that are printed after a dynamic
memory allocation function returns a NULL pointer.  The memory
subsystem already ensures that a verbose message is printed when
an allocation is attempted and insufficient memory is available.

This issue was found with checkpatch.

Change-Id: Id16a985f55da2442c25fefe5f2f7564f8c6efde6
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent a5eb2c93
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -354,10 +354,8 @@ static int cpr3_msm8996_hmss_read_fuse_data(struct cpr3_thread *thread)
	int i, id, rc;

	fuse = devm_kzalloc(thread->ctrl->dev, sizeof(*fuse), GFP_KERNEL);
	if (!fuse) {
		cpr3_err(thread, "could not allocate memory for fuse data\n");
	if (!fuse)
		return -ENOMEM;
	}

	rc = cpr3_read_fuse_param(base, msm8996_hmss_speed_bin_param,
				&fuse->speed_bin);
@@ -520,7 +518,6 @@ static int cpr3_msm8996_hmss_calculate_open_loop_voltages(
	fmax_corner = kzalloc(sizeof(*fmax_corner) * thread->fuse_corner_count,
					GFP_KERNEL);
	if (!fuse_volt || !fmax_corner) {
		cpr3_err(thread, "unable to allocate temp memory\n");
		rc = -ENOMEM;
		goto done;
	}
@@ -751,10 +748,8 @@ static int cpr3_hmss_parse_closed_loop_voltage_adjustments(
	ro_all_scale = kzalloc(sizeof(*ro_all_scale)
				* thread->fuse_corner_count * CPR3_RO_COUNT,
				GFP_KERNEL);
	if (!ro_all_scale) {
		cpr3_err(thread, "memory allocation failed\n");
	if (!ro_all_scale)
		return -ENOMEM;
	}

	rc = cpr3_parse_array_property(thread, "qcom,cpr-ro-scaling-factor",
		thread->fuse_corner_count * CPR3_RO_COUNT,
@@ -908,7 +903,6 @@ static int cpr3_msm8996_hmss_calculate_target_quotients(
					GFP_KERNEL);
	if (!volt_adjust || !volt_adjust_fuse || !ro_scale ||
	    !fmax_corner || !quot_low || !quot_high) {
		cpr3_err(thread, "unable to allocate temp memory\n");
		rc = -ENOMEM;
		goto done;
	}
@@ -1349,10 +1343,8 @@ static int cpr3_hmss_init_controller(struct cpr3_controller *ctrl)

	ctrl->sensor_owner = devm_kzalloc(ctrl->dev,
		sizeof(*ctrl->sensor_owner) * ctrl->sensor_count, GFP_KERNEL);
	if (!ctrl->sensor_owner) {
		cpr3_err(ctrl, "memory allocation failed\n");
	if (!ctrl->sensor_owner)
		return -ENOMEM;
	}

	/* Specify sensor ownership */
	for (i = MSM8996_HMSS_THREAD0_SENSOR_MIN;
@@ -1402,10 +1394,8 @@ static int cpr3_hmss_regulator_probe(struct platform_device *pdev)
	}

	ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
	if (!ctrl) {
		dev_err(dev, "cpr3 controller memory allocation failed\n");
	if (!ctrl)
		return -ENOMEM;
	}

	ctrl->dev = dev;
	/* Set to false later if anything precludes CPR operation. */
+4 −14
Original line number Diff line number Diff line
@@ -142,10 +142,8 @@ static int cpr3_msm8996_mmss_read_fuse_data(struct cpr3_thread *thread)
	int i, rc;

	fuse = devm_kzalloc(thread->ctrl->dev, sizeof(*fuse), GFP_KERNEL);
	if (!fuse) {
		cpr3_err(thread, "could not allocate memory for fuse data\n");
	if (!fuse)
		return -ENOMEM;
	}

	rc = cpr3_read_fuse_param(base, msm8996_cpr_fusing_rev_param,
				&fuse->cpr_fusing_rev);
@@ -213,10 +211,8 @@ static int cpr3_mmss_parse_corner_data(struct cpr3_thread *thread,

	temp = kzalloc(sizeof(*temp) * thread->corner_count * CPR3_RO_COUNT,
			GFP_KERNEL);
	if (!temp) {
		cpr3_err(thread, "memory allocation failed\n");
	if (!temp)
		return -ENOMEM;
	}

	rc = cpr3_parse_array_property(thread, "qcom,cpr-target-quotients",
			thread->corner_count * CPR3_RO_COUNT,
@@ -269,7 +265,6 @@ static int cpr3_mmss_adjust_target_quotients(struct cpr3_thread *thread,
	ro_scale = kzalloc(sizeof(*ro_scale) * thread->corner_count
				* CPR3_RO_COUNT, GFP_KERNEL);
	if (!volt_adjust || !ro_scale) {
		cpr3_err(thread, "memory allocation failed\n");
		rc = -ENOMEM;
		goto done;
	}
@@ -357,7 +352,6 @@ static int cpr3_msm8996_mmss_calculate_open_loop_voltages(
	fmax_corner = kzalloc(sizeof(*fmax_corner) * thread->fuse_corner_count,
					GFP_KERNEL);
	if (!fuse_volt || !fmax_corner) {
		cpr3_err(thread, "unable to allocate temp memory\n");
		rc = -ENOMEM;
		goto done;
	}
@@ -573,10 +567,8 @@ static int cpr3_mmss_init_controller(struct cpr3_controller *ctrl)
	 */
	ctrl->sensor_owner = devm_kzalloc(ctrl->dev,
		sizeof(*ctrl->sensor_owner) * ctrl->sensor_count, GFP_KERNEL);
	if (!ctrl->sensor_owner) {
		cpr3_err(ctrl, "memory allocation failed\n");
	if (!ctrl->sensor_owner)
		return -ENOMEM;
	}

	ctrl->cpr_clock_rate = MSM8996_MMSS_CPR_CLOCK_RATE;

@@ -633,10 +625,8 @@ static int cpr3_mmss_regulator_probe(struct platform_device *pdev)
	}

	ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
	if (!ctrl) {
		dev_err(dev, "cpr3 controller memory allocation failed\n");
	if (!ctrl)
		return -ENOMEM;
	}

	ctrl->dev = dev;
	/* Set to false later if anything precludes CPR operation. */
+5 −9
Original line number Diff line number Diff line
@@ -1900,10 +1900,8 @@ static struct dentry *cpr3_debugfs_create_corner_int(struct cpr3_thread *thread,
	struct cpr3_debug_corner_info *info;

	info = devm_kzalloc(thread->ctrl->dev, sizeof(*info), GFP_KERNEL);
	if (!info) {
		cpr3_err(thread, "could not allocate memory for debugfs function data\n");
	if (!info)
		return NULL;
	}

	info->thread = thread;
	info->index = index;
@@ -2012,10 +2010,9 @@ static void cpr3_regulator_debugfs_corner_add(struct cpr3_thread *thread,
	}

	info = devm_kzalloc(thread->ctrl->dev, sizeof(*info), GFP_KERNEL);
	if (!info) {
		cpr3_err(thread, "could not allocate memory for debugfs function data\n");
	if (!info)
		return;
	}

	info->thread = thread;
	info->index = index;

@@ -2124,10 +2121,9 @@ static void cpr3_regulator_debugfs_thread_add(struct cpr3_thread *thread)
	name_len = strlen(thread->name) + 2;
	name = devm_kzalloc(thread->ctrl->dev, name_len, GFP_KERNEL);
	blob = devm_kzalloc(thread->ctrl->dev, sizeof(*blob), GFP_KERNEL);
	if (!name || !blob) {
		cpr3_err(thread, "could not allocate memory for debugfs name data\n");
	if (!name || !blob)
		return;
	}

	strlcpy(name, thread->name, name_len);
	strlcat(name, "\n", name_len);
	blob->data = name;
+6 −23
Original line number Diff line number Diff line
@@ -90,10 +90,8 @@ int cpr3_allocate_threads(struct cpr3_controller *ctrl, u32 min_thread_id,

	ctrl->thread = devm_kzalloc(dev,
			sizeof(*ctrl->thread) * ctrl->thread_count, GFP_KERNEL);
	if (!ctrl->thread) {
		dev_err(dev, "could not allocate memory for CPR threads\n");
	if (!ctrl->thread)
		return -ENOMEM;
	}

	i = 0;
	for_each_available_child_of_node(dev->of_node, thread_node) {
@@ -405,10 +403,8 @@ int cpr3_parse_common_corner_data(struct cpr3_thread *thread, int *corner_sum,

	combo_corners = kzalloc(sizeof(*combo_corners) * max_fuse_combos,
				GFP_KERNEL);
	if (!combo_corners) {
		cpr3_err(thread, "could not allocate temp memory\n");
	if (!combo_corners)
		return -ENOMEM;
	}

	rc = of_property_read_u32_array(node, "qcom,cpr-corners", combo_corners,
					max_fuse_combos);
@@ -441,16 +437,9 @@ int cpr3_parse_common_corner_data(struct cpr3_thread *thread, int *corner_sum,
	thread->corner = devm_kzalloc(thread->ctrl->dev,
			sizeof(*thread->corner) * thread->corner_count,
			GFP_KERNEL);
	if (!thread->corner) {
		cpr3_err(thread, "could not allocate memory for corner array\n");
		return -ENOMEM;
	}

	temp = kzalloc(sizeof(*temp) * thread->corner_count, GFP_KERNEL);
	if (!temp) {
		cpr3_err(thread, "could not allocate temp memory\n");
	if (!thread->corner || !temp)
		return -ENOMEM;
	}

	rc = cpr3_parse_array_property(thread, "qcom,cpr-voltage-ceiling",
			thread->corner_count, *corner_sum, *combo_offset, temp);
@@ -794,10 +783,8 @@ void cpr3_print_quots(struct cpr3_thread *thread)

	buflen = sizeof(*buf) * CPR3_RO_COUNT * (MAX_CHARS_PER_INT + 2);
	buf = kzalloc(buflen, GFP_KERNEL);
	if (!buf) {
		cpr3_err(thread, "could not allocate memory for debug logging\n");
	if (!buf)
		return;
	}

	for (i = 0; i < thread->corner_count; i++) {
		for (j = 0, pos = 0; j < CPR3_RO_COUNT; j++)
@@ -834,10 +821,8 @@ int cpr3_adjust_fused_open_loop_voltages(struct cpr3_thread *thread,

	volt_adjust = kzalloc(sizeof(*volt_adjust) * thread->fuse_corner_count,
				GFP_KERNEL);
	if (!volt_adjust) {
		cpr3_err(thread, "memory allocation failed\n");
	if (!volt_adjust)
		return -ENOMEM;
	}

	rc = cpr3_parse_array_property(thread,
		"qcom,cpr-open-loop-voltage-fuse-adjustment",
@@ -888,10 +873,8 @@ int cpr3_adjust_open_loop_voltages(struct cpr3_thread *thread, int corner_sum,

	volt_adjust = kzalloc(sizeof(*volt_adjust) * thread->corner_count,
				GFP_KERNEL);
	if (!volt_adjust) {
		cpr3_err(thread, "memory allocation failed\n");
	if (!volt_adjust)
		return -ENOMEM;
	}

	rc = cpr3_parse_array_property(thread,
		"qcom,cpr-open-loop-voltage-adjustment",