mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: barebox <barebox@lists.infradead.org>
Subject: [PATCH] eeprom: Support pagesize OF device tree property
Date: Tue, 24 Nov 2015 19:53:56 +0000	[thread overview]
Message-ID: <1448394839.4553.203.camel@rtred1test09.kymeta.local> (raw)

Allows specifying the page size when the eeproms are in the device
tree.  Same as the Linux kernel device-tree bindings for at24.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
 drivers/eeprom/at24.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index 76f30e7..d025db8 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -381,6 +381,7 @@ static int at24_probe(struct device_d *dev)
 		chip = *(struct at24_platform_data *)dev->platform_data;
 	} else {
 		unsigned long magic;
+		u32 page_size;
 
 		err = dev_get_drvdata(dev, (const void **)&magic);
 		if (err)
@@ -389,12 +390,17 @@ static int at24_probe(struct device_d *dev)
 		chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
 		magic >>= AT24_SIZE_BYTELEN;
 		chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
-		/*
-		 * This is slow, but we can't know all eeproms, so we better
-		 * play safe. Specifying custom eeprom-types via platform_data
-		 * is recommended anyhow.
-		 */
-		chip.page_size = 1;
+		if (dev->device_node &&
+		    !of_property_read_u32(dev->device_node, "pagesize", &page_size))
+			chip.page_size = page_size;
+		else {
+			/*
+			 * This is slow, but we can't know all eeproms, so we better
+			 * play safe. Specifying custom eeprom-types via platform_data
+			 * is recommended anyhow.
+			 */
+			chip.page_size = 1;
+		}
 	}
 
 	if (!is_power_of_2(chip.byte_len))
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-11-24 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 19:53 Trent Piepho [this message]
2015-11-26  8:07 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448394839.4553.203.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox