Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision 9359aae9d5e8472d1863d2eb319c40c5d632be19)
+++ uspace/lib/drv/generic/interrupt.c	(revision 9b201262edcb92c27cf4a25a8379320113426ab7)
@@ -44,20 +44,4 @@
 #include "private/driver.h"
 
-static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall);
-static interrupt_context_t *create_interrupt_context(void);
-static void delete_interrupt_context(interrupt_context_t *ctx);
-static void init_interrupt_context_list(interrupt_context_list_t *list);
-static void add_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx);
-static void remove_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx);
-static interrupt_context_t *find_interrupt_context_by_id(
-    interrupt_context_list_t *list, int id);
-static interrupt_context_t *find_interrupt_context(
-    interrupt_context_list_t *list, ddf_dev_t *dev, int irq);
-
-/** Interrupts */
-static interrupt_context_list_t interrupt_contexts;
-
 static irq_cmd_t default_cmds[] = {
 	{
@@ -73,132 +57,14 @@
 };
 
-void interrupt_init(void)
-{
-	/* Initialize the list of interrupt contexts. */
-	init_interrupt_context_list(&interrupt_contexts);
-	
-	/* Set generic interrupt handler. */
-	async_set_interrupt_received(driver_irq_handler);
-}
-
-static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
-{
-	int id = (int)IPC_GET_IMETHOD(*icall);
-	interrupt_context_t *ctx;
-	
-	ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
-	if (ctx != NULL && ctx->handler != NULL)
-		(*ctx->handler)(ctx->dev, iid, icall);
-}
-
-static interrupt_context_t *create_interrupt_context(void)
-{
-	interrupt_context_t *ctx;
-	
-	ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
-	if (ctx != NULL)
-		memset(ctx, 0, sizeof(interrupt_context_t));
-	
-	return ctx;
-}
-
-static void delete_interrupt_context(interrupt_context_t *ctx)
-{
-	if (ctx != NULL)
-		free(ctx);
-}
-
-static void init_interrupt_context_list(interrupt_context_list_t *list)
-{
-	memset(list, 0, sizeof(interrupt_context_list_t));
-	fibril_mutex_initialize(&list->mutex);
-	list_initialize(&list->contexts);
-}
-
-static void add_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx)
-{
-	fibril_mutex_lock(&list->mutex);
-	ctx->id = list->curr_id++;
-	list_append(&ctx->link, &list->contexts);
-	fibril_mutex_unlock(&list->mutex);
-}
-
-static void remove_interrupt_context(interrupt_context_list_t *list,
-    interrupt_context_t *ctx)
-{
-	fibril_mutex_lock(&list->mutex);
-	list_remove(&ctx->link);
-	fibril_mutex_unlock(&list->mutex);
-}
-
-static interrupt_context_t *find_interrupt_context_by_id(
-    interrupt_context_list_t *list, int id)
-{
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
-		if (ctx->id == id) {
-			fibril_mutex_unlock(&list->mutex);
-			return ctx;
-		}
-	}
-	
-	fibril_mutex_unlock(&list->mutex);
-	return NULL;
-}
-
-static interrupt_context_t *find_interrupt_context(
-    interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
-{
-	fibril_mutex_lock(&list->mutex);
-	
-	list_foreach(list->contexts, link, interrupt_context_t, ctx) {
-		if (ctx->irq == irq && ctx->dev == dev) {
-			fibril_mutex_unlock(&list->mutex);
-			return ctx;
-		}
-	}
-	
-	fibril_mutex_unlock(&list->mutex);
-	return NULL;
-}
-
-
 int register_interrupt_handler(ddf_dev_t *dev, int irq,
     interrupt_handler_t *handler, const irq_code_t *pseudocode)
 {
-	interrupt_context_t *ctx = create_interrupt_context();
-	
-	ctx->dev = dev;
-	ctx->irq = irq;
-	ctx->handler = handler;
-	
-	add_interrupt_context(&interrupt_contexts, ctx);
-	
-	if (pseudocode == NULL)
-		pseudocode = &default_pseudocode;
-	
-	int res = irq_register(irq, dev->handle, ctx->id, pseudocode);
-	if (res != EOK) {
-		remove_interrupt_context(&interrupt_contexts, ctx);
-		delete_interrupt_context(ctx);
-	}
-	
-	return res;
+	return async_irq_subscribe(irq, dev->handle,
+	    (async_notification_handler_t) handler, dev, pseudocode);
 }
 
 int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
 {
-	interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
-	    dev, irq);
-	int res = irq_unregister(irq, dev->handle);
-	
-	if (ctx != NULL) {
-		remove_interrupt_context(&interrupt_contexts, ctx);
-		delete_interrupt_context(ctx);
-	}
-	
-	return res;
+	return async_irq_unsubscribe(irq, dev->handle);
 }
 
