Commit a24a6b22254bca8d54be6c8b7d8730d09f1058cc
1 parent
2b21d5e47b
Exists in
master
and in
7 other branches
m68k: amiga - A4000T SCSI platform device conversion
Acked-by: James Bottomley <James.Bottomley@suse.de> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Showing 2 changed files with 57 additions and 55 deletions Side-by-side Diff
arch/m68k/amiga/platform.c
... | ... | @@ -65,6 +65,13 @@ |
65 | 65 | }; |
66 | 66 | |
67 | 67 | |
68 | +static const struct resource a4000t_scsi_resource __initconst = { | |
69 | + .start = 0xdd0000, | |
70 | + .end = 0xdd0fff, | |
71 | + .flags = IORESOURCE_MEM, | |
72 | +}; | |
73 | + | |
74 | + | |
68 | 75 | static int __init amiga_init_devices(void) |
69 | 76 | { |
70 | 77 | if (!MACH_IS_AMIGA) |
... | ... | @@ -87,6 +94,10 @@ |
87 | 94 | if (AMIGAHW_PRESENT(A3000_SCSI)) |
88 | 95 | platform_device_register_simple("amiga-a3000-scsi", -1, |
89 | 96 | &a3000_scsi_resource, 1); |
97 | + | |
98 | + if (AMIGAHW_PRESENT(A4000_SCSI)) | |
99 | + platform_device_register_simple("amiga-a4000t-scsi", -1, | |
100 | + &a4000t_scsi_resource, 1); | |
90 | 101 | |
91 | 102 | return 0; |
92 | 103 | } |
drivers/scsi/a4000t.c
... | ... | @@ -20,11 +20,7 @@ |
20 | 20 | |
21 | 21 | #include "53c700.h" |
22 | 22 | |
23 | -MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>"); | |
24 | -MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver"); | |
25 | -MODULE_LICENSE("GPL"); | |
26 | 23 | |
27 | - | |
28 | 24 | static struct scsi_host_template a4000t_scsi_driver_template = { |
29 | 25 | .name = "A4000T builtin SCSI", |
30 | 26 | .proc_name = "A4000t", |
31 | 27 | |
32 | 28 | |
33 | 29 | |
34 | 30 | |
35 | 31 | |
36 | 32 | |
37 | 33 | |
38 | 34 | |
39 | 35 | |
40 | 36 | |
41 | 37 | |
... | ... | @@ -32,30 +28,35 @@ |
32 | 28 | .module = THIS_MODULE, |
33 | 29 | }; |
34 | 30 | |
35 | -static struct platform_device *a4000t_scsi_device; | |
36 | 31 | |
37 | -#define A4000T_SCSI_ADDR 0xdd0040 | |
32 | +#define A4000T_SCSI_OFFSET 0x40 | |
38 | 33 | |
39 | -static int __devinit a4000t_probe(struct platform_device *dev) | |
34 | +static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev) | |
40 | 35 | { |
41 | - struct Scsi_Host *host; | |
36 | + struct resource *res; | |
37 | + phys_addr_t scsi_addr; | |
42 | 38 | struct NCR_700_Host_Parameters *hostdata; |
39 | + struct Scsi_Host *host; | |
43 | 40 | |
44 | - if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI))) | |
45 | - goto out; | |
41 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
42 | + if (!res) | |
43 | + return -ENODEV; | |
46 | 44 | |
47 | - if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000, | |
45 | + if (!request_mem_region(res->start, resource_size(res), | |
48 | 46 | "A4000T builtin SCSI")) |
49 | - goto out; | |
47 | + return -EBUSY; | |
50 | 48 | |
51 | - hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); | |
49 | + hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), | |
50 | + GFP_KERNEL); | |
52 | 51 | if (!hostdata) { |
53 | - printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n"); | |
52 | + dev_err(&pdev->dev, "Failed to allocate host data\n"); | |
54 | 53 | goto out_release; |
55 | 54 | } |
56 | 55 | |
56 | + scsi_addr = res->start + A4000T_SCSI_OFFSET; | |
57 | + | |
57 | 58 | /* Fill in the required pieces of hostdata */ |
58 | - hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR); | |
59 | + hostdata->base = (void __iomem *)ZTWO_VADDR(scsi_addr); | |
59 | 60 | hostdata->clock = 50; |
60 | 61 | hostdata->chip710 = 1; |
61 | 62 | hostdata->dmode_extra = DMODE_FC2; |
62 | 63 | |
63 | 64 | |
64 | 65 | |
65 | 66 | |
66 | 67 | |
... | ... | @@ -63,26 +64,25 @@ |
63 | 64 | |
64 | 65 | /* and register the chip */ |
65 | 66 | host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, |
66 | - &dev->dev); | |
67 | + &pdev->dev); | |
67 | 68 | if (!host) { |
68 | - printk(KERN_ERR "a4000t-scsi: No host detected; " | |
69 | - "board configuration problem?\n"); | |
69 | + dev_err(&pdev->dev, | |
70 | + "No host detected; board configuration problem?\n"); | |
70 | 71 | goto out_free; |
71 | 72 | } |
72 | 73 | |
73 | 74 | host->this_id = 7; |
74 | - host->base = A4000T_SCSI_ADDR; | |
75 | + host->base = scsi_addr; | |
75 | 76 | host->irq = IRQ_AMIGA_PORTS; |
76 | 77 | |
77 | 78 | if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi", |
78 | 79 | host)) { |
79 | - printk(KERN_ERR "a4000t-scsi: request_irq failed\n"); | |
80 | + dev_err(&pdev->dev, "request_irq failed\n"); | |
80 | 81 | goto out_put_host; |
81 | 82 | } |
82 | 83 | |
83 | - platform_set_drvdata(dev, host); | |
84 | + platform_set_drvdata(pdev, host); | |
84 | 85 | scsi_scan_host(host); |
85 | - | |
86 | 86 | return 0; |
87 | 87 | |
88 | 88 | out_put_host: |
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | 98 | |
99 | 99 | |
100 | 100 | |
... | ... | @@ -90,59 +90,50 @@ |
90 | 90 | out_free: |
91 | 91 | kfree(hostdata); |
92 | 92 | out_release: |
93 | - release_mem_region(A4000T_SCSI_ADDR, 0x1000); | |
94 | - out: | |
93 | + release_mem_region(res->start, resource_size(res)); | |
95 | 94 | return -ENODEV; |
96 | 95 | } |
97 | 96 | |
98 | -static __devexit int a4000t_device_remove(struct platform_device *dev) | |
97 | +static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev) | |
99 | 98 | { |
100 | - struct Scsi_Host *host = platform_get_drvdata(dev); | |
99 | + struct Scsi_Host *host = platform_get_drvdata(pdev); | |
101 | 100 | struct NCR_700_Host_Parameters *hostdata = shost_priv(host); |
101 | + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
102 | 102 | |
103 | 103 | scsi_remove_host(host); |
104 | - | |
105 | 104 | NCR_700_release(host); |
106 | 105 | kfree(hostdata); |
107 | 106 | free_irq(host->irq, host); |
108 | - release_mem_region(A4000T_SCSI_ADDR, 0x1000); | |
109 | - | |
107 | + release_mem_region(res->start, resource_size(res)); | |
110 | 108 | return 0; |
111 | 109 | } |
112 | 110 | |
113 | -static struct platform_driver a4000t_scsi_driver = { | |
114 | - .driver = { | |
115 | - .name = "a4000t-scsi", | |
116 | - .owner = THIS_MODULE, | |
111 | +static struct platform_driver amiga_a4000t_scsi_driver = { | |
112 | + .remove = __exit_p(amiga_a4000t_scsi_remove), | |
113 | + .driver = { | |
114 | + .name = "amiga-a4000t-scsi", | |
115 | + .owner = THIS_MODULE, | |
117 | 116 | }, |
118 | - .probe = a4000t_probe, | |
119 | - .remove = __devexit_p(a4000t_device_remove), | |
120 | 117 | }; |
121 | 118 | |
122 | -static int __init a4000t_scsi_init(void) | |
119 | +static int __init amiga_a4000t_scsi_init(void) | |
123 | 120 | { |
124 | - int err; | |
125 | - | |
126 | - err = platform_driver_register(&a4000t_scsi_driver); | |
127 | - if (err) | |
128 | - return err; | |
129 | - | |
130 | - a4000t_scsi_device = platform_device_register_simple("a4000t-scsi", | |
131 | - -1, NULL, 0); | |
132 | - if (IS_ERR(a4000t_scsi_device)) { | |
133 | - platform_driver_unregister(&a4000t_scsi_driver); | |
134 | - return PTR_ERR(a4000t_scsi_device); | |
135 | - } | |
136 | - | |
137 | - return err; | |
121 | + return platform_driver_probe(&amiga_a4000t_scsi_driver, | |
122 | + amiga_a4000t_scsi_probe); | |
138 | 123 | } |
139 | 124 | |
140 | -static void __exit a4000t_scsi_exit(void) | |
125 | +module_init(amiga_a4000t_scsi_init); | |
126 | + | |
127 | +static void __exit amiga_a4000t_scsi_exit(void) | |
141 | 128 | { |
142 | - platform_device_unregister(a4000t_scsi_device); | |
143 | - platform_driver_unregister(&a4000t_scsi_driver); | |
129 | + platform_driver_unregister(&amiga_a4000t_scsi_driver); | |
144 | 130 | } |
145 | 131 | |
146 | -module_init(a4000t_scsi_init); | |
147 | -module_exit(a4000t_scsi_exit); | |
132 | +module_exit(amiga_a4000t_scsi_exit); | |
133 | + | |
134 | +MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / " | |
135 | + "Kars de Jong <jongk@linux-m68k.org>"); | |
136 | +MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver"); | |
137 | +MODULE_LICENSE("GPL"); | |
138 | +MODULE_ALIAS("platform:amiga-a4000t-scsi"); |