aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/sst25l.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/sst25l.c')
-rw-r--r--drivers/mtd/devices/sst25l.c46
1 files changed, 8 insertions, 38 deletions
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index 5fc198350b94..ab8a2f4c8d60 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -175,9 +175,6 @@ static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr)
175 int err; 175 int err;
176 176
177 /* Sanity checks */ 177 /* Sanity checks */
178 if (instr->addr + instr->len > flash->mtd.size)
179 return -EINVAL;
180
181 if ((uint32_t)instr->len % mtd->erasesize) 178 if ((uint32_t)instr->len % mtd->erasesize)
182 return -EINVAL; 179 return -EINVAL;
183 180
@@ -223,16 +220,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len,
223 unsigned char command[4]; 220 unsigned char command[4];
224 int ret; 221 int ret;
225 222
226 /* Sanity checking */
227 if (len == 0)
228 return 0;
229
230 if (from + len > flash->mtd.size)
231 return -EINVAL;
232
233 if (retlen)
234 *retlen = 0;
235
236 spi_message_init(&message); 223 spi_message_init(&message);
237 memset(&transfer, 0, sizeof(transfer)); 224 memset(&transfer, 0, sizeof(transfer));
238 225
@@ -274,13 +261,6 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len,
274 int i, j, ret, bytes, copied = 0; 261 int i, j, ret, bytes, copied = 0;
275 unsigned char command[5]; 262 unsigned char command[5];
276 263
277 /* Sanity checks */
278 if (!len)
279 return 0;
280
281 if (to + len > flash->mtd.size)
282 return -EINVAL;
283
284 if ((uint32_t)to % mtd->writesize) 264 if ((uint32_t)to % mtd->writesize)
285 return -EINVAL; 265 return -EINVAL;
286 266
@@ -402,10 +382,11 @@ static int __devinit sst25l_probe(struct spi_device *spi)
402 flash->mtd.flags = MTD_CAP_NORFLASH; 382 flash->mtd.flags = MTD_CAP_NORFLASH;
403 flash->mtd.erasesize = flash_info->erase_size; 383 flash->mtd.erasesize = flash_info->erase_size;
404 flash->mtd.writesize = flash_info->page_size; 384 flash->mtd.writesize = flash_info->page_size;
385 flash->mtd.writebufsize = flash_info->page_size;
405 flash->mtd.size = flash_info->page_size * flash_info->nr_pages; 386 flash->mtd.size = flash_info->page_size * flash_info->nr_pages;
406 flash->mtd.erase = sst25l_erase; 387 flash->mtd._erase = sst25l_erase;
407 flash->mtd.read = sst25l_read; 388 flash->mtd._read = sst25l_read;
408 flash->mtd.write = sst25l_write; 389 flash->mtd._write = sst25l_write;
409 390
410 dev_info(&spi->dev, "%s (%lld KiB)\n", flash_info->name, 391 dev_info(&spi->dev, "%s (%lld KiB)\n", flash_info->name,
411 (long long)flash->mtd.size >> 10); 392 (long long)flash->mtd.size >> 10);
@@ -418,9 +399,9 @@ static int __devinit sst25l_probe(struct spi_device *spi)
418 flash->mtd.numeraseregions); 399 flash->mtd.numeraseregions);
419 400
420 401
421 ret = mtd_device_parse_register(&flash->mtd, NULL, 0, 402 ret = mtd_device_parse_register(&flash->mtd, NULL, NULL,
422 data ? data->parts : NULL, 403 data ? data->parts : NULL,
423 data ? data->nr_parts : 0); 404 data ? data->nr_parts : 0);
424 if (ret) { 405 if (ret) {
425 kfree(flash); 406 kfree(flash);
426 dev_set_drvdata(&spi->dev, NULL); 407 dev_set_drvdata(&spi->dev, NULL);
@@ -450,18 +431,7 @@ static struct spi_driver sst25l_driver = {
450 .remove = __devexit_p(sst25l_remove), 431 .remove = __devexit_p(sst25l_remove),
451}; 432};
452 433
453static int __init sst25l_init(void) 434module_spi_driver(sst25l_driver);
454{
455 return spi_register_driver(&sst25l_driver);
456}
457
458static void __exit sst25l_exit(void)
459{
460 spi_unregister_driver(&sst25l_driver);
461}
462
463module_init(sst25l_init);
464module_exit(sst25l_exit);
465 435
466MODULE_DESCRIPTION("MTD SPI driver for SST25L Flash chips"); 436MODULE_DESCRIPTION("MTD SPI driver for SST25L Flash chips");
467MODULE_AUTHOR("Andre Renaud <andre@bluewatersys.com>, " 437MODULE_AUTHOR("Andre Renaud <andre@bluewatersys.com>, "