hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/ide/macide.c
....@@ -18,10 +18,11 @@
1818 #include <linux/delay.h>
1919 #include <linux/ide.h>
2020 #include <linux/module.h>
21
+#include <linux/platform_device.h>
2122
2223 #include <asm/macintosh.h>
23
-#include <asm/macints.h>
24
-#include <asm/mac_baboon.h>
24
+
25
+#define DRV_NAME "mac_ide"
2526
2627 #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
2728
....@@ -100,42 +101,61 @@
100101 * Probe for a Macintosh IDE interface
101102 */
102103
103
-static int __init macide_init(void)
104
+static int mac_ide_probe(struct platform_device *pdev)
104105 {
105
- unsigned long base;
106
- int irq;
106
+ struct resource *mem, *irq;
107107 struct ide_hw hw, *hws[] = { &hw };
108108 struct ide_port_info d = macide_port_info;
109
+ struct ide_host *host;
110
+ int rc;
109111
110112 if (!MACH_IS_MAC)
111113 return -ENODEV;
112114
113
- switch (macintosh_config->ide_type) {
114
- case MAC_IDE_QUADRA:
115
- base = IDE_BASE;
116
- irq = IRQ_NUBUS_F;
117
- break;
118
- case MAC_IDE_PB:
119
- base = IDE_BASE;
120
- irq = IRQ_NUBUS_C;
121
- break;
122
- case MAC_IDE_BABOON:
123
- base = BABOON_BASE;
124
- d.port_ops = NULL;
125
- irq = IRQ_BABOON_1;
126
- break;
127
- default:
115
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
116
+ if (!mem)
128117 return -ENODEV;
118
+
119
+ irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
120
+ if (!irq)
121
+ return -ENODEV;
122
+
123
+ if (!devm_request_mem_region(&pdev->dev, mem->start,
124
+ resource_size(mem), DRV_NAME)) {
125
+ dev_err(&pdev->dev, "resources busy\n");
126
+ return -EBUSY;
129127 }
130128
131129 printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
132130 mac_ide_name[macintosh_config->ide_type - 1]);
133131
134
- macide_setup_ports(&hw, base, irq);
132
+ macide_setup_ports(&hw, mem->start, irq->start);
135133
136
- return ide_host_add(&d, hws, 1, NULL);
134
+ rc = ide_host_add(&d, hws, 1, &host);
135
+ if (rc)
136
+ return rc;
137
+
138
+ platform_set_drvdata(pdev, host);
139
+ return 0;
137140 }
138141
139
-module_init(macide_init);
142
+static int mac_ide_remove(struct platform_device *pdev)
143
+{
144
+ struct ide_host *host = platform_get_drvdata(pdev);
140145
146
+ ide_host_remove(host);
147
+ return 0;
148
+}
149
+
150
+static struct platform_driver mac_ide_driver = {
151
+ .driver = {
152
+ .name = DRV_NAME,
153
+ },
154
+ .probe = mac_ide_probe,
155
+ .remove = mac_ide_remove,
156
+};
157
+
158
+module_platform_driver(mac_ide_driver);
159
+
160
+MODULE_ALIAS("platform:" DRV_NAME);
141161 MODULE_LICENSE("GPL");