Commit 2bd320f89d417c370f4cf45470d102332c25ea24

Authored by David S. Miller
1 parent dc8aa2e9d6

dbri: Convert to pure OF driver.

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 27 additions and 32 deletions Side-by-side Diff

... ... @@ -67,7 +67,7 @@
67 67 #include <sound/initval.h>
68 68  
69 69 #include <linux/of.h>
70   -#include <asm/sbus.h>
  70 +#include <linux/of_device.h>
71 71 #include <asm/atomic.h>
72 72  
73 73 MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets");
... ... @@ -298,7 +298,7 @@
298 298 /* This structure holds the information for both chips (DBRI & CS4215) */
299 299 struct snd_dbri {
300 300 int regs_size, irq; /* Needed for unload */
301   - struct sbus_dev *sdev; /* SBUS device info */
  301 + struct of_device *op; /* OF device info */
302 302 spinlock_t lock;
303 303  
304 304 struct dbri_dma *dma; /* Pointer to our DMA block */
... ... @@ -2099,7 +2099,7 @@
2099 2099 direction = DMA_FROM_DEVICE;
2100 2100  
2101 2101 info->dvma_buffer =
2102   - dma_map_single(&dbri->sdev->ofdev.dev,
  2102 + dma_map_single(&dbri->op->dev,
2103 2103 runtime->dma_area,
2104 2104 params_buffer_bytes(hw_params),
2105 2105 direction);
... ... @@ -2127,7 +2127,7 @@
2127 2127 else
2128 2128 direction = DMA_FROM_DEVICE;
2129 2129  
2130   - dma_unmap_single(&dbri->sdev->ofdev.dev, info->dvma_buffer,
  2130 + dma_unmap_single(&dbri->op->dev, info->dvma_buffer,
2131 2131 substream->runtime->buffer_size, direction);
2132 2132 info->dvma_buffer = 0;
2133 2133 }
2134 2134  
2135 2135  
... ... @@ -2516,17 +2516,17 @@
2516 2516 static void snd_dbri_free(struct snd_dbri *dbri);
2517 2517  
2518 2518 static int __devinit snd_dbri_create(struct snd_card *card,
2519   - struct sbus_dev *sdev,
2520   - int irq, int dev)
  2519 + struct of_device *op,
  2520 + int irq, int dev)
2521 2521 {
2522 2522 struct snd_dbri *dbri = card->private_data;
2523 2523 int err;
2524 2524  
2525 2525 spin_lock_init(&dbri->lock);
2526   - dbri->sdev = sdev;
  2526 + dbri->op = op;
2527 2527 dbri->irq = irq;
2528 2528  
2529   - dbri->dma = dma_alloc_coherent(&sdev->ofdev.dev,
  2529 + dbri->dma = dma_alloc_coherent(&op->dev,
2530 2530 sizeof(struct dbri_dma),
2531 2531 &dbri->dma_dvma, GFP_ATOMIC);
2532 2532 memset((void *)dbri->dma, 0, sizeof(struct dbri_dma));
2533 2533  
... ... @@ -2535,12 +2535,12 @@
2535 2535 dbri->dma, dbri->dma_dvma);
2536 2536  
2537 2537 /* Map the registers into memory. */
2538   - dbri->regs_size = sdev->reg_addrs[0].reg_size;
2539   - dbri->regs = sbus_ioremap(&sdev->resource[0], 0,
2540   - dbri->regs_size, "DBRI Registers");
  2538 + dbri->regs_size = resource_size(&op->resource[0]);
  2539 + dbri->regs = of_ioremap(&op->resource[0], 0,
  2540 + dbri->regs_size, "DBRI Registers");
2541 2541 if (!dbri->regs) {
2542 2542 printk(KERN_ERR "DBRI: could not allocate registers\n");
2543   - dma_free_coherent(&sdev->ofdev.dev, sizeof(struct dbri_dma),
  2543 + dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
2544 2544 (void *)dbri->dma, dbri->dma_dvma);
2545 2545 return -EIO;
2546 2546 }
... ... @@ -2549,8 +2549,8 @@
2549 2549 "DBRI audio", dbri);
2550 2550 if (err) {
2551 2551 printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq);
2552   - sbus_iounmap(dbri->regs, dbri->regs_size);
2553   - dma_free_coherent(&sdev->ofdev.dev, sizeof(struct dbri_dma),
  2552 + of_iounmap(&op->resource[0], dbri->regs, dbri->regs_size);
  2553 + dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
2554 2554 (void *)dbri->dma, dbri->dma_dvma);
2555 2555 return err;
2556 2556 }
2557 2557  
2558 2558  
2559 2559  
2560 2560  
2561 2561  
2562 2562  
... ... @@ -2575,28 +2575,23 @@
2575 2575 free_irq(dbri->irq, dbri);
2576 2576  
2577 2577 if (dbri->regs)
2578   - sbus_iounmap(dbri->regs, dbri->regs_size);
  2578 + of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size);
2579 2579  
2580 2580 if (dbri->dma)
2581   - dma_free_coherent(&dbri->sdev->ofdev.dev,
  2581 + dma_free_coherent(&dbri->op->dev,
2582 2582 sizeof(struct dbri_dma),
2583 2583 (void *)dbri->dma, dbri->dma_dvma);
2584 2584 }
2585 2585  
2586   -static int __devinit dbri_probe(struct of_device *of_dev,
2587   - const struct of_device_id *match)
  2586 +static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match)
2588 2587 {
2589   - struct sbus_dev *sdev = to_sbus_device(&of_dev->dev);
2590 2588 struct snd_dbri *dbri;
2591   - int irq;
2592 2589 struct resource *rp;
2593 2590 struct snd_card *card;
2594 2591 static int dev = 0;
  2592 + int irq;
2595 2593 int err;
2596 2594  
2597   - dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n",
2598   - sdev->prom_name, sdev->slot);
2599   -
2600 2595 if (dev >= SNDRV_CARDS)
2601 2596 return -ENODEV;
2602 2597 if (!enable[dev]) {
... ... @@ -2604,7 +2599,7 @@
2604 2599 return -ENOENT;
2605 2600 }
2606 2601  
2607   - irq = sdev->irqs[0];
  2602 + irq = op->irqs[0];
2608 2603 if (irq <= 0) {
2609 2604 printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev);
2610 2605 return -ENODEV;
2611 2606  
... ... @@ -2617,12 +2612,12 @@
2617 2612  
2618 2613 strcpy(card->driver, "DBRI");
2619 2614 strcpy(card->shortname, "Sun DBRI");
2620   - rp = &sdev->resource[0];
  2615 + rp = &op->resource[0];
2621 2616 sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d",
2622 2617 card->shortname,
2623 2618 rp->flags & 0xffL, (unsigned long long)rp->start, irq);
2624 2619  
2625   - err = snd_dbri_create(card, sdev, irq, dev);
  2620 + err = snd_dbri_create(card, op, irq, dev);
2626 2621 if (err < 0) {
2627 2622 snd_card_free(card);
2628 2623 return err;
... ... @@ -2639,7 +2634,7 @@
2639 2634  
2640 2635 /* /proc file handling */
2641 2636 snd_dbri_proc(card);
2642   - dev_set_drvdata(&of_dev->dev, card);
  2637 + dev_set_drvdata(&op->dev, card);
2643 2638  
2644 2639 err = snd_card_register(card);
2645 2640 if (err < 0)
... ... @@ -2647,7 +2642,7 @@
2647 2642  
2648 2643 printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n",
2649 2644 dev, dbri->regs,
2650   - dbri->irq, sdev->prom_name[9], dbri->mm.version);
  2645 + dbri->irq, op->node->name[9], dbri->mm.version);
2651 2646 dev++;
2652 2647  
2653 2648 return 0;
2654 2649  
2655 2650  
... ... @@ -2658,14 +2653,14 @@
2658 2653 return err;
2659 2654 }
2660 2655  
2661   -static int __devexit dbri_remove(struct of_device *dev)
  2656 +static int __devexit dbri_remove(struct of_device *op)
2662 2657 {
2663   - struct snd_card *card = dev_get_drvdata(&dev->dev);
  2658 + struct snd_card *card = dev_get_drvdata(&op->dev);
2664 2659  
2665 2660 snd_dbri_free(card->private_data);
2666 2661 snd_card_free(card);
2667 2662  
2668   - dev_set_drvdata(&dev->dev, NULL);
  2663 + dev_set_drvdata(&op->dev, NULL);
2669 2664  
2670 2665 return 0;
2671 2666 }
... ... @@ -2692,7 +2687,7 @@
2692 2687 /* Probe for the dbri chip and then attach the driver. */
2693 2688 static int __init dbri_init(void)
2694 2689 {
2695   - return of_register_driver(&dbri_sbus_driver, &sbus_bus_type);
  2690 + return of_register_driver(&dbri_sbus_driver, &of_bus_type);
2696 2691 }
2697 2692  
2698 2693 static void __exit dbri_exit(void)