diff options
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/Makefile | 2 | ||||
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 4 | ||||
-rw-r--r-- | drivers/mtd/devices/pmc551.c | 4 | ||||
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 68 |
4 files changed, 37 insertions, 41 deletions
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index ab5c9b92ac82..f3226b1d38fc 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # linux/drivers/devices/Makefile | 2 | # linux/drivers/mtd/devices/Makefile |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_MTD_DOC2000) += doc2000.o | 5 | obj-$(CONFIG_MTD_DOC2000) += doc2000.o |
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index ce6424008ed9..93651865ddbe 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -276,12 +276,10 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
276 | 276 | ||
277 | /* Setup the MTD structure */ | 277 | /* Setup the MTD structure */ |
278 | /* make the name contain the block device in */ | 278 | /* make the name contain the block device in */ |
279 | name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1, | 279 | name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname); |
280 | GFP_KERNEL); | ||
281 | if (!name) | 280 | if (!name) |
282 | goto devinit_err; | 281 | goto devinit_err; |
283 | 282 | ||
284 | sprintf(name, "block2mtd: %s", devname); | ||
285 | dev->mtd.name = name; | 283 | dev->mtd.name = name; |
286 | 284 | ||
287 | dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; | 285 | dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; |
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index d2fd550f7e09..fc8ea0a57ac2 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
@@ -668,7 +668,7 @@ static int __init init_pmc551(void) | |||
668 | { | 668 | { |
669 | struct pci_dev *PCI_Device = NULL; | 669 | struct pci_dev *PCI_Device = NULL; |
670 | struct mypriv *priv; | 670 | struct mypriv *priv; |
671 | int count, found = 0; | 671 | int found = 0; |
672 | struct mtd_info *mtd; | 672 | struct mtd_info *mtd; |
673 | u32 length = 0; | 673 | u32 length = 0; |
674 | 674 | ||
@@ -695,7 +695,7 @@ static int __init init_pmc551(void) | |||
695 | /* | 695 | /* |
696 | * PCU-bus chipset probe. | 696 | * PCU-bus chipset probe. |
697 | */ | 697 | */ |
698 | for (count = 0; count < MAX_MTD_DEVICES; count++) { | 698 | for (;;) { |
699 | 699 | ||
700 | if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI, | 700 | if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI, |
701 | PCI_DEVICE_ID_V3_SEMI_V370PDC, | 701 | PCI_DEVICE_ID_V3_SEMI_V370PDC, |
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index fe17054ee2fe..ab5d8cd02a15 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c | |||
@@ -73,15 +73,25 @@ static struct flash_info __initdata sst25l_flash_info[] = { | |||
73 | 73 | ||
74 | static int sst25l_status(struct sst25l_flash *flash, int *status) | 74 | static int sst25l_status(struct sst25l_flash *flash, int *status) |
75 | { | 75 | { |
76 | unsigned char command, response; | 76 | struct spi_message m; |
77 | struct spi_transfer t; | ||
78 | unsigned char cmd_resp[2]; | ||
77 | int err; | 79 | int err; |
78 | 80 | ||
79 | command = SST25L_CMD_RDSR; | 81 | spi_message_init(&m); |
80 | err = spi_write_then_read(flash->spi, &command, 1, &response, 1); | 82 | memset(&t, 0, sizeof(struct spi_transfer)); |
83 | |||
84 | cmd_resp[0] = SST25L_CMD_RDSR; | ||
85 | cmd_resp[1] = 0xff; | ||
86 | t.tx_buf = cmd_resp; | ||
87 | t.rx_buf = cmd_resp; | ||
88 | t.len = sizeof(cmd_resp); | ||
89 | spi_message_add_tail(&t, &m); | ||
90 | err = spi_sync(flash->spi, &m); | ||
81 | if (err < 0) | 91 | if (err < 0) |
82 | return err; | 92 | return err; |
83 | 93 | ||
84 | *status = response; | 94 | *status = cmd_resp[1]; |
85 | return 0; | 95 | return 0; |
86 | } | 96 | } |
87 | 97 | ||
@@ -328,33 +338,32 @@ out: | |||
328 | static struct flash_info *__init sst25l_match_device(struct spi_device *spi) | 338 | static struct flash_info *__init sst25l_match_device(struct spi_device *spi) |
329 | { | 339 | { |
330 | struct flash_info *flash_info = NULL; | 340 | struct flash_info *flash_info = NULL; |
331 | unsigned char command[4], response; | 341 | struct spi_message m; |
342 | struct spi_transfer t; | ||
343 | unsigned char cmd_resp[6]; | ||
332 | int i, err; | 344 | int i, err; |
333 | uint16_t id; | 345 | uint16_t id; |
334 | 346 | ||
335 | command[0] = SST25L_CMD_READ_ID; | 347 | spi_message_init(&m); |
336 | command[1] = 0; | 348 | memset(&t, 0, sizeof(struct spi_transfer)); |
337 | command[2] = 0; | 349 | |
338 | command[3] = 0; | 350 | cmd_resp[0] = SST25L_CMD_READ_ID; |
339 | err = spi_write_then_read(spi, command, sizeof(command), &response, 1); | 351 | cmd_resp[1] = 0; |
352 | cmd_resp[2] = 0; | ||
353 | cmd_resp[3] = 0; | ||
354 | cmd_resp[4] = 0xff; | ||
355 | cmd_resp[5] = 0xff; | ||
356 | t.tx_buf = cmd_resp; | ||
357 | t.rx_buf = cmd_resp; | ||
358 | t.len = sizeof(cmd_resp); | ||
359 | spi_message_add_tail(&t, &m); | ||
360 | err = spi_sync(spi, &m); | ||
340 | if (err < 0) { | 361 | if (err < 0) { |
341 | dev_err(&spi->dev, "error reading device id msb\n"); | 362 | dev_err(&spi->dev, "error reading device id\n"); |
342 | return NULL; | 363 | return NULL; |
343 | } | 364 | } |
344 | 365 | ||
345 | id = response << 8; | 366 | id = (cmd_resp[4] << 8) | cmd_resp[5]; |
346 | |||
347 | command[0] = SST25L_CMD_READ_ID; | ||
348 | command[1] = 0; | ||
349 | command[2] = 0; | ||
350 | command[3] = 1; | ||
351 | err = spi_write_then_read(spi, command, sizeof(command), &response, 1); | ||
352 | if (err < 0) { | ||
353 | dev_err(&spi->dev, "error reading device id lsb\n"); | ||
354 | return NULL; | ||
355 | } | ||
356 | |||
357 | id |= response; | ||
358 | 367 | ||
359 | for (i = 0; i < ARRAY_SIZE(sst25l_flash_info); i++) | 368 | for (i = 0; i < ARRAY_SIZE(sst25l_flash_info); i++) |
360 | if (sst25l_flash_info[i].device_id == id) | 369 | if (sst25l_flash_info[i].device_id == id) |
@@ -411,17 +420,6 @@ static int __init sst25l_probe(struct spi_device *spi) | |||
411 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, | 420 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, |
412 | flash->mtd.numeraseregions); | 421 | flash->mtd.numeraseregions); |
413 | 422 | ||
414 | if (flash->mtd.numeraseregions) | ||
415 | for (i = 0; i < flash->mtd.numeraseregions; i++) | ||
416 | DEBUG(MTD_DEBUG_LEVEL2, | ||
417 | "mtd.eraseregions[%d] = { .offset = 0x%llx, " | ||
418 | ".erasesize = 0x%.8x (%uKiB), " | ||
419 | ".numblocks = %d }\n", | ||
420 | i, (long long)flash->mtd.eraseregions[i].offset, | ||
421 | flash->mtd.eraseregions[i].erasesize, | ||
422 | flash->mtd.eraseregions[i].erasesize / 1024, | ||
423 | flash->mtd.eraseregions[i].numblocks); | ||
424 | |||
425 | if (mtd_has_partitions()) { | 423 | if (mtd_has_partitions()) { |
426 | struct mtd_partition *parts = NULL; | 424 | struct mtd_partition *parts = NULL; |
427 | int nr_parts = 0; | 425 | int nr_parts = 0; |