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

Commit bfe405c9 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: gsi: Using kzalloc instead of devm_kzalloc"

parents d64fa8eb b1778242
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/of.h>
@@ -11,6 +11,7 @@
#include <linux/msm_gsi.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include "gsi.h"
#include "gsi_reg.h"
#include "gsi_emulation.h"
@@ -2354,7 +2355,7 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
{
	struct gsi_chan_ctx *ctx;
	uint32_t val;
	int res;
	int res, size;
	int ee;
	enum gsi_ch_cmd_opcode op = GSI_CH_ALLOCATE;
	uint8_t erindex;
@@ -2415,9 +2416,8 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
	if (props->prot == GSI_CHAN_PROT_GCI)
		user_data_size += GSI_VEID_MAX;

	user_data = devm_kzalloc(gsi_ctx->dev,
		user_data_size * sizeof(*user_data),
		GFP_KERNEL);
	size = user_data_size * sizeof(*user_data);
	user_data = kzalloc(size, GFP_KERNEL);
	if (user_data == NULL) {
		GSIERR("context not allocated\n");
		return -GSI_STATUS_RES_ALLOC_FAILURE;
@@ -2442,14 +2442,14 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
		if (res == 0) {
			GSIERR("chan_hdl=%u timed out\n", props->ch_id);
			mutex_unlock(&gsi_ctx->mlock);
			devm_kfree(gsi_ctx->dev, user_data);
			kfree(user_data);
			return -GSI_STATUS_TIMED_OUT;
		}
		if (ctx->state != GSI_CHAN_STATE_ALLOCATED) {
			GSIERR("chan_hdl=%u allocation failed state=%d\n",
					props->ch_id, ctx->state);
			mutex_unlock(&gsi_ctx->mlock);
			devm_kfree(gsi_ctx->dev, user_data);
			kfree(user_data);
			return -GSI_STATUS_RES_ALLOC_FAILURE;
		}
		mutex_unlock(&gsi_ctx->mlock);
@@ -2462,7 +2462,7 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
		GSI_NO_EVT_ERINDEX;
	if (erindex != GSI_NO_EVT_ERINDEX && erindex >= GSI_EVT_RING_MAX) {
		GSIERR("invalid erindex %u\n", erindex);
		devm_kfree(gsi_ctx->dev, user_data);
		kfree(user_data);
		return -GSI_STATUS_INVALID_PARAMS;
	}

@@ -3228,7 +3228,7 @@ int gsi_dealloc_channel(unsigned long chan_hdl)
								ctx->state);
		mutex_unlock(&gsi_ctx->mlock);
	}
	devm_kfree(gsi_ctx->dev, ctx->user_data);
	kfree(ctx->user_data);
	ctx->allocated = false;
	if (ctx->evtr && (ctx->props.prot != GSI_CHAN_PROT_GCI))
		atomic_dec(&ctx->evtr->chan_ref_cnt);