revert hotplug malloc change

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ted Unangst
Date: Monday, December 13, 2010 - 9:01 pm

keeping a little bit of the change, i'm leaving the element expansion in 
there.  that's what i was really after the first time anyway.

Index: hotplug.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/dev/hotplug.c,v
retrieving revision 1.10
diff -u -r1.10 hotplug.c
--- hotplug.c	2 Dec 2010 04:12:35 -0000	1.10
+++ hotplug.c	14 Dec 2010 03:59:10 -0000
@@ -26,14 +26,13 @@
 #include <sys/fcntl.h>
 #include <sys/hotplug.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
 #include <sys/poll.h>
 #include <sys/vnode.h>
 
 #define HOTPLUG_MAXEVENTS	64
 
 static int opened;
-static struct hotplug_event *evqueue;
+static struct hotplug_event evqueue[HOTPLUG_MAXEVENTS];
 static int evqueue_head, evqueue_tail, evqueue_count;
 static struct selinfo hotplug_sel;
 
@@ -89,8 +88,6 @@
 		printf("hotplug: event lost, queue full\n");
 		return (1);
 	}
-	if (!evqueue)
-		return (1);
 
 	evqueue[evqueue_head] = *he;
 	evqueue_head = EVQUEUE_NEXT(evqueue_head);
@@ -122,22 +119,12 @@
 int
 hotplugopen(dev_t dev, int flag, int mode, struct proc *p)
 {
-	struct hotplug_event *q;
-
 	if (minor(dev) != 0)
 		return (ENXIO);
 	if ((flag & FWRITE))
 		return (EPERM);
 	if (opened)
 		return (EBUSY);
-	if (!evqueue) {
-		q = malloc(sizeof(*q) * HOTPLUG_MAXEVENTS, M_DEVBUF, M_WAITOK);
-		if (opened) {
-			free(q, M_DEVBUF);
-			return (EBUSY);
-		}
-		evqueue = q;
-	}
 	opened = 1;
 	return (0);
 }
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
revert hotplug malloc change, Ted Unangst, (Mon Dec 13, 9:01 pm)