Skip to content

Commit 2bd320f

Browse files
committed
dbri: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dc8aa2e commit 2bd320f

1 file changed

Lines changed: 27 additions & 32 deletions

File tree

‎sound/sparc/dbri.c‎

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
#include <sound/initval.h>
6868

6969
#include <linux/of.h>
70-
#include <asm/sbus.h>
70+
#include <linux/of_device.h>
7171
#include <asm/atomic.h>
7272

7373
MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets");
@@ -298,7 +298,7 @@ struct dbri_streaminfo {
298298
/* This structure holds the information for both chips (DBRI & CS4215) */
299299
struct snd_dbri {
300300
int regs_size, irq; /* Needed for unload */
301-
struct sbus_dev *sdev; /* SBUS device info */
301+
struct of_device *op; /* OF device info */
302302
spinlock_t lock;
303303

304304
struct dbri_dma *dma; /* Pointer to our DMA block */
@@ -2099,7 +2099,7 @@ static int snd_dbri_hw_params(struct snd_pcm_substream *substream,
20992099
direction = DMA_FROM_DEVICE;
21002100

21012101
info->dvma_buffer =
2102-
dma_map_single(&dbri->sdev->ofdev.dev,
2102+
dma_map_single(&dbri->op->dev,
21032103
runtime->dma_area,
21042104
params_buffer_bytes(hw_params),
21052105
direction);
@@ -2127,7 +2127,7 @@ static int snd_dbri_hw_free(struct snd_pcm_substream *substream)
21272127
else
21282128
direction = DMA_FROM_DEVICE;
21292129

2130-
dma_unmap_single(&dbri->sdev->ofdev.dev, info->dvma_buffer,
2130+
dma_unmap_single(&dbri->op->dev, info->dvma_buffer,
21312131
substream->runtime->buffer_size, direction);
21322132
info->dvma_buffer = 0;
21332133
}
@@ -2516,17 +2516,17 @@ static void __devinit snd_dbri_proc(struct snd_card *card)
25162516
static void snd_dbri_free(struct snd_dbri *dbri);
25172517

25182518
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)
25212521
{
25222522
struct snd_dbri *dbri = card->private_data;
25232523
int err;
25242524

25252525
spin_lock_init(&dbri->lock);
2526-
dbri->sdev = sdev;
2526+
dbri->op = op;
25272527
dbri->irq = irq;
25282528

2529-
dbri->dma = dma_alloc_coherent(&sdev->ofdev.dev,
2529+
dbri->dma = dma_alloc_coherent(&op->dev,
25302530
sizeof(struct dbri_dma),
25312531
&dbri->dma_dvma, GFP_ATOMIC);
25322532
memset((void *)dbri->dma, 0, sizeof(struct dbri_dma));
@@ -2535,12 +2535,12 @@ static int __devinit snd_dbri_create(struct snd_card *card,
25352535
dbri->dma, dbri->dma_dvma);
25362536

25372537
/* 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");
25412541
if (!dbri->regs) {
25422542
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),
25442544
(void *)dbri->dma, dbri->dma_dvma);
25452545
return -EIO;
25462546
}
@@ -2549,8 +2549,8 @@ static int __devinit snd_dbri_create(struct snd_card *card,
25492549
"DBRI audio", dbri);
25502550
if (err) {
25512551
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),
25542554
(void *)dbri->dma, dbri->dma_dvma);
25552555
return err;
25562556
}
@@ -2575,36 +2575,31 @@ static void snd_dbri_free(struct snd_dbri *dbri)
25752575
free_irq(dbri->irq, dbri);
25762576

25772577
if (dbri->regs)
2578-
sbus_iounmap(dbri->regs, dbri->regs_size);
2578+
of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size);
25792579

25802580
if (dbri->dma)
2581-
dma_free_coherent(&dbri->sdev->ofdev.dev,
2581+
dma_free_coherent(&dbri->op->dev,
25822582
sizeof(struct dbri_dma),
25832583
(void *)dbri->dma, dbri->dma_dvma);
25842584
}
25852585

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)
25882587
{
2589-
struct sbus_dev *sdev = to_sbus_device(&of_dev->dev);
25902588
struct snd_dbri *dbri;
2591-
int irq;
25922589
struct resource *rp;
25932590
struct snd_card *card;
25942591
static int dev = 0;
2592+
int irq;
25952593
int err;
25962594

2597-
dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n",
2598-
sdev->prom_name, sdev->slot);
2599-
26002595
if (dev >= SNDRV_CARDS)
26012596
return -ENODEV;
26022597
if (!enable[dev]) {
26032598
dev++;
26042599
return -ENOENT;
26052600
}
26062601

2607-
irq = sdev->irqs[0];
2602+
irq = op->irqs[0];
26082603
if (irq <= 0) {
26092604
printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev);
26102605
return -ENODEV;
@@ -2617,12 +2612,12 @@ static int __devinit dbri_probe(struct of_device *of_dev,
26172612

26182613
strcpy(card->driver, "DBRI");
26192614
strcpy(card->shortname, "Sun DBRI");
2620-
rp = &sdev->resource[0];
2615+
rp = &op->resource[0];
26212616
sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d",
26222617
card->shortname,
26232618
rp->flags & 0xffL, (unsigned long long)rp->start, irq);
26242619

2625-
err = snd_dbri_create(card, sdev, irq, dev);
2620+
err = snd_dbri_create(card, op, irq, dev);
26262621
if (err < 0) {
26272622
snd_card_free(card);
26282623
return err;
@@ -2639,15 +2634,15 @@ static int __devinit dbri_probe(struct of_device *of_dev,
26392634

26402635
/* /proc file handling */
26412636
snd_dbri_proc(card);
2642-
dev_set_drvdata(&of_dev->dev, card);
2637+
dev_set_drvdata(&op->dev, card);
26432638

26442639
err = snd_card_register(card);
26452640
if (err < 0)
26462641
goto _err;
26472642

26482643
printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n",
26492644
dev, dbri->regs,
2650-
dbri->irq, sdev->prom_name[9], dbri->mm.version);
2645+
dbri->irq, op->node->name[9], dbri->mm.version);
26512646
dev++;
26522647

26532648
return 0;
@@ -2658,14 +2653,14 @@ static int __devinit dbri_probe(struct of_device *of_dev,
26582653
return err;
26592654
}
26602655

2661-
static int __devexit dbri_remove(struct of_device *dev)
2656+
static int __devexit dbri_remove(struct of_device *op)
26622657
{
2663-
struct snd_card *card = dev_get_drvdata(&dev->dev);
2658+
struct snd_card *card = dev_get_drvdata(&op->dev);
26642659

26652660
snd_dbri_free(card->private_data);
26662661
snd_card_free(card);
26672662

2668-
dev_set_drvdata(&dev->dev, NULL);
2663+
dev_set_drvdata(&op->dev, NULL);
26692664

26702665
return 0;
26712666
}
@@ -2692,7 +2687,7 @@ static struct of_platform_driver dbri_sbus_driver = {
26922687
/* Probe for the dbri chip and then attach the driver. */
26932688
static int __init dbri_init(void)
26942689
{
2695-
return of_register_driver(&dbri_sbus_driver, &sbus_bus_type);
2690+
return of_register_driver(&dbri_sbus_driver, &of_bus_type);
26962691
}
26972692

26982693
static void __exit dbri_exit(void)

0 commit comments

Comments
 (0)