mtd: m25p80: fix allocation size
PATCH 1/5 mtd: m25p80: fix allocation size
This patch fixes two memory errors:
1. During a probe failure (in mtd_device_parse_register?) the command buffer would not be freed.
2. The command buffer's size is determined based on the 'fast_read' boolean, but the assignment of fast_read is made after this allocation. Thus, the buffer may be allocated "too small".
To fix the first, just switch to the devres version of kzalloc.
To fix the second, increase MAX_CMD_SIZE unconditionally. It's not worth saving a byte to fiddle around with the conditions here.
This problem was reported by Yuhang Wang a while back.
--- drivers/mtd/devices/m25p80.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/mtd/devices/m25p80.c +7 -13
@@ -78,7 +78,7 @@/* Define max times to check status register before we give up. */ #define MAX_READY_WAIT_JIFFIES (40 * HZ)/* M25P16 specs 40s max chip erase */ -#define MAX_CMD_SIZE 5 +#define MAX_CMD_SIZE 6#define JEDEC_MFR (_jedec_id) ((_jedec_id) >> 16)
@@ -996,15 +996,13 @@ static int m25p_probe(struct spi_device *spi) } } - flash =kzalloc (sizeof *flash,GFP_KERNEL ); + flash =devm_kzalloc (&spi->dev,sizeof (*flash),GFP_KERNEL );if (!flash)return -ENOMEM ; - flash->command =kmalloc (MAX_CMD_SIZE + (flash->fast_read ?1 :0 ), -GFP_KERNEL ); -if (!flash->command) { -kfree (flash); + + flash->command =devm_kzalloc (&spi->dev,MAX_CMD_SIZE ,GFP_KERNEL ); +if (!flash->command)return -ENOMEM ; - } flash->spi = spi;mutex_init (&flash->lock);
@@ -1137,14 +1135,10 @@ static int m25p_probe(struct spi_device *spi)static int m25p_remove (struct spi_device *spi) {struct m25p *flash =spi_get_drvdata (spi); -int status;/* Clean up MTD stuff. */ - status =mtd_device_unregister (&flash->mtd); -if (status ==0 ) { -kfree (flash->command); -kfree (flash); - } +mtd_device_unregister (&flash->mtd); +return 0 ; }
Signature · 1 line
1.8.4
A message that is not in the archive (sent off-list or not yet received): 1382583503-13748-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 5/5 mtd: m25p80: remove 'disabled' device check
It seems like the following commit was never necessary
commit 5f949137952020214cd167093dd7be448f21c079
Author: Shaohui Xie <[email protected]>
Date: Fri Oct 14 15:49:00 2011 +0800
mtd: m25p80: don't probe device which has status of 'disabled'
because it duplicates the code in of_platform_device_create_pdata() which ensures that 'disabled' nodes are never instantiated.
Also, drop the __maybe_unused.
--- drivers/mtd/devices/m25p80.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/mtd/devices/m25p80.c +1 -6
@@ -935,12 +935,7 @@ static int m25p_probe(struct spi_device *spi)struct flash_info *info;unsigned i;struct mtd_part_parser_data ppdata; -struct device_node __maybe_unused *np = spi->dev.of_node; - -#ifdef CONFIG_MTD_OF_PARTS -if (!of_device_is_available (np)) -return -ENODEV ; -#endif +struct device_node *np = spi->dev.of_node;/* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have
Signature · 6 lines
1.8.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1382583503-13748-5-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Sourav Poddar
Reviewed-byRe: [PATCH 5/5] mtd: m25p80: remove 'disabled' device check
Quoted 11 lines · Brian Norris
It seems like the following commit was never necessary
commit
5f949137952020214cd167093dd7be448f21c079
Author: Shaohui Xie<[email protected]>
Date: Fri Oct 14 15:49:00 2011 +0800mtd: m25p80: don't probe device which has status of 'disabled'
because it duplicates the code in
of_platform_device_create_pdata()which ensures that 'disabled' nodes are never instantiated.
Quoted 6 lines
Also, drop the
__maybe_unused.Signed-off-by Brian Norris<[email protected]>Cc Grant Likely<[email protected]>Cc Rob Herring<rob.herring-bsGFqQB8/[email protected]>Cc <[email protected]>
Quoted 12 lines
--- drivers/mtd/devices/m25p80.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/mtd/devices/m25p80.c +0
-0@@ -935,12 +935,7 @@ static int m25p_probe(struct spi_device *spi)struct flash_info *info;unsigned i;struct mtd_part_parser_data ppdata;
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 941
Quoted 10 lines
drivers/mtd/devices/m25p80.c +1
-6-struct device_node __maybe_unused *np = spi->dev.of_node; - -#ifdef CONFIG_MTD_OF_PARTS -if (!of_device_is_available (np)) -return -ENODEV ; -#endif +struct device_node *np = spi->dev.of_node;/* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Grant Likely
Reviewed-byRe: [PATCH 5/5] mtd: m25p80: remove 'disabled' device check
In reply to a message not in the archiveQuoted 6 lines · Brian Norris
It seems like the following commit was never necessary
commit
5f949137952020214cd167093dd7be448f21c079
Author: Shaohui Xie <[email protected]>
Date: Fri Oct 14 15:49:00 2011 +0800
Quoted 6 lines
mtd: m25p80: don't probe device which has status of 'disabled'
because it duplicates the code in
of_platform_device_create_pdata()which ensures that 'disabled' nodes are never instantiated.Also, drop the
__maybe_unused.
Looks reasonable.
Quoted 30 lines
Signed-off-by Brian Norris <[email protected]>Cc Grant Likely <[email protected]>Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc <[email protected]>--- drivers/mtd/devices/m25p80.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/mtd/devices/m25p80.c +1
-6@@ -935,12 +935,7 @@ static int m25p_probe(struct spi_device *spi)struct flash_info *info;unsigned i;struct mtd_part_parser_data ppdata; -struct device_node __maybe_unused *np = spi->dev.of_node; - -#ifdef CONFIG_MTD_OF_PARTS -if (!of_device_is_available (np)) -return -ENODEV ; -#endif +struct device_node *np = spi->dev.of_node;/* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have Signature · 1 line
1.8.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Brian Norris
AppliedRe: [PATCH 5/5] mtd: m25p80: remove 'disabled' device check
In reply to a message not in the archiveQuoted 11 lines · Brian Norris
It seems like the following commit was never necessary
commit
5f949137952020214cd167093dd7be448f21c079
Author: Shaohui Xie <[email protected]>
Date: Fri Oct 14 15:49:00 2011 +0800mtd: m25p80: don't probe device which has status of 'disabled'
because it duplicates the code in
of_platform_device_create_pdata()which ensures that 'disabled' nodes are never instantiated.
Quoted 6 lines
Also, drop the
__maybe_unused.Signed-off-by Brian Norris <[email protected]>Cc Grant Likely <[email protected]>Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc <[email protected]>
Pushed to l2-mtd.git.
Brian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/5 mtd: m25p80: remove obsolete FIXME
In reply to Brian NorrisThe FIXME and NOTE have already been fixed (we have FAST_READ support).
--- drivers/mtd/devices/m25p80.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/mtd/devices/m25p80.c +0 -9
@@ -367,10 +367,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,spi_message_init (&m);memset (t,0 , (sizeof t)); -/* NOTE: -* OPCODE_FAST_READ (if available) is faster. -* Should add 1 byte DUMMY_BYTE. -*/ t[0 ].tx_buf = flash->command; t[0 ].len =m25p_cmdsz (flash) + (flash->fast_read ?1 :0 );spi_message_add_tail (&t[0 ], &m);
@@ -388,11 +384,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,return 1 ; } -/* FIXME switch to OPCODE_FAST_READ. It's required for higher -* clocks; and at this writing, every chip this driver handles -* supports that opcode. -*/ -/* Set up the write data buffer. */ opcode = flash->read_opcode; flash->command[0 ] = opcode;
Signature · 1 line
1.8.4
Re: [PATCH 2/5] mtd: m25p80: remove obsolete FIXME
Quoted 3 lines · Brian Norris
The FIXME and NOTE have already been fixed (we have
FAST_READsupport).Signed-off-by Brian Norris<[email protected]>
Quoted 31 lines
--- drivers/mtd/devices/m25p80.c | 9 --------- 1 file changed, 9 deletions(-)drivers/mtd/devices/m25p80.c +0
-9@@ -367,10 +367,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,spi_message_init (&m);memset (t,0 , (sizeof t)); -/* NOTE: -* OPCODE_FAST_READ (if available) is faster. -* Should add 1 byte DUMMY_BYTE. -*/ t[0 ].tx_buf = flash->command; t[0 ].len =m25p_cmdsz (flash) + (flash->fast_read ?1 :0 );spi_message_add_tail (&t[0 ],&m);@@ -388,11 +384,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,return 1 ; } -/* FIXME switch to OPCODE_FAST_READ. It's required for higher -* clocks; and at this writing, every chip this driver handles -* supports that opcode. -*/ -/* Set up the write data buffer. */ opcode = flash->read_opcode; flash->command[0 ] = opcode;
Re: [PATCH 2/5] mtd: m25p80: remove obsolete FIXME
In reply to Brian NorrisHi Brian,
Quoted 24 lines
The FIXME and NOTE have already been fixed (we have
FAST_READsupport).Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/devices/m25p80.c | 9 --------- 1 file changed, 9 deletions(-)drivers/mtd/devices/m25p80.c +0
-4@@ -367,10 +367,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, spi_message_init(&m);memset (t,0 , (sizeof t)); -/* NOTE: -* OPCODE_FAST_READ (if available) is faster. -* Should add 1 byte DUMMY_BYTE. -*/ t[0 ].tx_buf = flash->command; t[0 ].len =m25p_cmdsz (flash) + (flash->fast_read ?1 :0 );spi_message_add_tail (&t[0 ], &m);@@ -388,11 +384,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, return 1;
drivers/mtd/devices/m25p80.c static int m25p80_read(struct mtd_info *mtd, loff_t · line 389
Quoted 10 lines
drivers/mtd/devices/m25p80.c +0
-5} -/* FIXME switch to OPCODE_FAST_READ. It's required for higher -* clocks; and at this writing, every chip this driver handles -* supports that opcode. -*/ -/* Set up the write data buffer. */ opcode = flash->read_opcode; flash->command[0 ] = opcode;
Makes great share of sense ;-)
Best regards,
Marek Vasut
PATCH 3/5 mtd: m25p80: re-align ID entries
In reply to Brian NorrisNo change in the table data.
--- drivers/mtd/devices/m25p80.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/mtd/devices/m25p80.c +16 -16
@@ -740,19 +740,19 @@ static const struct spi_device_id m25p_ids[] = { { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) },/* EON -- en25xxx */ - { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, - { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, - { "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) }, - { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, - { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, - { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) }, + { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, + { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, + { "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) }, + { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, + { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, + { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) },/* ESMT */ { "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) },/* Everspin */ - { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, M25P_NO_ERASE | M25P_NO_FR) }, - { "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, M25P_NO_ERASE | M25P_NO_FR) }, + { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, M25P_NO_ERASE | M25P_NO_FR) }, + { "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, M25P_NO_ERASE | M25P_NO_FR) },/* GigaDevice */ { "gd25q32", INFO(0xc84016, 0, 64 * 1024, 64, SECT_4K) },
@@ -777,16 +777,16 @@ static const struct spi_device_id m25p_ids[] = { { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, 0) },/* Micron */ - { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) }, - { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) }, - { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, - { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) }, - { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) }, + { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) }, + { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) }, + { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, + { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) }, + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },/* PMC */ - { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, - { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, - { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) }, + { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, + { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, + { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) },/* Spansion -- single (large) sector size only, at least * for the chips listed here (without boot sectors).
Signature · 1 line
1.8.4
Re: [PATCH 3/5] mtd: m25p80: re-align ID entries
Quoted 3 lines · Brian Norris
No change in the table data.
Signed-off-by Brian Norris<[email protected]>
Quoted 61 lines
--- drivers/mtd/devices/m25p80.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/mtd/devices/m25p80.c +16
-16@@ -740,19 +740,19 @@ static const struct spi_device_id m25p_ids[] = { { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) },/* EON -- en25xxx */ - { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, - { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, - { "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) }, - { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, - { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, - { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) }, + { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, + { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, + { "en25q32b", INFO(0x1c3016, 0, 64 * 1024, 64, 0) }, + { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, + { "en25q64", INFO(0x1c3017, 0, 64 * 1024, 128, SECT_4K) }, + { "en25qh256", INFO(0x1c7019, 0, 64 * 1024, 512, 0) },/* ESMT */ { "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K) },/* Everspin */ - { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, M25P_NO_ERASE | M25P_NO_FR) }, - { "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, M25P_NO_ERASE | M25P_NO_FR) }, + { "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, M25P_NO_ERASE | M25P_NO_FR) }, + { "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, M25P_NO_ERASE | M25P_NO_FR) },/* GigaDevice */ { "gd25q32", INFO(0xc84016, 0, 64 * 1024, 64, SECT_4K) },@@ -777,16 +777,16 @@ static const struct spi_device_id m25p_ids[] = { { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, 0) },/* Micron */ - { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) }, - { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) }, - { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, - { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) }, - { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) }, + { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) }, + { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) }, + { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) }, + { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) }, + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },/* PMC */ - { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, - { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, - { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) }, + { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) }, + { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, + { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) },/* Spansion -- single (large) sector size only, at least * for the chips listed here (without boot sectors).
PATCH 4/5 mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
In reply to Brian NorrisRemove the compile-time option for FAST_READ, since we have run-time support for detecting it.
--- drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/mtd/devices/Kconfig +0 -7
@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK >= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEAR
drivers/mtd/devices/m25p80.c +6 -5
@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true; -#ifdef CONFIG_M25PXX_USE_FAST_READ - flash->fast_read = true; -#endif +/* Some devices cannot do fast-read, no matter what DT tells us */ if (info->flags &M25P_NO_FR ) flash->fast_read = false;
Signature · 1 line
1.8.4
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Hi Brian,
Quoted 34 lines · Brian Norris
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris<[email protected]>--- drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-7@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK>= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEARdrivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1064
Quoted 10 lines
drivers/mtd/devices/m25p80.c +5
-2- flash->fast_read = false; -if (np&&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;
This comment is in sync with my quad read mode support patch on the mtd list.
Here, you are defaulting the fast read to be true. Once I add quad mode
on top of this, I will set flash->quad_read = true. So, we will have both
fast and quad read set(which will not be correct). So, it is necessary to default to fast read ?
Quoted 7 lines
drivers/mtd/devices/m25p80.c +1
-3-#ifdef CONFIG_M25PXX_USE_FAST_READ - flash->fast_read = true; -#endif +/* Some devices cannot do fast-read, no matter what DT tells us */ if (info->flags&M25P_NO_FR ) flash->fast_read = false;
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Quoted 49 lines · Sourav Poddar
Hi Brian,
Quoted 35 lines · Brian Norris
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris<[email protected]>--- drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-0@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a devicewhich
doesn't support the JEDEC ID instruction.drivers/mtd/devices/Kconfig +0
-7-config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK>= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEARdrivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1064
Quoted 10 lines
drivers/mtd/devices/m25p80.c +5
-2- flash->fast_read = false; -if (np&&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;This comment is in sync with my quad read mode support patch on the mtd list.
Quoted 3 lines
Here, you are defaulting the fast read to be true. Once I add quad mode
on top of this, I will setflash->quad_read= true. So, we will have both
fast and quad read set(which will not be correct). So, it is necessary to default to fast read ?
Though, we will hit this scenario only for a non dt case. For dt case, things will be fine.
Quoted 8 lines
Quoted 7 lines
drivers/mtd/devices/m25p80.c +1
-3-#ifdef CONFIG_M25PXX_USE_FAST_READ - flash->fast_read = true; -#endif +/* Some devices cannot do fast-read, no matter what DT tells us */ if (info->flags&M25P_NO_FR ) flash->fast_read = false;
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Quoted 20 lines · Sourav Poddar
Quoted 19 lines · Sourav Poddar
Quoted 5 lines · Brian Norris
drivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1064
Quoted 10 lines
drivers/mtd/devices/m25p80.c +5
-2- flash->fast_read = false; -if (np&&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;This comment is in sync with my quad read mode support patch on the mtd list.
Quoted 1 line
Quoted 1 line
Here, you are defaulting the fast read to be true.
It was already default true for non-DT case where M25PXX_USE_FAST_READ=y. I believe my code is purely a refactoring of the code, assuming M25PXX_USE_FAST_READ is always enabled (and removing the Kconfig).
Quoted 4 lines
Quoted 4 lines
Once I add quad mode
on top of this, I will setflash->quad_read= true. So, we will have both fast and quad read set(which will not be correct). So, it is necessary to default to fast read ?
I think my patch is a correct refactoring by itself. Any problem your quad read patch has with it would still be a problem without this patch.
So, without quad-read support, we should default to fast-read unless the chip doesn't support it. I think this is reasonable.
Now, once you add quad-read, you need to have quad-read override fast-read.
Quoted 2 lines
Though, we will hit this scenario only for a non dt case. For dt case, things will be fine.
Yes, but we need to make sure things make sense for all cases.
Quoted 8 lines
Quoted 8 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1068
Quoted 7 lines
drivers/mtd/devices/m25p80.c +1
-3-#ifdef CONFIG_M25PXX_USE_FAST_READ - flash->fast_read = true; -#endif +/* Some devices cannot do fast-read, no matter what DT tells us */ if (info->flags&M25P_NO_FR ) flash->fast_read = false;
I just realized this: fast-read and quad-read are mutually exclusive, so the field that is currently 'bool m25p.fast_read' could easily just become an 'enum m25p.read_type' (with values M25P_READ_NORMAL, M25P_READ_FAST, M25P_READ_QUAD). That may or may not help your quad read patch.
I can delay this patch until others have looked at it, if you'd like. You can resubmit your quad read patch without this patch 4. (But I think this patch will help clean up your patch slightly.)
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Quoted 27 lines · Brian Norris
Quoted 20 lines · Sourav Poddar
Quoted 19 lines · Sourav Poddar
Quoted 5 lines · Brian Norris
drivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1064
Quoted 10 lines
drivers/mtd/devices/m25p80.c +5
-2- flash->fast_read = false; -if (np&&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;This comment is in sync with my quad read mode support patch on the mtd list.
Quoted 1 line
Quoted 1 line
Here, you are defaulting the fast read to be true.
It was already default true for non-DT case where M25PXX_USE_FAST_READ=y. I believe my code is purely a refactoring of the code, assuming
M25PXX_USE_FAST_READis always enabled (and removing theKconfig).
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Once I add quad mode
on top of this, I will setflash->quad_read= true. So, we will have both fast and quad read set(which will not be correct). So, it is necessary to default to fast read ?I think my patch is a correct refactoring by itself. Any problem your quad read patch has with it would still be a problem without this patch.
True, my bad I didn't realise that for internal testing I disable fast read option in menuconfig.
Quoted 10 lines
So, without quad-read support, we should default to fast-read unless the chip doesn't support it. I think this is reasonable.
Now, once you add quad-read, you need to have quad-read override fast-read.
Quoted 2 lines
Though, we will hit this scenario only for a non dt case. For dt case, things will be fine.
Yes, but we need to make sure things make sense for all cases.
Yes.
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1068
Quoted 7 lines
drivers/mtd/devices/m25p80.c +1
-3-#ifdef CONFIG_M25PXX_USE_FAST_READ - flash->fast_read = true; -#endif +/* Some devices cannot do fast-read, no matter what DT tells us */ if (info->flags&M25P_NO_FR ) flash->fast_read = false;I just realized this: fast-read and quad-read are mutually exclusive, so the field that is currently 'bool m25p.fast_read' could easily just become
correct.
Quoted 6 lines
an 'enum m25p.read_type' (with values
M25P_READ_NORMAL,M25P_READ_FAST,M25P_READ_QUAD). That may or may not help your quad read patch.I can delay this patch until others have looked at it, if you'd like. You can resubmit your quad read patch without this patch 4. (But I think this patch will help clean up your patch slightly.)
Ok. I will include this patch and try to cleanup.
Quoted 1 line
Brian
Brian Norris
AppliedRe: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
In reply to Brian NorrisQuoted 4 lines · Brian Norris
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>
Pushed to l2-mtd.git. Comments are still welcome.
FYI Huang: Sourav's new quad read patch applies on top of this patch.
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
In reply to Brian NorrisHi Brian,
Quoted 33 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-7@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK >= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEARdrivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size;
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 10 lines
drivers/mtd/devices/m25p80.c +5
-2flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;
We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
[...]
Best regards,
Marek Vasut
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
I see I never responded to this one.
Quoted 37 lines · Marek Vasut
Hi Brian,
Quoted 35 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-7@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK >= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEARdrivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;
Quoted 11 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 8 lines
drivers/mtd/devices/m25p80.c +5
-2- flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y. (In my experience, everyone has it set to y. Perhaps I'm wrong.)
Now, it's unclear to me what this Kconfig was used for. It's the wrong approach for controlling fast read on a per-controller or per-flash-device basis, as it provides a blunt hammer to disable it for ALL systems which might use the same kernel (think multiplatform kernels). And now we have a better alternative: the M25P_NO_FR flag for flash which do not support fast-read.
However, if we come across SPI controllers which can't handle this, then we might have a problem. Such a situation would really suggest that we need to identify whether a SPI controller supports fast-read, not just the flash device.
(Side note: IMO, given the fact that we have to have an ID table for these flash anyway, the DT property simply provides redundant information. In the case of the quad-read patch, we were able to identify this early to avoid an unnecessary DT binding. But in this case, we also have an indication of controller support for quad I/O...)
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Dear Brian Norris,
Quoted 54 lines
I see I never responded to this one.
Quoted 51 lines · Marek Vasut
Hi Brian,
Quoted 49 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>---
drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-7@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK >= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMIdrivers/mtd/devices/Kconfig +0
-0tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEAR(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex 7e3ec7a..d6c5c57 100644drivers/mtd/devices/m25p80.c +5
-2@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */
Quoted 8 lines
Quoted 4 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 1 line
drivers/mtd/devices/m25p80.c +0
-0flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y. (In my experience, everyone has it set to y. Perhaps I'm wrong.)
OK, this is where we diverged. I always set FAST_READ to =n and only enabled it via this DT prop if I was dead sure the chip could do it.
Quoted 6 lines
Now, it's unclear to me what this
Kconfigwas used for. It's the wrong approach for controlling fast read on a per-controller or per-flash-device basis, as it provides a blunt hammer to disable it for ALL systems which might use the same kernel (think multiplatform kernels). And now we have a better alternative: theM25P_NO_FRflag for flash which do not support fast-read.
This Kconfig was entirely wrong. I suspect it was there from the old times to force-enable the fast read and was meant for simple systems with one SPI NOR. Multiplatform kernels weren't taken into consideration here, the thing was added 5 years ago.
commit 2230b76b3838a37167f80487c694d8691248da9f
Date: Fri Apr 25 12:07:32 2008 +0800
[MTD] m25p80: add FAST_READ access support to M25Pxx
Quoted 4 lines
However, if we come across SPI controllers which can't handle this, then we might have a problem. Such a situation would really suggest that we need to identify whether a SPI controller supports fast-read, not just the flash device.
The FAST_READ is entirely flash-device thing, it has nothing to do with the controller. I wonder why there's this 50 MHz limit in the kernel config at all. My understanding of FAST_READ is that after you send FAST_READ opcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.
Quoted 3 lines
(Side note: IMO, given the fact that we have to have an ID table for these flash anyway, the DT property simply provides redundant information.
Side note: I wonder how we should handle exotic chips like the N25Q256A which recycle the ID for different chips with different capabilities though. We might need to have some DT props.
Quoted 3 lines
In the case of the quad-read patch, we were able to
identify this early to avoid an unnecessary DT binding. But in this case, we also have an indication of controller support for quad I/O...)
Yes. I see your point why the fast-read might be redundant.
Quoted 4 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Quoted 76 lines · Marek Vasut
Dear Brian Norris,
Quoted 54 lines
I see I never responded to this one.
Quoted 51 lines · Marek Vasut
Hi Brian,
Quoted 49 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris<[email protected]>---
drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)drivers/mtd/devices/Kconfig +0
-7@@ -95,13 +95,6 @@ config MTD_M25P80 if you want to specify device partitioning or to use a device which doesn't support the JEDEC ID instruction. -config M25PXX_USE_FAST_READ - bool "Use FAST_READ OPCode allowing SPI CLK>= 50MHz" - depends on MTD_M25P80 - default y - help - This option enables FAST_READ access supported by ST M25Pxx. - config MTD_SPEAR_SMItristate "SPEAR MTD NOR Support through SMI controller" depends on
PLAT_SPEAR(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex 7e3ec7a..d6c5c57 100644drivers/mtd/devices/m25p80.c +5
-2@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np&&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ Quoted 6 lines
Quoted 3 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 1 line
drivers/mtd/devices/m25p80.c +0
-0flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y. (In my experience, everyone has it set to y. Perhaps I'm wrong.)
OK, this is where we diverged. I always set
FAST_READto =n and only enabled it via this DT prop if I was dead sure the chip could do it.Quoted 6 lines
Now, it's unclear to me what this
Kconfigwas used for. It's the wrong approach for controlling fast read on a per-controller or per-flash-device basis, as it provides a blunt hammer to disable it for ALL systems which might use the same kernel (think multiplatform kernels). And now we have a better alternative: theM25P_NO_FRflag for flash which do not support fast-read.This
Kconfigwas entirely wrong. I suspect it was there from the old times to force-enable the fast read and was meant for simple systems with one SPI NOR. Multiplatform kernels weren't taken into consideration here, the thing was added 5 years ago.
Quoted 5 lines
commit
2230b76b3838a37167f80487c694d8691248da9f
Date: Fri Apr 25 12:07:32 2008 +0800[MTD] m25p80: add
FAST_READaccess support to M25Pxx
I tried to work around this in my quad patch, where based on some check, I have tried to assign opcode to quad or fast read. By default, I have kept the command to NORMAL read.
Quoted 10 lines
Quoted 4 lines
However, if we come across SPI controllers which can't handle this, then we might have a problem. Such a situation would really suggest that we need to identify whether a SPI controller supports fast-read, not just the flash device.
The
FAST_READis entirely flash-device thing, it has nothing to do with the controller. I wonder why there's this 50 MHz limit in the kernel config at all. My understanding ofFAST_READis that after you sendFAST_READopcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.
I dont think resending commands after each block comes into picture for slow read. What differnece I see between NORMAL(slow) ad fast read is just the dummy bytes.
Quoted 16 lines
Quoted 3 lines
(Side note: IMO, given the fact that we have to have an ID table for these flash anyway, the DT property simply provides redundant information.
Side note: I wonder how we should handle exotic chips like the N25Q256A which recycle the ID for different chips with different capabilities though. We might need to have some DT props.
Quoted 3 lines
In the case of the quad-read patch, we were able to
identify this early to avoid an unnecessary DT binding. But in this case, we also have an indication of controller support for quad I/O...)Yes. I see your point why the fast-read might be redundant.
Quoted 4 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
In reply to Marek VasutHi Marek,
Quoted 39 lines · Marek Vasut
Dear Brian Norris,
Quoted 37 lines · Marek Vasut
Quoted 29 lines
Hi Brian,
Quoted 27 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>---
drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex 7e3ec7a..d6c5c57 100644drivers/mtd/devices/m25p80.c +5
-2@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ Quoted 4 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 1 line
drivers/mtd/devices/m25p80.c +0
-0flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y.
Ah, my statement was wrong: for DT-instantiated devices, my patch "defaulted" as if M25PXX_USE_FAST_READ=n; for devices without a DT node, it defaulted as if M25PXX_USE_FAST_READ=y.
Quoted 5 lines
Quoted 2 lines
(In my experience, everyone has
it set to y. Perhaps I'm wrong.)OK, this is where we diverged. I always set
FAST_READto =n and only enabled it via this DT prop if I was dead sure the chip could do it.
Right, that actually makes sense, and your mode is not affected by my patch. For DT-enabled devices, we default to the DT property.
The only mode that has less flexibility is for platform devices (non-DT), where we only use normal read for devices that can't handle FAST READ.
Quoted 11 lines
Quoted 6 lines
Now, it's unclear to me what this
Kconfigwas used for. It's the wrong approach for controlling fast read on a per-controller or per-flash-device basis, as it provides a blunt hammer to disable it for ALL systems which might use the same kernel (think multiplatform kernels). And now we have a better alternative: theM25P_NO_FRflag for flash which do not support fast-read.This
Kconfigwas entirely wrong. I suspect it was there from the old times to force-enable the fast read and was meant for simple systems with one SPI NOR. Multiplatform kernels weren't taken into consideration here, the thing was added 5 years ago.
Sure, I agree.
Quoted 5 lines
commit
2230b76b3838a37167f80487c694d8691248da9f
Date: Fri Apr 25 12:07:32 2008 +0800[MTD] m25p80: add
FAST_READaccess support to M25Pxx
Quoted 7 lines
Quoted 4 lines
However, if we come across SPI controllers which can't handle this, then we might have a problem. Such a situation would really suggest that we need to identify whether a SPI controller supports fast-read, not just the flash device.
The
FAST_READis entirely flash-device thing, it has nothing to do with the controller. I wonder why there's this 50 MHz limit in the kernel config at all.
I have a Spansion S25FL128S datasheet which says:
"The maximum operating clock frequency for the READ command is 50 MHz."
And:
"The maximum operating clock frequency for FAST READ command is 133 MHz."
But this does suggest, as you say, that the controller provides no limitation on using FAST READ. However, the extra dummy cycles would be a *slight* penalty for using FAST READ instead of (normal) READ when run at a frequency under which either would suffice. But this likely isn't a significant problem.
Quoted 3 lines
My understanding of
FAST_READis that after you sendFAST_READopcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.
As Sourav said in his response, I don't believe this is true. AIUI, the only differences are the dummy cycles and the maximum clock frequency.
Quoted 7 lines
Quoted 3 lines
(Side note: IMO, given the fact that we have to have an ID table for these flash anyway, the DT property simply provides redundant information.
Side note: I wonder how we should handle exotic chips like the N25Q256A which recycle the ID for different chips with different capabilities though. We might need to have some DT props.
Cross that bridge when/if we come to it, I guess? :) Do you know of any current problems with this device?
Quoted 8 lines
Quoted 3 lines
In the case of the quad-read patch, we were able to
identify this early to avoid an unnecessary DT binding. But in this case, we also have an indication of controller support for quad I/O...)Yes. I see your point why the fast-read might be redundant.
Quoted 2 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
So what do you think? I feel like my current patch is the right way to go, but I think I could update the description to be more verbose, since there are obviously a few other issues coming into play here.
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Hi Brian,
Quoted 25 lines
Hi Marek,
Quoted 22 lines · Marek Vasut
Dear Brian Norris,
Quoted 20 lines · Marek Vasut
Quoted 19 lines
Hi Brian,
Quoted 17 lines
Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it.Signed-off-by Brian Norris <[email protected]>---
drivers/mtd/devices/Kconfig | 7 ------- drivers/mtd/devices/m25p80.c | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex 7e3ec7a..d6c5c57 100644drivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi)
Quoted 8 lines
drivers/mtd/devices/m25p80.c +3
-2flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read = of_property_read_bool(np, "m25p,fast-
read");
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device · line 1064
Quoted 2 lines
drivers/mtd/devices/m25p80.c +2
-0+else +/* If we weren't instantiated by DT, default to fast-
read */
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 2 lines
drivers/mtd/devices/m25p80.c +0
-0flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y.
Ah, my statement was wrong: for DT-instantiated devices, my patch "defaulted" as if M25PXX_USE_FAST_READ=n; for devices without a DT node, it defaulted as if M25PXX_USE_FAST_READ=y.
I'd say old devices (which are not DT capable even) might actually be less able to support the FAST READ opcode. But I think we're reaching a point where we cannot clearly tell and either way we will break some devices here. If that's the case, let's do it ;-)
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
(In my experience, everyone has
it set to y. Perhaps I'm wrong.)OK, this is where we diverged. I always set
FAST_READto =n and only enabled it via this DT prop if I was dead sure the chip could do it.
Quoted 6 lines
Right, that actually makes sense, and your mode is not affected by my patch. For DT-enabled devices, we default to the DT property.
The only mode that has less flexibility is for platform devices (non-DT), where we only use normal read for devices that can't handle FAST READ.
And there we should disable it by default to play safe, no ?
Quoted 35 lines
Quoted 11 lines
Quoted 6 lines
Now, it's unclear to me what this
Kconfigwas used for. It's the wrong approach for controlling fast read on a per-controller or per-flash-device basis, as it provides a blunt hammer to disable it for ALL systems which might use the same kernel (think multiplatform kernels). And now we have a better alternative: theM25P_NO_FRflag for flash which do not support fast-read.This
Kconfigwas entirely wrong. I suspect it was there from the old times to force-enable the fast read and was meant for simple systems with one SPI NOR. Multiplatform kernels weren't taken into consideration here, the thing was added 5 years ago.Sure, I agree.
Quoted 5 lines
commit
2230b76b3838a37167f80487c694d8691248da9f
Date: Fri Apr 25 12:07:32 2008 +0800[MTD] m25p80: add
FAST_READaccess support to M25PxxQuoted 1 line
Quoted 8 lines
Quoted 4 lines
However, if we come across SPI controllers which can't handle this, then we might have a problem. Such a situation would really suggest that we need to identify whether a SPI controller supports fast-read, not just the flash device.
The
FAST_READis entirely flash-device thing, it has nothing to do with the controller. I wonder why there's this 50 MHz limit in the kernel config at all.I have a Spansion S25FL128S datasheet which says:
"The maximum operating clock frequency for the READ command is 50 MHz."
And:
Quoted 8 lines
"The maximum operating clock frequency for FAST READ command is 133 MHz."
But this does suggest, as you say, that the controller provides no limitation on using FAST READ. However, the extra dummy cycles would be a *slight* penalty for using FAST READ instead of (normal) READ when run at a frequency under which either would suffice. But this likely isn't a significant problem.
Certainly. All we need to know is whether or not does the chip support FAST READ and if so, we can use it.
Quoted 7 lines
Quoted 4 lines
My understanding of
FAST_READis that after you sendFAST_READopcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.As Sourav said in his response, I don't believe this is true. AIUI, the only differences are the dummy cycles and the maximum clock frequency.
Aka. "slow" READ can also read as many bytes as seen fit ?
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
(Side note: IMO, given the fact that we have to have an ID table for these flash anyway, the DT property simply provides redundant information.
Side note: I wonder how we should handle exotic chips like the N25Q256A which recycle the ID for different chips with different capabilities though. We might need to have some DT props.
Cross that bridge when/if we come to it, I guess? :) Do you know of any current problems with this device?
This particular one? Not in this context, but there are many otherwise.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
In the case of the quad-read patch, we were able to
identify this early to avoid an unnecessary DT binding. But in this case, we also have an indication of controller support for quad I/O...)
Quoted 8 lines
Quoted 4 lines
Yes. I see your point why the fast-read might be redundant.
Quoted 2 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
So what do you think? I feel like my current patch is the right way to go, but I think I could update the description to be more verbose, since there are obviously a few other issues coming into play here.
Yes, I won't hold it any longer. If someone complains, we will know where the wind blows from anyway and then we can fix his platform properly.
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Hi Marek,
Quoted 33 lines · Marek Vasut
Hi Brian,
Quoted 31 lines
Hi Marek,
Quoted 27 lines · Marek Vasut
Dear Brian Norris,
Quoted 25 lines · Marek Vasut
Quoted 17 lines
Hi Brian,
Quoted 15 lines
drivers/mtd/devices/m25p80.c +5
-2@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size; - flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read =of_property_read_bool (np,"m25p,fast-read" ); +else +/* If we weren't instantiated by DT, default to fast-read */ Quoted 4 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1063
Quoted 1 line
drivers/mtd/devices/m25p80.c +0
-0flash->fast_read = true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y.
Quoted 8 lines
Quoted 3 lines
Ah, my statement was wrong: for DT-instantiated devices, my patch "defaulted" as if M25PXX_USE_FAST_READ=n; for devices without a DT node, it defaulted as if M25PXX_USE_FAST_READ=y.
I'd say old devices (which are not DT capable even) might actually be less able to support the FAST READ opcode. But I think we're reaching a point where we cannot clearly tell and either way we will break some devices here. If that's the case, let's do it ;-)
I agree, let's just do it.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
(In my experience, everyone has
it set to y. Perhaps I'm wrong.)OK, this is where we diverged. I always set
FAST_READto =n and only enabled it via this DT prop if I was dead sure the chip could do it.
Quoted 8 lines
Quoted 6 lines
Right, that actually makes sense, and your mode is not affected by my patch. For DT-enabled devices, we default to the DT property.
The only mode that has less flexibility is for platform devices (non-DT), where we only use normal read for devices that can't handle FAST READ.
And there we should disable it by default to play safe, no ?
Unless the device table M25P_NO_FR flag is imprecisely-used (which it may be), I don't think we need a "play-it-safe" option here. The current code seems to have the right level of precision.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
My understanding of
FAST_READis that after you sendFAST_READopcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.As Sourav said in his response, I don't believe this is true. AIUI, the only differences are the dummy cycles and the maximum clock frequency.
Aka. "slow" READ can also read as many bytes as seen fit ?
Yes, according to the data sheet I read.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
So what do you think? I feel like my current patch is the right way to go, but I think I could update the description to be more verbose, since there are obviously a few other issues coming into play here.
Yes, I won't hold it any longer. If someone complains, we will know where the wind blows from anyway and then we can fix his platform properly.
Sounds good. I'm updating the commit to include the following description (no code changes, so no need to rebase, Sourav):
------------------ BEGIN DESCRIPTION ------------------ Remove the compile-time option for FAST_READ, since we have run-time support for detecting it. This refactors the logic for enabling fast-read, such that for DT-enabled devices, we honor the "m25p,fast-read" property but for non-DT devices, we default to using FAST_READ whenever the flash device supports it according to our m25p_ids[] table.
Normal READ and FAST_READ differ only in the following:
* FAST_READ supports SPI higher clock frequencies [1]
* number of dummy cycles; FAST_READ requires 8 dummy cycles (whereas READ requires 0) to allow the flash sufficient setup time, even when running at higher clock speeds
Thus, for flash chips which support FAST_READ, there is otherwise no limiting reason why we cannot use the FAST_READ opcode instead of READ. It simply allows the SPI controller to run at higher clock rates. So theoretically, nobody should be needing the compile-time option anyway.
[1] I have a Spansion S25FL128S datasheet which says:
"The maximum operating clock frequency for the READ command is 50 MHz."
And:
"The maximum operating clock frequency for FAST READ command is 133 MHz."
-------------------- END DESCRIPTION ------------------
Brian
Re: [PATCH 4/5] mtd: m25p80: remove M25PXX_USE_FAST_READ Kconfig
Dear Brian Norris,
Quoted 21 lines
Hi Marek,
Quoted 18 lines · Marek Vasut
Hi Brian,
Quoted 16 lines
Hi Marek,
Quoted 13 lines · Marek Vasut
Dear Brian Norris,
Quoted 11 lines · Marek Vasut
Quoted 10 lines
Hi Brian,
Quoted 8 lines
drivers/mtd/devices/m25p80.c +0
-0@@ -1055,13 +1055,14 @@ static int m25p_probe(struct spi_device *spi) flash->page_size = info->page_size; flash->mtd.writebufsize = flash->page_size;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mtd/devices/m25p80.c
Quoted 7 lines
drivers/mtd/devices/m25p80.c +3
-2- flash->fast_read = false; -if (np &&of_property_read_bool (np,"m25p,fast-read" )) +if (np) +/* If we were instantiated by DT, use it */ + flash->fast_read = of_property_read_bool(np,"m25p,fast-read"); + else
drivers/mtd/devices/m25p80.c +1
-0+/* If we weren't instantiated by DT, default to fast-
read */
Quoted 33 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
flash->fast_read= true;We should default to FALSE , unless explicitly requested by DT, am I wrong? Otherwise this might break the old chips.
I believe my patch is simply a refactoring of the existing code with the assumption that M25PXX_USE_FAST_READ=y.
Quoted 8 lines
Quoted 3 lines
Ah, my statement was wrong: for DT-instantiated devices, my patch "defaulted" as if M25PXX_USE_FAST_READ=n; for devices without a DT node, it defaulted as if M25PXX_USE_FAST_READ=y.
I'd say old devices (which are not DT capable even) might actually be less able to support the FAST READ opcode. But I think we're reaching a point where we cannot clearly tell and either way we will break some devices here. If that's the case, let's do it ;-)
I agree, let's just do it.
Quoted 13 lines
Quoted 12 lines
Quoted 5 lines
Quoted 2 lines
(In my experience, everyone has
it set to y. Perhaps I'm wrong.)OK, this is where we diverged. I always set
FAST_READto =n and only enabled it via this DT prop if I was dead sure the chip could do it.Right, that actually makes sense, and your mode is not affected by my patch. For DT-enabled devices, we default to the DT property.
The only mode that has less flexibility is for platform devices (non-DT), where we only use normal read for devices that can't handle FAST READ.
Quoted 5 lines
Quoted 1 line
And there we should disable it by default to play safe, no ?
Unless the device table
M25P_NO_FRflag is imprecisely-used (which it may be), I don't think we need a "play-it-safe" option here. The current code seems to have the right level of precision.
Yes, I found this NO_FR flag just yesterday (shame on me!) when I was searching for some strange behavior on one of my boards here. I think we're good.
Quoted 20 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
My understanding of
FAST_READis that after you sendFAST_READopcode, you can read all you want until CS is toggled, only then you can send another opcode. The "slow" READ opcode on the other hand has to be sent for each block.As Sourav said in his response, I don't believe this is true. AIUI, the only differences are the dummy cycles and the maximum clock frequency.
Aka. "slow" READ can also read as many bytes as seen fit ?
Yes, according to the data sheet I read.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
If you still object to this patch, I can drop the patch from l2-mtd.git for now. Then Sourav will need to rebase his patch again.
So what do you think? I feel like my current patch is the right way to go, but I think I could update the description to be more verbose, since there are obviously a few other issues coming into play here.
Quoted 5 lines
Quoted 2 lines
Yes, I won't hold it any longer. If someone complains, we will know where the wind blows from anyway and then we can fix his platform properly.
Sounds good. I'm updating the commit to include the following description (no code changes, so no need to rebase, Sourav):
Cool, thanks!
Quoted 33 lines
------------------ BEGIN DESCRIPTION ------------------ Remove the compile-time option for
FAST_READ, since we have run-time support for detecting it. This refactors the logic for enabling fast-read, such that for DT-enabled devices, we honor the "m25p,fast-read" property but for non-DT devices, we default to usingFAST_READwhenever the flash device supports it according to our m25p_ids[] table.Normal READ and
FAST_READdiffer only in the following:*
FAST_READsupports SPI higher clock frequencies [1]* number of dummy cycles;
FAST_READrequires 8 dummy cycles (whereas READ requires 0) to allow the flash sufficient setup time, even when running at higher clock speedsThus, for flash chips which support
FAST_READ, there is otherwise no limiting reason why we cannot use theFAST_READopcode instead of READ. It simply allows the SPI controller to run at higher clock rates. So theoretically, nobody should be needing the compile-time option anyway.[1] I have a Spansion S25FL128S datasheet which says:
"The maximum operating clock frequency for the READ command is 50 MHz."
And:
"The maximum operating clock frequency for FAST READ command is 133 MHz."
-------------------- END DESCRIPTION ------------------Brian
Quoted 11 lines · Brian Norris
This patch fixes two memory errors:
1. During a probe failure (in
mtd_device_parse_register?) the command buffer would not be freed.2. The command buffer's size is determined based on the '
fast_read' boolean, but the assignment offast_readis made after this allocation. Thus, the buffer may be allocated "too small".To fix the first, just switch to the devres version of kzalloc.
Quoted 8 lines
To fix the second, increase
MAX_CMD_SIZEunconditionally. It's not worth saving a byte to fiddle around with the conditions here.This problem was reported by Yuhang Wang a while back.
Signed-off-by Brian Norris<[email protected]>Reported-by Yuhang Wang<[email protected]>Cc <[email protected]>
Quoted 54 lines
--- drivers/mtd/devices/m25p80.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)drivers/mtd/devices/m25p80.c +7
-13@@ -78,7 +78,7 @@/* Define max times to check status register before we give up. */ #define MAX_READY_WAIT_JIFFIES (40 * HZ)/* M25P16 specs 40s max chip erase */ -#define MAX_CMD_SIZE 5 +#define MAX_CMD_SIZE 6#define JEDEC_MFR (_jedec_id) ((_jedec_id)>> 16)@@ -996,15 +996,13 @@ static int m25p_probe(struct spi_device *spi) } } - flash =kzalloc (sizeof *flash,GFP_KERNEL ); + flash =devm_kzalloc (&spi->dev,sizeof (*flash),GFP_KERNEL );if (!flash)return -ENOMEM ; - flash->command =kmalloc (MAX_CMD_SIZE + (flash->fast_read ?1 :0 ), -GFP_KERNEL ); -if (!flash->command) { -kfree (flash); + + flash->command =devm_kzalloc (&spi->dev,MAX_CMD_SIZE ,GFP_KERNEL ); +if (!flash->command)return -ENOMEM ; - } flash->spi = spi;mutex_init (&flash->lock);@@ -1137,14 +1135,10 @@ static int m25p_probe(struct spi_device *spi)static int m25p_remove (struct spi_device *spi) {struct m25p *flash =spi_get_drvdata (spi); -int status;/* Clean up MTD stuff. */ - status =mtd_device_unregister (&flash->mtd); -if (status ==0 ) { -kfree (flash->command); -kfree (flash); - } +mtd_device_unregister (&flash->mtd); +return 0 ; }
Quoted 11 lines · Brian Norris
This patch fixes two memory errors:
1. During a probe failure (in
mtd_device_parse_register?) the command buffer would not be freed.2. The command buffer's size is determined based on the '
fast_read' boolean, but the assignment offast_readis made after this allocation. Thus, the buffer may be allocated "too small".To fix the first, just switch to the devres version of kzalloc.
Quoted 8 lines
To fix the second, increase
MAX_CMD_SIZEunconditionally. It's not worth saving a byte to fiddle around with the conditions here.This problem was reported by Yuhang Wang a while back.
Signed-off-by Brian Norris <[email protected]>Reported-by Yuhang Wang <[email protected]>Cc <[email protected]>
I pushed patches 1, 2, and 3 to l2-mtd.git (for Sourav's sake). I'll wait a little while on the others. Comments are still welcome on the whole series, though.
Brian
Quoted 15 lines · Brian Norris
Quoted 14 lines · Brian Norris
This patch fixes two memory errors:
1. During a probe failure (in
mtd_device_parse_register?) the command buffer would not be freed.2. The command buffer's size is determined based on the '
fast_read' boolean, but the assignment offast_readis made after this allocation. Thus, the buffer may be allocated "too small".To fix the first, just switch to the devres version of kzalloc.
To fix the second, increase
MAX_CMD_SIZEunconditionally. It's not worth saving a byte to fiddle around with the conditions here.
Quoted 6 lines
Quoted 5 lines
This problem was reported by Yuhang Wang a while back.
Signed-off-by Brian Norris<[email protected]>Reported-by Yuhang Wang<[email protected]>Cc <[email protected]>I pushed patches 1, 2, and 3 to l2-mtd.git (for Sourav's sake).
Thanks!
Quoted 5 lines
I'll
wait a little while on the others. Comments are still welcome on the whole series, though.Brian
Hi Brian,
[...]
Quoted 6 lines
drivers/mtd/devices/m25p80.c +0
-1@@ -1137,14 +1135,10 @@ static int m25p_probe(struct spi_device *spi)static int m25p_remove (struct spi_device *spi) {struct m25p *flash =spi_get_drvdata (spi); -int status;
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1143
Quoted 10 lines
drivers/mtd/devices/m25p80.c +2
-5/* Clean up MTD stuff. */ - status =mtd_device_unregister (&flash->mtd); -if (status ==0 ) { -kfree (flash->command); -kfree (flash); - } +mtd_device_unregister (&flash->mtd); +return 0 ; }
I wonder if we shouldn't return "status" in here in case mtd_device_unregister() failed.
Best regards,
Marek Vasut
Quoted 10 lines · Marek Vasut
Hi Brian,
[...]
Quoted 6 lines
drivers/mtd/devices/m25p80.c +0
-1@@ -1137,14 +1135,10 @@ static int m25p_probe(struct spi_device *spi)static int m25p_remove (struct spi_device *spi) {struct m25p *flash =spi_get_drvdata (spi); -int status;
Quoted 13 lines
drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 1143
Quoted 10 lines
drivers/mtd/devices/m25p80.c +2
-5/* Clean up MTD stuff. */ - status =mtd_device_unregister (&flash->mtd); -if (status ==0 ) { -kfree (flash->command); -kfree (flash); - } +mtd_device_unregister (&flash->mtd); +return 0 ; }I wonder if we shouldn't return "status" in here in case
mtd_device_unregister()failed.
Sure, I thought of that earlier actually. I may send a trivial follow-up patch for this.
Thanks,
Brian
Hi Brian,
Quoted 26 lines · Marek Vasut
Quoted 25 lines
Hi Brian,
[...]
Quoted 21 lines
(quoted diff) +2
-6@@ -1137,14 +1135,10 @@ static int m25p_probe(struct spi_device *spi) static int m25p_remove(struct spi_device *spi) { struct m25p *flash = spi_get_drvdata(spi); - int status; /* Clean up MTD stuff. */ - status = mtd_device_unregister(&flash->mtd); - if (status == 0) { - kfree(flash->command); - kfree(flash); - } + mtd_device_unregister(&flash->mtd); + return 0;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
}
I wonder if we shouldn't return "status" in here in case
mtd_device_unregister()failed.Sure, I thought of that earlier actually. I may send a trivial follow-up patch for this.
Sounds good, certainly better than mixing two things into one patch. Thanks!
Best regards,
Marek Vasut