summaryrefslogtreecommitdiff
path: root/drivers/misc/eeprom
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2019-02-05 14:18:25 +0100
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2019-02-14 09:32:35 +0100
commit950bcbbe31548636d24e49b3abaf3780204f7fe8 (patch)
treeb4eef914d250efd1b45ec0246ea8c99ea947110c /drivers/misc/eeprom
parente7224a116f0dac593233143849f25bc095f8d2cc (diff)
eeprom: at24: implement support for 'num-addresses' property
If the device node defines 'num-addresses', let it override the default behavior. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/misc/eeprom')
-rw-r--r--drivers/misc/eeprom/at24.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index b806a403ca46..63aa541c9608 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -641,11 +641,14 @@ static int at24_probe(struct i2c_client *client)
if (!is_power_of_2(page_size))
dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
- if (flags & AT24_FLAG_TAKE8ADDR)
- num_addresses = 8;
- else
- num_addresses = DIV_ROUND_UP(byte_len,
- (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+ err = device_property_read_u32(dev, "num-addresses", &num_addresses);
+ if (err) {
+ if (flags & AT24_FLAG_TAKE8ADDR)
+ num_addresses = 8;
+ else
+ num_addresses = DIV_ROUND_UP(byte_len,
+ (flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+ }
if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
dev_err(dev,