Commit 851f166e authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

thread: move interrupt allocation to a function



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I71cd8fbfb0e7dfb6836d716ab420b3af45b3d2d3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25465


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent c12cb8fe
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -2880,13 +2880,11 @@ spdk_interrupt_register_for_events(int efd, uint32_t events, spdk_interrupt_fn f
	return spdk_interrupt_register_ext(efd, fn, arg, name, &opts);
}

struct spdk_interrupt *
spdk_interrupt_register_ext(int efd, spdk_interrupt_fn fn, void *arg, const char *name,
			    struct spdk_event_handler_opts *opts)
static struct spdk_interrupt *
alloc_interrupt(int efd, spdk_interrupt_fn fn, void *arg, const char *name)
{
	struct spdk_thread *thread;
	struct spdk_interrupt *intr;
	int ret;

	thread = spdk_get_thread();
	if (!thread) {
@@ -2916,11 +2914,26 @@ spdk_interrupt_register_ext(int efd, spdk_interrupt_fn fn, void *arg, const char
	intr->fn = fn;
	intr->arg = arg;

	ret = spdk_fd_group_add_ext(thread->fgrp, efd, _interrupt_wrapper, intr, intr->name, opts);
	return intr;
}

struct spdk_interrupt *
spdk_interrupt_register_ext(int efd, spdk_interrupt_fn fn, void *arg, const char *name,
			    struct spdk_event_handler_opts *opts)
{
	struct spdk_interrupt *intr;
	int ret;

	intr = alloc_interrupt(efd, fn, arg, name);
	if (intr == NULL) {
		return NULL;
	}

	ret = spdk_fd_group_add_ext(intr->thread->fgrp, efd,
				    _interrupt_wrapper, intr, intr->name, opts);
	if (ret != 0) {
		SPDK_ERRLOG("thread %s: failed to add fd %d: %s\n",
			    thread->name, efd, spdk_strerror(-ret));
			    intr->thread->name, efd, spdk_strerror(-ret));
		free(intr);
		return NULL;
	}