[PATCH] eeprom: Support pagesize OF device tree property

Trent Piepho tpiepho at kymetacorp.com
Tue Nov 24 11:53:56 PST 2015


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 at 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




More information about the barebox mailing list