misc: at25: Fix issues brought with FRAM support
cover misc: at25: Fix issues brought with FRAM support
A few fixes to the AT25 driver that have been brought by FRAM support series.
Andy Shevchenko (3):
misc: at25: Make driver OF independent again
misc: at25: Don't copy garbage to the at25->chip in FRAM case
misc: at25: Check proper value of chip length in FRAM case
drivers/misc/eeprom/at25.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/3 misc: at25: Make driver OF independent again
The commit f60e7074902a ("misc: at25: Make use of device property API") made a good job by enabling the driver for non-OF platforms, but the recent commit 604288bc6196 ("nvmem: eeprom: at25: fix type compiler warnings") brought that back.
Restore greatness of the driver once again.
--- drivers/misc/eeprom/at25.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/misc/eeprom/at25.c +6 -7
@@ -17,8 +17,6 @@#include <linux/spi/spi.h> #include <linux/spi/eeprom.h> #include <linux/property.h> -#include <linux/of.h> -#include <linux/of_device.h> #include <linux/math.h> /*
@@ -381,13 +379,14 @@ static int at25_probe(struct spi_device *spi)int sr;u8 id[FM25_ID_LEN ];u8 sernum[FM25_SN_LEN ]; +bool is_fram;int i; -const struct of_device_id *match; -bool is_fram =0 ; - match =of_match_device (of_match_ptr (at25_of_match), &spi->dev); -if (match && !strcmp (match->compatible,"cypress,fm25" )) - is_fram =1 ; + err =device_property_match_string (&spi->dev,"compatible" ,"cypress,fm25" ); +if (err >=0 ) + is_fram = true; +else + is_fram = false;/* Chip description */ if (!spi->dev.platform_data) {
Signature · 1 line
2.33.0
PATCH 2/3 misc: at25: Don't copy garbage to the at25->chip in FRAM case
In reply to Andy ShevchenkoEven if we know that we are going to fill everything later on it's bad style and fragile to copy garbage from the stack to the data structure that will be used in the driver.
--- drivers/misc/eeprom/at25.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/misc/eeprom/at25.c +4 -1
@@ -390,7 +390,10 @@ static int at25_probe(struct spi_device *spi)/* Chip description */ if (!spi->dev.platform_data) { -if (!is_fram) { +if (is_fram) { +/* We file fields for FRAM case later on */ +memset (&chip,0 ,sizeof (chip)); + }else { err =at25_fw_to_chip (&spi->dev, &chip);if (err)return err;
Signature · 1 line
2.33.0
PATCH 3/3 misc: at25: Check proper value of chip length in FRAM case
In reply to Andy ShevchenkoObviously the byte_len value should be checked from the chip and not from at25->chip.
--- drivers/misc/eeprom/at25.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/eeprom/at25.c +2 -2
@@ -433,9 +433,9 @@ static int at25_probe(struct spi_device *spi)dev_err (&spi->dev,"Error: unsupported size (id %02x)\n" , id[7 ]);return -ENODEV ; } - chip.byte_len =int_pow (2 , id[7 ] -0x21 +4 ) *1024 ; -if (at25->chip.byte_len >64 *1024 ) + chip.byte_len =int_pow (2 , id[7 ] -0x21 +4 ) *1024 ; +if (chip.byte_len >64 *1024 ) at25->chip.flags |=EE_ADDR3 ;else at25->chip.flags |=EE_ADDR2 ;
Signature · 1 line
2.33.0
Quoted 7 lines · Andy Shevchenko
A few fixes to the AT25 driver that have been brought by FRAM support series.
Andy Shevchenko (3):
misc: at25: Make driver OF independent again
misc: at25: Don't copy garbage to theat25->chipin FRAM case
misc: at25: Check proper value of chip length in FRAM case
Looks all good to me,
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Andy Shevchenko
A few fixes to the AT25 driver that have been brought by FRAM support series.
Quoted 8 lines
Quoted 4 lines
Andy Shevchenko (3):
misc: at25: Make driver OF independent again
misc: at25: Don't copy garbage to theat25->chipin FRAM case
misc: at25: Check proper value of chip length in FRAM caseLooks all good to me,
Acked-by Arnd Bergmann <[email protected]>
Thank you!
There is also cleanup series if you are interested of looking into...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
A few fixes to the AT25 driver that have been brought by FRAM support series.
Andy Shevchenko (3):
misc: at25: Make driver OF independent again
misc: at25: Don't copy garbage to theat25->chipin FRAM case
misc: at25: Check proper value of chip length in FRAM casedrivers/misc/eeprom/at25.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
Greg, it seem under your realm, can you apply this for current cycle, please?
Signature · 2 lines
With Best Regards, Andy Shevchenko