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

Commit 61d654d3 authored by Yong Ding's avatar Yong Ding Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: hab: return an error for some issue during closing a hab socket



habmm_socket_close should return some relevant error code back to
its caller. Then, its caller can handle it properly.

Change-Id: I04d2fb39644514d59aa94d0dfab7efd1e279ce6a
Signed-off-by: default avatarYong Ding <yongding@codeaurora.org>
parent 11ae02d0
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, 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
@@ -720,12 +720,14 @@ void hab_send_close_msg(struct virtual_channel *vchan)
	}
}

void hab_vchan_close(struct uhab_context *ctx, int32_t vcid)
int hab_vchan_close(struct uhab_context *ctx, int32_t vcid)
{
	struct virtual_channel *vchan, *tmp;
	struct virtual_channel *vchan = NULL, *tmp = NULL;
	int vchan_found = 0;
	int ret = 0;

	if (!ctx)
		return;
		return -EINVAL;

	write_lock(&ctx->ctx_lock);
	list_for_each_entry_safe(vchan, tmp, &ctx->vchannels, node) {
@@ -746,10 +748,16 @@ void hab_vchan_close(struct uhab_context *ctx, int32_t vcid)
			hab_vchan_stop_notify(vchan);
			hab_vchan_put(vchan); /* there is a lock inside */
			write_lock(&ctx->ctx_lock);
			vchan_found = 1;
			break;
		}
	}
	write_unlock(&ctx->ctx_lock);

	if (!vchan_found)
		ret = -ENODEV;

	return ret;
}

/*
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, 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
@@ -384,7 +384,7 @@ struct export_desc_super {
int hab_vchan_open(struct uhab_context *ctx,
		unsigned int mmid, int32_t *vcid,
		int32_t timeout, uint32_t flags);
void hab_vchan_close(struct uhab_context *ctx,
int hab_vchan_close(struct uhab_context *ctx,
		int32_t vcid);
long hab_vchan_send(struct uhab_context *ctx,
		int vcid,
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2019-2020, 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
@@ -117,7 +117,7 @@ static long hab_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
		break;
	case IOCTL_HAB_VC_CLOSE:
		close_param = (struct hab_close *)data;
		hab_vchan_close(ctx, close_param->vcid);
		ret = hab_vchan_close(ctx, close_param->vcid);
		break;
	case IOCTL_HAB_SEND:
		send_param = (struct hab_send *)data;
+2 −3
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2020, 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
@@ -23,8 +23,7 @@ EXPORT_SYMBOL(habmm_socket_open);

int32_t habmm_socket_close(int32_t handle)
{
	hab_vchan_close(hab_driver.kctx, handle);
	return 0;
	return hab_vchan_close(hab_driver.kctx, handle);
}
EXPORT_SYMBOL(habmm_socket_close);