diff mbox series

i2c: eeprom: Use reg property instead of offset and size

Message ID 6310cfaca2ee5d9168de4aef051a0fdfc5e47a00.1591795100.git.michal.simek@xilinx.com
State Accepted
Commit f692b479f02d9b2689b0686f1f6ff2f06c6ecc59
Headers show
Series i2c: eeprom: Use reg property instead of offset and size | expand

Commit Message

Michal Simek June 10, 2020, 1:18 p.m. UTC
Remove adhoc dt binding for fixed-partition definition for i2c eeprom.
fixed-partition are using reg property instead of offset/size pair.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

Just build tested - ge_bx50v3_defconfig
Definitely please retest on hardware.
---
 arch/arm/dts/imx53-ppd-uboot.dtsi    | 12 ++++++------
 arch/arm/dts/imx6q-bx50v3-uboot.dtsi | 10 +++++-----
 drivers/misc/i2c_eeprom.c            | 15 +++++----------
 3 files changed, 16 insertions(+), 21 deletions(-)

Comments

Simon Glass June 17, 2020, 3:11 a.m. UTC | #1
Hi Michal,

On Wed, 10 Jun 2020 at 07:18, Michal Simek <michal.simek at xilinx.com> wrote:
>
> Remove adhoc dt binding for fixed-partition definition for i2c eeprom.
> fixed-partition are using reg property instead of offset/size pair.
>
> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
> ---
>
> Just build tested - ge_bx50v3_defconfig
> Definitely please retest on hardware.
> ---
>  arch/arm/dts/imx53-ppd-uboot.dtsi    | 12 ++++++------
>  arch/arm/dts/imx6q-bx50v3-uboot.dtsi | 10 +++++-----
>  drivers/misc/i2c_eeprom.c            | 15 +++++----------
>  3 files changed, 16 insertions(+), 21 deletions(-)

Can the sandbox tests update for this?

Regards,
Simon
diff mbox series

Patch

diff --git a/arch/arm/dts/imx53-ppd-uboot.dtsi b/arch/arm/dts/imx53-ppd-uboot.dtsi
index d38a1bc264c9..d61b7cb87642 100644
--- a/arch/arm/dts/imx53-ppd-uboot.dtsi
+++ b/arch/arm/dts/imx53-ppd-uboot.dtsi
@@ -24,15 +24,15 @@ 
 &eeprom {
 	partitions {
 		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
 
-		vpd {
-			offset = <0>;
-			size = <1022>;
+		vpd at 0 {
+			reg = <0 1022>;
 		};
 
-		bootcount: bootcount {
-			offset = <1022>;
-			size = <2>;
+		bootcount: bootcount at 1022 {
+			reg = <1022 2>;
 		};
 	};
 };
diff --git a/arch/arm/dts/imx6q-bx50v3-uboot.dtsi b/arch/arm/dts/imx6q-bx50v3-uboot.dtsi
index df446e0ed149..01321cab781b 100644
--- a/arch/arm/dts/imx6q-bx50v3-uboot.dtsi
+++ b/arch/arm/dts/imx6q-bx50v3-uboot.dtsi
@@ -23,15 +23,15 @@ 
 &eeprom {
 	partitions {
 		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
 
-		vpd {
-			offset = <0>;
-			size = <1022>;
+		vpd at 0 {
+			reg = <0 1022>;
 		};
 
 		bootcount: bootcount {
-			offset = <1022>;
-			size = <2>;
+			reg = <1022 2>;
 		};
 	};
 };
diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 45c34d388c8a..ad7c1f70e654 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -301,19 +301,14 @@  static int i2c_eeprom_partition_probe(struct udevice *dev)
 static int i2c_eeprom_partition_ofdata_to_platdata(struct udevice *dev)
 {
 	struct i2c_eeprom_partition *priv = dev_get_priv(dev);
-	u32 offset, size;
-	int ret;
 
-	ret = dev_read_u32(dev, "offset", &offset);
-	if (ret)
-		return ret;
+	priv->offset = dev_read_addr_index(dev, 0);
+	priv->size = dev_read_addr_index(dev, 1);
 
-	ret = dev_read_u32(dev, "size", &size);
-	if (ret)
-		return ret;
+	if (!priv->size)
+		return -EINVAL;
 
-	priv->offset = offset;
-	priv->size = size;
+	debug("%s: base %x, size %x\n", priv->offset, priv->size);
 
 	return 0;
 }