Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio: convert switch drivers to modules

Rework RapidIO switch drivers to add an option to build them as loadable
kernel modules.

This patch removes RapidIO-specific vmlinux section and converts switch
drivers to be compatible with LDM driver registration method. To simplify
registration of device-specific callback routines this patch introduces
rio_switch_ops data structure. The sw_sysfs() callback is removed from
the list of device-specific operations because under the new structure its
functions can be handled by switch driver's probe() and remove() routines.

If a specific switch device driver is not loaded the RapidIO subsystem
core will use default standard-based operations to configure a switch.
Because the current implementation of RapidIO enumeration/discovery method
relies on availability of device-specific operations for error management,
switch device drivers must be loaded before the RapidIO
enumeration/discovery starts.

This patch also moves several common routines from enumeration/discovery
module into the RapidIO core code to make switch-specific operations
accessible to all components of RapidIO subsystem.

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Andre van Herk <andre.van.herk@Prodrive.nl>
Cc: Micha Nelissen <micha.nelissen@Prodrive.nl>
Cc: Stef van Os <stef.van.os@Prodrive.nl>
Cc: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
2ec3ba69 36f0efbb

+566 -343
+5
drivers/rapidio/Kconfig
··· 67 67 68 68 endchoice 69 69 70 + menu "RapidIO Switch drivers" 71 + depends on RAPIDIO 72 + 70 73 source "drivers/rapidio/switches/Kconfig" 74 + 75 + endmenu
+9 -162
drivers/rapidio/rio-scan.c
··· 406 406 rio_mport_write_config_32(port, destid, hopcount, 407 407 RIO_COMPONENT_TAG_CSR, next_comptag); 408 408 rdev->comp_tag = next_comptag++; 409 + rdev->do_enum = true; 409 410 } else { 410 411 rio_mport_read_config_32(port, destid, hopcount, 411 412 RIO_COMPONENT_TAG_CSR, ··· 435 434 rswitch = rdev->rswitch; 436 435 rswitch->switchid = rdev->comp_tag & RIO_CTAG_UDEVID; 437 436 rswitch->port_ok = 0; 437 + spin_lock_init(&rswitch->lock); 438 438 rswitch->route_table = kzalloc(sizeof(u8)* 439 439 RIO_MAX_ROUTE_ENTRIES(port->sys_size), 440 440 GFP_KERNEL); ··· 447 445 rswitch->route_table[rdid] = RIO_INVALID_ROUTE; 448 446 dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id, 449 447 rswitch->switchid); 450 - rio_switch_init(rdev, do_enum); 451 448 452 - if (do_enum && rswitch->clr_table) 453 - rswitch->clr_table(port, destid, hopcount, 454 - RIO_GLOBAL_TABLE); 449 + if (do_enum) 450 + rio_route_clr_table(rdev, RIO_GLOBAL_TABLE, 0); 455 451 456 452 list_add_tail(&rswitch->node, &net->switches); 457 453 ··· 530 530 &result); 531 531 532 532 return result & RIO_PORT_N_ERR_STS_PORT_OK; 533 - } 534 - 535 - /** 536 - * rio_lock_device - Acquires host device lock for specified device 537 - * @port: Master port to send transaction 538 - * @destid: Destination ID for device/switch 539 - * @hopcount: Hopcount to reach switch 540 - * @wait_ms: Max wait time in msec (0 = no timeout) 541 - * 542 - * Attepts to acquire host device lock for specified device 543 - * Returns 0 if device lock acquired or EINVAL if timeout expires. 544 - */ 545 - static int 546 - rio_lock_device(struct rio_mport *port, u16 destid, u8 hopcount, int wait_ms) 547 - { 548 - u32 result; 549 - int tcnt = 0; 550 - 551 - /* Attempt to acquire device lock */ 552 - rio_mport_write_config_32(port, destid, hopcount, 553 - RIO_HOST_DID_LOCK_CSR, port->host_deviceid); 554 - rio_mport_read_config_32(port, destid, hopcount, 555 - RIO_HOST_DID_LOCK_CSR, &result); 556 - 557 - while (result != port->host_deviceid) { 558 - if (wait_ms != 0 && tcnt == wait_ms) { 559 - pr_debug("RIO: timeout when locking device %x:%x\n", 560 - destid, hopcount); 561 - return -EINVAL; 562 - } 563 - 564 - /* Delay a bit */ 565 - mdelay(1); 566 - tcnt++; 567 - /* Try to acquire device lock again */ 568 - rio_mport_write_config_32(port, destid, 569 - hopcount, 570 - RIO_HOST_DID_LOCK_CSR, 571 - port->host_deviceid); 572 - rio_mport_read_config_32(port, destid, 573 - hopcount, 574 - RIO_HOST_DID_LOCK_CSR, &result); 575 - } 576 - 577 - return 0; 578 - } 579 - 580 - /** 581 - * rio_unlock_device - Releases host device lock for specified device 582 - * @port: Master port to send transaction 583 - * @destid: Destination ID for device/switch 584 - * @hopcount: Hopcount to reach switch 585 - * 586 - * Returns 0 if device lock released or EINVAL if fails. 587 - */ 588 - static int 589 - rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) 590 - { 591 - u32 result; 592 - 593 - /* Release device lock */ 594 - rio_mport_write_config_32(port, destid, 595 - hopcount, 596 - RIO_HOST_DID_LOCK_CSR, 597 - port->host_deviceid); 598 - rio_mport_read_config_32(port, destid, hopcount, 599 - RIO_HOST_DID_LOCK_CSR, &result); 600 - if ((result & 0xffff) != 0xffff) { 601 - pr_debug("RIO: badness when releasing device lock %x:%x\n", 602 - destid, hopcount); 603 - return -EINVAL; 604 - } 605 - 606 - return 0; 607 - } 608 - 609 - /** 610 - * rio_route_add_entry- Add a route entry to a switch routing table 611 - * @rdev: RIO device 612 - * @table: Routing table ID 613 - * @route_destid: Destination ID to be routed 614 - * @route_port: Port number to be routed 615 - * @lock: lock switch device flag 616 - * 617 - * Calls the switch specific add_entry() method to add a route entry 618 - * on a switch. The route table can be specified using the @table 619 - * argument if a switch has per port routing tables or the normal 620 - * use is to specific all tables (or the global table) by passing 621 - * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL 622 - * on failure. 623 - */ 624 - static int 625 - rio_route_add_entry(struct rio_dev *rdev, 626 - u16 table, u16 route_destid, u8 route_port, int lock) 627 - { 628 - int rc; 629 - 630 - if (lock) { 631 - rc = rio_lock_device(rdev->net->hport, rdev->destid, 632 - rdev->hopcount, 1000); 633 - if (rc) 634 - return rc; 635 - } 636 - 637 - rc = rdev->rswitch->add_entry(rdev->net->hport, rdev->destid, 638 - rdev->hopcount, table, 639 - route_destid, route_port); 640 - if (lock) 641 - rio_unlock_device(rdev->net->hport, rdev->destid, 642 - rdev->hopcount); 643 - 644 - return rc; 645 - } 646 - 647 - /** 648 - * rio_route_get_entry- Read a route entry in a switch routing table 649 - * @rdev: RIO device 650 - * @table: Routing table ID 651 - * @route_destid: Destination ID to be routed 652 - * @route_port: Pointer to read port number into 653 - * @lock: lock switch device flag 654 - * 655 - * Calls the switch specific get_entry() method to read a route entry 656 - * in a switch. The route table can be specified using the @table 657 - * argument if a switch has per port routing tables or the normal 658 - * use is to specific all tables (or the global table) by passing 659 - * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL 660 - * on failure. 661 - */ 662 - static int 663 - rio_route_get_entry(struct rio_dev *rdev, u16 table, 664 - u16 route_destid, u8 *route_port, int lock) 665 - { 666 - int rc; 667 - 668 - if (lock) { 669 - rc = rio_lock_device(rdev->net->hport, rdev->destid, 670 - rdev->hopcount, 1000); 671 - if (rc) 672 - return rc; 673 - } 674 - 675 - rc = rdev->rswitch->get_entry(rdev->net->hport, rdev->destid, 676 - rdev->hopcount, table, 677 - route_destid, route_port); 678 - if (lock) 679 - rio_unlock_device(rdev->net->hport, rdev->destid, 680 - rdev->hopcount); 681 - 682 - return rc; 683 533 } 684 534 685 535 /** ··· 944 1094 945 1095 sport = RIO_GET_PORT_NUM(swrdev->swpinfo); 946 1096 947 - if (rswitch->add_entry) { 948 - rio_route_add_entry(swrdev, 949 - RIO_GLOBAL_TABLE, destid, 950 - sport, 0); 951 - rswitch->route_table[destid] = sport; 952 - } 1097 + rio_route_add_entry(swrdev, RIO_GLOBAL_TABLE, 1098 + destid, sport, 0); 1099 + rswitch->route_table[destid] = sport; 953 1100 } 954 1101 } 955 1102 } ··· 962 1115 static void rio_init_em(struct rio_dev *rdev) 963 1116 { 964 1117 if (rio_is_switch(rdev) && (rdev->em_efptr) && 965 - (rdev->rswitch->em_init)) { 966 - rdev->rswitch->em_init(rdev); 1118 + rdev->rswitch->ops && rdev->rswitch->ops->em_init) { 1119 + rdev->rswitch->ops->em_init(rdev); 967 1120 } 968 1121 } 969 1122
-4
drivers/rapidio/rio-sysfs.c
··· 257 257 err |= device_create_file(&rdev->dev, &dev_attr_routes); 258 258 err |= device_create_file(&rdev->dev, &dev_attr_lnext); 259 259 err |= device_create_file(&rdev->dev, &dev_attr_hopcount); 260 - if (!err && rdev->rswitch->sw_sysfs) 261 - err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE); 262 260 } 263 261 264 262 if (err) ··· 279 281 device_remove_file(&rdev->dev, &dev_attr_routes); 280 282 device_remove_file(&rdev->dev, &dev_attr_lnext); 281 283 device_remove_file(&rdev->dev, &dev_attr_hopcount); 282 - if (rdev->rswitch->sw_sysfs) 283 - rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); 284 284 } 285 285 } 286 286
+239 -47
drivers/rapidio/rio.c
··· 7 7 * 8 8 * Copyright 2009 Integrated Device Technology, Inc. 9 9 * Alex Bounine <alexandre.bounine@idt.com> 10 - * - Added Port-Write/Error Management initialization and handling 11 10 * 12 11 * This program is free software; you can redistribute it and/or modify it 13 12 * under the terms of the GNU General Public License as published by the ··· 579 580 EXPORT_SYMBOL_GPL(rio_set_port_lockout); 580 581 581 582 /** 582 - * rio_switch_init - Sets switch operations for a particular vendor switch 583 - * @rdev: RIO device 584 - * @do_enum: Enumeration/Discovery mode flag 585 - * 586 - * Searches the RIO switch ops table for known switch types. If the vid 587 - * and did match a switch table entry, then call switch initialization 588 - * routine to setup switch-specific routines. 589 - */ 590 - void rio_switch_init(struct rio_dev *rdev, int do_enum) 591 - { 592 - struct rio_switch_ops *cur = __start_rio_switch_ops; 593 - struct rio_switch_ops *end = __end_rio_switch_ops; 594 - 595 - while (cur < end) { 596 - if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) { 597 - pr_debug("RIO: calling init routine for %s\n", 598 - rio_name(rdev)); 599 - cur->init_hook(rdev, do_enum); 600 - break; 601 - } 602 - cur++; 603 - } 604 - 605 - if ((cur >= end) && (rdev->pef & RIO_PEF_STD_RT)) { 606 - pr_debug("RIO: adding STD routing ops for %s\n", 607 - rio_name(rdev)); 608 - rdev->rswitch->add_entry = rio_std_route_add_entry; 609 - rdev->rswitch->get_entry = rio_std_route_get_entry; 610 - rdev->rswitch->clr_table = rio_std_route_clr_table; 611 - } 612 - 613 - if (!rdev->rswitch->add_entry || !rdev->rswitch->get_entry) 614 - printk(KERN_ERR "RIO: missing routing ops for %s\n", 615 - rio_name(rdev)); 616 - } 617 - EXPORT_SYMBOL_GPL(rio_switch_init); 618 - 619 - /** 620 583 * rio_enable_rx_tx_port - enable input receiver and output transmitter of 621 584 * given port 622 585 * @port: Master port associated with the RIO network ··· 931 970 /* 932 971 * Process the port-write notification from switch 933 972 */ 934 - if (rdev->rswitch->em_handle) 935 - rdev->rswitch->em_handle(rdev, portnum); 973 + if (rdev->rswitch->ops && rdev->rswitch->ops->em_handle) 974 + rdev->rswitch->ops->em_handle(rdev, portnum); 936 975 937 976 rio_read_config_32(rdev, 938 977 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), ··· 1168 1207 * @route_destid: destID entry in the RT 1169 1208 * @route_port: destination port for specified destID 1170 1209 */ 1171 - int rio_std_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, 1172 - u16 table, u16 route_destid, u8 route_port) 1210 + static int 1211 + rio_std_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, 1212 + u16 table, u16 route_destid, u8 route_port) 1173 1213 { 1174 1214 if (table == RIO_GLOBAL_TABLE) { 1175 1215 rio_mport_write_config_32(mport, destid, hopcount, ··· 1196 1234 * @route_destid: destID entry in the RT 1197 1235 * @route_port: returned destination port for specified destID 1198 1236 */ 1199 - int rio_std_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, 1200 - u16 table, u16 route_destid, u8 *route_port) 1237 + static int 1238 + rio_std_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, 1239 + u16 table, u16 route_destid, u8 *route_port) 1201 1240 { 1202 1241 u32 result; 1203 1242 ··· 1222 1259 * @hopcount: Number of switch hops to the device 1223 1260 * @table: routing table ID (global or port-specific) 1224 1261 */ 1225 - int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, 1226 - u16 table) 1262 + static int 1263 + rio_std_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, 1264 + u16 table) 1227 1265 { 1228 1266 u32 max_destid = 0xff; 1229 1267 u32 i, pef, id_inc = 1, ext_cfg = 0; ··· 1264 1300 udelay(10); 1265 1301 return 0; 1266 1302 } 1303 + 1304 + /** 1305 + * rio_lock_device - Acquires host device lock for specified device 1306 + * @port: Master port to send transaction 1307 + * @destid: Destination ID for device/switch 1308 + * @hopcount: Hopcount to reach switch 1309 + * @wait_ms: Max wait time in msec (0 = no timeout) 1310 + * 1311 + * Attepts to acquire host device lock for specified device 1312 + * Returns 0 if device lock acquired or EINVAL if timeout expires. 1313 + */ 1314 + int rio_lock_device(struct rio_mport *port, u16 destid, 1315 + u8 hopcount, int wait_ms) 1316 + { 1317 + u32 result; 1318 + int tcnt = 0; 1319 + 1320 + /* Attempt to acquire device lock */ 1321 + rio_mport_write_config_32(port, destid, hopcount, 1322 + RIO_HOST_DID_LOCK_CSR, port->host_deviceid); 1323 + rio_mport_read_config_32(port, destid, hopcount, 1324 + RIO_HOST_DID_LOCK_CSR, &result); 1325 + 1326 + while (result != port->host_deviceid) { 1327 + if (wait_ms != 0 && tcnt == wait_ms) { 1328 + pr_debug("RIO: timeout when locking device %x:%x\n", 1329 + destid, hopcount); 1330 + return -EINVAL; 1331 + } 1332 + 1333 + /* Delay a bit */ 1334 + mdelay(1); 1335 + tcnt++; 1336 + /* Try to acquire device lock again */ 1337 + rio_mport_write_config_32(port, destid, 1338 + hopcount, 1339 + RIO_HOST_DID_LOCK_CSR, 1340 + port->host_deviceid); 1341 + rio_mport_read_config_32(port, destid, 1342 + hopcount, 1343 + RIO_HOST_DID_LOCK_CSR, &result); 1344 + } 1345 + 1346 + return 0; 1347 + } 1348 + EXPORT_SYMBOL_GPL(rio_lock_device); 1349 + 1350 + /** 1351 + * rio_unlock_device - Releases host device lock for specified device 1352 + * @port: Master port to send transaction 1353 + * @destid: Destination ID for device/switch 1354 + * @hopcount: Hopcount to reach switch 1355 + * 1356 + * Returns 0 if device lock released or EINVAL if fails. 1357 + */ 1358 + int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount) 1359 + { 1360 + u32 result; 1361 + 1362 + /* Release device lock */ 1363 + rio_mport_write_config_32(port, destid, 1364 + hopcount, 1365 + RIO_HOST_DID_LOCK_CSR, 1366 + port->host_deviceid); 1367 + rio_mport_read_config_32(port, destid, hopcount, 1368 + RIO_HOST_DID_LOCK_CSR, &result); 1369 + if ((result & 0xffff) != 0xffff) { 1370 + pr_debug("RIO: badness when releasing device lock %x:%x\n", 1371 + destid, hopcount); 1372 + return -EINVAL; 1373 + } 1374 + 1375 + return 0; 1376 + } 1377 + EXPORT_SYMBOL_GPL(rio_unlock_device); 1378 + 1379 + /** 1380 + * rio_route_add_entry- Add a route entry to a switch routing table 1381 + * @rdev: RIO device 1382 + * @table: Routing table ID 1383 + * @route_destid: Destination ID to be routed 1384 + * @route_port: Port number to be routed 1385 + * @lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock) 1386 + * 1387 + * If available calls the switch specific add_entry() method to add a route 1388 + * entry into a switch routing table. Otherwise uses standard RT update method 1389 + * as defined by RapidIO specification. A specific routing table can be selected 1390 + * using the @table argument if a switch has per port routing tables or 1391 + * the standard (or global) table may be used by passing 1392 + * %RIO_GLOBAL_TABLE in @table. 1393 + * 1394 + * Returns %0 on success or %-EINVAL on failure. 1395 + */ 1396 + int rio_route_add_entry(struct rio_dev *rdev, 1397 + u16 table, u16 route_destid, u8 route_port, int lock) 1398 + { 1399 + int rc = -EINVAL; 1400 + struct rio_switch_ops *ops = rdev->rswitch->ops; 1401 + 1402 + if (lock) { 1403 + rc = rio_lock_device(rdev->net->hport, rdev->destid, 1404 + rdev->hopcount, 1000); 1405 + if (rc) 1406 + return rc; 1407 + } 1408 + 1409 + spin_lock(&rdev->rswitch->lock); 1410 + 1411 + if (ops == NULL || ops->add_entry == NULL) { 1412 + rc = rio_std_route_add_entry(rdev->net->hport, rdev->destid, 1413 + rdev->hopcount, table, 1414 + route_destid, route_port); 1415 + } else if (try_module_get(ops->owner)) { 1416 + rc = ops->add_entry(rdev->net->hport, rdev->destid, 1417 + rdev->hopcount, table, route_destid, 1418 + route_port); 1419 + module_put(ops->owner); 1420 + } 1421 + 1422 + spin_unlock(&rdev->rswitch->lock); 1423 + 1424 + if (lock) 1425 + rio_unlock_device(rdev->net->hport, rdev->destid, 1426 + rdev->hopcount); 1427 + 1428 + return rc; 1429 + } 1430 + EXPORT_SYMBOL_GPL(rio_route_add_entry); 1431 + 1432 + /** 1433 + * rio_route_get_entry- Read an entry from a switch routing table 1434 + * @rdev: RIO device 1435 + * @table: Routing table ID 1436 + * @route_destid: Destination ID to be routed 1437 + * @route_port: Pointer to read port number into 1438 + * @lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock) 1439 + * 1440 + * If available calls the switch specific get_entry() method to fetch a route 1441 + * entry from a switch routing table. Otherwise uses standard RT read method 1442 + * as defined by RapidIO specification. A specific routing table can be selected 1443 + * using the @table argument if a switch has per port routing tables or 1444 + * the standard (or global) table may be used by passing 1445 + * %RIO_GLOBAL_TABLE in @table. 1446 + * 1447 + * Returns %0 on success or %-EINVAL on failure. 1448 + */ 1449 + int rio_route_get_entry(struct rio_dev *rdev, u16 table, 1450 + u16 route_destid, u8 *route_port, int lock) 1451 + { 1452 + int rc = -EINVAL; 1453 + struct rio_switch_ops *ops = rdev->rswitch->ops; 1454 + 1455 + if (lock) { 1456 + rc = rio_lock_device(rdev->net->hport, rdev->destid, 1457 + rdev->hopcount, 1000); 1458 + if (rc) 1459 + return rc; 1460 + } 1461 + 1462 + spin_lock(&rdev->rswitch->lock); 1463 + 1464 + if (ops == NULL || ops->get_entry == NULL) { 1465 + rc = rio_std_route_get_entry(rdev->net->hport, rdev->destid, 1466 + rdev->hopcount, table, 1467 + route_destid, route_port); 1468 + } else if (try_module_get(ops->owner)) { 1469 + rc = ops->get_entry(rdev->net->hport, rdev->destid, 1470 + rdev->hopcount, table, route_destid, 1471 + route_port); 1472 + module_put(ops->owner); 1473 + } 1474 + 1475 + spin_unlock(&rdev->rswitch->lock); 1476 + 1477 + if (lock) 1478 + rio_unlock_device(rdev->net->hport, rdev->destid, 1479 + rdev->hopcount); 1480 + return rc; 1481 + } 1482 + EXPORT_SYMBOL_GPL(rio_route_get_entry); 1483 + 1484 + /** 1485 + * rio_route_clr_table - Clear a switch routing table 1486 + * @rdev: RIO device 1487 + * @table: Routing table ID 1488 + * @lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock) 1489 + * 1490 + * If available calls the switch specific clr_table() method to clear a switch 1491 + * routing table. Otherwise uses standard RT write method as defined by RapidIO 1492 + * specification. A specific routing table can be selected using the @table 1493 + * argument if a switch has per port routing tables or the standard (or global) 1494 + * table may be used by passing %RIO_GLOBAL_TABLE in @table. 1495 + * 1496 + * Returns %0 on success or %-EINVAL on failure. 1497 + */ 1498 + int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock) 1499 + { 1500 + int rc = -EINVAL; 1501 + struct rio_switch_ops *ops = rdev->rswitch->ops; 1502 + 1503 + if (lock) { 1504 + rc = rio_lock_device(rdev->net->hport, rdev->destid, 1505 + rdev->hopcount, 1000); 1506 + if (rc) 1507 + return rc; 1508 + } 1509 + 1510 + spin_lock(&rdev->rswitch->lock); 1511 + 1512 + if (ops == NULL || ops->clr_table == NULL) { 1513 + rc = rio_std_route_clr_table(rdev->net->hport, rdev->destid, 1514 + rdev->hopcount, table); 1515 + } else if (try_module_get(ops->owner)) { 1516 + rc = ops->clr_table(rdev->net->hport, rdev->destid, 1517 + rdev->hopcount, table); 1518 + 1519 + module_put(ops->owner); 1520 + } 1521 + 1522 + spin_unlock(&rdev->rswitch->lock); 1523 + 1524 + if (lock) 1525 + rio_unlock_device(rdev->net->hport, rdev->destid, 1526 + rdev->hopcount); 1527 + 1528 + return rc; 1529 + } 1530 + EXPORT_SYMBOL_GPL(rio_route_clr_table); 1267 1531 1268 1532 #ifdef CONFIG_RAPIDIO_DMA_ENGINE 1269 1533
+8 -33
drivers/rapidio/rio.h
··· 28 28 extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, 29 29 u8 hopcount); 30 30 extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); 31 - extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid, 32 - u8 hopcount, u16 table, u16 route_destid, 33 - u8 route_port); 34 - extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid, 35 - u8 hopcount, u16 table, u16 route_destid, 36 - u8 *route_port); 37 - extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, 38 - u8 hopcount, u16 table); 31 + extern int rio_lock_device(struct rio_mport *port, u16 destid, 32 + u8 hopcount, int wait_ms); 33 + extern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount); 34 + extern int rio_route_add_entry(struct rio_dev *rdev, 35 + u16 table, u16 route_destid, u8 route_port, int lock); 36 + extern int rio_route_get_entry(struct rio_dev *rdev, u16 table, 37 + u16 route_destid, u8 *route_port, int lock); 38 + extern int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock); 39 39 extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); 40 40 extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from); 41 41 extern int rio_add_device(struct rio_dev *rdev); 42 - extern void rio_switch_init(struct rio_dev *rdev, int do_enum); 43 42 extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid, 44 43 u8 hopcount, u8 port_num); 45 44 extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops); ··· 49 50 /* Structures internal to the RIO core code */ 50 51 extern struct device_attribute rio_dev_attrs[]; 51 52 extern struct bus_attribute rio_bus_attrs[]; 52 - 53 - extern struct rio_switch_ops __start_rio_switch_ops[]; 54 - extern struct rio_switch_ops __end_rio_switch_ops[]; 55 - 56 - /* Helpers internal to the RIO core code */ 57 - #define DECLARE_RIO_SWITCH_SECTION(section, name, vid, did, init_hook) \ 58 - static const struct rio_switch_ops __rio_switch_##name __used \ 59 - __section(section) = { vid, did, init_hook }; 60 - 61 - /** 62 - * DECLARE_RIO_SWITCH_INIT - Registers switch initialization routine 63 - * @vid: RIO vendor ID 64 - * @did: RIO device ID 65 - * @init_hook: Callback that performs switch-specific initialization 66 - * 67 - * Manipulating switch route tables and error management in RIO 68 - * is switch specific. This registers a switch by vendor and device ID with 69 - * initialization callback for setting up switch operations and (if required) 70 - * hardware initialization. A &struct rio_switch_ops is initialized with 71 - * pointer to the init routine and placed into a RIO-specific kernel section. 72 - */ 73 - #define DECLARE_RIO_SWITCH_INIT(vid, did, init_hook) \ 74 - DECLARE_RIO_SWITCH_SECTION(.rio_switch_ops, vid##did, \ 75 - vid, did, init_hook) 76 53 77 54 #define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16)) 78 55 #define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
+4 -8
drivers/rapidio/switches/Kconfig
··· 2 2 # RapidIO switches configuration 3 3 # 4 4 config RAPIDIO_TSI57X 5 - bool "IDT Tsi57x SRIO switches support" 6 - depends on RAPIDIO 5 + tristate "IDT Tsi57x SRIO switches support" 7 6 ---help--- 8 7 Includes support for IDT Tsi57x family of serial RapidIO switches. 9 8 10 9 config RAPIDIO_CPS_XX 11 - bool "IDT CPS-xx SRIO switches support" 12 - depends on RAPIDIO 10 + tristate "IDT CPS-xx SRIO switches support" 13 11 ---help--- 14 12 Includes support for IDT CPS-16/12/10/8 serial RapidIO switches. 15 13 16 14 config RAPIDIO_TSI568 17 - bool "Tsi568 SRIO switch support" 18 - depends on RAPIDIO 15 + tristate "Tsi568 SRIO switch support" 19 16 default n 20 17 ---help--- 21 18 Includes support for IDT Tsi568 serial RapidIO switch. 22 19 23 20 config RAPIDIO_CPS_GEN2 24 - bool "IDT CPS Gen.2 SRIO switch support" 25 - depends on RAPIDIO 21 + tristate "IDT CPS Gen.2 SRIO switch support" 26 22 default n 27 23 ---help--- 28 24 Includes support for ITD CPS Gen.2 serial RapidIO switches.
+79 -17
drivers/rapidio/switches/idt_gen2.c
··· 11 11 */ 12 12 13 13 #include <linux/stat.h> 14 + #include <linux/module.h> 14 15 #include <linux/rio.h> 15 16 #include <linux/rio_drv.h> 16 17 #include <linux/rio_ids.h> ··· 388 387 389 388 static DEVICE_ATTR(errlog, S_IRUGO, idtg2_show_errlog, NULL); 390 389 391 - static int idtg2_sysfs(struct rio_dev *rdev, int create) 390 + static int idtg2_sysfs(struct rio_dev *rdev, bool create) 392 391 { 393 392 struct device *dev = &rdev->dev; 394 393 int err = 0; 395 394 396 - if (create == RIO_SW_SYSFS_CREATE) { 395 + if (create) { 397 396 /* Initialize sysfs entries */ 398 397 err = device_create_file(dev, &dev_attr_errlog); 399 398 if (err) ··· 404 403 return err; 405 404 } 406 405 407 - static int idtg2_switch_init(struct rio_dev *rdev, int do_enum) 406 + static struct rio_switch_ops idtg2_switch_ops = { 407 + .owner = THIS_MODULE, 408 + .add_entry = idtg2_route_add_entry, 409 + .get_entry = idtg2_route_get_entry, 410 + .clr_table = idtg2_route_clr_table, 411 + .set_domain = idtg2_set_domain, 412 + .get_domain = idtg2_get_domain, 413 + .em_init = idtg2_em_init, 414 + .em_handle = idtg2_em_handler, 415 + }; 416 + 417 + static int idtg2_probe(struct rio_dev *rdev, const struct rio_device_id *id) 408 418 { 409 419 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 410 - rdev->rswitch->add_entry = idtg2_route_add_entry; 411 - rdev->rswitch->get_entry = idtg2_route_get_entry; 412 - rdev->rswitch->clr_table = idtg2_route_clr_table; 413 - rdev->rswitch->set_domain = idtg2_set_domain; 414 - rdev->rswitch->get_domain = idtg2_get_domain; 415 - rdev->rswitch->em_init = idtg2_em_init; 416 - rdev->rswitch->em_handle = idtg2_em_handler; 417 - rdev->rswitch->sw_sysfs = idtg2_sysfs; 418 420 419 - if (do_enum) { 421 + spin_lock(&rdev->rswitch->lock); 422 + 423 + if (rdev->rswitch->ops) { 424 + spin_unlock(&rdev->rswitch->lock); 425 + return -EINVAL; 426 + } 427 + 428 + rdev->rswitch->ops = &idtg2_switch_ops; 429 + 430 + if (rdev->do_enum) { 420 431 /* Ensure that default routing is disabled on startup */ 421 432 rio_write_config_32(rdev, 422 433 RIO_STD_RTE_DEFAULT_PORT, IDT_NO_ROUTE); 423 434 } 424 435 436 + /* Create device-specific sysfs attributes */ 437 + idtg2_sysfs(rdev, true); 438 + 439 + spin_unlock(&rdev->rswitch->lock); 425 440 return 0; 426 441 } 427 442 428 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS1848, idtg2_switch_init); 429 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS1616, idtg2_switch_init); 430 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTVPS1616, idtg2_switch_init); 431 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTSPS1616, idtg2_switch_init); 432 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS1432, idtg2_switch_init); 443 + static void idtg2_remove(struct rio_dev *rdev) 444 + { 445 + pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 446 + spin_lock(&rdev->rswitch->lock); 447 + if (rdev->rswitch->ops != &idtg2_switch_ops) { 448 + spin_unlock(&rdev->rswitch->lock); 449 + return; 450 + } 451 + rdev->rswitch->ops = NULL; 452 + 453 + /* Remove device-specific sysfs attributes */ 454 + idtg2_sysfs(rdev, false); 455 + 456 + spin_unlock(&rdev->rswitch->lock); 457 + } 458 + 459 + static struct rio_device_id idtg2_id_table[] = { 460 + {RIO_DEVICE(RIO_DID_IDTCPS1848, RIO_VID_IDT)}, 461 + {RIO_DEVICE(RIO_DID_IDTCPS1616, RIO_VID_IDT)}, 462 + {RIO_DEVICE(RIO_DID_IDTVPS1616, RIO_VID_IDT)}, 463 + {RIO_DEVICE(RIO_DID_IDTSPS1616, RIO_VID_IDT)}, 464 + {RIO_DEVICE(RIO_DID_IDTCPS1432, RIO_VID_IDT)}, 465 + { 0, } /* terminate list */ 466 + }; 467 + 468 + static struct rio_driver idtg2_driver = { 469 + .name = "idt_gen2", 470 + .id_table = idtg2_id_table, 471 + .probe = idtg2_probe, 472 + .remove = idtg2_remove, 473 + }; 474 + 475 + static int __init idtg2_init(void) 476 + { 477 + return rio_register_driver(&idtg2_driver); 478 + } 479 + 480 + static void __exit idtg2_exit(void) 481 + { 482 + pr_debug("RIO: %s\n", __func__); 483 + rio_unregister_driver(&idtg2_driver); 484 + pr_debug("RIO: %s done\n", __func__); 485 + } 486 + 487 + device_initcall(idtg2_init); 488 + module_exit(idtg2_exit); 489 + 490 + MODULE_DESCRIPTION("IDT CPS Gen.2 Serial RapidIO switch family driver"); 491 + MODULE_AUTHOR("Integrated Device Technology, Inc."); 492 + MODULE_LICENSE("GPL");
+69 -15
drivers/rapidio/switches/idtcps.c
··· 13 13 #include <linux/rio.h> 14 14 #include <linux/rio_drv.h> 15 15 #include <linux/rio_ids.h> 16 + #include <linux/module.h> 16 17 #include "../rio.h" 17 18 18 19 #define CPS_DEFAULT_ROUTE 0xde ··· 119 118 return 0; 120 119 } 121 120 122 - static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) 121 + static struct rio_switch_ops idtcps_switch_ops = { 122 + .owner = THIS_MODULE, 123 + .add_entry = idtcps_route_add_entry, 124 + .get_entry = idtcps_route_get_entry, 125 + .clr_table = idtcps_route_clr_table, 126 + .set_domain = idtcps_set_domain, 127 + .get_domain = idtcps_get_domain, 128 + .em_init = NULL, 129 + .em_handle = NULL, 130 + }; 131 + 132 + static int idtcps_probe(struct rio_dev *rdev, const struct rio_device_id *id) 123 133 { 124 134 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 125 - rdev->rswitch->add_entry = idtcps_route_add_entry; 126 - rdev->rswitch->get_entry = idtcps_route_get_entry; 127 - rdev->rswitch->clr_table = idtcps_route_clr_table; 128 - rdev->rswitch->set_domain = idtcps_set_domain; 129 - rdev->rswitch->get_domain = idtcps_get_domain; 130 - rdev->rswitch->em_init = NULL; 131 - rdev->rswitch->em_handle = NULL; 132 135 133 - if (do_enum) { 136 + spin_lock(&rdev->rswitch->lock); 137 + 138 + if (rdev->rswitch->ops) { 139 + spin_unlock(&rdev->rswitch->lock); 140 + return -EINVAL; 141 + } 142 + 143 + rdev->rswitch->ops = &idtcps_switch_ops; 144 + 145 + if (rdev->do_enum) { 134 146 /* set TVAL = ~50us */ 135 147 rio_write_config_32(rdev, 136 148 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); ··· 152 138 RIO_STD_RTE_DEFAULT_PORT, CPS_NO_ROUTE); 153 139 } 154 140 141 + spin_unlock(&rdev->rswitch->lock); 155 142 return 0; 156 143 } 157 144 158 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS6Q, idtcps_switch_init); 159 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS8, idtcps_switch_init); 160 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS10Q, idtcps_switch_init); 161 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS12, idtcps_switch_init); 162 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS16, idtcps_switch_init); 163 - DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDT70K200, idtcps_switch_init); 145 + static void idtcps_remove(struct rio_dev *rdev) 146 + { 147 + pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 148 + spin_lock(&rdev->rswitch->lock); 149 + if (rdev->rswitch->ops != &idtcps_switch_ops) { 150 + spin_unlock(&rdev->rswitch->lock); 151 + return; 152 + } 153 + rdev->rswitch->ops = NULL; 154 + spin_unlock(&rdev->rswitch->lock); 155 + } 156 + 157 + static struct rio_device_id idtcps_id_table[] = { 158 + {RIO_DEVICE(RIO_DID_IDTCPS6Q, RIO_VID_IDT)}, 159 + {RIO_DEVICE(RIO_DID_IDTCPS8, RIO_VID_IDT)}, 160 + {RIO_DEVICE(RIO_DID_IDTCPS10Q, RIO_VID_IDT)}, 161 + {RIO_DEVICE(RIO_DID_IDTCPS12, RIO_VID_IDT)}, 162 + {RIO_DEVICE(RIO_DID_IDTCPS16, RIO_VID_IDT)}, 163 + {RIO_DEVICE(RIO_DID_IDT70K200, RIO_VID_IDT)}, 164 + { 0, } /* terminate list */ 165 + }; 166 + 167 + static struct rio_driver idtcps_driver = { 168 + .name = "idtcps", 169 + .id_table = idtcps_id_table, 170 + .probe = idtcps_probe, 171 + .remove = idtcps_remove, 172 + }; 173 + 174 + static int __init idtcps_init(void) 175 + { 176 + return rio_register_driver(&idtcps_driver); 177 + } 178 + 179 + static void __exit idtcps_exit(void) 180 + { 181 + rio_unregister_driver(&idtcps_driver); 182 + } 183 + 184 + device_initcall(idtcps_init); 185 + module_exit(idtcps_exit); 186 + 187 + MODULE_DESCRIPTION("IDT CPS Gen.1 Serial RapidIO switch family driver"); 188 + MODULE_AUTHOR("Integrated Device Technology, Inc."); 189 + MODULE_LICENSE("GPL");
+62 -9
drivers/rapidio/switches/tsi568.c
··· 19 19 #include <linux/rio_drv.h> 20 20 #include <linux/rio_ids.h> 21 21 #include <linux/delay.h> 22 + #include <linux/module.h> 22 23 #include "../rio.h" 23 24 24 25 /* Global (broadcast) route registers */ ··· 130 129 return 0; 131 130 } 132 131 133 - static int tsi568_switch_init(struct rio_dev *rdev, int do_enum) 132 + static struct rio_switch_ops tsi568_switch_ops = { 133 + .owner = THIS_MODULE, 134 + .add_entry = tsi568_route_add_entry, 135 + .get_entry = tsi568_route_get_entry, 136 + .clr_table = tsi568_route_clr_table, 137 + .set_domain = NULL, 138 + .get_domain = NULL, 139 + .em_init = tsi568_em_init, 140 + .em_handle = NULL, 141 + }; 142 + 143 + static int tsi568_probe(struct rio_dev *rdev, const struct rio_device_id *id) 134 144 { 135 145 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 136 - rdev->rswitch->add_entry = tsi568_route_add_entry; 137 - rdev->rswitch->get_entry = tsi568_route_get_entry; 138 - rdev->rswitch->clr_table = tsi568_route_clr_table; 139 - rdev->rswitch->set_domain = NULL; 140 - rdev->rswitch->get_domain = NULL; 141 - rdev->rswitch->em_init = tsi568_em_init; 142 - rdev->rswitch->em_handle = NULL; 143 146 147 + spin_lock(&rdev->rswitch->lock); 148 + 149 + if (rdev->rswitch->ops) { 150 + spin_unlock(&rdev->rswitch->lock); 151 + return -EINVAL; 152 + } 153 + 154 + rdev->rswitch->ops = &tsi568_switch_ops; 155 + spin_unlock(&rdev->rswitch->lock); 144 156 return 0; 145 157 } 146 158 147 - DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_switch_init); 159 + static void tsi568_remove(struct rio_dev *rdev) 160 + { 161 + pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 162 + spin_lock(&rdev->rswitch->lock); 163 + if (rdev->rswitch->ops != &tsi568_switch_ops) { 164 + spin_unlock(&rdev->rswitch->lock); 165 + return; 166 + } 167 + rdev->rswitch->ops = NULL; 168 + spin_unlock(&rdev->rswitch->lock); 169 + } 170 + 171 + static struct rio_device_id tsi568_id_table[] = { 172 + {RIO_DEVICE(RIO_DID_TSI568, RIO_VID_TUNDRA)}, 173 + { 0, } /* terminate list */ 174 + }; 175 + 176 + static struct rio_driver tsi568_driver = { 177 + .name = "tsi568", 178 + .id_table = tsi568_id_table, 179 + .probe = tsi568_probe, 180 + .remove = tsi568_remove, 181 + }; 182 + 183 + static int __init tsi568_init(void) 184 + { 185 + return rio_register_driver(&tsi568_driver); 186 + } 187 + 188 + static void __exit tsi568_exit(void) 189 + { 190 + rio_unregister_driver(&tsi568_driver); 191 + } 192 + 193 + device_initcall(tsi568_init); 194 + module_exit(tsi568_exit); 195 + 196 + MODULE_DESCRIPTION("IDT Tsi568 Serial RapidIO switch driver"); 197 + MODULE_AUTHOR("Integrated Device Technology, Inc."); 198 + MODULE_LICENSE("GPL");
+66 -13
drivers/rapidio/switches/tsi57x.c
··· 19 19 #include <linux/rio_drv.h> 20 20 #include <linux/rio_ids.h> 21 21 #include <linux/delay.h> 22 + #include <linux/module.h> 22 23 #include "../rio.h" 23 24 24 25 /* Global (broadcast) route registers */ ··· 293 292 return 0; 294 293 } 295 294 296 - static int tsi57x_switch_init(struct rio_dev *rdev, int do_enum) 295 + static struct rio_switch_ops tsi57x_switch_ops = { 296 + .owner = THIS_MODULE, 297 + .add_entry = tsi57x_route_add_entry, 298 + .get_entry = tsi57x_route_get_entry, 299 + .clr_table = tsi57x_route_clr_table, 300 + .set_domain = tsi57x_set_domain, 301 + .get_domain = tsi57x_get_domain, 302 + .em_init = tsi57x_em_init, 303 + .em_handle = tsi57x_em_handler, 304 + }; 305 + 306 + static int tsi57x_probe(struct rio_dev *rdev, const struct rio_device_id *id) 297 307 { 298 308 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 299 - rdev->rswitch->add_entry = tsi57x_route_add_entry; 300 - rdev->rswitch->get_entry = tsi57x_route_get_entry; 301 - rdev->rswitch->clr_table = tsi57x_route_clr_table; 302 - rdev->rswitch->set_domain = tsi57x_set_domain; 303 - rdev->rswitch->get_domain = tsi57x_get_domain; 304 - rdev->rswitch->em_init = tsi57x_em_init; 305 - rdev->rswitch->em_handle = tsi57x_em_handler; 306 309 307 - if (do_enum) { 310 + spin_lock(&rdev->rswitch->lock); 311 + 312 + if (rdev->rswitch->ops) { 313 + spin_unlock(&rdev->rswitch->lock); 314 + return -EINVAL; 315 + } 316 + rdev->rswitch->ops = &tsi57x_switch_ops; 317 + 318 + if (rdev->do_enum) { 308 319 /* Ensure that default routing is disabled on startup */ 309 320 rio_write_config_32(rdev, RIO_STD_RTE_DEFAULT_PORT, 310 321 RIO_INVALID_ROUTE); 311 322 } 312 323 324 + spin_unlock(&rdev->rswitch->lock); 313 325 return 0; 314 326 } 315 327 316 - DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_switch_init); 317 - DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_switch_init); 318 - DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_switch_init); 319 - DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_switch_init); 328 + static void tsi57x_remove(struct rio_dev *rdev) 329 + { 330 + pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 331 + spin_lock(&rdev->rswitch->lock); 332 + if (rdev->rswitch->ops != &tsi57x_switch_ops) { 333 + spin_unlock(&rdev->rswitch->lock); 334 + return; 335 + } 336 + rdev->rswitch->ops = NULL; 337 + spin_unlock(&rdev->rswitch->lock); 338 + } 339 + 340 + static struct rio_device_id tsi57x_id_table[] = { 341 + {RIO_DEVICE(RIO_DID_TSI572, RIO_VID_TUNDRA)}, 342 + {RIO_DEVICE(RIO_DID_TSI574, RIO_VID_TUNDRA)}, 343 + {RIO_DEVICE(RIO_DID_TSI577, RIO_VID_TUNDRA)}, 344 + {RIO_DEVICE(RIO_DID_TSI578, RIO_VID_TUNDRA)}, 345 + { 0, } /* terminate list */ 346 + }; 347 + 348 + static struct rio_driver tsi57x_driver = { 349 + .name = "tsi57x", 350 + .id_table = tsi57x_id_table, 351 + .probe = tsi57x_probe, 352 + .remove = tsi57x_remove, 353 + }; 354 + 355 + static int __init tsi57x_init(void) 356 + { 357 + return rio_register_driver(&tsi57x_driver); 358 + } 359 + 360 + static void __exit tsi57x_exit(void) 361 + { 362 + rio_unregister_driver(&tsi57x_driver); 363 + } 364 + 365 + device_initcall(tsi57x_init); 366 + module_exit(tsi57x_exit); 367 + 368 + MODULE_DESCRIPTION("IDT Tsi57x Serial RapidIO switch family driver"); 369 + MODULE_AUTHOR("Integrated Device Technology, Inc."); 370 + MODULE_LICENSE("GPL");
-7
include/asm-generic/vmlinux.lds.h
··· 275 275 VMLINUX_SYMBOL(__end_builtin_fw) = .; \ 276 276 } \ 277 277 \ 278 - /* RapidIO route ops */ \ 279 - .rio_ops : AT(ADDR(.rio_ops) - LOAD_OFFSET) { \ 280 - VMLINUX_SYMBOL(__start_rio_switch_ops) = .; \ 281 - *(.rio_switch_ops) \ 282 - VMLINUX_SYMBOL(__end_rio_switch_ops) = .; \ 283 - } \ 284 - \ 285 278 TRACEDATA \ 286 279 \ 287 280 /* Kernel symbol table: Normal symbols */ \
+25 -28
include/linux/rio.h
··· 94 94 * @switchid: Switch ID that is unique across a network 95 95 * @route_table: Copy of switch routing table 96 96 * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0 97 - * @add_entry: Callback for switch-specific route add function 98 - * @get_entry: Callback for switch-specific route get function 99 - * @clr_table: Callback for switch-specific clear route table function 100 - * @set_domain: Callback for switch-specific domain setting function 101 - * @get_domain: Callback for switch-specific domain get function 102 - * @em_init: Callback for switch-specific error management init function 103 - * @em_handle: Callback for switch-specific error management handler function 104 - * @sw_sysfs: Callback that initializes switch-specific sysfs attributes 97 + * @ops: pointer to switch-specific operations 98 + * @lock: lock to serialize operations updates 105 99 * @nextdev: Array of per-port pointers to the next attached device 106 100 */ 107 101 struct rio_switch { ··· 103 109 u16 switchid; 104 110 u8 *route_table; 105 111 u32 port_ok; 112 + struct rio_switch_ops *ops; 113 + spinlock_t lock; 114 + struct rio_dev *nextdev[0]; 115 + }; 116 + 117 + /** 118 + * struct rio_switch_ops - Per-switch operations 119 + * @owner: The module owner of this structure 120 + * @add_entry: Callback for switch-specific route add function 121 + * @get_entry: Callback for switch-specific route get function 122 + * @clr_table: Callback for switch-specific clear route table function 123 + * @set_domain: Callback for switch-specific domain setting function 124 + * @get_domain: Callback for switch-specific domain get function 125 + * @em_init: Callback for switch-specific error management init function 126 + * @em_handle: Callback for switch-specific error management handler function 127 + * 128 + * Defines the operations that are necessary to initialize/control 129 + * a particular RIO switch device. 130 + */ 131 + struct rio_switch_ops { 132 + struct module *owner; 106 133 int (*add_entry) (struct rio_mport *mport, u16 destid, u8 hopcount, 107 134 u16 table, u16 route_destid, u8 route_port); 108 135 int (*get_entry) (struct rio_mport *mport, u16 destid, u8 hopcount, ··· 136 121 u8 *sw_domain); 137 122 int (*em_init) (struct rio_dev *dev); 138 123 int (*em_handle) (struct rio_dev *dev, u8 swport); 139 - int (*sw_sysfs) (struct rio_dev *dev, int create); 140 - struct rio_dev *nextdev[0]; 141 124 }; 142 125 143 126 /** ··· 143 130 * @global_list: Node in list of all RIO devices 144 131 * @net_list: Node in list of RIO devices in a network 145 132 * @net: Network this device is a part of 133 + * @do_enum: Enumeration flag 146 134 * @did: Device ID 147 135 * @vid: Vendor ID 148 136 * @device_rev: Device revision ··· 172 158 struct list_head global_list; /* node in list of all RIO devices */ 173 159 struct list_head net_list; /* node in per net list */ 174 160 struct rio_net *net; /* RIO net this device resides in */ 161 + bool do_enum; 175 162 u16 did; 176 163 u16 vid; 177 164 u32 device_rev; ··· 312 297 struct rio_id_table destid_table; /* destID allocation table */ 313 298 }; 314 299 315 - /* Definitions used by switch sysfs initialization callback */ 316 - #define RIO_SW_SYSFS_CREATE 1 /* Create switch attributes */ 317 - #define RIO_SW_SYSFS_REMOVE 0 /* Remove switch attributes */ 318 - 319 300 /* Low-level architecture-dependent routines */ 320 301 321 302 /** ··· 409 398 struct rio_device_id { 410 399 u16 did, vid; 411 400 u16 asm_did, asm_vid; 412 - }; 413 - 414 - /** 415 - * struct rio_switch_ops - Per-switch operations 416 - * @vid: RIO vendor ID 417 - * @did: RIO device ID 418 - * @init_hook: Callback that performs switch device initialization 419 - * 420 - * Defines the operations that are necessary to initialize/control 421 - * a particular RIO switch device. 422 - */ 423 - struct rio_switch_ops { 424 - u16 vid, did; 425 - int (*init_hook) (struct rio_dev *rdev, int do_enum); 426 401 }; 427 402 428 403 union rio_pw_msg {