Commit 5dc2536bb8d8adb5fdfbe76cd6fdcdf9de3f40f8
1 parent
05bb5e93f2
Exists in
master
and in
39 other branches
qlogicpti: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 56 additions and 54 deletions Side-by-side Diff
drivers/scsi/qlogicpti.c
1 | 1 | /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. |
2 | 2 | * |
3 | - * Copyright (C) 1996, 2006 David S. Miller (davem@davemloft.net) | |
3 | + * Copyright (C) 1996, 2006, 2008 David S. Miller (davem@davemloft.net) | |
4 | 4 | * |
5 | 5 | * A lot of this driver was directly stolen from Erik H. Moe's PCI |
6 | 6 | * Qlogic ISP driver. Mucho kudos to him for this code. |
7 | 7 | |
... | ... | @@ -26,12 +26,13 @@ |
26 | 26 | #include <linux/module.h> |
27 | 27 | #include <linux/jiffies.h> |
28 | 28 | #include <linux/dma-mapping.h> |
29 | +#include <linux/of.h> | |
30 | +#include <linux/of_device.h> | |
29 | 31 | |
30 | 32 | #include <asm/byteorder.h> |
31 | 33 | |
32 | 34 | #include "qlogicpti.h" |
33 | 35 | |
34 | -#include <asm/sbus.h> | |
35 | 36 | #include <asm/dma.h> |
36 | 37 | #include <asm/system.h> |
37 | 38 | #include <asm/ptrace.h> |
38 | 39 | |
39 | 40 | |
... | ... | @@ -685,19 +686,19 @@ |
685 | 686 | |
686 | 687 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) |
687 | 688 | { |
688 | - struct sbus_dev *sdev = qpti->sdev; | |
689 | + struct of_device *op = qpti->op; | |
689 | 690 | |
690 | - qpti->qregs = sbus_ioremap(&sdev->resource[0], 0, | |
691 | - sdev->reg_addrs[0].reg_size, | |
692 | - "PTI Qlogic/ISP"); | |
691 | + qpti->qregs = of_ioremap(&op->resource[0], 0, | |
692 | + resource_size(&op->resource[0]), | |
693 | + "PTI Qlogic/ISP"); | |
693 | 694 | if (!qpti->qregs) { |
694 | 695 | printk("PTI: Qlogic/ISP registers are unmappable\n"); |
695 | 696 | return -1; |
696 | 697 | } |
697 | 698 | if (qpti->is_pti) { |
698 | - qpti->sreg = sbus_ioremap(&sdev->resource[0], (16 * 4096), | |
699 | - sizeof(unsigned char), | |
700 | - "PTI Qlogic/ISP statreg"); | |
699 | + qpti->sreg = of_ioremap(&op->resource[0], (16 * 4096), | |
700 | + sizeof(unsigned char), | |
701 | + "PTI Qlogic/ISP statreg"); | |
701 | 702 | if (!qpti->sreg) { |
702 | 703 | printk("PTI: Qlogic/ISP status register is unmappable\n"); |
703 | 704 | return -1; |
704 | 705 | |
... | ... | @@ -708,9 +709,9 @@ |
708 | 709 | |
709 | 710 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) |
710 | 711 | { |
711 | - struct sbus_dev *sdev = qpti->sdev; | |
712 | + struct of_device *op = qpti->op; | |
712 | 713 | |
713 | - qpti->qhost->irq = qpti->irq = sdev->irqs[0]; | |
714 | + qpti->qhost->irq = qpti->irq = op->irqs[0]; | |
714 | 715 | |
715 | 716 | /* We used to try various overly-clever things to |
716 | 717 | * reduce the interrupt processing overhead on |
717 | 718 | |
718 | 719 | |
... | ... | @@ -733,17 +734,19 @@ |
733 | 734 | |
734 | 735 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) |
735 | 736 | { |
736 | - qpti->scsi_id = prom_getintdefault(qpti->prom_node, | |
737 | - "initiator-id", | |
738 | - -1); | |
737 | + struct of_device *op = qpti->op; | |
738 | + struct device_node *dp; | |
739 | + | |
740 | + dp = op->node; | |
741 | + | |
742 | + qpti->scsi_id = of_getintprop_default(dp, "initiator-id", -1); | |
739 | 743 | if (qpti->scsi_id == -1) |
740 | - qpti->scsi_id = prom_getintdefault(qpti->prom_node, | |
741 | - "scsi-initiator-id", | |
742 | - -1); | |
744 | + qpti->scsi_id = of_getintprop_default(dp, "scsi-initiator-id", | |
745 | + -1); | |
743 | 746 | if (qpti->scsi_id == -1) |
744 | 747 | qpti->scsi_id = |
745 | - prom_getintdefault(qpti->sdev->bus->prom_node, | |
746 | - "scsi-initiator-id", 7); | |
748 | + of_getintprop_default(dp->parent, | |
749 | + "scsi-initiator-id", 7); | |
747 | 750 | qpti->qhost->this_id = qpti->scsi_id; |
748 | 751 | qpti->qhost->max_sectors = 64; |
749 | 752 | |
750 | 753 | |
... | ... | @@ -752,12 +755,11 @@ |
752 | 755 | |
753 | 756 | static void qpti_get_bursts(struct qlogicpti *qpti) |
754 | 757 | { |
755 | - struct sbus_dev *sdev = qpti->sdev; | |
758 | + struct of_device *op = qpti->op; | |
756 | 759 | u8 bursts, bmask; |
757 | 760 | |
758 | - bursts = prom_getintdefault(qpti->prom_node, "burst-sizes", 0xff); | |
759 | - bmask = prom_getintdefault(sdev->bus->prom_node, | |
760 | - "burst-sizes", 0xff); | |
761 | + bursts = of_getintprop_default(op->node, "burst-sizes", 0xff); | |
762 | + bmask = of_getintprop_default(op->node->parent, "burst-sizes", 0xff); | |
761 | 763 | if (bmask != 0xff) |
762 | 764 | bursts &= bmask; |
763 | 765 | if (bursts == 0xff || |
764 | 766 | |
... | ... | @@ -786,10 +788,10 @@ |
786 | 788 | */ |
787 | 789 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) |
788 | 790 | { |
789 | - struct sbus_dev *sdev = qpti->sdev; | |
791 | + struct of_device *op = qpti->op; | |
790 | 792 | |
791 | 793 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
792 | - qpti->res_cpu = dma_alloc_coherent(&sdev->ofdev.dev, | |
794 | + qpti->res_cpu = dma_alloc_coherent(&op->dev, | |
793 | 795 | QSIZE(RES_QUEUE_LEN), |
794 | 796 | &qpti->res_dvma, GFP_ATOMIC); |
795 | 797 | if (qpti->res_cpu == NULL || |
796 | 798 | |
... | ... | @@ -798,12 +800,12 @@ |
798 | 800 | return -1; |
799 | 801 | } |
800 | 802 | |
801 | - qpti->req_cpu = dma_alloc_coherent(&sdev->ofdev.dev, | |
803 | + qpti->req_cpu = dma_alloc_coherent(&op->dev, | |
802 | 804 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
803 | 805 | &qpti->req_dvma, GFP_ATOMIC); |
804 | 806 | if (qpti->req_cpu == NULL || |
805 | 807 | qpti->req_dvma == 0) { |
806 | - dma_free_coherent(&sdev->ofdev.dev, QSIZE(RES_QUEUE_LEN), | |
808 | + dma_free_coherent(&op->dev, QSIZE(RES_QUEUE_LEN), | |
807 | 809 | qpti->res_cpu, qpti->res_dvma); |
808 | 810 | printk("QPTI: Cannot map request queue.\n"); |
809 | 811 | return -1; |
... | ... | @@ -876,7 +878,7 @@ |
876 | 878 | int sg_count; |
877 | 879 | |
878 | 880 | sg = scsi_sglist(Cmnd); |
879 | - sg_count = dma_map_sg(&qpti->sdev->ofdev.dev, sg, | |
881 | + sg_count = dma_map_sg(&qpti->op->dev, sg, | |
880 | 882 | scsi_sg_count(Cmnd), |
881 | 883 | Cmnd->sc_data_direction); |
882 | 884 | |
... | ... | @@ -1153,7 +1155,7 @@ |
1153 | 1155 | Cmnd->result = DID_ERROR << 16; |
1154 | 1156 | |
1155 | 1157 | if (scsi_bufflen(Cmnd)) |
1156 | - dma_unmap_sg(&qpti->sdev->ofdev.dev, | |
1158 | + dma_unmap_sg(&qpti->op->dev, | |
1157 | 1159 | scsi_sglist(Cmnd), scsi_sg_count(Cmnd), |
1158 | 1160 | Cmnd->sc_data_direction); |
1159 | 1161 | |
1160 | 1162 | |
1161 | 1163 | |
1162 | 1164 | |
1163 | 1165 | |
1164 | 1166 | |
1165 | 1167 | |
1166 | 1168 | |
... | ... | @@ -1269,34 +1271,32 @@ |
1269 | 1271 | .use_clustering = ENABLE_CLUSTERING, |
1270 | 1272 | }; |
1271 | 1273 | |
1272 | -static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match) | |
1274 | +static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match) | |
1273 | 1275 | { |
1274 | - static int nqptis; | |
1275 | - struct sbus_dev *sdev = to_sbus_device(&dev->dev); | |
1276 | - struct device_node *dp = dev->node; | |
1277 | 1276 | struct scsi_host_template *tpnt = match->data; |
1277 | + struct device_node *dp = op->node; | |
1278 | 1278 | struct Scsi_Host *host; |
1279 | 1279 | struct qlogicpti *qpti; |
1280 | + static int nqptis; | |
1280 | 1281 | const char *fcode; |
1281 | 1282 | |
1282 | 1283 | /* Sometimes Antares cards come up not completely |
1283 | 1284 | * setup, and we get a report of a zero IRQ. |
1284 | 1285 | */ |
1285 | - if (sdev->irqs[0] == 0) | |
1286 | + if (op->irqs[0] == 0) | |
1286 | 1287 | return -ENODEV; |
1287 | 1288 | |
1288 | 1289 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); |
1289 | 1290 | if (!host) |
1290 | 1291 | return -ENOMEM; |
1291 | 1292 | |
1292 | - qpti = (struct qlogicpti *) host->hostdata; | |
1293 | + qpti = shost_priv(host); | |
1293 | 1294 | |
1294 | 1295 | host->max_id = MAX_TARGETS; |
1295 | 1296 | qpti->qhost = host; |
1296 | - qpti->sdev = sdev; | |
1297 | + qpti->op = op; | |
1297 | 1298 | qpti->qpti_id = nqptis; |
1298 | - qpti->prom_node = sdev->prom_node; | |
1299 | - strcpy(qpti->prom_name, sdev->ofdev.node->name); | |
1299 | + strcpy(qpti->prom_name, op->node->name); | |
1300 | 1300 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); |
1301 | 1301 | |
1302 | 1302 | if (qpti_map_regs(qpti) < 0) |
1303 | 1303 | |
... | ... | @@ -1342,12 +1342,12 @@ |
1342 | 1342 | (qpti->ultra ? "Ultra" : "Fast"), |
1343 | 1343 | (qpti->differential ? "differential" : "single ended")); |
1344 | 1344 | |
1345 | - if (scsi_add_host(host, &dev->dev)) { | |
1345 | + if (scsi_add_host(host, &op->dev)) { | |
1346 | 1346 | printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); |
1347 | 1347 | goto fail_unmap_queues; |
1348 | 1348 | } |
1349 | 1349 | |
1350 | - dev_set_drvdata(&sdev->ofdev.dev, qpti); | |
1350 | + dev_set_drvdata(&op->dev, qpti); | |
1351 | 1351 | |
1352 | 1352 | qpti_chain_add(qpti); |
1353 | 1353 | |
1354 | 1354 | |
1355 | 1355 | |
1356 | 1356 | |
... | ... | @@ -1358,19 +1358,20 @@ |
1358 | 1358 | |
1359 | 1359 | fail_unmap_queues: |
1360 | 1360 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1361 | - dma_free_coherent(&qpti->sdev->ofdev.dev, | |
1361 | + dma_free_coherent(&op->dev, | |
1362 | 1362 | QSIZE(RES_QUEUE_LEN), |
1363 | 1363 | qpti->res_cpu, qpti->res_dvma); |
1364 | - dma_free_coherent(&qpti->sdev->ofdev.dev, | |
1364 | + dma_free_coherent(&op->dev, | |
1365 | 1365 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1366 | 1366 | qpti->req_cpu, qpti->req_dvma); |
1367 | 1367 | #undef QSIZE |
1368 | 1368 | |
1369 | 1369 | fail_unmap_regs: |
1370 | - sbus_iounmap(qpti->qregs, | |
1371 | - qpti->sdev->reg_addrs[0].reg_size); | |
1370 | + of_iounmap(&op->resource[0], qpti->qregs, | |
1371 | + resource_size(&op->resource[0])); | |
1372 | 1372 | if (qpti->is_pti) |
1373 | - sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | |
1373 | + of_iounmap(&op->resource[0], qpti->sreg, | |
1374 | + sizeof(unsigned char)); | |
1374 | 1375 | |
1375 | 1376 | fail_free_irq: |
1376 | 1377 | free_irq(qpti->irq, qpti); |
1377 | 1378 | |
... | ... | @@ -1381,9 +1382,9 @@ |
1381 | 1382 | return -ENODEV; |
1382 | 1383 | } |
1383 | 1384 | |
1384 | -static int __devexit qpti_sbus_remove(struct of_device *dev) | |
1385 | +static int __devexit qpti_sbus_remove(struct of_device *op) | |
1385 | 1386 | { |
1386 | - struct qlogicpti *qpti = dev_get_drvdata(&dev->dev); | |
1387 | + struct qlogicpti *qpti = dev_get_drvdata(&op->dev); | |
1387 | 1388 | |
1388 | 1389 | qpti_chain_del(qpti); |
1389 | 1390 | |
1390 | 1391 | |
1391 | 1392 | |
1392 | 1393 | |
... | ... | @@ -1396,17 +1397,18 @@ |
1396 | 1397 | free_irq(qpti->irq, qpti); |
1397 | 1398 | |
1398 | 1399 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1399 | - dma_free_coherent(&qpti->sdev->ofdev.dev, | |
1400 | + dma_free_coherent(&op->dev, | |
1400 | 1401 | QSIZE(RES_QUEUE_LEN), |
1401 | 1402 | qpti->res_cpu, qpti->res_dvma); |
1402 | - dma_free_coherent(&qpti->sdev->ofdev.dev, | |
1403 | + dma_free_coherent(&op->dev, | |
1403 | 1404 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1404 | 1405 | qpti->req_cpu, qpti->req_dvma); |
1405 | 1406 | #undef QSIZE |
1406 | 1407 | |
1407 | - sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); | |
1408 | + of_iounmap(&op->resource[0], qpti->qregs, | |
1409 | + resource_size(&op->resource[0])); | |
1408 | 1410 | if (qpti->is_pti) |
1409 | - sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | |
1411 | + of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char)); | |
1410 | 1412 | |
1411 | 1413 | scsi_host_put(qpti->qhost); |
1412 | 1414 | |
... | ... | @@ -1443,7 +1445,7 @@ |
1443 | 1445 | |
1444 | 1446 | static int __init qpti_init(void) |
1445 | 1447 | { |
1446 | - return of_register_driver(&qpti_sbus_driver, &sbus_bus_type); | |
1448 | + return of_register_driver(&qpti_sbus_driver, &of_bus_type); | |
1447 | 1449 | } |
1448 | 1450 | |
1449 | 1451 | static void __exit qpti_exit(void) |
... | ... | @@ -1454,7 +1456,7 @@ |
1454 | 1456 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); |
1455 | 1457 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); |
1456 | 1458 | MODULE_LICENSE("GPL"); |
1457 | -MODULE_VERSION("2.0"); | |
1459 | +MODULE_VERSION("2.1"); | |
1458 | 1460 | |
1459 | 1461 | module_init(qpti_init); |
1460 | 1462 | module_exit(qpti_exit); |
drivers/scsi/qlogicpti.h
... | ... | @@ -342,7 +342,7 @@ |
342 | 342 | u_int req_in_ptr; /* index of next request slot */ |
343 | 343 | u_int res_out_ptr; /* index of next result slot */ |
344 | 344 | long send_marker; /* must we send a marker? */ |
345 | - struct sbus_dev *sdev; | |
345 | + struct of_device *op; | |
346 | 346 | unsigned long __pad; |
347 | 347 | |
348 | 348 | int cmd_count[MAX_TARGETS]; |