linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support
@ 2021-11-25 21:27 Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 1/3] misc: at25: Make driver OF independent again Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-11-25 21:27 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Jiri Prchal

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(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/3] misc: at25: Make driver OF independent again
  2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
@ 2021-11-25 21:27 ` Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 2/3] misc: at25: Don't copy garbage to the at25->chip in FRAM case Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-11-25 21:27 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Jiri Prchal

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.

Fixes: eab61fb1cc2e ("nvmem: eeprom: at25: fram discovery simplification")
Fixes: fd307a4ad332 ("nvmem: prepare basics for FRAM support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/eeprom/at25.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index 632325474233..57599eac2f71 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -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) {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/3] misc: at25: Don't copy garbage to the at25->chip in FRAM case
  2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 1/3] misc: at25: Make driver OF independent again Andy Shevchenko
@ 2021-11-25 21:27 ` Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 3/3] misc: at25: Check proper value of chip length " Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-11-25 21:27 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Jiri Prchal

Even 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.

Fixes: fd307a4ad332 ("nvmem: prepare basics for FRAM support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/eeprom/at25.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index 57599eac2f71..f0b0efc30ee6 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 3/3] misc: at25: Check proper value of chip length in FRAM case
  2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 1/3] misc: at25: Make driver OF independent again Andy Shevchenko
  2021-11-25 21:27 ` [PATCH v1 2/3] misc: at25: Don't copy garbage to the at25->chip in FRAM case Andy Shevchenko
@ 2021-11-25 21:27 ` Andy Shevchenko
  2021-11-25 21:47 ` [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Arnd Bergmann
  2021-12-01 14:19 ` Andy Shevchenko
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-11-25 21:27 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Jiri Prchal

Obviously the byte_len value should be checked from the chip
and not from at25->chip.

Fixes: fd307a4ad332 ("nvmem: prepare basics for FRAM support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/eeprom/at25.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c
index f0b0efc30ee6..e21216541b0f 100644
--- a/drivers/misc/eeprom/at25.c
+++ b/drivers/misc/eeprom/at25.c
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support
  2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
                   ` (2 preceding siblings ...)
  2021-11-25 21:27 ` [PATCH v1 3/3] misc: at25: Check proper value of chip length " Andy Shevchenko
@ 2021-11-25 21:47 ` Arnd Bergmann
  2021-11-25 22:01   ` Andy Shevchenko
  2021-12-01 14:19 ` Andy Shevchenko
  4 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2021-11-25 21:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Arnd Bergmann, Greg Kroah-Hartman,
	Jiri Prchal

On Thu, Nov 25, 2021 at 10:27 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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

Looks all good to me,

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support
  2021-11-25 21:47 ` [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Arnd Bergmann
@ 2021-11-25 22:01   ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-11-25 22:01 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Jiri Prchal

On Thu, Nov 25, 2021 at 10:47:43PM +0100, Arnd Bergmann wrote:
> On Thu, Nov 25, 2021 at 10:27 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > 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
> 
> Looks all good to me,
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thank you!
There is also cleanup series if you are interested of looking into...

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support
  2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
                   ` (3 preceding siblings ...)
  2021-11-25 21:47 ` [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Arnd Bergmann
@ 2021-12-01 14:19 ` Andy Shevchenko
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-12-01 14:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, Greg Kroah-Hartman, Jiri Prchal

On Thu, Nov 25, 2021 at 11:27:26PM +0200, Andy Shevchenko wrote:
> 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(-)

Greg, it seem under your realm, can you apply this for current cycle, please?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-01 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 21:27 [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Andy Shevchenko
2021-11-25 21:27 ` [PATCH v1 1/3] misc: at25: Make driver OF independent again Andy Shevchenko
2021-11-25 21:27 ` [PATCH v1 2/3] misc: at25: Don't copy garbage to the at25->chip in FRAM case Andy Shevchenko
2021-11-25 21:27 ` [PATCH v1 3/3] misc: at25: Check proper value of chip length " Andy Shevchenko
2021-11-25 21:47 ` [PATCH v1 0/3] misc: at25: Fix issues brought with FRAM support Arnd Bergmann
2021-11-25 22:01   ` Andy Shevchenko
2021-12-01 14:19 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).