diff options
Diffstat (limited to 'drivers/mtd/devices/mtd_dataflash.c')
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index a39b3b6b266c..99d3a0320fc9 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -147,7 +147,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
147 | { | 147 | { |
148 | struct dataflash *priv = (struct dataflash *)mtd->priv; | 148 | struct dataflash *priv = (struct dataflash *)mtd->priv; |
149 | struct spi_device *spi = priv->spi; | 149 | struct spi_device *spi = priv->spi; |
150 | struct spi_transfer x[1] = { { .tx_dma = 0, }, }; | 150 | struct spi_transfer x = { .tx_dma = 0, }; |
151 | struct spi_message msg; | 151 | struct spi_message msg; |
152 | unsigned blocksize = priv->page_size << 3; | 152 | unsigned blocksize = priv->page_size << 3; |
153 | u8 *command; | 153 | u8 *command; |
@@ -162,10 +162,11 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
162 | || (instr->addr % priv->page_size) != 0) | 162 | || (instr->addr % priv->page_size) != 0) |
163 | return -EINVAL; | 163 | return -EINVAL; |
164 | 164 | ||
165 | x[0].tx_buf = command = priv->command; | 165 | spi_message_init(&msg); |
166 | x[0].len = 4; | 166 | |
167 | msg.transfers = x; | 167 | x.tx_buf = command = priv->command; |
168 | msg.n_transfer = 1; | 168 | x.len = 4; |
169 | spi_message_add_tail(&x, &msg); | ||
169 | 170 | ||
170 | down(&priv->lock); | 171 | down(&priv->lock); |
171 | while (instr->len > 0) { | 172 | while (instr->len > 0) { |
@@ -256,12 +257,15 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
256 | DEBUG(MTD_DEBUG_LEVEL3, "READ: (%x) %x %x %x\n", | 257 | DEBUG(MTD_DEBUG_LEVEL3, "READ: (%x) %x %x %x\n", |
257 | command[0], command[1], command[2], command[3]); | 258 | command[0], command[1], command[2], command[3]); |
258 | 259 | ||
260 | spi_message_init(&msg); | ||
261 | |||
259 | x[0].tx_buf = command; | 262 | x[0].tx_buf = command; |
260 | x[0].len = 8; | 263 | x[0].len = 8; |
264 | spi_message_add_tail(&x[0], &msg); | ||
265 | |||
261 | x[1].rx_buf = buf; | 266 | x[1].rx_buf = buf; |
262 | x[1].len = len; | 267 | x[1].len = len; |
263 | msg.transfers = x; | 268 | spi_message_add_tail(&x[1], &msg); |
264 | msg.n_transfer = 2; | ||
265 | 269 | ||
266 | down(&priv->lock); | 270 | down(&priv->lock); |
267 | 271 | ||
@@ -320,9 +324,11 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
320 | if ((to + len) > mtd->size) | 324 | if ((to + len) > mtd->size) |
321 | return -EINVAL; | 325 | return -EINVAL; |
322 | 326 | ||
327 | spi_message_init(&msg); | ||
328 | |||
323 | x[0].tx_buf = command = priv->command; | 329 | x[0].tx_buf = command = priv->command; |
324 | x[0].len = 4; | 330 | x[0].len = 4; |
325 | msg.transfers = x; | 331 | spi_message_add_tail(&x[0], &msg); |
326 | 332 | ||
327 | pageaddr = ((unsigned)to / priv->page_size); | 333 | pageaddr = ((unsigned)to / priv->page_size); |
328 | offset = ((unsigned)to % priv->page_size); | 334 | offset = ((unsigned)to % priv->page_size); |
@@ -364,7 +370,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
364 | DEBUG(MTD_DEBUG_LEVEL3, "TRANSFER: (%x) %x %x %x\n", | 370 | DEBUG(MTD_DEBUG_LEVEL3, "TRANSFER: (%x) %x %x %x\n", |
365 | command[0], command[1], command[2], command[3]); | 371 | command[0], command[1], command[2], command[3]); |
366 | 372 | ||
367 | msg.n_transfer = 1; | ||
368 | status = spi_sync(spi, &msg); | 373 | status = spi_sync(spi, &msg); |
369 | if (status < 0) | 374 | if (status < 0) |
370 | DEBUG(MTD_DEBUG_LEVEL1, "%s: xfer %u -> %d \n", | 375 | DEBUG(MTD_DEBUG_LEVEL1, "%s: xfer %u -> %d \n", |
@@ -385,14 +390,16 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
385 | 390 | ||
386 | x[1].tx_buf = writebuf; | 391 | x[1].tx_buf = writebuf; |
387 | x[1].len = writelen; | 392 | x[1].len = writelen; |
388 | msg.n_transfer = 2; | 393 | spi_message_add_tail(x + 1, &msg); |
389 | status = spi_sync(spi, &msg); | 394 | status = spi_sync(spi, &msg); |
395 | spi_transfer_del(x + 1); | ||
390 | if (status < 0) | 396 | if (status < 0) |
391 | DEBUG(MTD_DEBUG_LEVEL1, "%s: pgm %u/%u -> %d \n", | 397 | DEBUG(MTD_DEBUG_LEVEL1, "%s: pgm %u/%u -> %d \n", |
392 | spi->dev.bus_id, addr, writelen, status); | 398 | spi->dev.bus_id, addr, writelen, status); |
393 | 399 | ||
394 | (void) dataflash_waitready(priv->spi); | 400 | (void) dataflash_waitready(priv->spi); |
395 | 401 | ||
402 | |||
396 | #ifdef CONFIG_DATAFLASH_WRITE_VERIFY | 403 | #ifdef CONFIG_DATAFLASH_WRITE_VERIFY |
397 | 404 | ||
398 | /* (3) Compare to Buffer1 */ | 405 | /* (3) Compare to Buffer1 */ |
@@ -405,7 +412,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
405 | DEBUG(MTD_DEBUG_LEVEL3, "COMPARE: (%x) %x %x %x\n", | 412 | DEBUG(MTD_DEBUG_LEVEL3, "COMPARE: (%x) %x %x %x\n", |
406 | command[0], command[1], command[2], command[3]); | 413 | command[0], command[1], command[2], command[3]); |
407 | 414 | ||
408 | msg.n_transfer = 1; | ||
409 | status = spi_sync(spi, &msg); | 415 | status = spi_sync(spi, &msg); |
410 | if (status < 0) | 416 | if (status < 0) |
411 | DEBUG(MTD_DEBUG_LEVEL1, "%s: compare %u -> %d \n", | 417 | DEBUG(MTD_DEBUG_LEVEL1, "%s: compare %u -> %d \n", |