From 569fccb6b48878d654310e1ffaf9a5a6e46b3144 Mon Sep 17 00:00:00 2001 From: Alexandre Bounine Date: Wed, 23 Mar 2011 16:43:05 -0700 Subject: rapidio: modify mport ID assignment Changes mport ID and host destination ID assignment to implement unified method common to all mport drivers. Makes "riohdid=" kernel command line parameter common for all architectures with support for more that one host destination ID assignment. Signed-off-by: Alexandre Bounine Cc: Kumar Gala Cc: Matt Porter Cc: Li Yang Cc: Thomas Moll Cc: Micha Nelissen Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rapidio/rio.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'drivers/rapidio') diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index f861b728f80e..9a7b2168d1d5 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c @@ -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 @@ -1164,8 +1165,33 @@ int __devinit rio_init_mports(void) 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); } -- cgit v1.2.2