diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2009-04-05 07:02:13 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-17 15:37:45 -0400 |
commit | 92183b346f02773dae09182c65f16b013f295d80 (patch) | |
tree | 51c6741126aada9f72ca1c5ce30e468b460414cd /drivers/block/amiflop.c | |
parent | ff2db7c5ab78817eb3c5d15dd87f18e9be726f1a (diff) |
m68k: amiga - Floppy platform device conversion
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'drivers/block/amiflop.c')
-rw-r--r-- | drivers/block/amiflop.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 0182a22c423a..832798aa14f6 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include <linux/blkdev.h> | 66 | #include <linux/blkdev.h> |
67 | #include <linux/elevator.h> | 67 | #include <linux/elevator.h> |
68 | #include <linux/interrupt.h> | 68 | #include <linux/interrupt.h> |
69 | #include <linux/platform_device.h> | ||
69 | 70 | ||
70 | #include <asm/setup.h> | 71 | #include <asm/setup.h> |
71 | #include <asm/uaccess.h> | 72 | #include <asm/uaccess.h> |
@@ -1696,34 +1697,18 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data) | |||
1696 | return get_disk(unit[drive].gendisk); | 1697 | return get_disk(unit[drive].gendisk); |
1697 | } | 1698 | } |
1698 | 1699 | ||
1699 | static int __init amiga_floppy_init(void) | 1700 | static int __init amiga_floppy_probe(struct platform_device *pdev) |
1700 | { | 1701 | { |
1701 | int i, ret; | 1702 | int i, ret; |
1702 | 1703 | ||
1703 | if (!MACH_IS_AMIGA) | ||
1704 | return -ENODEV; | ||
1705 | |||
1706 | if (!AMIGAHW_PRESENT(AMI_FLOPPY)) | ||
1707 | return -ENODEV; | ||
1708 | |||
1709 | if (register_blkdev(FLOPPY_MAJOR,"fd")) | 1704 | if (register_blkdev(FLOPPY_MAJOR,"fd")) |
1710 | return -EBUSY; | 1705 | return -EBUSY; |
1711 | 1706 | ||
1712 | /* | ||
1713 | * We request DSKPTR, DSKLEN and DSKDATA only, because the other | ||
1714 | * floppy registers are too spreaded over the custom register space | ||
1715 | */ | ||
1716 | ret = -EBUSY; | ||
1717 | if (!request_mem_region(CUSTOM_PHYSADDR+0x20, 8, "amiflop [Paula]")) { | ||
1718 | printk("fd: cannot get floppy registers\n"); | ||
1719 | goto out_blkdev; | ||
1720 | } | ||
1721 | |||
1722 | ret = -ENOMEM; | 1707 | ret = -ENOMEM; |
1723 | if ((raw_buf = (char *)amiga_chip_alloc (RAW_BUF_SIZE, "Floppy")) == | 1708 | if ((raw_buf = (char *)amiga_chip_alloc (RAW_BUF_SIZE, "Floppy")) == |
1724 | NULL) { | 1709 | NULL) { |
1725 | printk("fd: cannot get chip mem buffer\n"); | 1710 | printk("fd: cannot get chip mem buffer\n"); |
1726 | goto out_memregion; | 1711 | goto out_blkdev; |
1727 | } | 1712 | } |
1728 | 1713 | ||
1729 | ret = -EBUSY; | 1714 | ret = -EBUSY; |
@@ -1792,18 +1777,13 @@ out_irq2: | |||
1792 | free_irq(IRQ_AMIGA_DSKBLK, NULL); | 1777 | free_irq(IRQ_AMIGA_DSKBLK, NULL); |
1793 | out_irq: | 1778 | out_irq: |
1794 | amiga_chip_free(raw_buf); | 1779 | amiga_chip_free(raw_buf); |
1795 | out_memregion: | ||
1796 | release_mem_region(CUSTOM_PHYSADDR+0x20, 8); | ||
1797 | out_blkdev: | 1780 | out_blkdev: |
1798 | unregister_blkdev(FLOPPY_MAJOR,"fd"); | 1781 | unregister_blkdev(FLOPPY_MAJOR,"fd"); |
1799 | return ret; | 1782 | return ret; |
1800 | } | 1783 | } |
1801 | 1784 | ||
1802 | module_init(amiga_floppy_init); | ||
1803 | #ifdef MODULE | ||
1804 | |||
1805 | #if 0 /* not safe to unload */ | 1785 | #if 0 /* not safe to unload */ |
1806 | void cleanup_module(void) | 1786 | static int __exit amiga_floppy_remove(struct platform_device *pdev) |
1807 | { | 1787 | { |
1808 | int i; | 1788 | int i; |
1809 | 1789 | ||
@@ -1820,12 +1800,25 @@ void cleanup_module(void) | |||
1820 | custom.dmacon = DMAF_DISK; /* disable DMA */ | 1800 | custom.dmacon = DMAF_DISK; /* disable DMA */ |
1821 | amiga_chip_free(raw_buf); | 1801 | amiga_chip_free(raw_buf); |
1822 | blk_cleanup_queue(floppy_queue); | 1802 | blk_cleanup_queue(floppy_queue); |
1823 | release_mem_region(CUSTOM_PHYSADDR+0x20, 8); | ||
1824 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 1803 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
1825 | } | 1804 | } |
1826 | #endif | 1805 | #endif |
1827 | 1806 | ||
1828 | #else | 1807 | static struct platform_driver amiga_floppy_driver = { |
1808 | .driver = { | ||
1809 | .name = "amiga-floppy", | ||
1810 | .owner = THIS_MODULE, | ||
1811 | }, | ||
1812 | }; | ||
1813 | |||
1814 | static int __init amiga_floppy_init(void) | ||
1815 | { | ||
1816 | return platform_driver_probe(&amiga_floppy_driver, amiga_floppy_probe); | ||
1817 | } | ||
1818 | |||
1819 | module_init(amiga_floppy_init); | ||
1820 | |||
1821 | #ifndef MODULE | ||
1829 | static int __init amiga_floppy_setup (char *str) | 1822 | static int __init amiga_floppy_setup (char *str) |
1830 | { | 1823 | { |
1831 | int n; | 1824 | int n; |
@@ -1840,3 +1833,5 @@ static int __init amiga_floppy_setup (char *str) | |||
1840 | 1833 | ||
1841 | __setup("floppy=", amiga_floppy_setup); | 1834 | __setup("floppy=", amiga_floppy_setup); |
1842 | #endif | 1835 | #endif |
1836 | |||
1837 | MODULE_ALIAS("platform:amiga-floppy"); | ||