hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/atm/fore200e.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 A FORE Systems 200E-series driver for ATM on Linux.
34 Christophe Lizzi (lizzi@cnam.fr), October 1999-March 2003.
....@@ -7,19 +8,6 @@
78 This driver simultaneously supports PCA-200E and SBA-200E adapters
89 on i386, alpha (untested), powerpc, sparc and sparc64 architectures.
910
10
- This program is free software; you can redistribute it and/or modify
11
- it under the terms of the GNU General Public License as published by
12
- the Free Software Foundation; either version 2 of the License, or
13
- (at your option) any later version.
14
-
15
- This program is distributed in the hope that it will be useful,
16
- but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- GNU General Public License for more details.
19
-
20
- You should have received a copy of the GNU General Public License
21
- along with this program; if not, write to the Free Software
22
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2311 */
2412
2513
....@@ -37,6 +25,7 @@
3725 #include <linux/dma-mapping.h>
3826 #include <linux/delay.h>
3927 #include <linux/firmware.h>
28
+#include <linux/pgtable.h>
4029 #include <asm/io.h>
4130 #include <asm/string.h>
4231 #include <asm/page.h>
....@@ -52,7 +41,6 @@
5241 #include <asm/idprom.h>
5342 #include <asm/openprom.h>
5443 #include <asm/oplib.h>
55
-#include <asm/pgtable.h>
5644 #endif
5745
5846 #if defined(CONFIG_ATM_FORE200E_USE_TASKLET) /* defer interrupt work to a tasklet */
....@@ -106,7 +94,6 @@
10694
10795
10896 static const struct atmdev_ops fore200e_ops;
109
-static const struct fore200e_bus fore200e_bus[];
11097
11198 static LIST_HEAD(fore200e_boards);
11299
....@@ -183,10 +170,9 @@
183170 alignment = 0;
184171
185172 chunk->alloc_size = size + alignment;
186
- chunk->align_size = size;
187173 chunk->direction = direction;
188174
189
- chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA);
175
+ chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL);
190176 if (chunk->alloc_addr == NULL)
191177 return -ENOMEM;
192178
....@@ -195,8 +181,12 @@
195181
196182 chunk->align_addr = chunk->alloc_addr + offset;
197183
198
- chunk->dma_addr = fore200e->bus->dma_map(fore200e, chunk->align_addr, chunk->align_size, direction);
199
-
184
+ chunk->dma_addr = dma_map_single(fore200e->dev, chunk->align_addr,
185
+ size, direction);
186
+ if (dma_mapping_error(fore200e->dev, chunk->dma_addr)) {
187
+ kfree(chunk->alloc_addr);
188
+ return -ENOMEM;
189
+ }
200190 return 0;
201191 }
202192
....@@ -206,11 +196,39 @@
206196 static void
207197 fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
208198 {
209
- fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction);
210
-
199
+ dma_unmap_single(fore200e->dev, chunk->dma_addr, chunk->dma_size,
200
+ chunk->direction);
211201 kfree(chunk->alloc_addr);
212202 }
213203
204
+/*
205
+ * Allocate a DMA consistent chunk of memory intended to act as a communication
206
+ * mechanism (to hold descriptors, status, queues, etc.) shared by the driver
207
+ * and the adapter.
208
+ */
209
+static int
210
+fore200e_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk,
211
+ int size, int nbr, int alignment)
212
+{
213
+ /* returned chunks are page-aligned */
214
+ chunk->alloc_size = size * nbr;
215
+ chunk->alloc_addr = dma_alloc_coherent(fore200e->dev, chunk->alloc_size,
216
+ &chunk->dma_addr, GFP_KERNEL);
217
+ if (!chunk->alloc_addr)
218
+ return -ENOMEM;
219
+ chunk->align_addr = chunk->alloc_addr;
220
+ return 0;
221
+}
222
+
223
+/*
224
+ * Free a DMA consistent chunk of memory.
225
+ */
226
+static void
227
+fore200e_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
228
+{
229
+ dma_free_coherent(fore200e->dev, chunk->alloc_size, chunk->alloc_addr,
230
+ chunk->dma_addr);
231
+}
214232
215233 static void
216234 fore200e_spin(int msecs)
....@@ -303,10 +321,10 @@
303321 struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block;
304322
305323 if (status->alloc_addr)
306
- fore200e->bus->dma_chunk_free(fore200e, status);
324
+ fore200e_dma_chunk_free(fore200e, status);
307325
308326 if (rbd_block->alloc_addr)
309
- fore200e->bus->dma_chunk_free(fore200e, rbd_block);
327
+ fore200e_dma_chunk_free(fore200e, rbd_block);
310328 }
311329 }
312330 }
....@@ -358,33 +376,33 @@
358376 case FORE200E_STATE_COMPLETE:
359377 kfree(fore200e->stats);
360378
361
- /* fall through */
379
+ fallthrough;
362380 case FORE200E_STATE_IRQ:
363381 free_irq(fore200e->irq, fore200e->atm_dev);
364382
365
- /* fall through */
383
+ fallthrough;
366384 case FORE200E_STATE_ALLOC_BUF:
367385 fore200e_free_rx_buf(fore200e);
368386
369
- /* fall through */
387
+ fallthrough;
370388 case FORE200E_STATE_INIT_BSQ:
371389 fore200e_uninit_bs_queue(fore200e);
372390
373
- /* fall through */
391
+ fallthrough;
374392 case FORE200E_STATE_INIT_RXQ:
375
- fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.status);
376
- fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.rpd);
393
+ fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.status);
394
+ fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.rpd);
377395
378
- /* fall through */
396
+ fallthrough;
379397 case FORE200E_STATE_INIT_TXQ:
380
- fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.status);
381
- fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.tpd);
398
+ fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.status);
399
+ fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.tpd);
382400
383
- /* fall through */
401
+ fallthrough;
384402 case FORE200E_STATE_INIT_CMDQ:
385
- fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_cmdq.status);
403
+ fore200e_dma_chunk_free(fore200e, &fore200e->host_cmdq.status);
386404
387
- /* fall through */
405
+ fallthrough;
388406 case FORE200E_STATE_INITIALIZE:
389407 /* nothing to do for that state */
390408
....@@ -397,7 +415,7 @@
397415 case FORE200E_STATE_MAP:
398416 fore200e->bus->unmap(fore200e);
399417
400
- /* fall through */
418
+ fallthrough;
401419 case FORE200E_STATE_CONFIGURE:
402420 /* nothing to do for that state */
403421
....@@ -428,81 +446,6 @@
428446 the endianess of slave RAM accesses */
429447 writel(cpu_to_le32(val), addr);
430448 }
431
-
432
-
433
-static u32
434
-fore200e_pca_dma_map(struct fore200e* fore200e, void* virt_addr, int size, int direction)
435
-{
436
- u32 dma_addr = dma_map_single(&((struct pci_dev *) fore200e->bus_dev)->dev, virt_addr, size, direction);
437
-
438
- DPRINTK(3, "PCI DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d, --> dma_addr = 0x%08x\n",
439
- virt_addr, size, direction, dma_addr);
440
-
441
- return dma_addr;
442
-}
443
-
444
-
445
-static void
446
-fore200e_pca_dma_unmap(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
447
-{
448
- DPRINTK(3, "PCI DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d\n",
449
- dma_addr, size, direction);
450
-
451
- dma_unmap_single(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction);
452
-}
453
-
454
-
455
-static void
456
-fore200e_pca_dma_sync_for_cpu(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
457
-{
458
- DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction);
459
-
460
- dma_sync_single_for_cpu(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction);
461
-}
462
-
463
-static void
464
-fore200e_pca_dma_sync_for_device(struct fore200e* fore200e, u32 dma_addr, int size, int direction)
465
-{
466
- DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction);
467
-
468
- dma_sync_single_for_device(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction);
469
-}
470
-
471
-
472
-/* allocate a DMA consistent chunk of memory intended to act as a communication mechanism
473
- (to hold descriptors, status, queues, etc.) shared by the driver and the adapter */
474
-
475
-static int
476
-fore200e_pca_dma_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk,
477
- int size, int nbr, int alignment)
478
-{
479
- /* returned chunks are page-aligned */
480
- chunk->alloc_size = size * nbr;
481
- chunk->alloc_addr = dma_alloc_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev,
482
- chunk->alloc_size,
483
- &chunk->dma_addr,
484
- GFP_KERNEL);
485
-
486
- if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0))
487
- return -ENOMEM;
488
-
489
- chunk->align_addr = chunk->alloc_addr;
490
-
491
- return 0;
492
-}
493
-
494
-
495
-/* free a DMA consistent chunk of memory */
496
-
497
-static void
498
-fore200e_pca_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk)
499
-{
500
- dma_free_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev,
501
- chunk->alloc_size,
502
- chunk->alloc_addr,
503
- chunk->dma_addr);
504
-}
505
-
506449
507450 static int
508451 fore200e_pca_irq_check(struct fore200e* fore200e)
....@@ -571,7 +514,7 @@
571514
572515 static int fore200e_pca_configure(struct fore200e *fore200e)
573516 {
574
- struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev;
517
+ struct pci_dev *pci_dev = to_pci_dev(fore200e->dev);
575518 u8 master_ctrl, latency;
576519
577520 DPRINTK(2, "device %s being configured\n", fore200e->name);
....@@ -623,7 +566,10 @@
623566 opcode.opcode = OPCODE_GET_PROM;
624567 opcode.pad = 0;
625568
626
- prom_dma = fore200e->bus->dma_map(fore200e, prom, sizeof(struct prom_data), DMA_FROM_DEVICE);
569
+ prom_dma = dma_map_single(fore200e->dev, prom, sizeof(struct prom_data),
570
+ DMA_FROM_DEVICE);
571
+ if (dma_mapping_error(fore200e->dev, prom_dma))
572
+ return -ENOMEM;
627573
628574 fore200e->bus->write(prom_dma, &entry->cp_entry->cmd.prom_block.prom_haddr);
629575
....@@ -635,7 +581,7 @@
635581
636582 *entry->status = STATUS_FREE;
637583
638
- fore200e->bus->dma_unmap(fore200e, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE);
584
+ dma_unmap_single(fore200e->dev, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE);
639585
640586 if (ok == 0) {
641587 printk(FORE200E "unable to get PROM data from device %s\n", fore200e->name);
....@@ -658,14 +604,30 @@
658604 static int
659605 fore200e_pca_proc_read(struct fore200e* fore200e, char *page)
660606 {
661
- struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev;
607
+ struct pci_dev *pci_dev = to_pci_dev(fore200e->dev);
662608
663609 return sprintf(page, " PCI bus/slot/function:\t%d/%d/%d\n",
664610 pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
665611 }
666612
613
+static const struct fore200e_bus fore200e_pci_ops = {
614
+ .model_name = "PCA-200E",
615
+ .proc_name = "pca200e",
616
+ .descr_alignment = 32,
617
+ .buffer_alignment = 4,
618
+ .status_alignment = 32,
619
+ .read = fore200e_pca_read,
620
+ .write = fore200e_pca_write,
621
+ .configure = fore200e_pca_configure,
622
+ .map = fore200e_pca_map,
623
+ .reset = fore200e_pca_reset,
624
+ .prom_read = fore200e_pca_prom_read,
625
+ .unmap = fore200e_pca_unmap,
626
+ .irq_check = fore200e_pca_irq_check,
627
+ .irq_ack = fore200e_pca_irq_ack,
628
+ .proc_read = fore200e_pca_proc_read,
629
+};
667630 #endif /* CONFIG_PCI */
668
-
669631
670632 #ifdef CONFIG_SBUS
671633
....@@ -677,78 +639,6 @@
677639 static void fore200e_sba_write(u32 val, volatile u32 __iomem *addr)
678640 {
679641 sbus_writel(val, addr);
680
-}
681
-
682
-static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int size, int direction)
683
-{
684
- struct platform_device *op = fore200e->bus_dev;
685
- u32 dma_addr;
686
-
687
- dma_addr = dma_map_single(&op->dev, virt_addr, size, direction);
688
-
689
- DPRINTK(3, "SBUS DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d --> dma_addr = 0x%08x\n",
690
- virt_addr, size, direction, dma_addr);
691
-
692
- return dma_addr;
693
-}
694
-
695
-static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
696
-{
697
- struct platform_device *op = fore200e->bus_dev;
698
-
699
- DPRINTK(3, "SBUS DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d,\n",
700
- dma_addr, size, direction);
701
-
702
- dma_unmap_single(&op->dev, dma_addr, size, direction);
703
-}
704
-
705
-static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
706
-{
707
- struct platform_device *op = fore200e->bus_dev;
708
-
709
- DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction);
710
-
711
- dma_sync_single_for_cpu(&op->dev, dma_addr, size, direction);
712
-}
713
-
714
-static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_addr, int size, int direction)
715
-{
716
- struct platform_device *op = fore200e->bus_dev;
717
-
718
- DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction);
719
-
720
- dma_sync_single_for_device(&op->dev, dma_addr, size, direction);
721
-}
722
-
723
-/* Allocate a DVMA consistent chunk of memory intended to act as a communication mechanism
724
- * (to hold descriptors, status, queues, etc.) shared by the driver and the adapter.
725
- */
726
-static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk,
727
- int size, int nbr, int alignment)
728
-{
729
- struct platform_device *op = fore200e->bus_dev;
730
-
731
- chunk->alloc_size = chunk->align_size = size * nbr;
732
-
733
- /* returned chunks are page-aligned */
734
- chunk->alloc_addr = dma_alloc_coherent(&op->dev, chunk->alloc_size,
735
- &chunk->dma_addr, GFP_ATOMIC);
736
-
737
- if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0))
738
- return -ENOMEM;
739
-
740
- chunk->align_addr = chunk->alloc_addr;
741
-
742
- return 0;
743
-}
744
-
745
-/* free a DVMA consistent chunk of memory */
746
-static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk)
747
-{
748
- struct platform_device *op = fore200e->bus_dev;
749
-
750
- dma_free_coherent(&op->dev, chunk->alloc_size,
751
- chunk->alloc_addr, chunk->dma_addr);
752642 }
753643
754644 static void fore200e_sba_irq_enable(struct fore200e *fore200e)
....@@ -777,7 +667,7 @@
777667
778668 static int __init fore200e_sba_map(struct fore200e *fore200e)
779669 {
780
- struct platform_device *op = fore200e->bus_dev;
670
+ struct platform_device *op = to_platform_device(fore200e->dev);
781671 unsigned int bursts;
782672
783673 /* gain access to the SBA specific registers */
....@@ -807,7 +697,7 @@
807697
808698 static void fore200e_sba_unmap(struct fore200e *fore200e)
809699 {
810
- struct platform_device *op = fore200e->bus_dev;
700
+ struct platform_device *op = to_platform_device(fore200e->dev);
811701
812702 of_iounmap(&op->resource[0], fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH);
813703 of_iounmap(&op->resource[1], fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH);
....@@ -823,7 +713,7 @@
823713
824714 static int __init fore200e_sba_prom_read(struct fore200e *fore200e, struct prom_data *prom)
825715 {
826
- struct platform_device *op = fore200e->bus_dev;
716
+ struct platform_device *op = to_platform_device(fore200e->dev);
827717 const u8 *prop;
828718 int len;
829719
....@@ -847,16 +737,34 @@
847737
848738 static int fore200e_sba_proc_read(struct fore200e *fore200e, char *page)
849739 {
850
- struct platform_device *op = fore200e->bus_dev;
740
+ struct platform_device *op = to_platform_device(fore200e->dev);
851741 const struct linux_prom_registers *regs;
852742
853743 regs = of_get_property(op->dev.of_node, "reg", NULL);
854744
855
- return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n",
856
- (regs ? regs->which_io : 0), op->dev.of_node->name);
745
+ return sprintf(page, " SBUS slot/device:\t\t%d/'%pOFn'\n",
746
+ (regs ? regs->which_io : 0), op->dev.of_node);
857747 }
858
-#endif /* CONFIG_SBUS */
859748
749
+static const struct fore200e_bus fore200e_sbus_ops = {
750
+ .model_name = "SBA-200E",
751
+ .proc_name = "sba200e",
752
+ .descr_alignment = 32,
753
+ .buffer_alignment = 64,
754
+ .status_alignment = 32,
755
+ .read = fore200e_sba_read,
756
+ .write = fore200e_sba_write,
757
+ .configure = fore200e_sba_configure,
758
+ .map = fore200e_sba_map,
759
+ .reset = fore200e_sba_reset,
760
+ .prom_read = fore200e_sba_prom_read,
761
+ .unmap = fore200e_sba_unmap,
762
+ .irq_enable = fore200e_sba_irq_enable,
763
+ .irq_check = fore200e_sba_irq_check,
764
+ .irq_ack = fore200e_sba_irq_ack,
765
+ .proc_read = fore200e_sba_proc_read,
766
+};
767
+#endif /* CONFIG_SBUS */
860768
861769 static void
862770 fore200e_tx_irq(struct fore200e* fore200e)
....@@ -884,7 +792,7 @@
884792 kfree(entry->data);
885793
886794 /* remove DMA mapping */
887
- fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length,
795
+ dma_unmap_single(fore200e->dev, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length,
888796 DMA_TO_DEVICE);
889797
890798 vc_map = entry->vc_map;
....@@ -1105,12 +1013,14 @@
11051013 buffer = FORE200E_HDL2BUF(rpd->rsd[ i ].handle);
11061014
11071015 /* Make device DMA transfer visible to CPU. */
1108
- fore200e->bus->dma_sync_for_cpu(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
1016
+ dma_sync_single_for_cpu(fore200e->dev, buffer->data.dma_addr,
1017
+ rpd->rsd[i].length, DMA_FROM_DEVICE);
11091018
11101019 skb_put_data(skb, buffer->data.align_addr, rpd->rsd[i].length);
11111020
11121021 /* Now let the device get at it again. */
1113
- fore200e->bus->dma_sync_for_device(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
1022
+ dma_sync_single_for_device(fore200e->dev, buffer->data.dma_addr,
1023
+ rpd->rsd[i].length, DMA_FROM_DEVICE);
11141024 }
11151025
11161026 DPRINTK(3, "rx skb: len = %d, truesize = %d\n", skb->len, skb->truesize);
....@@ -1622,7 +1532,7 @@
16221532 }
16231533
16241534 if (tx_copy) {
1625
- data = kmalloc(tx_len, GFP_ATOMIC | GFP_DMA);
1535
+ data = kmalloc(tx_len, GFP_ATOMIC);
16261536 if (data == NULL) {
16271537 if (vcc->pop) {
16281538 vcc->pop(vcc, skb);
....@@ -1690,7 +1600,14 @@
16901600 entry->data = tx_copy ? data : NULL;
16911601
16921602 tpd = entry->tpd;
1693
- tpd->tsd[ 0 ].buffer = fore200e->bus->dma_map(fore200e, data, tx_len, DMA_TO_DEVICE);
1603
+ tpd->tsd[ 0 ].buffer = dma_map_single(fore200e->dev, data, tx_len,
1604
+ DMA_TO_DEVICE);
1605
+ if (dma_mapping_error(fore200e->dev, tpd->tsd[0].buffer)) {
1606
+ if (tx_copy)
1607
+ kfree(data);
1608
+ spin_unlock_irqrestore(&fore200e->q_lock, flags);
1609
+ return -ENOMEM;
1610
+ }
16941611 tpd->tsd[ 0 ].length = tx_len;
16951612
16961613 FORE200E_NEXT_ENTRY(txq->head, QUEUE_SIZE_TX);
....@@ -1758,13 +1675,15 @@
17581675 u32 stats_dma_addr;
17591676
17601677 if (fore200e->stats == NULL) {
1761
- fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL | GFP_DMA);
1678
+ fore200e->stats = kzalloc(sizeof(struct stats), GFP_KERNEL);
17621679 if (fore200e->stats == NULL)
17631680 return -ENOMEM;
17641681 }
17651682
1766
- stats_dma_addr = fore200e->bus->dma_map(fore200e, fore200e->stats,
1767
- sizeof(struct stats), DMA_FROM_DEVICE);
1683
+ stats_dma_addr = dma_map_single(fore200e->dev, fore200e->stats,
1684
+ sizeof(struct stats), DMA_FROM_DEVICE);
1685
+ if (dma_mapping_error(fore200e->dev, stats_dma_addr))
1686
+ return -ENOMEM;
17681687
17691688 FORE200E_NEXT_ENTRY(cmdq->head, QUEUE_SIZE_CMD);
17701689
....@@ -1781,7 +1700,7 @@
17811700
17821701 *entry->status = STATUS_FREE;
17831702
1784
- fore200e->bus->dma_unmap(fore200e, stats_dma_addr, sizeof(struct stats), DMA_FROM_DEVICE);
1703
+ dma_unmap_single(fore200e->dev, stats_dma_addr, sizeof(struct stats), DMA_FROM_DEVICE);
17851704
17861705 if (ok == 0) {
17871706 printk(FORE200E "unable to get statistics from device %s\n", fore200e->name);
....@@ -1790,31 +1709,6 @@
17901709
17911710 return 0;
17921711 }
1793
-
1794
-
1795
-static int
1796
-fore200e_getsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, int optlen)
1797
-{
1798
- /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */
1799
-
1800
- DPRINTK(2, "getsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n",
1801
- vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen);
1802
-
1803
- return -EINVAL;
1804
-}
1805
-
1806
-
1807
-static int
1808
-fore200e_setsockopt(struct atm_vcc* vcc, int level, int optname, void __user *optval, unsigned int optlen)
1809
-{
1810
- /* struct fore200e* fore200e = FORE200E_DEV(vcc->dev); */
1811
-
1812
- DPRINTK(2, "setsockopt %d.%d.%d, level = %d, optname = 0x%x, optval = 0x%p, optlen = %d\n",
1813
- vcc->itf, vcc->vpi, vcc->vci, level, optname, optval, optlen);
1814
-
1815
- return -EINVAL;
1816
-}
1817
-
18181712
18191713 #if 0 /* currently unused */
18201714 static int
....@@ -2060,7 +1954,7 @@
20601954
20611955 static int fore200e_get_esi(struct fore200e *fore200e)
20621956 {
2063
- struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL | GFP_DMA);
1957
+ struct prom_data* prom = kzalloc(sizeof(struct prom_data), GFP_KERNEL);
20641958 int ok, i;
20651959
20661960 if (!prom)
....@@ -2167,7 +2061,7 @@
21672061 bsq = &fore200e->host_bsq[ scheme ][ magn ];
21682062
21692063 /* allocate and align the array of status words */
2170
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2064
+ if (fore200e_dma_chunk_alloc(fore200e,
21712065 &bsq->status,
21722066 sizeof(enum status),
21732067 QUEUE_SIZE_BS,
....@@ -2176,13 +2070,13 @@
21762070 }
21772071
21782072 /* allocate and align the array of receive buffer descriptors */
2179
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2073
+ if (fore200e_dma_chunk_alloc(fore200e,
21802074 &bsq->rbd_block,
21812075 sizeof(struct rbd_block),
21822076 QUEUE_SIZE_BS,
21832077 fore200e->bus->descr_alignment) < 0) {
21842078
2185
- fore200e->bus->dma_chunk_free(fore200e, &bsq->status);
2079
+ fore200e_dma_chunk_free(fore200e, &bsq->status);
21862080 return -ENOMEM;
21872081 }
21882082
....@@ -2223,7 +2117,7 @@
22232117 DPRINTK(2, "receive queue is being initialized\n");
22242118
22252119 /* allocate and align the array of status words */
2226
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2120
+ if (fore200e_dma_chunk_alloc(fore200e,
22272121 &rxq->status,
22282122 sizeof(enum status),
22292123 QUEUE_SIZE_RX,
....@@ -2232,13 +2126,13 @@
22322126 }
22332127
22342128 /* allocate and align the array of receive PDU descriptors */
2235
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2129
+ if (fore200e_dma_chunk_alloc(fore200e,
22362130 &rxq->rpd,
22372131 sizeof(struct rpd),
22382132 QUEUE_SIZE_RX,
22392133 fore200e->bus->descr_alignment) < 0) {
22402134
2241
- fore200e->bus->dma_chunk_free(fore200e, &rxq->status);
2135
+ fore200e_dma_chunk_free(fore200e, &rxq->status);
22422136 return -ENOMEM;
22432137 }
22442138
....@@ -2282,7 +2176,7 @@
22822176 DPRINTK(2, "transmit queue is being initialized\n");
22832177
22842178 /* allocate and align the array of status words */
2285
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2179
+ if (fore200e_dma_chunk_alloc(fore200e,
22862180 &txq->status,
22872181 sizeof(enum status),
22882182 QUEUE_SIZE_TX,
....@@ -2291,13 +2185,13 @@
22912185 }
22922186
22932187 /* allocate and align the array of transmit PDU descriptors */
2294
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2188
+ if (fore200e_dma_chunk_alloc(fore200e,
22952189 &txq->tpd,
22962190 sizeof(struct tpd),
22972191 QUEUE_SIZE_TX,
22982192 fore200e->bus->descr_alignment) < 0) {
22992193
2300
- fore200e->bus->dma_chunk_free(fore200e, &txq->status);
2194
+ fore200e_dma_chunk_free(fore200e, &txq->status);
23012195 return -ENOMEM;
23022196 }
23032197
....@@ -2344,7 +2238,7 @@
23442238 DPRINTK(2, "command queue is being initialized\n");
23452239
23462240 /* allocate and align the array of status words */
2347
- if (fore200e->bus->dma_chunk_alloc(fore200e,
2241
+ if (fore200e_dma_chunk_alloc(fore200e,
23482242 &cmdq->status,
23492243 sizeof(enum status),
23502244 QUEUE_SIZE_CMD,
....@@ -2498,25 +2392,15 @@
24982392 static int fore200e_load_and_start_fw(struct fore200e *fore200e)
24992393 {
25002394 const struct firmware *firmware;
2501
- struct device *device;
25022395 const struct fw_header *fw_header;
25032396 const __le32 *fw_data;
25042397 u32 fw_size;
25052398 u32 __iomem *load_addr;
25062399 char buf[48];
2507
- int err = -ENODEV;
2508
-
2509
- if (strcmp(fore200e->bus->model_name, "PCA-200E") == 0)
2510
- device = &((struct pci_dev *) fore200e->bus_dev)->dev;
2511
-#ifdef CONFIG_SBUS
2512
- else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0)
2513
- device = &((struct platform_device *) fore200e->bus_dev)->dev;
2514
-#endif
2515
- else
2516
- return err;
2400
+ int err;
25172401
25182402 sprintf(buf, "%s%s", fore200e->bus->proc_name, FW_EXT);
2519
- if ((err = request_firmware(&firmware, buf, device)) < 0) {
2403
+ if ((err = request_firmware(&firmware, buf, fore200e->dev)) < 0) {
25202404 printk(FORE200E "problem loading firmware image %s\n", fore200e->bus->model_name);
25212405 return err;
25222406 }
....@@ -2642,7 +2526,6 @@
26422526 static int fore200e_sba_probe(struct platform_device *op)
26432527 {
26442528 const struct of_device_id *match;
2645
- const struct fore200e_bus *bus;
26462529 struct fore200e *fore200e;
26472530 static int index = 0;
26482531 int err;
....@@ -2650,18 +2533,17 @@
26502533 match = of_match_device(fore200e_sba_match, &op->dev);
26512534 if (!match)
26522535 return -EINVAL;
2653
- bus = match->data;
26542536
26552537 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
26562538 if (!fore200e)
26572539 return -ENOMEM;
26582540
2659
- fore200e->bus = bus;
2660
- fore200e->bus_dev = op;
2541
+ fore200e->bus = &fore200e_sbus_ops;
2542
+ fore200e->dev = &op->dev;
26612543 fore200e->irq = op->archdata.irqs[0];
26622544 fore200e->phys_base = op->resource[0].start;
26632545
2664
- sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2546
+ sprintf(fore200e->name, "SBA-200E-%d", index);
26652547
26662548 err = fore200e_init(fore200e, &op->dev);
26672549 if (err < 0) {
....@@ -2689,7 +2571,6 @@
26892571 static const struct of_device_id fore200e_sba_match[] = {
26902572 {
26912573 .name = SBA200E_PROM_NAME,
2692
- .data = (void *) &fore200e_bus[1],
26932574 },
26942575 {},
26952576 };
....@@ -2709,7 +2590,6 @@
27092590 static int fore200e_pca_detect(struct pci_dev *pci_dev,
27102591 const struct pci_device_id *pci_ent)
27112592 {
2712
- const struct fore200e_bus* bus = (struct fore200e_bus*) pci_ent->driver_data;
27132593 struct fore200e* fore200e;
27142594 int err = 0;
27152595 static int index = 0;
....@@ -2730,20 +2610,19 @@
27302610 goto out_disable;
27312611 }
27322612
2733
- fore200e->bus = bus;
2734
- fore200e->bus_dev = pci_dev;
2613
+ fore200e->bus = &fore200e_pci_ops;
2614
+ fore200e->dev = &pci_dev->dev;
27352615 fore200e->irq = pci_dev->irq;
27362616 fore200e->phys_base = pci_resource_start(pci_dev, 0);
27372617
2738
- sprintf(fore200e->name, "%s-%d", bus->model_name, index - 1);
2618
+ sprintf(fore200e->name, "PCA-200E-%d", index - 1);
27392619
27402620 pci_set_master(pci_dev);
27412621
2742
- printk(FORE200E "device %s found at 0x%lx, IRQ %s\n",
2743
- fore200e->bus->model_name,
2622
+ printk(FORE200E "device PCA-200E found at 0x%lx, IRQ %s\n",
27442623 fore200e->phys_base, fore200e_irq_itoa(fore200e->irq));
27452624
2746
- sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2625
+ sprintf(fore200e->name, "PCA-200E-%d", index);
27472626
27482627 err = fore200e_init(fore200e, &pci_dev->dev);
27492628 if (err < 0) {
....@@ -2778,8 +2657,7 @@
27782657
27792658
27802659 static const struct pci_device_id fore200e_pca_tbl[] = {
2781
- { PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_PCA200E, PCI_ANY_ID, PCI_ANY_ID,
2782
- 0, 0, (unsigned long) &fore200e_bus[0] },
2660
+ { PCI_VENDOR_ID_FORE, PCI_DEVICE_ID_FORE_PCA200E, PCI_ANY_ID, PCI_ANY_ID },
27832661 { 0, }
27842662 };
27852663
....@@ -3119,64 +2997,14 @@
31192997 module_exit(fore200e_module_cleanup);
31202998
31212999
3122
-static const struct atmdev_ops fore200e_ops =
3123
-{
3000
+static const struct atmdev_ops fore200e_ops = {
31243001 .open = fore200e_open,
31253002 .close = fore200e_close,
31263003 .ioctl = fore200e_ioctl,
3127
- .getsockopt = fore200e_getsockopt,
3128
- .setsockopt = fore200e_setsockopt,
31293004 .send = fore200e_send,
31303005 .change_qos = fore200e_change_qos,
31313006 .proc_read = fore200e_proc_read,
31323007 .owner = THIS_MODULE
3133
-};
3134
-
3135
-
3136
-static const struct fore200e_bus fore200e_bus[] = {
3137
-#ifdef CONFIG_PCI
3138
- { "PCA-200E", "pca200e", 32, 4, 32,
3139
- fore200e_pca_read,
3140
- fore200e_pca_write,
3141
- fore200e_pca_dma_map,
3142
- fore200e_pca_dma_unmap,
3143
- fore200e_pca_dma_sync_for_cpu,
3144
- fore200e_pca_dma_sync_for_device,
3145
- fore200e_pca_dma_chunk_alloc,
3146
- fore200e_pca_dma_chunk_free,
3147
- fore200e_pca_configure,
3148
- fore200e_pca_map,
3149
- fore200e_pca_reset,
3150
- fore200e_pca_prom_read,
3151
- fore200e_pca_unmap,
3152
- NULL,
3153
- fore200e_pca_irq_check,
3154
- fore200e_pca_irq_ack,
3155
- fore200e_pca_proc_read,
3156
- },
3157
-#endif
3158
-#ifdef CONFIG_SBUS
3159
- { "SBA-200E", "sba200e", 32, 64, 32,
3160
- fore200e_sba_read,
3161
- fore200e_sba_write,
3162
- fore200e_sba_dma_map,
3163
- fore200e_sba_dma_unmap,
3164
- fore200e_sba_dma_sync_for_cpu,
3165
- fore200e_sba_dma_sync_for_device,
3166
- fore200e_sba_dma_chunk_alloc,
3167
- fore200e_sba_dma_chunk_free,
3168
- fore200e_sba_configure,
3169
- fore200e_sba_map,
3170
- fore200e_sba_reset,
3171
- fore200e_sba_prom_read,
3172
- fore200e_sba_unmap,
3173
- fore200e_sba_irq_enable,
3174
- fore200e_sba_irq_check,
3175
- fore200e_sba_irq_ack,
3176
- fore200e_sba_proc_read,
3177
- },
3178
-#endif
3179
- {}
31803008 };
31813009
31823010 MODULE_LICENSE("GPL");