Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / rapidio / rio.c
index f861b72..c29719c 100644 (file)
@@ -32,6 +32,7 @@
 #include "rio.h"
 
 static LIST_HEAD(rio_mports);
+static unsigned char next_portid;
 
 /**
  * rio_local_get_device_id - Get the base/extended device id for a port
@@ -1136,20 +1137,9 @@ static int __devinit rio_init(void)
 
 int __devinit rio_init_mports(void)
 {
-       int rc = 0;
        struct rio_mport *port;
 
        list_for_each_entry(port, &rio_mports, node) {
-               if (!request_mem_region(port->iores.start,
-                                       resource_size(&port->iores),
-                                       port->name)) {
-                       printk(KERN_ERR
-                              "RIO: Error requesting master port region 0x%016llx-0x%016llx\n",
-                              (u64)port->iores.start, (u64)port->iores.end);
-                       rc = -ENOMEM;
-                       goto out;
-               }
-
                if (port->host_deviceid >= 0)
                        rio_enum_mport(port);
                else
@@ -1158,14 +1148,38 @@ int __devinit rio_init_mports(void)
 
        rio_init();
 
-      out:
-       return rc;
+       return 0;
 }
 
 device_initcall_sync(rio_init_mports);
 
+static int hdids[RIO_MAX_MPORTS + 1];
+
+static int rio_get_hdid(int index)
+{
+       if (!hdids[0] || hdids[0] <= index || index >= RIO_MAX_MPORTS)
+               return -1;
+
+       return hdids[index + 1];
+}
+
+static int rio_hdid_setup(char *str)
+{
+       (void)get_options(str, ARRAY_SIZE(hdids), hdids);
+       return 1;
+}
+
+__setup("riohdid=", rio_hdid_setup);
+
 void rio_register_mport(struct rio_mport *port)
 {
+       if (next_portid >= RIO_MAX_MPORTS) {
+               pr_err("RIO: reached specified max number of mports\n");
+               return;
+       }
+
+       port->id = next_portid++;
+       port->host_deviceid = rio_get_hdid(port->id);
        list_add_tail(&port->node, &rio_mports);
 }