Patchwork reduce the size of devices

login
register
about
Submitter Myles Watson
Date 2010-05-20 23:20:41
Message ID <AANLkTikf--OrENBF-oegIX_9co5-fsdvk1eYKDSiMv-B@mail.gmail.com>
Download mbox | patch
Permalink /patch/1366/
State Not Applicable, archived
Headers show

Comments

Myles Watson - 2010-05-20 23:20:41
> We could add the resources to the end of the list to maintain
> the old order if anyone cares.  Since we're using a list, the
> resources are in reverse order.

Since it makes it easier to debug in case there's a problem, here it is.

Signed-off-by: Myles Watson <mylesgw@gmail.com>

Thanks,
Myles

Patch

Index: svn/src/devices/device_util.c
===================================================================
--- svn.orig/src/devices/device_util.c
+++ svn/src/devices/device_util.c
@@ -339,7 +339,7 @@  struct resource *probe_resource(device_t
  */
 struct resource *new_resource(device_t dev, unsigned index)
 {
-	struct resource *resource;
+	struct resource *resource, *tail;
 
 	/* First move all of the free resources to the end */
 	compact_resources(dev);
@@ -353,8 +353,14 @@  struct resource *new_resource(device_t d
 		resource = free_resources;
 		free_resources = free_resources->next;
 		memset(resource, 0, sizeof(*resource));
-		resource->next = dev->resource_list;
-		dev->resource_list = resource;
+		resource->next = NULL;
+		tail = dev->resource_list;
+		if (tail) {
+			while (tail->next) tail = tail->next;
+			tail->next = resource;
+		}
+		else
+			dev->resource_list = resource;
 	}
 	/* Initialize the resource values */
 	if (!(resource->flags & IORESOURCE_FIXED)) {