OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 2 Rev 3
1 /* 1 /*
2 * NAND flash driver for the MikroTik RouterBoard 4xx series 2 * NAND flash driver for the MikroTik RouterBoard 4xx series
3 * 3 *
4 * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> 4 * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> 5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * 6 *
7 * This file was based on the driver for Linux 2.6.22 published by 7 * This file was based on the driver for Linux 2.6.22 published by
8 * MikroTik for their RouterBoard 4xx series devices. 8 * MikroTik for their RouterBoard 4xx series devices.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published 11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation. 12 * by the Free Software Foundation.
13 */ 13 */
14   -  
15 #include <linux/version.h> 14  
16 #include <linux/kernel.h> 15 #include <linux/kernel.h>
17 #include <linux/module.h> 16 #include <linux/module.h>
18 #include <linux/init.h> 17 #include <linux/init.h>
19 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) -  
20 #include <linux/mtd/nand.h> 18 #include <linux/mtd/nand.h>
21 #else -  
22 #include <linux/mtd/rawnand.h> -  
23 #endif -  
24 #include <linux/mtd/mtd.h> 19 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h> 20 #include <linux/mtd/partitions.h>
26 #include <linux/platform_device.h> 21 #include <linux/platform_device.h>
27 #include <linux/delay.h> 22 #include <linux/delay.h>
28 #include <linux/io.h> 23 #include <linux/io.h>
29 #include <linux/gpio.h> 24 #include <linux/gpio.h>
30 #include <linux/slab.h> 25 #include <linux/slab.h>
-   26 #include <linux/version.h>
31   27  
32 #include <asm/mach-ath79/ath79.h> 28 #include <asm/mach-ath79/ath79.h>
33 #include <asm/mach-ath79/rb4xx_cpld.h> 29 #include <asm/mach-ath79/rb4xx_cpld.h>
34   30  
35 #define DRV_NAME "rb4xx-nand" 31 #define DRV_NAME "rb4xx-nand"
36 #define DRV_VERSION "0.2.0" 32 #define DRV_VERSION "0.2.0"
37 #define DRV_DESC "NAND flash driver for RouterBoard 4xx series" 33 #define DRV_DESC "NAND flash driver for RouterBoard 4xx series"
38   34  
39 #define RB4XX_NAND_GPIO_READY 5 35 #define RB4XX_NAND_GPIO_READY 5
40 #define RB4XX_NAND_GPIO_ALE 37 36 #define RB4XX_NAND_GPIO_ALE 37
41 #define RB4XX_NAND_GPIO_CLE 38 37 #define RB4XX_NAND_GPIO_CLE 38
42 #define RB4XX_NAND_GPIO_NCE 39 38 #define RB4XX_NAND_GPIO_NCE 39
43   39  
44 struct rb4xx_nand_info { 40 struct rb4xx_nand_info {
45 struct nand_chip chip; 41 struct nand_chip chip;
46 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 42 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
47 struct mtd_info mtd; 43 struct mtd_info mtd;
48 #endif 44 #endif
49 }; 45 };
50   46  
51 static inline struct rb4xx_nand_info *mtd_to_rbinfo(struct mtd_info *mtd) 47 static inline struct rb4xx_nand_info *mtd_to_rbinfo(struct mtd_info *mtd)
52 { 48 {
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 49 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
54 return container_of(mtd, struct rb4xx_nand_info, mtd); 50 return container_of(mtd, struct rb4xx_nand_info, mtd);
55 #else 51 #else
56 struct nand_chip *chip = mtd_to_nand(mtd); 52 struct nand_chip *chip = mtd_to_nand(mtd);
57   53  
58 return container_of(chip, struct rb4xx_nand_info, chip); 54 return container_of(chip, struct rb4xx_nand_info, chip);
59 #endif 55 #endif
60 } 56 }
61   57  
62 static struct mtd_info *rbinfo_to_mtd(struct rb4xx_nand_info *nfc) 58 static struct mtd_info *rbinfo_to_mtd(struct rb4xx_nand_info *nfc)
63 { 59 {
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 60 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
65 return &nfc->mtd; 61 return &nfc->mtd;
66 #else 62 #else
67 return nand_to_mtd(&nfc->chip); 63 return nand_to_mtd(&nfc->chip);
68 #endif 64 #endif
69 } 65 }
70   66  
71 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 67 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
72 /* 68 /*
73 * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader 69 * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
74 * will not be able to find the kernel that we load. 70 * will not be able to find the kernel that we load.
75 */ 71 */
76 static struct nand_ecclayout rb4xx_nand_ecclayout = { 72 static struct nand_ecclayout rb4xx_nand_ecclayout = {
77 .eccbytes = 6, 73 .eccbytes = 6,
78 .eccpos = { 8, 9, 10, 13, 14, 15 }, 74 .eccpos = { 8, 9, 10, 13, 14, 15 },
79 .oobavail = 9, 75 .oobavail = 9,
80 .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } 76 .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
81 }; 77 };
82   78  
83 #else 79 #else
84   80  
85 static int rb4xx_ooblayout_ecc(struct mtd_info *mtd, int section, 81 static int rb4xx_ooblayout_ecc(struct mtd_info *mtd, int section,
86 struct mtd_oob_region *oobregion) 82 struct mtd_oob_region *oobregion)
87 { 83 {
88 switch (section) { 84 switch (section) {
89 case 0: 85 case 0:
90 oobregion->offset = 8; 86 oobregion->offset = 8;
91 oobregion->length = 3; 87 oobregion->length = 3;
92 return 0; 88 return 0;
93 case 1: 89 case 1:
94 oobregion->offset = 13; 90 oobregion->offset = 13;
95 oobregion->length = 3; 91 oobregion->length = 3;
96 return 0; 92 return 0;
97 default: 93 default:
98 return -ERANGE; 94 return -ERANGE;
99 } 95 }
100 } 96 }
101   97  
102 static int rb4xx_ooblayout_free(struct mtd_info *mtd, int section, 98 static int rb4xx_ooblayout_free(struct mtd_info *mtd, int section,
103 struct mtd_oob_region *oobregion) 99 struct mtd_oob_region *oobregion)
104 { 100 {
105 switch (section) { 101 switch (section) {
106 case 0: 102 case 0:
107 oobregion->offset = 0; 103 oobregion->offset = 0;
108 oobregion->length = 4; 104 oobregion->length = 4;
109 return 0; 105 return 0;
110 case 1: 106 case 1:
111 oobregion->offset = 4; 107 oobregion->offset = 4;
112 oobregion->length = 1; 108 oobregion->length = 1;
113 return 0; 109 return 0;
114 case 2: 110 case 2:
115 oobregion->offset = 6; 111 oobregion->offset = 6;
116 oobregion->length = 2; 112 oobregion->length = 2;
117 return 0; 113 return 0;
118 case 3: 114 case 3:
119 oobregion->offset = 11; 115 oobregion->offset = 11;
120 oobregion->length = 2; 116 oobregion->length = 2;
121 return 0; 117 return 0;
122 default: 118 default:
123 return -ERANGE; 119 return -ERANGE;
124 } 120 }
125 } 121 }
126   122  
127 static const struct mtd_ooblayout_ops rb4xx_nand_ecclayout_ops = { 123 static const struct mtd_ooblayout_ops rb4xx_nand_ecclayout_ops = {
128 .ecc = rb4xx_ooblayout_ecc, 124 .ecc = rb4xx_ooblayout_ecc,
129 .free = rb4xx_ooblayout_free, 125 .free = rb4xx_ooblayout_free,
130 }; 126 };
131 #endif /* < 4.6 */ 127 #endif /* < 4.6 */
132   128  
133 static struct mtd_partition rb4xx_nand_partitions[] = { 129 static struct mtd_partition rb4xx_nand_partitions[] = {
134 { 130 {
135 .name = "booter", 131 .name = "booter",
136 .offset = 0, 132 .offset = 0,
137 .size = (256 * 1024), 133 .size = (256 * 1024),
138 .mask_flags = MTD_WRITEABLE, 134 .mask_flags = MTD_WRITEABLE,
139 }, 135 },
140 { 136 {
141 .name = "kernel", 137 .name = "kernel",
142 .offset = (256 * 1024), 138 .offset = (256 * 1024),
143 .size = (4 * 1024 * 1024) - (256 * 1024), 139 .size = (4 * 1024 * 1024) - (256 * 1024),
144 }, 140 },
145 { 141 {
146 .name = "ubi", 142 .name = "ubi",
147 .offset = MTDPART_OFS_NXTBLK, 143 .offset = MTDPART_OFS_NXTBLK,
148 .size = MTDPART_SIZ_FULL, 144 .size = MTDPART_SIZ_FULL,
149 }, 145 },
150 }; 146 };
151   147  
152 static int rb4xx_nand_dev_ready(struct mtd_info *mtd) 148 static int rb4xx_nand_dev_ready(struct mtd_info *mtd)
153 { 149 {
154 return gpio_get_value_cansleep(RB4XX_NAND_GPIO_READY); 150 return gpio_get_value_cansleep(RB4XX_NAND_GPIO_READY);
155 } 151 }
156   152  
157 static void rb4xx_nand_write_cmd(unsigned char cmd) 153 static void rb4xx_nand_write_cmd(unsigned char cmd)
158 { 154 {
159 unsigned char data = cmd; 155 unsigned char data = cmd;
160 int err; 156 int err;
161   157  
162 err = rb4xx_cpld_write(&data, 1); 158 err = rb4xx_cpld_write(&data, 1);
163 if (err) 159 if (err)
164 pr_err("rb4xx_nand: write cmd failed, err=%d\n", err); 160 pr_err("rb4xx_nand: write cmd failed, err=%d\n", err);
165 } 161 }
166   162  
167 static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, 163 static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
168 unsigned int ctrl) 164 unsigned int ctrl)
169 { 165 {
170 if (ctrl & NAND_CTRL_CHANGE) { 166 if (ctrl & NAND_CTRL_CHANGE) {
171 gpio_set_value_cansleep(RB4XX_NAND_GPIO_CLE, 167 gpio_set_value_cansleep(RB4XX_NAND_GPIO_CLE,
172 (ctrl & NAND_CLE) ? 1 : 0); 168 (ctrl & NAND_CLE) ? 1 : 0);
173 gpio_set_value_cansleep(RB4XX_NAND_GPIO_ALE, 169 gpio_set_value_cansleep(RB4XX_NAND_GPIO_ALE,
174 (ctrl & NAND_ALE) ? 1 : 0); 170 (ctrl & NAND_ALE) ? 1 : 0);
175 gpio_set_value_cansleep(RB4XX_NAND_GPIO_NCE, 171 gpio_set_value_cansleep(RB4XX_NAND_GPIO_NCE,
176 (ctrl & NAND_NCE) ? 0 : 1); 172 (ctrl & NAND_NCE) ? 0 : 1);
177 } 173 }
178   174  
179 if (cmd != NAND_CMD_NONE) 175 if (cmd != NAND_CMD_NONE)
180 rb4xx_nand_write_cmd(cmd); 176 rb4xx_nand_write_cmd(cmd);
181 } 177 }
182   178  
183 static unsigned char rb4xx_nand_read_byte(struct mtd_info *mtd) 179 static unsigned char rb4xx_nand_read_byte(struct mtd_info *mtd)
184 { 180 {
185 unsigned char data = 0; 181 unsigned char data = 0;
186 int err; 182 int err;
187   183  
188 err = rb4xx_cpld_read(&data, 1); 184 err = rb4xx_cpld_read(&data, 1);
189 if (err) { 185 if (err) {
190 pr_err("rb4xx_nand: read data failed, err=%d\n", err); 186 pr_err("rb4xx_nand: read data failed, err=%d\n", err);
191 data = 0xff; 187 data = 0xff;
192 } 188 }
193   189  
194 return data; 190 return data;
195 } 191 }
196   192  
197 static void rb4xx_nand_write_buf(struct mtd_info *mtd, const unsigned char *buf, 193 static void rb4xx_nand_write_buf(struct mtd_info *mtd, const unsigned char *buf,
198 int len) 194 int len)
199 { 195 {
200 int err; 196 int err;
201   197  
202 err = rb4xx_cpld_write(buf, len); 198 err = rb4xx_cpld_write(buf, len);
203 if (err) 199 if (err)
204 pr_err("rb4xx_nand: write buf failed, err=%d\n", err); 200 pr_err("rb4xx_nand: write buf failed, err=%d\n", err);
205 } 201 }
206   202  
207 static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf, 203 static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf,
208 int len) 204 int len)
209 { 205 {
210 int err; 206 int err;
211   207  
212 err = rb4xx_cpld_read(buf, len); 208 err = rb4xx_cpld_read(buf, len);
213 if (err) 209 if (err)
214 pr_err("rb4xx_nand: read buf failed, err=%d\n", err); 210 pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
215 } 211 }
216   212  
217 static int rb4xx_nand_probe(struct platform_device *pdev) 213 static int rb4xx_nand_probe(struct platform_device *pdev)
218 { 214 {
219 struct rb4xx_nand_info *info; 215 struct rb4xx_nand_info *info;
220 struct mtd_info *mtd; 216 struct mtd_info *mtd;
221 int ret; 217 int ret;
222   218  
223 printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n"); 219 printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
224   220  
225 ret = gpio_request(RB4XX_NAND_GPIO_READY, "NAND RDY"); 221 ret = gpio_request(RB4XX_NAND_GPIO_READY, "NAND RDY");
226 if (ret) { 222 if (ret) {
227 dev_err(&pdev->dev, "unable to request gpio %d\n", 223 dev_err(&pdev->dev, "unable to request gpio %d\n",
228 RB4XX_NAND_GPIO_READY); 224 RB4XX_NAND_GPIO_READY);
229 goto err; 225 goto err;
230 } 226 }
231   227  
232 ret = gpio_direction_input(RB4XX_NAND_GPIO_READY); 228 ret = gpio_direction_input(RB4XX_NAND_GPIO_READY);
233 if (ret) { 229 if (ret) {
234 dev_err(&pdev->dev, "unable to set input mode on gpio %d\n", 230 dev_err(&pdev->dev, "unable to set input mode on gpio %d\n",
235 RB4XX_NAND_GPIO_READY); 231 RB4XX_NAND_GPIO_READY);
236 goto err_free_gpio_ready; 232 goto err_free_gpio_ready;
237 } 233 }
238   234  
239 ret = gpio_request(RB4XX_NAND_GPIO_ALE, "NAND ALE"); 235 ret = gpio_request(RB4XX_NAND_GPIO_ALE, "NAND ALE");
240 if (ret) { 236 if (ret) {
241 dev_err(&pdev->dev, "unable to request gpio %d\n", 237 dev_err(&pdev->dev, "unable to request gpio %d\n",
242 RB4XX_NAND_GPIO_ALE); 238 RB4XX_NAND_GPIO_ALE);
243 goto err_free_gpio_ready; 239 goto err_free_gpio_ready;
244 } 240 }
245   241  
246 ret = gpio_direction_output(RB4XX_NAND_GPIO_ALE, 0); 242 ret = gpio_direction_output(RB4XX_NAND_GPIO_ALE, 0);
247 if (ret) { 243 if (ret) {
248 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n", 244 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
249 RB4XX_NAND_GPIO_ALE); 245 RB4XX_NAND_GPIO_ALE);
250 goto err_free_gpio_ale; 246 goto err_free_gpio_ale;
251 } 247 }
252   248  
253 ret = gpio_request(RB4XX_NAND_GPIO_CLE, "NAND CLE"); 249 ret = gpio_request(RB4XX_NAND_GPIO_CLE, "NAND CLE");
254 if (ret) { 250 if (ret) {
255 dev_err(&pdev->dev, "unable to request gpio %d\n", 251 dev_err(&pdev->dev, "unable to request gpio %d\n",
256 RB4XX_NAND_GPIO_CLE); 252 RB4XX_NAND_GPIO_CLE);
257 goto err_free_gpio_ale; 253 goto err_free_gpio_ale;
258 } 254 }
259   255  
260 ret = gpio_direction_output(RB4XX_NAND_GPIO_CLE, 0); 256 ret = gpio_direction_output(RB4XX_NAND_GPIO_CLE, 0);
261 if (ret) { 257 if (ret) {
262 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n", 258 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
263 RB4XX_NAND_GPIO_CLE); 259 RB4XX_NAND_GPIO_CLE);
264 goto err_free_gpio_cle; 260 goto err_free_gpio_cle;
265 } 261 }
266   262  
267 ret = gpio_request(RB4XX_NAND_GPIO_NCE, "NAND NCE"); 263 ret = gpio_request(RB4XX_NAND_GPIO_NCE, "NAND NCE");
268 if (ret) { 264 if (ret) {
269 dev_err(&pdev->dev, "unable to request gpio %d\n", 265 dev_err(&pdev->dev, "unable to request gpio %d\n",
270 RB4XX_NAND_GPIO_NCE); 266 RB4XX_NAND_GPIO_NCE);
271 goto err_free_gpio_cle; 267 goto err_free_gpio_cle;
272 } 268 }
273   269  
274 ret = gpio_direction_output(RB4XX_NAND_GPIO_NCE, 1); 270 ret = gpio_direction_output(RB4XX_NAND_GPIO_NCE, 1);
275 if (ret) { 271 if (ret) {
276 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n", 272 dev_err(&pdev->dev, "unable to set output mode on gpio %d\n",
277 RB4XX_NAND_GPIO_ALE); 273 RB4XX_NAND_GPIO_ALE);
278 goto err_free_gpio_nce; 274 goto err_free_gpio_nce;
279 } 275 }
280   276  
281 info = kzalloc(sizeof(*info), GFP_KERNEL); 277 info = kzalloc(sizeof(*info), GFP_KERNEL);
282 if (!info) { 278 if (!info) {
283 dev_err(&pdev->dev, "rb4xx-nand: no memory for private data\n"); 279 dev_err(&pdev->dev, "rb4xx-nand: no memory for private data\n");
284 ret = -ENOMEM; 280 ret = -ENOMEM;
285 goto err_free_gpio_nce; 281 goto err_free_gpio_nce;
286 } 282 }
287   283  
288 info->chip.priv = &info; 284 info->chip.priv = &info;
289 mtd = rbinfo_to_mtd(info); 285 mtd = rbinfo_to_mtd(info);
290   286  
291 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 287 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
292 mtd->priv = &info->chip; 288 mtd->priv = &info->chip;
293 #endif 289 #endif
294 mtd->owner = THIS_MODULE; 290 mtd->owner = THIS_MODULE;
295   291  
296 info->chip.cmd_ctrl = rb4xx_nand_cmd_ctrl; 292 info->chip.cmd_ctrl = rb4xx_nand_cmd_ctrl;
297 info->chip.dev_ready = rb4xx_nand_dev_ready; 293 info->chip.dev_ready = rb4xx_nand_dev_ready;
298 info->chip.read_byte = rb4xx_nand_read_byte; 294 info->chip.read_byte = rb4xx_nand_read_byte;
299 info->chip.write_buf = rb4xx_nand_write_buf; 295 info->chip.write_buf = rb4xx_nand_write_buf;
300 info->chip.read_buf = rb4xx_nand_read_buf; 296 info->chip.read_buf = rb4xx_nand_read_buf;
301   297  
302 info->chip.chip_delay = 25; 298 info->chip.chip_delay = 25;
303 info->chip.ecc.mode = NAND_ECC_SOFT; 299 info->chip.ecc.mode = NAND_ECC_SOFT;
304 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) 300 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
305 info->chip.ecc.algo = NAND_ECC_HAMMING; 301 info->chip.ecc.algo = NAND_ECC_HAMMING;
306 #endif 302 #endif
307 info->chip.options = NAND_NO_SUBPAGE_WRITE; 303 info->chip.options = NAND_NO_SUBPAGE_WRITE;
308   304  
309 platform_set_drvdata(pdev, info); 305 platform_set_drvdata(pdev, info);
310   306  
311 ret = nand_scan_ident(mtd, 1, NULL); 307 ret = nand_scan_ident(mtd, 1, NULL);
312 if (ret) { 308 if (ret) {
313 ret = -ENXIO; 309 ret = -ENXIO;
314 goto err_free_info; 310 goto err_free_info;
315 } 311 }
316   312  
317 if (mtd->writesize == 512) 313 if (mtd->writesize == 512)
318 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 314 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
319 info->chip.ecc.layout = &rb4xx_nand_ecclayout; 315 info->chip.ecc.layout = &rb4xx_nand_ecclayout;
320 #else 316 #else
321 mtd_set_ooblayout(mtd, &rb4xx_nand_ecclayout_ops); 317 mtd_set_ooblayout(mtd, &rb4xx_nand_ecclayout_ops);
322 #endif 318 #endif
323   319  
324 ret = nand_scan_tail(mtd); 320 ret = nand_scan_tail(mtd);
325 if (ret) { 321 if (ret) {
326 return -ENXIO; 322 return -ENXIO;
327 goto err_set_drvdata; 323 goto err_set_drvdata;
328 } 324 }
329   325  
330 mtd_device_register(mtd, rb4xx_nand_partitions, 326 mtd_device_register(mtd, rb4xx_nand_partitions,
331 ARRAY_SIZE(rb4xx_nand_partitions)); 327 ARRAY_SIZE(rb4xx_nand_partitions));
332 if (ret) 328 if (ret)
333 goto err_release_nand; 329 goto err_release_nand;
334   330  
335 return 0; 331 return 0;
336   332  
337 err_release_nand: 333 err_release_nand:
338 nand_release(mtd); 334 nand_release(mtd);
339 err_set_drvdata: 335 err_set_drvdata:
340 platform_set_drvdata(pdev, NULL); 336 platform_set_drvdata(pdev, NULL);
341 err_free_info: 337 err_free_info:
342 kfree(info); 338 kfree(info);
343 err_free_gpio_nce: 339 err_free_gpio_nce:
344 gpio_free(RB4XX_NAND_GPIO_NCE); 340 gpio_free(RB4XX_NAND_GPIO_NCE);
345 err_free_gpio_cle: 341 err_free_gpio_cle:
346 gpio_free(RB4XX_NAND_GPIO_CLE); 342 gpio_free(RB4XX_NAND_GPIO_CLE);
347 err_free_gpio_ale: 343 err_free_gpio_ale:
348 gpio_free(RB4XX_NAND_GPIO_ALE); 344 gpio_free(RB4XX_NAND_GPIO_ALE);
349 err_free_gpio_ready: 345 err_free_gpio_ready:
350 gpio_free(RB4XX_NAND_GPIO_READY); 346 gpio_free(RB4XX_NAND_GPIO_READY);
351 err: 347 err:
352 return ret; 348 return ret;
353 } 349 }
354   350  
355 static int rb4xx_nand_remove(struct platform_device *pdev) 351 static int rb4xx_nand_remove(struct platform_device *pdev)
356 { 352 {
357 struct rb4xx_nand_info *info = platform_get_drvdata(pdev); 353 struct rb4xx_nand_info *info = platform_get_drvdata(pdev);
358   354  
359 nand_release(rbinfo_to_mtd(info)); 355 nand_release(rbinfo_to_mtd(info));
360 platform_set_drvdata(pdev, NULL); 356 platform_set_drvdata(pdev, NULL);
361 kfree(info); 357 kfree(info);
362 gpio_free(RB4XX_NAND_GPIO_NCE); 358 gpio_free(RB4XX_NAND_GPIO_NCE);
363 gpio_free(RB4XX_NAND_GPIO_CLE); 359 gpio_free(RB4XX_NAND_GPIO_CLE);
364 gpio_free(RB4XX_NAND_GPIO_ALE); 360 gpio_free(RB4XX_NAND_GPIO_ALE);
365 gpio_free(RB4XX_NAND_GPIO_READY); 361 gpio_free(RB4XX_NAND_GPIO_READY);
366   362  
367 return 0; 363 return 0;
368 } 364 }
369   365  
370 static struct platform_driver rb4xx_nand_driver = { 366 static struct platform_driver rb4xx_nand_driver = {
371 .probe = rb4xx_nand_probe, 367 .probe = rb4xx_nand_probe,
372 .remove = rb4xx_nand_remove, 368 .remove = rb4xx_nand_remove,
373 .driver = { 369 .driver = {
374 .name = DRV_NAME, 370 .name = DRV_NAME,
375 .owner = THIS_MODULE, 371 .owner = THIS_MODULE,
376 }, 372 },
377 }; 373 };
378   374  
379 static int __init rb4xx_nand_init(void) 375 static int __init rb4xx_nand_init(void)
380 { 376 {
381 return platform_driver_register(&rb4xx_nand_driver); 377 return platform_driver_register(&rb4xx_nand_driver);
382 } 378 }
383   379  
384 static void __exit rb4xx_nand_exit(void) 380 static void __exit rb4xx_nand_exit(void)
385 { 381 {
386 platform_driver_unregister(&rb4xx_nand_driver); 382 platform_driver_unregister(&rb4xx_nand_driver);
387 } 383 }
388   384  
389 module_init(rb4xx_nand_init); 385 module_init(rb4xx_nand_init);
390 module_exit(rb4xx_nand_exit); 386 module_exit(rb4xx_nand_exit);
391   387  
392 MODULE_DESCRIPTION(DRV_DESC); 388 MODULE_DESCRIPTION(DRV_DESC);
393 MODULE_VERSION(DRV_VERSION); 389 MODULE_VERSION(DRV_VERSION);
394 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>"); 390 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
395 MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>"); 391 MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
396 MODULE_LICENSE("GPL v2"); 392 MODULE_LICENSE("GPL v2");
397   393