提交 61c3506c 编写于 作者: J Johannes Stezenbach 提交者: David Woodhouse

mtd: m25p80: make command buffer DMA-safe

spi_write() requires the buffer to be DMA-safe, kmalloc()
it seperately to ensure this.
Signed-off-by: NJohannes Stezenbach <js@sig21.net>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 74218fed
...@@ -78,7 +78,7 @@ struct m25p { ...@@ -78,7 +78,7 @@ struct m25p {
struct mtd_info mtd; struct mtd_info mtd;
unsigned partitioned:1; unsigned partitioned:1;
u8 erase_opcode; u8 erase_opcode;
u8 command[CMD_SIZE + FAST_READ_DUMMY_BYTE]; u8 *command;
}; };
static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd) static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
...@@ -769,6 +769,11 @@ static int __devinit m25p_probe(struct spi_device *spi) ...@@ -769,6 +769,11 @@ static int __devinit m25p_probe(struct spi_device *spi)
flash = kzalloc(sizeof *flash, GFP_KERNEL); flash = kzalloc(sizeof *flash, GFP_KERNEL);
if (!flash) if (!flash)
return -ENOMEM; return -ENOMEM;
flash->command = kmalloc(CMD_SIZE + FAST_READ_DUMMY_BYTE, GFP_KERNEL);
if (!flash->command) {
kfree(flash);
return -ENOMEM;
}
flash->spi = spi; flash->spi = spi;
mutex_init(&flash->lock); mutex_init(&flash->lock);
...@@ -888,8 +893,10 @@ static int __devexit m25p_remove(struct spi_device *spi) ...@@ -888,8 +893,10 @@ static int __devexit m25p_remove(struct spi_device *spi)
status = del_mtd_partitions(&flash->mtd); status = del_mtd_partitions(&flash->mtd);
else else
status = del_mtd_device(&flash->mtd); status = del_mtd_device(&flash->mtd);
if (status == 0) if (status == 0) {
kfree(flash->command);
kfree(flash); kfree(flash);
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册