1 From 0a8079b232e9188ba267e37e20f192bed6c2b29b Mon Sep 17 00:00:00 2001
2 From: Michal Suchanek <hramrach@gmail.com>
3 Date: Wed, 2 Dec 2015 10:38:19 +0000
4 Subject: [PATCH 091/113] mtd: spi-nor: change return value of read/write
6 Change the return value of spi-nor device read and write methods to
7 allow returning amount of data transferred and errors as
10 Signed-off-by: Michal Suchanek <hramrach@gmail.com>
11 Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@freescale.com>
13 drivers/mtd/devices/m25p80.c | 5 +++--
14 drivers/mtd/spi-nor/fsl-quadspi.c | 5 +++--
15 include/linux/mtd/spi-nor.h | 4 ++--
16 3 files changed, 8 insertions(+), 6 deletions(-)
18 --- a/drivers/mtd/devices/m25p80.c
19 +++ b/drivers/mtd/devices/m25p80.c
20 @@ -73,7 +73,7 @@ static int m25p80_write_reg(struct spi_n
21 return spi_write(spi, flash->command, len + 1);
24 -static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
25 +static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
26 size_t *retlen, const u_char *buf)
28 struct m25p *flash = nor->priv;
29 @@ -101,6 +101,7 @@ static void m25p80_write(struct spi_nor
32 *retlen += m.actual_length - cmd_sz;
36 static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)
37 @@ -119,7 +120,7 @@ static inline unsigned int m25p80_rx_nbi
38 * Read an address range from the nor chip. The address range
39 * may be any size provided it is within the physical boundaries.
41 -static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
42 +static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
43 size_t *retlen, u_char *buf)
45 struct m25p *flash = nor->priv;
46 --- a/drivers/mtd/spi-nor/fsl-quadspi.c
47 +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
48 @@ -868,7 +868,7 @@ static int fsl_qspi_write_reg(struct spi
52 -static void fsl_qspi_write(struct spi_nor *nor, loff_t to,
53 +static ssize_t fsl_qspi_write(struct spi_nor *nor, loff_t to,
54 size_t len, size_t *retlen, const u_char *buf)
56 struct fsl_qspi *q = nor->priv;
57 @@ -878,9 +878,10 @@ static void fsl_qspi_write(struct spi_no
59 /* invalid the data in the AHB buffer. */
64 -static int fsl_qspi_read(struct spi_nor *nor, loff_t from,
65 +static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from,
66 size_t len, size_t *retlen, u_char *buf)
68 struct fsl_qspi *q = nor->priv;
69 --- a/include/linux/mtd/spi-nor.h
70 +++ b/include/linux/mtd/spi-nor.h
71 @@ -170,9 +170,9 @@ struct spi_nor {
72 int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
73 int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
75 - int (*read)(struct spi_nor *nor, loff_t from,
76 + ssize_t (*read)(struct spi_nor *nor, loff_t from,
77 size_t len, size_t *retlen, u_char *read_buf);
78 - void (*write)(struct spi_nor *nor, loff_t to,
79 + ssize_t (*write)(struct spi_nor *nor, loff_t to,
80 size_t len, size_t *retlen, const u_char *write_buf);
81 int (*erase)(struct spi_nor *nor, loff_t offs);