diff options
Diffstat (limited to 'drivers/mtd/devices/sst25l.c')
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 68 |
1 files changed, 33 insertions, 35 deletions
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; |