Commit 18c0635363364ca2fc2d1cbd65bbf918daf89d1a
Exists in
master
and in
6 other branches
Merge branch 'spi/next' of git://git.secretlab.ca/git/linux-2.6
* 'spi/next' of git://git.secretlab.ca/git/linux-2.6: drivercore: Add helper macro for platform_driver boilerplate spi: irq: Remove IRQF_DISABLED OMAP: SPI: Fix the trying to free nonexistent resource error spi/spi-ep93xx: add module.h include spi/tegra: fix compilation error in spi-tegra.c spi: spi-dw: fix all sparse warnings spi/spi-pl022: Call pl022_dma_remove(pl022) only if enable_dma is true spi/spi-pl022: calculate_effective_freq() must set rate <= requested rate spi/spi-pl022: Don't allocate more sg than required. spi/spi-pl022: Use GFP_ATOMIC for allocation from tasklet spi/spi-pl022: Resolve formatting issues
Showing 33 changed files Side-by-side Diff
- drivers/spi/spi-altera.c
- drivers/spi/spi-ath79.c
- drivers/spi/spi-atmel.c
- drivers/spi/spi-bfin-sport.c
- drivers/spi/spi-bfin5xx.c
- drivers/spi/spi-coldfire-qspi.c
- drivers/spi/spi-davinci.c
- drivers/spi/spi-dw-mid.c
- drivers/spi/spi-dw-mmio.c
- drivers/spi/spi-dw.c
- drivers/spi/spi-dw.h
- drivers/spi/spi-ep93xx.c
- drivers/spi/spi-fsl-espi.c
- drivers/spi/spi-gpio.c
- drivers/spi/spi-imx.c
- drivers/spi/spi-mpc512x-psc.c
- drivers/spi/spi-mpc52xx-psc.c
- drivers/spi/spi-mpc52xx.c
- drivers/spi/spi-nuc900.c
- drivers/spi/spi-oc-tiny.c
- drivers/spi/spi-omap2-mcspi.c
- drivers/spi/spi-pl022.c
- drivers/spi/spi-ppc4xx.c
- drivers/spi/spi-s3c24xx.c
- drivers/spi/spi-sh-msiof.c
- drivers/spi/spi-sh-sci.c
- drivers/spi/spi-sh.c
- drivers/spi/spi-stmp.c
- drivers/spi/spi-tegra.c
- drivers/spi/spi-ti-ssp.c
- drivers/spi/spi-xilinx.c
- drivers/tty/serial/of_serial.c
- include/linux/platform_device.h
drivers/spi/spi-altera.c
... | ... | @@ -320,18 +320,7 @@ |
320 | 320 | .of_match_table = altera_spi_match, |
321 | 321 | }, |
322 | 322 | }; |
323 | - | |
324 | -static int __init altera_spi_init(void) | |
325 | -{ | |
326 | - return platform_driver_register(&altera_spi_driver); | |
327 | -} | |
328 | -module_init(altera_spi_init); | |
329 | - | |
330 | -static void __exit altera_spi_exit(void) | |
331 | -{ | |
332 | - platform_driver_unregister(&altera_spi_driver); | |
333 | -} | |
334 | -module_exit(altera_spi_exit); | |
323 | +module_platform_driver(altera_spi_driver); | |
335 | 324 | |
336 | 325 | MODULE_DESCRIPTION("Altera SPI driver"); |
337 | 326 | MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>"); |
drivers/spi/spi-ath79.c
... | ... | @@ -273,18 +273,7 @@ |
273 | 273 | .owner = THIS_MODULE, |
274 | 274 | }, |
275 | 275 | }; |
276 | - | |
277 | -static __init int ath79_spi_init(void) | |
278 | -{ | |
279 | - return platform_driver_register(&ath79_spi_driver); | |
280 | -} | |
281 | -module_init(ath79_spi_init); | |
282 | - | |
283 | -static __exit void ath79_spi_exit(void) | |
284 | -{ | |
285 | - platform_driver_unregister(&ath79_spi_driver); | |
286 | -} | |
287 | -module_exit(ath79_spi_exit); | |
276 | +module_platform_driver(ath79_spi_driver); | |
288 | 277 | |
289 | 278 | MODULE_DESCRIPTION("SPI controller driver for Atheros AR71XX/AR724X/AR913X"); |
290 | 279 | MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>"); |
drivers/spi/spi-atmel.c
... | ... | @@ -1074,18 +1074,7 @@ |
1074 | 1074 | .resume = atmel_spi_resume, |
1075 | 1075 | .remove = __exit_p(atmel_spi_remove), |
1076 | 1076 | }; |
1077 | - | |
1078 | -static int __init atmel_spi_init(void) | |
1079 | -{ | |
1080 | - return platform_driver_probe(&atmel_spi_driver, atmel_spi_probe); | |
1081 | -} | |
1082 | -module_init(atmel_spi_init); | |
1083 | - | |
1084 | -static void __exit atmel_spi_exit(void) | |
1085 | -{ | |
1086 | - platform_driver_unregister(&atmel_spi_driver); | |
1087 | -} | |
1088 | -module_exit(atmel_spi_exit); | |
1077 | +module_platform_driver(atmel_spi_driver); | |
1089 | 1078 | |
1090 | 1079 | MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver"); |
1091 | 1080 | MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); |
drivers/spi/spi-bfin-sport.c
... | ... | @@ -938,16 +938,5 @@ |
938 | 938 | .suspend = bfin_sport_spi_suspend, |
939 | 939 | .resume = bfin_sport_spi_resume, |
940 | 940 | }; |
941 | - | |
942 | -static int __init bfin_sport_spi_init(void) | |
943 | -{ | |
944 | - return platform_driver_register(&bfin_sport_spi_driver); | |
945 | -} | |
946 | -module_init(bfin_sport_spi_init); | |
947 | - | |
948 | -static void __exit bfin_sport_spi_exit(void) | |
949 | -{ | |
950 | - platform_driver_unregister(&bfin_sport_spi_driver); | |
951 | -} | |
952 | -module_exit(bfin_sport_spi_exit); | |
941 | +module_platform_driver(bfin_sport_spi_driver); |
drivers/spi/spi-bfin5xx.c
... | ... | @@ -1098,7 +1098,7 @@ |
1098 | 1098 | |
1099 | 1099 | if (chip->pio_interrupt && !drv_data->irq_requested) { |
1100 | 1100 | ret = request_irq(drv_data->spi_irq, bfin_spi_pio_irq_handler, |
1101 | - IRQF_DISABLED, "BFIN_SPI", drv_data); | |
1101 | + 0, "BFIN_SPI", drv_data); | |
1102 | 1102 | if (ret) { |
1103 | 1103 | dev_err(&spi->dev, "Unable to register spi IRQ\n"); |
1104 | 1104 | goto error; |
drivers/spi/spi-coldfire-qspi.c
... | ... | @@ -487,7 +487,7 @@ |
487 | 487 | goto fail2; |
488 | 488 | } |
489 | 489 | |
490 | - status = request_irq(mcfqspi->irq, mcfqspi_irq_handler, IRQF_DISABLED, | |
490 | + status = request_irq(mcfqspi->irq, mcfqspi_irq_handler, 0, | |
491 | 491 | pdev->name, mcfqspi); |
492 | 492 | if (status) { |
493 | 493 | dev_dbg(&pdev->dev, "request_irq failed\n"); |
494 | 494 | |
... | ... | @@ -621,20 +621,10 @@ |
621 | 621 | .driver.name = DRIVER_NAME, |
622 | 622 | .driver.owner = THIS_MODULE, |
623 | 623 | .driver.pm = MCFQSPI_DEV_PM_OPS, |
624 | + .probe = mcfqspi_probe, | |
624 | 625 | .remove = __devexit_p(mcfqspi_remove), |
625 | 626 | }; |
626 | - | |
627 | -static int __init mcfqspi_init(void) | |
628 | -{ | |
629 | - return platform_driver_probe(&mcfqspi_driver, mcfqspi_probe); | |
630 | -} | |
631 | -module_init(mcfqspi_init); | |
632 | - | |
633 | -static void __exit mcfqspi_exit(void) | |
634 | -{ | |
635 | - platform_driver_unregister(&mcfqspi_driver); | |
636 | -} | |
637 | -module_exit(mcfqspi_exit); | |
627 | +module_platform_driver(mcfqspi_driver); | |
638 | 628 | |
639 | 629 | MODULE_AUTHOR("Steven King <sfking@fdwdc.com>"); |
640 | 630 | MODULE_DESCRIPTION("Coldfire QSPI Controller Driver"); |
drivers/spi/spi-davinci.c
... | ... | @@ -799,7 +799,7 @@ |
799 | 799 | * It will invoke spi_bitbang_start to create work queue so that client driver |
800 | 800 | * can register transfer method to work queue. |
801 | 801 | */ |
802 | -static int davinci_spi_probe(struct platform_device *pdev) | |
802 | +static int __devinit davinci_spi_probe(struct platform_device *pdev) | |
803 | 803 | { |
804 | 804 | struct spi_master *master; |
805 | 805 | struct davinci_spi *dspi; |
... | ... | @@ -984,7 +984,7 @@ |
984 | 984 | * It will also call spi_bitbang_stop to destroy the work queue which was |
985 | 985 | * created by spi_bitbang_start. |
986 | 986 | */ |
987 | -static int __exit davinci_spi_remove(struct platform_device *pdev) | |
987 | +static int __devexit davinci_spi_remove(struct platform_device *pdev) | |
988 | 988 | { |
989 | 989 | struct davinci_spi *dspi; |
990 | 990 | struct spi_master *master; |
991 | 991 | |
... | ... | @@ -1011,20 +1011,10 @@ |
1011 | 1011 | .name = "spi_davinci", |
1012 | 1012 | .owner = THIS_MODULE, |
1013 | 1013 | }, |
1014 | - .remove = __exit_p(davinci_spi_remove), | |
1014 | + .probe = davinci_spi_probe, | |
1015 | + .remove = __devexit_p(davinci_spi_remove), | |
1015 | 1016 | }; |
1016 | - | |
1017 | -static int __init davinci_spi_init(void) | |
1018 | -{ | |
1019 | - return platform_driver_probe(&davinci_spi_driver, davinci_spi_probe); | |
1020 | -} | |
1021 | -module_init(davinci_spi_init); | |
1022 | - | |
1023 | -static void __exit davinci_spi_exit(void) | |
1024 | -{ | |
1025 | - platform_driver_unregister(&davinci_spi_driver); | |
1026 | -} | |
1027 | -module_exit(davinci_spi_exit); | |
1017 | +module_platform_driver(davinci_spi_driver); | |
1028 | 1018 | |
1029 | 1019 | MODULE_DESCRIPTION("TI DaVinci SPI Master Controller Driver"); |
1030 | 1020 | MODULE_LICENSE("GPL"); |
drivers/spi/spi-dw-mid.c
... | ... | @@ -116,13 +116,13 @@ |
116 | 116 | /* 1. setup DMA related registers */ |
117 | 117 | if (cs_change) { |
118 | 118 | spi_enable_chip(dws, 0); |
119 | - dw_writew(dws, dmardlr, 0xf); | |
120 | - dw_writew(dws, dmatdlr, 0x10); | |
119 | + dw_writew(dws, DW_SPI_DMARDLR, 0xf); | |
120 | + dw_writew(dws, DW_SPI_DMATDLR, 0x10); | |
121 | 121 | if (dws->tx_dma) |
122 | 122 | dma_ctrl |= 0x2; |
123 | 123 | if (dws->rx_dma) |
124 | 124 | dma_ctrl |= 0x1; |
125 | - dw_writew(dws, dmacr, dma_ctrl); | |
125 | + dw_writew(dws, DW_SPI_DMACR, dma_ctrl); | |
126 | 126 | spi_enable_chip(dws, 1); |
127 | 127 | } |
128 | 128 | |
... | ... | @@ -200,7 +200,8 @@ |
200 | 200 | |
201 | 201 | int dw_spi_mid_init(struct dw_spi *dws) |
202 | 202 | { |
203 | - u32 *clk_reg, clk_cdiv; | |
203 | + void __iomem *clk_reg; | |
204 | + u32 clk_cdiv; | |
204 | 205 | |
205 | 206 | clk_reg = ioremap_nocache(MRST_CLK_SPI0_REG, 16); |
206 | 207 | if (!clk_reg) |
drivers/spi/spi-dw-mmio.c
... | ... | @@ -127,24 +127,14 @@ |
127 | 127 | } |
128 | 128 | |
129 | 129 | static struct platform_driver dw_spi_mmio_driver = { |
130 | + .probe = dw_spi_mmio_probe, | |
130 | 131 | .remove = __devexit_p(dw_spi_mmio_remove), |
131 | 132 | .driver = { |
132 | 133 | .name = DRIVER_NAME, |
133 | 134 | .owner = THIS_MODULE, |
134 | 135 | }, |
135 | 136 | }; |
136 | - | |
137 | -static int __init dw_spi_mmio_init(void) | |
138 | -{ | |
139 | - return platform_driver_probe(&dw_spi_mmio_driver, dw_spi_mmio_probe); | |
140 | -} | |
141 | -module_init(dw_spi_mmio_init); | |
142 | - | |
143 | -static void __exit dw_spi_mmio_exit(void) | |
144 | -{ | |
145 | - platform_driver_unregister(&dw_spi_mmio_driver); | |
146 | -} | |
147 | -module_exit(dw_spi_mmio_exit); | |
137 | +module_platform_driver(dw_spi_mmio_driver); | |
148 | 138 | |
149 | 139 | MODULE_AUTHOR("Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>"); |
150 | 140 | MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core"); |
drivers/spi/spi-dw.c
... | ... | @@ -88,35 +88,35 @@ |
88 | 88 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
89 | 89 | "=================================\n"); |
90 | 90 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
91 | - "CTRL0: \t\t0x%08x\n", dw_readl(dws, ctrl0)); | |
91 | + "CTRL0: \t\t0x%08x\n", dw_readl(dws, DW_SPI_CTRL0)); | |
92 | 92 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
93 | - "CTRL1: \t\t0x%08x\n", dw_readl(dws, ctrl1)); | |
93 | + "CTRL1: \t\t0x%08x\n", dw_readl(dws, DW_SPI_CTRL1)); | |
94 | 94 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
95 | - "SSIENR: \t0x%08x\n", dw_readl(dws, ssienr)); | |
95 | + "SSIENR: \t0x%08x\n", dw_readl(dws, DW_SPI_SSIENR)); | |
96 | 96 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
97 | - "SER: \t\t0x%08x\n", dw_readl(dws, ser)); | |
97 | + "SER: \t\t0x%08x\n", dw_readl(dws, DW_SPI_SER)); | |
98 | 98 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
99 | - "BAUDR: \t\t0x%08x\n", dw_readl(dws, baudr)); | |
99 | + "BAUDR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_BAUDR)); | |
100 | 100 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
101 | - "TXFTLR: \t0x%08x\n", dw_readl(dws, txfltr)); | |
101 | + "TXFTLR: \t0x%08x\n", dw_readl(dws, DW_SPI_TXFLTR)); | |
102 | 102 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
103 | - "RXFTLR: \t0x%08x\n", dw_readl(dws, rxfltr)); | |
103 | + "RXFTLR: \t0x%08x\n", dw_readl(dws, DW_SPI_RXFLTR)); | |
104 | 104 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
105 | - "TXFLR: \t\t0x%08x\n", dw_readl(dws, txflr)); | |
105 | + "TXFLR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_TXFLR)); | |
106 | 106 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
107 | - "RXFLR: \t\t0x%08x\n", dw_readl(dws, rxflr)); | |
107 | + "RXFLR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_RXFLR)); | |
108 | 108 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
109 | - "SR: \t\t0x%08x\n", dw_readl(dws, sr)); | |
109 | + "SR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_SR)); | |
110 | 110 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
111 | - "IMR: \t\t0x%08x\n", dw_readl(dws, imr)); | |
111 | + "IMR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_IMR)); | |
112 | 112 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
113 | - "ISR: \t\t0x%08x\n", dw_readl(dws, isr)); | |
113 | + "ISR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_ISR)); | |
114 | 114 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
115 | - "DMACR: \t\t0x%08x\n", dw_readl(dws, dmacr)); | |
115 | + "DMACR: \t\t0x%08x\n", dw_readl(dws, DW_SPI_DMACR)); | |
116 | 116 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
117 | - "DMATDLR: \t0x%08x\n", dw_readl(dws, dmatdlr)); | |
117 | + "DMATDLR: \t0x%08x\n", dw_readl(dws, DW_SPI_DMATDLR)); | |
118 | 118 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
119 | - "DMARDLR: \t0x%08x\n", dw_readl(dws, dmardlr)); | |
119 | + "DMARDLR: \t0x%08x\n", dw_readl(dws, DW_SPI_DMARDLR)); | |
120 | 120 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
121 | 121 | "=================================\n"); |
122 | 122 | |
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | u32 tx_left, tx_room, rxtx_gap; |
167 | 167 | |
168 | 168 | tx_left = (dws->tx_end - dws->tx) / dws->n_bytes; |
169 | - tx_room = dws->fifo_len - dw_readw(dws, txflr); | |
169 | + tx_room = dws->fifo_len - dw_readw(dws, DW_SPI_TXFLR); | |
170 | 170 | |
171 | 171 | /* |
172 | 172 | * Another concern is about the tx/rx mismatch, we |
... | ... | @@ -187,7 +187,7 @@ |
187 | 187 | { |
188 | 188 | u32 rx_left = (dws->rx_end - dws->rx) / dws->n_bytes; |
189 | 189 | |
190 | - return min(rx_left, (u32)dw_readw(dws, rxflr)); | |
190 | + return min(rx_left, (u32)dw_readw(dws, DW_SPI_RXFLR)); | |
191 | 191 | } |
192 | 192 | |
193 | 193 | static void dw_writer(struct dw_spi *dws) |
... | ... | @@ -203,7 +203,7 @@ |
203 | 203 | else |
204 | 204 | txw = *(u16 *)(dws->tx); |
205 | 205 | } |
206 | - dw_writew(dws, dr, txw); | |
206 | + dw_writew(dws, DW_SPI_DR, txw); | |
207 | 207 | dws->tx += dws->n_bytes; |
208 | 208 | } |
209 | 209 | } |
... | ... | @@ -214,7 +214,7 @@ |
214 | 214 | u16 rxw; |
215 | 215 | |
216 | 216 | while (max--) { |
217 | - rxw = dw_readw(dws, dr); | |
217 | + rxw = dw_readw(dws, DW_SPI_DR); | |
218 | 218 | /* Care rx only if the transfer's original "rx" is not null */ |
219 | 219 | if (dws->rx_end - dws->len) { |
220 | 220 | if (dws->n_bytes == 1) |
221 | 221 | |
... | ... | @@ -322,13 +322,13 @@ |
322 | 322 | |
323 | 323 | static irqreturn_t interrupt_transfer(struct dw_spi *dws) |
324 | 324 | { |
325 | - u16 irq_status = dw_readw(dws, isr); | |
325 | + u16 irq_status = dw_readw(dws, DW_SPI_ISR); | |
326 | 326 | |
327 | 327 | /* Error handling */ |
328 | 328 | if (irq_status & (SPI_INT_TXOI | SPI_INT_RXOI | SPI_INT_RXUI)) { |
329 | - dw_readw(dws, txoicr); | |
330 | - dw_readw(dws, rxoicr); | |
331 | - dw_readw(dws, rxuicr); | |
329 | + dw_readw(dws, DW_SPI_TXOICR); | |
330 | + dw_readw(dws, DW_SPI_RXOICR); | |
331 | + dw_readw(dws, DW_SPI_RXUICR); | |
332 | 332 | int_error_stop(dws, "interrupt_transfer: fifo overrun/underrun"); |
333 | 333 | return IRQ_HANDLED; |
334 | 334 | } |
... | ... | @@ -352,7 +352,7 @@ |
352 | 352 | static irqreturn_t dw_spi_irq(int irq, void *dev_id) |
353 | 353 | { |
354 | 354 | struct dw_spi *dws = dev_id; |
355 | - u16 irq_status = dw_readw(dws, isr) & 0x3f; | |
355 | + u16 irq_status = dw_readw(dws, DW_SPI_ISR) & 0x3f; | |
356 | 356 | |
357 | 357 | if (!irq_status) |
358 | 358 | return IRQ_NONE; |
359 | 359 | |
... | ... | @@ -520,11 +520,11 @@ |
520 | 520 | * 2. clk_div is changed |
521 | 521 | * 3. control value changes |
522 | 522 | */ |
523 | - if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) { | |
523 | + if (dw_readw(dws, DW_SPI_CTRL0) != cr0 || cs_change || clk_div || imask) { | |
524 | 524 | spi_enable_chip(dws, 0); |
525 | 525 | |
526 | - if (dw_readw(dws, ctrl0) != cr0) | |
527 | - dw_writew(dws, ctrl0, cr0); | |
526 | + if (dw_readw(dws, DW_SPI_CTRL0) != cr0) | |
527 | + dw_writew(dws, DW_SPI_CTRL0, cr0); | |
528 | 528 | |
529 | 529 | spi_set_clk(dws, clk_div ? clk_div : chip->clk_div); |
530 | 530 | spi_chip_sel(dws, spi->chip_select); |
... | ... | @@ -534,7 +534,7 @@ |
534 | 534 | if (imask) |
535 | 535 | spi_umask_intr(dws, imask); |
536 | 536 | if (txint_level) |
537 | - dw_writew(dws, txfltr, txint_level); | |
537 | + dw_writew(dws, DW_SPI_TXFLTR, txint_level); | |
538 | 538 | |
539 | 539 | spi_enable_chip(dws, 1); |
540 | 540 | if (cs_change) |
541 | 541 | |
... | ... | @@ -790,13 +790,13 @@ |
790 | 790 | if (!dws->fifo_len) { |
791 | 791 | u32 fifo; |
792 | 792 | for (fifo = 2; fifo <= 257; fifo++) { |
793 | - dw_writew(dws, txfltr, fifo); | |
794 | - if (fifo != dw_readw(dws, txfltr)) | |
793 | + dw_writew(dws, DW_SPI_TXFLTR, fifo); | |
794 | + if (fifo != dw_readw(dws, DW_SPI_TXFLTR)) | |
795 | 795 | break; |
796 | 796 | } |
797 | 797 | |
798 | 798 | dws->fifo_len = (fifo == 257) ? 0 : fifo; |
799 | - dw_writew(dws, txfltr, 0); | |
799 | + dw_writew(dws, DW_SPI_TXFLTR, 0); | |
800 | 800 | } |
801 | 801 | } |
802 | 802 |
drivers/spi/spi-dw.h
... | ... | @@ -4,6 +4,33 @@ |
4 | 4 | #include <linux/io.h> |
5 | 5 | #include <linux/scatterlist.h> |
6 | 6 | |
7 | +/* Register offsets */ | |
8 | +#define DW_SPI_CTRL0 0x00 | |
9 | +#define DW_SPI_CTRL1 0x04 | |
10 | +#define DW_SPI_SSIENR 0x08 | |
11 | +#define DW_SPI_MWCR 0x0c | |
12 | +#define DW_SPI_SER 0x10 | |
13 | +#define DW_SPI_BAUDR 0x14 | |
14 | +#define DW_SPI_TXFLTR 0x18 | |
15 | +#define DW_SPI_RXFLTR 0x1c | |
16 | +#define DW_SPI_TXFLR 0x20 | |
17 | +#define DW_SPI_RXFLR 0x24 | |
18 | +#define DW_SPI_SR 0x28 | |
19 | +#define DW_SPI_IMR 0x2c | |
20 | +#define DW_SPI_ISR 0x30 | |
21 | +#define DW_SPI_RISR 0x34 | |
22 | +#define DW_SPI_TXOICR 0x38 | |
23 | +#define DW_SPI_RXOICR 0x3c | |
24 | +#define DW_SPI_RXUICR 0x40 | |
25 | +#define DW_SPI_MSTICR 0x44 | |
26 | +#define DW_SPI_ICR 0x48 | |
27 | +#define DW_SPI_DMACR 0x4c | |
28 | +#define DW_SPI_DMATDLR 0x50 | |
29 | +#define DW_SPI_DMARDLR 0x54 | |
30 | +#define DW_SPI_IDR 0x58 | |
31 | +#define DW_SPI_VERSION 0x5c | |
32 | +#define DW_SPI_DR 0x60 | |
33 | + | |
7 | 34 | /* Bit fields in CTRLR0 */ |
8 | 35 | #define SPI_DFS_OFFSET 0 |
9 | 36 | |
... | ... | @@ -55,35 +82,6 @@ |
55 | 82 | SSI_NS_MICROWIRE, |
56 | 83 | }; |
57 | 84 | |
58 | -struct dw_spi_reg { | |
59 | - u32 ctrl0; | |
60 | - u32 ctrl1; | |
61 | - u32 ssienr; | |
62 | - u32 mwcr; | |
63 | - u32 ser; | |
64 | - u32 baudr; | |
65 | - u32 txfltr; | |
66 | - u32 rxfltr; | |
67 | - u32 txflr; | |
68 | - u32 rxflr; | |
69 | - u32 sr; | |
70 | - u32 imr; | |
71 | - u32 isr; | |
72 | - u32 risr; | |
73 | - u32 txoicr; | |
74 | - u32 rxoicr; | |
75 | - u32 rxuicr; | |
76 | - u32 msticr; | |
77 | - u32 icr; | |
78 | - u32 dmacr; | |
79 | - u32 dmatdlr; | |
80 | - u32 dmardlr; | |
81 | - u32 idr; | |
82 | - u32 version; | |
83 | - u32 dr; /* Currently oper as 32 bits, | |
84 | - though only low 16 bits matters */ | |
85 | -} __packed; | |
86 | - | |
87 | 85 | struct dw_spi; |
88 | 86 | struct dw_spi_dma_ops { |
89 | 87 | int (*dma_init)(struct dw_spi *dws); |
90 | 88 | |
91 | 89 | |
92 | 90 | |
... | ... | @@ -161,23 +159,34 @@ |
161 | 159 | #endif |
162 | 160 | }; |
163 | 161 | |
164 | -#define dw_readl(dw, name) \ | |
165 | - __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name)) | |
166 | -#define dw_writel(dw, name, val) \ | |
167 | - __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name)) | |
168 | -#define dw_readw(dw, name) \ | |
169 | - __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name)) | |
170 | -#define dw_writew(dw, name, val) \ | |
171 | - __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name)) | |
162 | +static inline u32 dw_readl(struct dw_spi *dws, u32 offset) | |
163 | +{ | |
164 | + return __raw_readl(dws->regs + offset); | |
165 | +} | |
172 | 166 | |
167 | +static inline void dw_writel(struct dw_spi *dws, u32 offset, u32 val) | |
168 | +{ | |
169 | + __raw_writel(val, dws->regs + offset); | |
170 | +} | |
171 | + | |
172 | +static inline u16 dw_readw(struct dw_spi *dws, u32 offset) | |
173 | +{ | |
174 | + return __raw_readw(dws->regs + offset); | |
175 | +} | |
176 | + | |
177 | +static inline void dw_writew(struct dw_spi *dws, u32 offset, u16 val) | |
178 | +{ | |
179 | + __raw_writew(val, dws->regs + offset); | |
180 | +} | |
181 | + | |
173 | 182 | static inline void spi_enable_chip(struct dw_spi *dws, int enable) |
174 | 183 | { |
175 | - dw_writel(dws, ssienr, (enable ? 1 : 0)); | |
184 | + dw_writel(dws, DW_SPI_SSIENR, (enable ? 1 : 0)); | |
176 | 185 | } |
177 | 186 | |
178 | 187 | static inline void spi_set_clk(struct dw_spi *dws, u16 div) |
179 | 188 | { |
180 | - dw_writel(dws, baudr, div); | |
189 | + dw_writel(dws, DW_SPI_BAUDR, div); | |
181 | 190 | } |
182 | 191 | |
183 | 192 | static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) |
... | ... | @@ -188,7 +197,7 @@ |
188 | 197 | if (dws->cs_control) |
189 | 198 | dws->cs_control(1); |
190 | 199 | |
191 | - dw_writel(dws, ser, 1 << cs); | |
200 | + dw_writel(dws, DW_SPI_SER, 1 << cs); | |
192 | 201 | } |
193 | 202 | |
194 | 203 | /* Disable IRQ bits */ |
... | ... | @@ -196,8 +205,8 @@ |
196 | 205 | { |
197 | 206 | u32 new_mask; |
198 | 207 | |
199 | - new_mask = dw_readl(dws, imr) & ~mask; | |
200 | - dw_writel(dws, imr, new_mask); | |
208 | + new_mask = dw_readl(dws, DW_SPI_IMR) & ~mask; | |
209 | + dw_writel(dws, DW_SPI_IMR, new_mask); | |
201 | 210 | } |
202 | 211 | |
203 | 212 | /* Enable IRQ bits */ |
... | ... | @@ -205,8 +214,8 @@ |
205 | 214 | { |
206 | 215 | u32 new_mask; |
207 | 216 | |
208 | - new_mask = dw_readl(dws, imr) | mask; | |
209 | - dw_writel(dws, imr, new_mask); | |
217 | + new_mask = dw_readl(dws, DW_SPI_IMR) | mask; | |
218 | + dw_writel(dws, DW_SPI_IMR, new_mask); | |
210 | 219 | } |
211 | 220 | |
212 | 221 | /* |
drivers/spi/spi-ep93xx.c
... | ... | @@ -24,6 +24,7 @@ |
24 | 24 | #include <linux/dmaengine.h> |
25 | 25 | #include <linux/bitops.h> |
26 | 26 | #include <linux/interrupt.h> |
27 | +#include <linux/module.h> | |
27 | 28 | #include <linux/platform_device.h> |
28 | 29 | #include <linux/workqueue.h> |
29 | 30 | #include <linux/sched.h> |
... | ... | @@ -1025,7 +1026,7 @@ |
1025 | 1026 | free_page((unsigned long)espi->zeropage); |
1026 | 1027 | } |
1027 | 1028 | |
1028 | -static int __init ep93xx_spi_probe(struct platform_device *pdev) | |
1029 | +static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | |
1029 | 1030 | { |
1030 | 1031 | struct spi_master *master; |
1031 | 1032 | struct ep93xx_spi_info *info; |
... | ... | @@ -1150,7 +1151,7 @@ |
1150 | 1151 | return error; |
1151 | 1152 | } |
1152 | 1153 | |
1153 | -static int __exit ep93xx_spi_remove(struct platform_device *pdev) | |
1154 | +static int __devexit ep93xx_spi_remove(struct platform_device *pdev) | |
1154 | 1155 | { |
1155 | 1156 | struct spi_master *master = platform_get_drvdata(pdev); |
1156 | 1157 | struct ep93xx_spi *espi = spi_master_get_devdata(master); |
1157 | 1158 | |
... | ... | @@ -1196,20 +1197,10 @@ |
1196 | 1197 | .name = "ep93xx-spi", |
1197 | 1198 | .owner = THIS_MODULE, |
1198 | 1199 | }, |
1199 | - .remove = __exit_p(ep93xx_spi_remove), | |
1200 | + .probe = ep93xx_spi_probe, | |
1201 | + .remove = __devexit_p(ep93xx_spi_remove), | |
1200 | 1202 | }; |
1201 | - | |
1202 | -static int __init ep93xx_spi_init(void) | |
1203 | -{ | |
1204 | - return platform_driver_probe(&ep93xx_spi_driver, ep93xx_spi_probe); | |
1205 | -} | |
1206 | -module_init(ep93xx_spi_init); | |
1207 | - | |
1208 | -static void __exit ep93xx_spi_exit(void) | |
1209 | -{ | |
1210 | - platform_driver_unregister(&ep93xx_spi_driver); | |
1211 | -} | |
1212 | -module_exit(ep93xx_spi_exit); | |
1203 | +module_platform_driver(ep93xx_spi_driver); | |
1213 | 1204 | |
1214 | 1205 | MODULE_DESCRIPTION("EP93xx SPI Controller driver"); |
1215 | 1206 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>"); |
drivers/spi/spi-fsl-espi.c
... | ... | @@ -744,18 +744,7 @@ |
744 | 744 | .probe = of_fsl_espi_probe, |
745 | 745 | .remove = __devexit_p(of_fsl_espi_remove), |
746 | 746 | }; |
747 | - | |
748 | -static int __init fsl_espi_init(void) | |
749 | -{ | |
750 | - return platform_driver_register(&fsl_espi_driver); | |
751 | -} | |
752 | -module_init(fsl_espi_init); | |
753 | - | |
754 | -static void __exit fsl_espi_exit(void) | |
755 | -{ | |
756 | - platform_driver_unregister(&fsl_espi_driver); | |
757 | -} | |
758 | -module_exit(fsl_espi_exit); | |
747 | +module_platform_driver(fsl_espi_driver); | |
759 | 748 | |
760 | 749 | MODULE_AUTHOR("Mingkai Hu"); |
761 | 750 | MODULE_DESCRIPTION("Enhanced Freescale SPI Driver"); |
drivers/spi/spi-gpio.c
... | ... | @@ -311,7 +311,7 @@ |
311 | 311 | return value; |
312 | 312 | } |
313 | 313 | |
314 | -static int __init spi_gpio_probe(struct platform_device *pdev) | |
314 | +static int __devinit spi_gpio_probe(struct platform_device *pdev) | |
315 | 315 | { |
316 | 316 | int status; |
317 | 317 | struct spi_master *master; |
... | ... | @@ -379,7 +379,7 @@ |
379 | 379 | return status; |
380 | 380 | } |
381 | 381 | |
382 | -static int __exit spi_gpio_remove(struct platform_device *pdev) | |
382 | +static int __devexit spi_gpio_remove(struct platform_device *pdev) | |
383 | 383 | { |
384 | 384 | struct spi_gpio *spi_gpio; |
385 | 385 | struct spi_gpio_platform_data *pdata; |
386 | 386 | |
... | ... | @@ -408,21 +408,10 @@ |
408 | 408 | static struct platform_driver spi_gpio_driver = { |
409 | 409 | .driver.name = DRIVER_NAME, |
410 | 410 | .driver.owner = THIS_MODULE, |
411 | - .remove = __exit_p(spi_gpio_remove), | |
411 | + .probe = spi_gpio_probe, | |
412 | + .remove = __devexit_p(spi_gpio_remove), | |
412 | 413 | }; |
413 | - | |
414 | -static int __init spi_gpio_init(void) | |
415 | -{ | |
416 | - return platform_driver_probe(&spi_gpio_driver, spi_gpio_probe); | |
417 | -} | |
418 | -module_init(spi_gpio_init); | |
419 | - | |
420 | -static void __exit spi_gpio_exit(void) | |
421 | -{ | |
422 | - platform_driver_unregister(&spi_gpio_driver); | |
423 | -} | |
424 | -module_exit(spi_gpio_exit); | |
425 | - | |
414 | +module_platform_driver(spi_gpio_driver); | |
426 | 415 | |
427 | 416 | MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO "); |
428 | 417 | MODULE_AUTHOR("David Brownell"); |
drivers/spi/spi-imx.c
... | ... | @@ -929,19 +929,7 @@ |
929 | 929 | .probe = spi_imx_probe, |
930 | 930 | .remove = __devexit_p(spi_imx_remove), |
931 | 931 | }; |
932 | - | |
933 | -static int __init spi_imx_init(void) | |
934 | -{ | |
935 | - return platform_driver_register(&spi_imx_driver); | |
936 | -} | |
937 | - | |
938 | -static void __exit spi_imx_exit(void) | |
939 | -{ | |
940 | - platform_driver_unregister(&spi_imx_driver); | |
941 | -} | |
942 | - | |
943 | -module_init(spi_imx_init); | |
944 | -module_exit(spi_imx_exit); | |
932 | +module_platform_driver(spi_imx_driver); | |
945 | 933 | |
946 | 934 | MODULE_DESCRIPTION("SPI Master Controller driver"); |
947 | 935 | MODULE_AUTHOR("Sascha Hauer, Pengutronix"); |
drivers/spi/spi-mpc512x-psc.c
... | ... | @@ -559,18 +559,7 @@ |
559 | 559 | .of_match_table = mpc512x_psc_spi_of_match, |
560 | 560 | }, |
561 | 561 | }; |
562 | - | |
563 | -static int __init mpc512x_psc_spi_init(void) | |
564 | -{ | |
565 | - return platform_driver_register(&mpc512x_psc_spi_of_driver); | |
566 | -} | |
567 | -module_init(mpc512x_psc_spi_init); | |
568 | - | |
569 | -static void __exit mpc512x_psc_spi_exit(void) | |
570 | -{ | |
571 | - platform_driver_unregister(&mpc512x_psc_spi_of_driver); | |
572 | -} | |
573 | -module_exit(mpc512x_psc_spi_exit); | |
562 | +module_platform_driver(mpc512x_psc_spi_of_driver); | |
574 | 563 | |
575 | 564 | MODULE_AUTHOR("John Rigby"); |
576 | 565 | MODULE_DESCRIPTION("MPC512x PSC SPI Driver"); |
drivers/spi/spi-mpc52xx-psc.c
... | ... | @@ -511,18 +511,7 @@ |
511 | 511 | .of_match_table = mpc52xx_psc_spi_of_match, |
512 | 512 | }, |
513 | 513 | }; |
514 | - | |
515 | -static int __init mpc52xx_psc_spi_init(void) | |
516 | -{ | |
517 | - return platform_driver_register(&mpc52xx_psc_spi_of_driver); | |
518 | -} | |
519 | -module_init(mpc52xx_psc_spi_init); | |
520 | - | |
521 | -static void __exit mpc52xx_psc_spi_exit(void) | |
522 | -{ | |
523 | - platform_driver_unregister(&mpc52xx_psc_spi_of_driver); | |
524 | -} | |
525 | -module_exit(mpc52xx_psc_spi_exit); | |
514 | +module_platform_driver(mpc52xx_psc_spi_of_driver); | |
526 | 515 | |
527 | 516 | MODULE_AUTHOR("Dragos Carp"); |
528 | 517 | MODULE_DESCRIPTION("MPC52xx PSC SPI Driver"); |
drivers/spi/spi-mpc52xx.c
... | ... | @@ -564,16 +564,5 @@ |
564 | 564 | .probe = mpc52xx_spi_probe, |
565 | 565 | .remove = __devexit_p(mpc52xx_spi_remove), |
566 | 566 | }; |
567 | - | |
568 | -static int __init mpc52xx_spi_init(void) | |
569 | -{ | |
570 | - return platform_driver_register(&mpc52xx_spi_of_driver); | |
571 | -} | |
572 | -module_init(mpc52xx_spi_init); | |
573 | - | |
574 | -static void __exit mpc52xx_spi_exit(void) | |
575 | -{ | |
576 | - platform_driver_unregister(&mpc52xx_spi_of_driver); | |
577 | -} | |
578 | -module_exit(mpc52xx_spi_exit); | |
567 | +module_platform_driver(mpc52xx_spi_of_driver); |
drivers/spi/spi-nuc900.c
... | ... | @@ -484,19 +484,7 @@ |
484 | 484 | .owner = THIS_MODULE, |
485 | 485 | }, |
486 | 486 | }; |
487 | - | |
488 | -static int __init nuc900_spi_init(void) | |
489 | -{ | |
490 | - return platform_driver_register(&nuc900_spi_driver); | |
491 | -} | |
492 | - | |
493 | -static void __exit nuc900_spi_exit(void) | |
494 | -{ | |
495 | - platform_driver_unregister(&nuc900_spi_driver); | |
496 | -} | |
497 | - | |
498 | -module_init(nuc900_spi_init); | |
499 | -module_exit(nuc900_spi_exit); | |
487 | +module_platform_driver(nuc900_spi_driver); | |
500 | 488 | |
501 | 489 | MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); |
502 | 490 | MODULE_DESCRIPTION("nuc900 spi driver!"); |
drivers/spi/spi-oc-tiny.c
... | ... | @@ -406,18 +406,7 @@ |
406 | 406 | .of_match_table = tiny_spi_match, |
407 | 407 | }, |
408 | 408 | }; |
409 | - | |
410 | -static int __init tiny_spi_init(void) | |
411 | -{ | |
412 | - return platform_driver_register(&tiny_spi_driver); | |
413 | -} | |
414 | -module_init(tiny_spi_init); | |
415 | - | |
416 | -static void __exit tiny_spi_exit(void) | |
417 | -{ | |
418 | - platform_driver_unregister(&tiny_spi_driver); | |
419 | -} | |
420 | -module_exit(tiny_spi_exit); | |
409 | +module_platform_driver(tiny_spi_driver); | |
421 | 410 | |
422 | 411 | MODULE_DESCRIPTION("OpenCores tiny SPI driver"); |
423 | 412 | MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>"); |
drivers/spi/spi-omap2-mcspi.c
... | ... | @@ -1116,15 +1116,16 @@ |
1116 | 1116 | status = -ENODEV; |
1117 | 1117 | goto err1; |
1118 | 1118 | } |
1119 | + | |
1120 | + r->start += pdata->regs_offset; | |
1121 | + r->end += pdata->regs_offset; | |
1122 | + mcspi->phys = r->start; | |
1119 | 1123 | if (!request_mem_region(r->start, resource_size(r), |
1120 | 1124 | dev_name(&pdev->dev))) { |
1121 | 1125 | status = -EBUSY; |
1122 | 1126 | goto err1; |
1123 | 1127 | } |
1124 | 1128 | |
1125 | - r->start += pdata->regs_offset; | |
1126 | - r->end += pdata->regs_offset; | |
1127 | - mcspi->phys = r->start; | |
1128 | 1129 | mcspi->base = ioremap(r->start, resource_size(r)); |
1129 | 1130 | if (!mcspi->base) { |
1130 | 1131 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); |
drivers/spi/spi-pl022.c
... | ... | @@ -113,7 +113,6 @@ |
113 | 113 | #define SSP_CR0_MASK_CSS_ST (0x1FUL << 16) |
114 | 114 | #define SSP_CR0_MASK_FRF_ST (0x3UL << 21) |
115 | 115 | |
116 | - | |
117 | 116 | /* |
118 | 117 | * SSP Control Register 0 - SSP_CR1 |
119 | 118 | */ |
... | ... | @@ -283,7 +282,6 @@ |
283 | 282 | |
284 | 283 | #define SPI_POLLING_TIMEOUT 1000 |
285 | 284 | |
286 | - | |
287 | 285 | /* |
288 | 286 | * The type of reading going on on this chip |
289 | 287 | */ |
... | ... | @@ -749,7 +747,6 @@ |
749 | 747 | */ |
750 | 748 | } |
751 | 749 | |
752 | - | |
753 | 750 | /** |
754 | 751 | * next_transfer - Move to the Next transfer in the current spi message |
755 | 752 | * @pl022: SSP driver private data structure |
756 | 753 | |
757 | 754 | |
... | ... | @@ -1016,14 +1013,14 @@ |
1016 | 1013 | dmaengine_slave_config(txchan, &tx_conf); |
1017 | 1014 | |
1018 | 1015 | /* Create sglists for the transfers */ |
1019 | - pages = (pl022->cur_transfer->len >> PAGE_SHIFT) + 1; | |
1016 | + pages = DIV_ROUND_UP(pl022->cur_transfer->len, PAGE_SIZE); | |
1020 | 1017 | dev_dbg(&pl022->adev->dev, "using %d pages for transfer\n", pages); |
1021 | 1018 | |
1022 | - ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_KERNEL); | |
1019 | + ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_ATOMIC); | |
1023 | 1020 | if (ret) |
1024 | 1021 | goto err_alloc_rx_sg; |
1025 | 1022 | |
1026 | - ret = sg_alloc_table(&pl022->sgt_tx, pages, GFP_KERNEL); | |
1023 | + ret = sg_alloc_table(&pl022->sgt_tx, pages, GFP_ATOMIC); | |
1027 | 1024 | if (ret) |
1028 | 1025 | goto err_alloc_tx_sg; |
1029 | 1026 | |
... | ... | @@ -1531,8 +1528,7 @@ |
1531 | 1528 | /* Initial message state */ |
1532 | 1529 | pl022->cur_msg->state = STATE_START; |
1533 | 1530 | pl022->cur_transfer = list_entry(pl022->cur_msg->transfers.next, |
1534 | - struct spi_transfer, | |
1535 | - transfer_list); | |
1531 | + struct spi_transfer, transfer_list); | |
1536 | 1532 | |
1537 | 1533 | /* Setup the SPI using the per chip configuration */ |
1538 | 1534 | pl022->cur_chip = spi_get_ctldata(pl022->cur_msg->spi); |
... | ... | @@ -1551,7 +1547,6 @@ |
1551 | 1547 | do_interrupt_dma_transfer(pl022); |
1552 | 1548 | } |
1553 | 1549 | |
1554 | - | |
1555 | 1550 | static int __init init_queue(struct pl022 *pl022) |
1556 | 1551 | { |
1557 | 1552 | INIT_LIST_HEAD(&pl022->queue); |
... | ... | @@ -1560,8 +1555,8 @@ |
1560 | 1555 | pl022->running = false; |
1561 | 1556 | pl022->busy = false; |
1562 | 1557 | |
1563 | - tasklet_init(&pl022->pump_transfers, | |
1564 | - pump_transfers, (unsigned long)pl022); | |
1558 | + tasklet_init(&pl022->pump_transfers, pump_transfers, | |
1559 | + (unsigned long)pl022); | |
1565 | 1560 | |
1566 | 1561 | INIT_WORK(&pl022->pump_messages, pump_messages); |
1567 | 1562 | pl022->workqueue = create_singlethread_workqueue( |
... | ... | @@ -1572,7 +1567,6 @@ |
1572 | 1567 | return 0; |
1573 | 1568 | } |
1574 | 1569 | |
1575 | - | |
1576 | 1570 | static int start_queue(struct pl022 *pl022) |
1577 | 1571 | { |
1578 | 1572 | unsigned long flags; |
... | ... | @@ -1595,7 +1589,6 @@ |
1595 | 1589 | return 0; |
1596 | 1590 | } |
1597 | 1591 | |
1598 | - | |
1599 | 1592 | static int stop_queue(struct pl022 *pl022) |
1600 | 1593 | { |
1601 | 1594 | unsigned long flags; |
1602 | 1595 | |
1603 | 1596 | |
1604 | 1597 | |
1605 | 1598 | |
1606 | 1599 | |
1607 | 1600 | |
1608 | 1601 | |
... | ... | @@ -1791,71 +1784,70 @@ |
1791 | 1784 | return 0; |
1792 | 1785 | } |
1793 | 1786 | |
1794 | -static int calculate_effective_freq(struct pl022 *pl022, | |
1795 | - int freq, | |
1796 | - struct ssp_clock_params *clk_freq) | |
1787 | +static inline u32 spi_rate(u32 rate, u16 cpsdvsr, u16 scr) | |
1797 | 1788 | { |
1789 | + return rate / (cpsdvsr * (1 + scr)); | |
1790 | +} | |
1791 | + | |
1792 | +static int calculate_effective_freq(struct pl022 *pl022, int freq, struct | |
1793 | + ssp_clock_params * clk_freq) | |
1794 | +{ | |
1798 | 1795 | /* Lets calculate the frequency parameters */ |
1799 | - u16 cpsdvsr = 2; | |
1800 | - u16 scr = 0; | |
1801 | - bool freq_found = false; | |
1802 | - u32 rate; | |
1803 | - u32 max_tclk; | |
1804 | - u32 min_tclk; | |
1796 | + u16 cpsdvsr = CPSDVR_MIN, scr = SCR_MIN; | |
1797 | + u32 rate, max_tclk, min_tclk, best_freq = 0, best_cpsdvsr = 0, | |
1798 | + best_scr = 0, tmp, found = 0; | |
1805 | 1799 | |
1806 | 1800 | rate = clk_get_rate(pl022->clk); |
1807 | 1801 | /* cpsdvscr = 2 & scr 0 */ |
1808 | - max_tclk = (rate / (CPSDVR_MIN * (1 + SCR_MIN))); | |
1802 | + max_tclk = spi_rate(rate, CPSDVR_MIN, SCR_MIN); | |
1809 | 1803 | /* cpsdvsr = 254 & scr = 255 */ |
1810 | - min_tclk = (rate / (CPSDVR_MAX * (1 + SCR_MAX))); | |
1804 | + min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX); | |
1811 | 1805 | |
1812 | - if ((freq <= max_tclk) && (freq >= min_tclk)) { | |
1813 | - while (cpsdvsr <= CPSDVR_MAX && !freq_found) { | |
1814 | - while (scr <= SCR_MAX && !freq_found) { | |
1815 | - if ((rate / | |
1816 | - (cpsdvsr * (1 + scr))) > freq) | |
1817 | - scr += 1; | |
1818 | - else { | |
1819 | - /* | |
1820 | - * This bool is made true when | |
1821 | - * effective frequency >= | |
1822 | - * target frequency is found | |
1823 | - */ | |
1824 | - freq_found = true; | |
1825 | - if ((rate / | |
1826 | - (cpsdvsr * (1 + scr))) != freq) { | |
1827 | - if (scr == SCR_MIN) { | |
1828 | - cpsdvsr -= 2; | |
1829 | - scr = SCR_MAX; | |
1830 | - } else | |
1831 | - scr -= 1; | |
1832 | - } | |
1833 | - } | |
1834 | - } | |
1835 | - if (!freq_found) { | |
1836 | - cpsdvsr += 2; | |
1837 | - scr = SCR_MIN; | |
1838 | - } | |
1839 | - } | |
1840 | - if (cpsdvsr != 0) { | |
1841 | - dev_dbg(&pl022->adev->dev, | |
1842 | - "SSP Effective Frequency is %u\n", | |
1843 | - (rate / (cpsdvsr * (1 + scr)))); | |
1844 | - clk_freq->cpsdvsr = (u8) (cpsdvsr & 0xFF); | |
1845 | - clk_freq->scr = (u8) (scr & 0xFF); | |
1846 | - dev_dbg(&pl022->adev->dev, | |
1847 | - "SSP cpsdvsr = %d, scr = %d\n", | |
1848 | - clk_freq->cpsdvsr, clk_freq->scr); | |
1849 | - } | |
1850 | - } else { | |
1806 | + if (!((freq <= max_tclk) && (freq >= min_tclk))) { | |
1851 | 1807 | dev_err(&pl022->adev->dev, |
1852 | 1808 | "controller data is incorrect: out of range frequency"); |
1853 | 1809 | return -EINVAL; |
1854 | 1810 | } |
1811 | + | |
1812 | + /* | |
1813 | + * best_freq will give closest possible available rate (<= requested | |
1814 | + * freq) for all values of scr & cpsdvsr. | |
1815 | + */ | |
1816 | + while ((cpsdvsr <= CPSDVR_MAX) && !found) { | |
1817 | + while (scr <= SCR_MAX) { | |
1818 | + tmp = spi_rate(rate, cpsdvsr, scr); | |
1819 | + | |
1820 | + if (tmp > freq) | |
1821 | + scr++; | |
1822 | + /* | |
1823 | + * If found exact value, update and break. | |
1824 | + * If found more closer value, update and continue. | |
1825 | + */ | |
1826 | + else if ((tmp == freq) || (tmp > best_freq)) { | |
1827 | + best_freq = tmp; | |
1828 | + best_cpsdvsr = cpsdvsr; | |
1829 | + best_scr = scr; | |
1830 | + | |
1831 | + if (tmp == freq) | |
1832 | + break; | |
1833 | + } | |
1834 | + scr++; | |
1835 | + } | |
1836 | + cpsdvsr += 2; | |
1837 | + scr = SCR_MIN; | |
1838 | + } | |
1839 | + | |
1840 | + clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF); | |
1841 | + clk_freq->scr = (u8) (best_scr & 0xFF); | |
1842 | + dev_dbg(&pl022->adev->dev, | |
1843 | + "SSP Target Frequency is: %u, Effective Frequency is %u\n", | |
1844 | + freq, best_freq); | |
1845 | + dev_dbg(&pl022->adev->dev, "SSP cpsdvsr = %d, scr = %d\n", | |
1846 | + clk_freq->cpsdvsr, clk_freq->scr); | |
1847 | + | |
1855 | 1848 | return 0; |
1856 | 1849 | } |
1857 | 1850 | |
1858 | - | |
1859 | 1851 | /* |
1860 | 1852 | * A piece of default chip info unless the platform |
1861 | 1853 | * supplies it. |
... | ... | @@ -1873,7 +1865,6 @@ |
1873 | 1865 | .cs_control = null_cs_control, |
1874 | 1866 | }; |
1875 | 1867 | |
1876 | - | |
1877 | 1868 | /** |
1878 | 1869 | * pl022_setup - setup function registered to SPI master framework |
1879 | 1870 | * @spi: spi device which is requesting setup |
... | ... | @@ -1950,7 +1941,6 @@ |
1950 | 1941 | goto err_config_params; |
1951 | 1942 | } |
1952 | 1943 | |
1953 | - | |
1954 | 1944 | status = verify_controller_parameters(pl022, chip_info); |
1955 | 1945 | if (status) { |
1956 | 1946 | dev_err(&spi->dev, "controller data is incorrect"); |
... | ... | @@ -2090,7 +2080,8 @@ |
2090 | 2080 | } |
2091 | 2081 | SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); |
2092 | 2082 | SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); |
2093 | - SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); | |
2083 | + SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, | |
2084 | + 3); | |
2094 | 2085 | |
2095 | 2086 | /* Save controller_state */ |
2096 | 2087 | spi_set_ctldata(spi, chip); |
... | ... | @@ -2116,7 +2107,6 @@ |
2116 | 2107 | kfree(chip); |
2117 | 2108 | } |
2118 | 2109 | |
2119 | - | |
2120 | 2110 | static int __devinit |
2121 | 2111 | pl022_probe(struct amba_device *adev, const struct amba_id *id) |
2122 | 2112 | { |
... | ... | @@ -2242,7 +2232,9 @@ |
2242 | 2232 | err_start_queue: |
2243 | 2233 | err_init_queue: |
2244 | 2234 | destroy_queue(pl022); |
2245 | - pl022_dma_remove(pl022); | |
2235 | + if (platform_info->enable_dma) | |
2236 | + pl022_dma_remove(pl022); | |
2237 | + | |
2246 | 2238 | free_irq(adev->irq[0], pl022); |
2247 | 2239 | err_no_irq: |
2248 | 2240 | clk_unprepare(pl022->clk); |
... | ... | @@ -2277,7 +2269,9 @@ |
2277 | 2269 | if (destroy_queue(pl022) != 0) |
2278 | 2270 | dev_err(&adev->dev, "queue remove failed\n"); |
2279 | 2271 | load_ssp_default_config(pl022); |
2280 | - pl022_dma_remove(pl022); | |
2272 | + if (pl022->master_info->enable_dma) | |
2273 | + pl022_dma_remove(pl022); | |
2274 | + | |
2281 | 2275 | free_irq(adev->irq[0], pl022); |
2282 | 2276 | clk_disable(pl022->clk); |
2283 | 2277 | clk_unprepare(pl022->clk); |
... | ... | @@ -2364,7 +2358,6 @@ |
2364 | 2358 | .loopback = true, |
2365 | 2359 | }; |
2366 | 2360 | |
2367 | - | |
2368 | 2361 | static struct vendor_data vendor_st = { |
2369 | 2362 | .fifodepth = 32, |
2370 | 2363 | .max_bpw = 32, |
... | ... | @@ -2419,9 +2412,9 @@ |
2419 | 2412 | * and 32 locations deep TX/RX FIFO but no extended |
2420 | 2413 | * CR0/CR1 register |
2421 | 2414 | */ |
2422 | - .id = 0x00080023, | |
2423 | - .mask = 0xffffffff, | |
2424 | - .data = &vendor_st_pl023, | |
2415 | + .id = 0x00080023, | |
2416 | + .mask = 0xffffffff, | |
2417 | + .data = &vendor_st_pl023, | |
2425 | 2418 | }, |
2426 | 2419 | { |
2427 | 2420 | .id = 0x10080023, |
2428 | 2421 | |
2429 | 2422 | |
... | ... | @@ -2441,19 +2434,16 @@ |
2441 | 2434 | .remove = __devexit_p(pl022_remove), |
2442 | 2435 | }; |
2443 | 2436 | |
2444 | - | |
2445 | 2437 | static int __init pl022_init(void) |
2446 | 2438 | { |
2447 | 2439 | return amba_driver_register(&pl022_driver); |
2448 | 2440 | } |
2449 | - | |
2450 | 2441 | subsys_initcall(pl022_init); |
2451 | 2442 | |
2452 | 2443 | static void __exit pl022_exit(void) |
2453 | 2444 | { |
2454 | 2445 | amba_driver_unregister(&pl022_driver); |
2455 | 2446 | } |
2456 | - | |
2457 | 2447 | module_exit(pl022_exit); |
2458 | 2448 | |
2459 | 2449 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); |
drivers/spi/spi-ppc4xx.c
... | ... | @@ -514,7 +514,7 @@ |
514 | 514 | /* Request IRQ */ |
515 | 515 | hw->irqnum = irq_of_parse_and_map(np, 0); |
516 | 516 | ret = request_irq(hw->irqnum, spi_ppc4xx_int, |
517 | - IRQF_DISABLED, "spi_ppc4xx_of", (void *)hw); | |
517 | + 0, "spi_ppc4xx_of", (void *)hw); | |
518 | 518 | if (ret) { |
519 | 519 | dev_err(dev, "unable to allocate interrupt\n"); |
520 | 520 | goto free_gpios; |
... | ... | @@ -594,18 +594,7 @@ |
594 | 594 | .of_match_table = spi_ppc4xx_of_match, |
595 | 595 | }, |
596 | 596 | }; |
597 | - | |
598 | -static int __init spi_ppc4xx_init(void) | |
599 | -{ | |
600 | - return platform_driver_register(&spi_ppc4xx_of_driver); | |
601 | -} | |
602 | -module_init(spi_ppc4xx_init); | |
603 | - | |
604 | -static void __exit spi_ppc4xx_exit(void) | |
605 | -{ | |
606 | - platform_driver_unregister(&spi_ppc4xx_of_driver); | |
607 | -} | |
608 | -module_exit(spi_ppc4xx_exit); | |
597 | +module_platform_driver(spi_ppc4xx_of_driver); | |
609 | 598 | |
610 | 599 | MODULE_AUTHOR("Gary Jennejohn & Stefan Roese"); |
611 | 600 | MODULE_DESCRIPTION("Simple PPC4xx SPI Driver"); |
drivers/spi/spi-s3c24xx.c
... | ... | @@ -505,7 +505,7 @@ |
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | -static int __init s3c24xx_spi_probe(struct platform_device *pdev) | |
508 | +static int __devinit s3c24xx_spi_probe(struct platform_device *pdev) | |
509 | 509 | { |
510 | 510 | struct s3c2410_spi_info *pdata; |
511 | 511 | struct s3c24xx_spi *hw; |
... | ... | @@ -661,7 +661,7 @@ |
661 | 661 | return err; |
662 | 662 | } |
663 | 663 | |
664 | -static int __exit s3c24xx_spi_remove(struct platform_device *dev) | |
664 | +static int __devexit s3c24xx_spi_remove(struct platform_device *dev) | |
665 | 665 | { |
666 | 666 | struct s3c24xx_spi *hw = platform_get_drvdata(dev); |
667 | 667 | |
668 | 668 | |
... | ... | @@ -719,26 +719,15 @@ |
719 | 719 | |
720 | 720 | MODULE_ALIAS("platform:s3c2410-spi"); |
721 | 721 | static struct platform_driver s3c24xx_spi_driver = { |
722 | - .remove = __exit_p(s3c24xx_spi_remove), | |
722 | + .probe = s3c24xx_spi_probe, | |
723 | + .remove = __devexit_p(s3c24xx_spi_remove), | |
723 | 724 | .driver = { |
724 | 725 | .name = "s3c2410-spi", |
725 | 726 | .owner = THIS_MODULE, |
726 | 727 | .pm = S3C24XX_SPI_PMOPS, |
727 | 728 | }, |
728 | 729 | }; |
729 | - | |
730 | -static int __init s3c24xx_spi_init(void) | |
731 | -{ | |
732 | - return platform_driver_probe(&s3c24xx_spi_driver, s3c24xx_spi_probe); | |
733 | -} | |
734 | - | |
735 | -static void __exit s3c24xx_spi_exit(void) | |
736 | -{ | |
737 | - platform_driver_unregister(&s3c24xx_spi_driver); | |
738 | -} | |
739 | - | |
740 | -module_init(s3c24xx_spi_init); | |
741 | -module_exit(s3c24xx_spi_exit); | |
730 | +module_platform_driver(s3c24xx_spi_driver); | |
742 | 731 | |
743 | 732 | MODULE_DESCRIPTION("S3C24XX SPI Driver"); |
744 | 733 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); |
drivers/spi/spi-sh-msiof.c
... | ... | @@ -635,7 +635,7 @@ |
635 | 635 | goto err2; |
636 | 636 | } |
637 | 637 | |
638 | - ret = request_irq(i, sh_msiof_spi_irq, IRQF_DISABLED, | |
638 | + ret = request_irq(i, sh_msiof_spi_irq, 0, | |
639 | 639 | dev_name(&pdev->dev), p); |
640 | 640 | if (ret) { |
641 | 641 | dev_err(&pdev->dev, "unable to request irq\n"); |
... | ... | @@ -730,18 +730,7 @@ |
730 | 730 | .pm = &sh_msiof_spi_dev_pm_ops, |
731 | 731 | }, |
732 | 732 | }; |
733 | - | |
734 | -static int __init sh_msiof_spi_init(void) | |
735 | -{ | |
736 | - return platform_driver_register(&sh_msiof_spi_drv); | |
737 | -} | |
738 | -module_init(sh_msiof_spi_init); | |
739 | - | |
740 | -static void __exit sh_msiof_spi_exit(void) | |
741 | -{ | |
742 | - platform_driver_unregister(&sh_msiof_spi_drv); | |
743 | -} | |
744 | -module_exit(sh_msiof_spi_exit); | |
733 | +module_platform_driver(sh_msiof_spi_drv); | |
745 | 734 | |
746 | 735 | MODULE_DESCRIPTION("SuperH MSIOF SPI Master Interface Driver"); |
747 | 736 | MODULE_AUTHOR("Magnus Damm"); |
drivers/spi/spi-sh-sci.c
... | ... | @@ -186,18 +186,7 @@ |
186 | 186 | .owner = THIS_MODULE, |
187 | 187 | }, |
188 | 188 | }; |
189 | - | |
190 | -static int __init sh_sci_spi_init(void) | |
191 | -{ | |
192 | - return platform_driver_register(&sh_sci_spi_drv); | |
193 | -} | |
194 | -module_init(sh_sci_spi_init); | |
195 | - | |
196 | -static void __exit sh_sci_spi_exit(void) | |
197 | -{ | |
198 | - platform_driver_unregister(&sh_sci_spi_drv); | |
199 | -} | |
200 | -module_exit(sh_sci_spi_exit); | |
189 | +module_platform_driver(sh_sci_spi_drv); | |
201 | 190 | |
202 | 191 | MODULE_DESCRIPTION("SH SCI SPI Driver"); |
203 | 192 | MODULE_AUTHOR("Magnus Damm <damm@opensource.se>"); |
drivers/spi/spi-sh.c
... | ... | @@ -484,7 +484,7 @@ |
484 | 484 | goto error2; |
485 | 485 | } |
486 | 486 | |
487 | - ret = request_irq(irq, spi_sh_irq, IRQF_DISABLED, "spi_sh", ss); | |
487 | + ret = request_irq(irq, spi_sh_irq, 0, "spi_sh", ss); | |
488 | 488 | if (ret < 0) { |
489 | 489 | dev_err(&pdev->dev, "request_irq error\n"); |
490 | 490 | goto error3; |
... | ... | @@ -524,18 +524,7 @@ |
524 | 524 | .owner = THIS_MODULE, |
525 | 525 | }, |
526 | 526 | }; |
527 | - | |
528 | -static int __init spi_sh_init(void) | |
529 | -{ | |
530 | - return platform_driver_register(&spi_sh_driver); | |
531 | -} | |
532 | -module_init(spi_sh_init); | |
533 | - | |
534 | -static void __exit spi_sh_exit(void) | |
535 | -{ | |
536 | - platform_driver_unregister(&spi_sh_driver); | |
537 | -} | |
538 | -module_exit(spi_sh_exit); | |
527 | +module_platform_driver(spi_sh_driver); | |
539 | 528 | |
540 | 529 | MODULE_DESCRIPTION("SH SPI bus driver"); |
541 | 530 | MODULE_LICENSE("GPL"); |
drivers/spi/spi-stmp.c
... | ... | @@ -659,19 +659,8 @@ |
659 | 659 | .suspend = stmp_spi_suspend, |
660 | 660 | .resume = stmp_spi_resume, |
661 | 661 | }; |
662 | +module_platform_driver(stmp_spi_driver); | |
662 | 663 | |
663 | -static int __init stmp_spi_init(void) | |
664 | -{ | |
665 | - return platform_driver_register(&stmp_spi_driver); | |
666 | -} | |
667 | - | |
668 | -static void __exit stmp_spi_exit(void) | |
669 | -{ | |
670 | - platform_driver_unregister(&stmp_spi_driver); | |
671 | -} | |
672 | - | |
673 | -module_init(stmp_spi_init); | |
674 | -module_exit(stmp_spi_exit); | |
675 | 664 | module_param(pio, int, S_IRUGO); |
676 | 665 | module_param(clock, int, S_IRUGO); |
677 | 666 | MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com>"); |
drivers/spi/spi-tegra.c
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | */ |
19 | 19 | |
20 | 20 | #include <linux/kernel.h> |
21 | +#include <linux/module.h> | |
21 | 22 | #include <linux/init.h> |
22 | 23 | #include <linux/err.h> |
23 | 24 | #include <linux/platform_device.h> |
... | ... | @@ -464,7 +465,7 @@ |
464 | 465 | return 0; |
465 | 466 | } |
466 | 467 | |
467 | -static int __init spi_tegra_probe(struct platform_device *pdev) | |
468 | +static int __devinit spi_tegra_probe(struct platform_device *pdev) | |
468 | 469 | { |
469 | 470 | struct spi_master *master; |
470 | 471 | struct spi_tegra_data *tspi; |
471 | 472 | |
... | ... | @@ -612,20 +613,10 @@ |
612 | 613 | .owner = THIS_MODULE, |
613 | 614 | .of_match_table = spi_tegra_of_match_table, |
614 | 615 | }, |
616 | + .probe = spi_tegra_probe, | |
615 | 617 | .remove = __devexit_p(spi_tegra_remove), |
616 | 618 | }; |
617 | - | |
618 | -static int __init spi_tegra_init(void) | |
619 | -{ | |
620 | - return platform_driver_probe(&spi_tegra_driver, spi_tegra_probe); | |
621 | -} | |
622 | -module_init(spi_tegra_init); | |
623 | - | |
624 | -static void __exit spi_tegra_exit(void) | |
625 | -{ | |
626 | - platform_driver_unregister(&spi_tegra_driver); | |
627 | -} | |
628 | -module_exit(spi_tegra_exit); | |
619 | +module_platform_driver(spi_tegra_driver); | |
629 | 620 | |
630 | 621 | MODULE_LICENSE("GPL"); |
drivers/spi/spi-ti-ssp.c
... | ... | @@ -383,18 +383,7 @@ |
383 | 383 | .owner = THIS_MODULE, |
384 | 384 | }, |
385 | 385 | }; |
386 | - | |
387 | -static int __init ti_ssp_spi_init(void) | |
388 | -{ | |
389 | - return platform_driver_register(&ti_ssp_spi_driver); | |
390 | -} | |
391 | -module_init(ti_ssp_spi_init); | |
392 | - | |
393 | -static void __exit ti_ssp_spi_exit(void) | |
394 | -{ | |
395 | - platform_driver_unregister(&ti_ssp_spi_driver); | |
396 | -} | |
397 | -module_exit(ti_ssp_spi_exit); | |
386 | +module_platform_driver(ti_ssp_spi_driver); | |
398 | 387 | |
399 | 388 | MODULE_DESCRIPTION("SSP SPI Master"); |
400 | 389 | MODULE_AUTHOR("Cyril Chemparathy"); |
drivers/spi/spi-xilinx.c
... | ... | @@ -538,18 +538,7 @@ |
538 | 538 | .of_match_table = xilinx_spi_of_match, |
539 | 539 | }, |
540 | 540 | }; |
541 | - | |
542 | -static int __init xilinx_spi_pltfm_init(void) | |
543 | -{ | |
544 | - return platform_driver_register(&xilinx_spi_driver); | |
545 | -} | |
546 | -module_init(xilinx_spi_pltfm_init); | |
547 | - | |
548 | -static void __exit xilinx_spi_pltfm_exit(void) | |
549 | -{ | |
550 | - platform_driver_unregister(&xilinx_spi_driver); | |
551 | -} | |
552 | -module_exit(xilinx_spi_pltfm_exit); | |
541 | +module_platform_driver(xilinx_spi_driver); | |
553 | 542 | |
554 | 543 | MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); |
555 | 544 | MODULE_DESCRIPTION("Xilinx SPI driver"); |
drivers/tty/serial/of_serial.c
... | ... | @@ -200,17 +200,7 @@ |
200 | 200 | .remove = of_platform_serial_remove, |
201 | 201 | }; |
202 | 202 | |
203 | -static int __init of_platform_serial_init(void) | |
204 | -{ | |
205 | - return platform_driver_register(&of_platform_serial_driver); | |
206 | -} | |
207 | -module_init(of_platform_serial_init); | |
208 | - | |
209 | -static void __exit of_platform_serial_exit(void) | |
210 | -{ | |
211 | - return platform_driver_unregister(&of_platform_serial_driver); | |
212 | -}; | |
213 | -module_exit(of_platform_serial_exit); | |
203 | +module_platform_driver(of_platform_serial_driver); | |
214 | 204 | |
215 | 205 | MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>"); |
216 | 206 | MODULE_LICENSE("GPL"); |
include/linux/platform_device.h
... | ... | @@ -190,6 +190,23 @@ |
190 | 190 | dev_set_drvdata(&pdev->dev, data); |
191 | 191 | } |
192 | 192 | |
193 | +/* module_platform_driver() - Helper macro for drivers that don't do | |
194 | + * anything special in module init/exit. This eliminates a lot of | |
195 | + * boilerplate. Each module may only use this macro once, and | |
196 | + * calling it replaces module_init() and module_exit() | |
197 | + */ | |
198 | +#define module_platform_driver(__platform_driver) \ | |
199 | +static int __init __platform_driver##_init(void) \ | |
200 | +{ \ | |
201 | + return platform_driver_register(&(__platform_driver)); \ | |
202 | +} \ | |
203 | +module_init(__platform_driver##_init); \ | |
204 | +static void __exit __platform_driver##_exit(void) \ | |
205 | +{ \ | |
206 | + platform_driver_unregister(&(__platform_driver)); \ | |
207 | +} \ | |
208 | +module_exit(__platform_driver##_exit); | |
209 | + | |
193 | 210 | extern struct platform_device *platform_create_bundle(struct platform_driver *driver, |
194 | 211 | int (*probe)(struct platform_device *), |
195 | 212 | struct resource *res, unsigned int n_res, |