Linux-RTC Archive on lore.kernel.org
 help / Atom feed
* [PATCH v4 0/5] Add NXP pcf85263 real-time clock support
@ 2018-12-07 11:27 Biju Das
  2018-12-07 11:27 ` [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write} Biju Das
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Srinivas Kandagatla, Geert Uytterhoeven, Alexandre Belloni
  Cc: Biju Das, Simon Horman, Chris Paterson, Fabrizio Castro,
	Alessandro Zummo, linux-rtc, linux-renesas-soc

This patch set aims to add support for NXP pcf85263 real-time clock.
pcf85263 rtc is compatible with pcf85363 rtc except that pcf85363 has
64 bytes additional RAM.

1 byte of nvmem is supported in pcf85263 and is exposed through sysfs.

The details of pcf85363 and pcf85263 can be found in the below data sheets.

https://www.nxp.com/docs/en/data-sheet/PCF85363A.pdf

https://www.nxp.com/docs/en/data-sheet/PCF85263A.pdf

This patch is tested against linux-next.

V1-->V2
   * Incorporated simon's review comment for binding patch.
   * Incorporated Geert and Alexandre's review comments.
V2-->V3
   * Incorporated Geert's review comments.
V3-->V4
   * Incorporated Geert and Alexandre's review comments.

Biju Das (5):
  nvmem: check invalid number of bytes in nvmem_device_{read,write}
  dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  rtc: pcf85363: Add support for NXP pcf85263 rtc
  ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  ARM: dts: iwg23s-sbc: Enable RTC

 Documentation/devicetree/bindings/rtc/pcf85363.txt |  4 +-
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts          | 18 +++++
 arch/arm/configs/shmobile_defconfig                |  1 +
 drivers/nvmem/core.c                               | 26 +++++-
 drivers/rtc/rtc-pcf85363.c                         | 94 +++++++++++++++++-----
 5 files changed, 122 insertions(+), 21 deletions(-)

-- 
2.7.4


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

* [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write}
  2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
@ 2018-12-07 11:27 ` Biju Das
  2018-12-10 12:37   ` Srinivas Kandagatla
  2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Srinivas Kandagatla, Geert Uytterhoeven, Alexandre Belloni
  Cc: Biju Das, Simon Horman, Chris Paterson, Fabrizio Castro,
	Alessandro Zummo, linux-rtc, linux-renesas-soc

Add check in nvmem_device_{read,write}()to ensure that nvmem core never
passes an invalid number of bytes.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
V3-->V4
	* New patch.
---
 drivers/nvmem/core.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index d9fd110..db7de33 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1433,10 +1433,21 @@ int nvmem_device_read(struct nvmem_device *nvmem,
 		      size_t bytes, void *buf)
 {
 	int rc;
+	size_t new_bytes;
 
 	if (!nvmem)
 		return -EINVAL;
 
+	/* Stop the user from reading */
+	if ((offset >= nvmem->size) || (bytes == 0))
+		return 0;
+
+	if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
+		return -EOVERFLOW;
+
+	if (new_bytes > nvmem->size)
+		bytes = nvmem->size - offset;
+
 	rc = nvmem_reg_read(nvmem, offset, buf, bytes);
 
 	if (rc)
@@ -1461,16 +1472,29 @@ int nvmem_device_write(struct nvmem_device *nvmem,
 		       size_t bytes, void *buf)
 {
 	int rc;
+	size_t new_bytes;
 
 	if (!nvmem)
 		return -EINVAL;
 
+	/* Stop the user from writing */
+	if (offset >= nvmem->size)
+		return -ENOSPC;
+
+	if (bytes == 0)
+		return 0;
+
+	if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
+		return -EOVERFLOW;
+
+	if (new_bytes > nvmem->size)
+		bytes = nvmem->size - offset;
+
 	rc = nvmem_reg_write(nvmem, offset, buf, bytes);
 
 	if (rc)
 		return rc;
 
-
 	return bytes;
 }
 EXPORT_SYMBOL_GPL(nvmem_device_write);
-- 
2.7.4


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

* [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
  2018-12-07 11:27 ` [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write} Biju Das
@ 2018-12-07 11:27 ` Biju Das
  2018-12-07 23:19   ` Rob Herring
                     ` (2 more replies)
  2018-12-07 11:27 ` [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Geert Uytterhoeven,
	Rob Herring, Mark Rutland
  Cc: Biju Das, linux-rtc, devicetree, Simon Horman, Chris Paterson,
	Srinivas Kandagatla, Fabrizio Castro, linux-renesas-soc

The pcf85263 RTC is compatible with the pcf85363 RTC.

The difference between the pcf85263 and pcf85363 RTC is that the latter has
64 bytes more RAM. This renders them incompatible from a DT point of view.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
V1-->V2
	* Incorporated Simon's review comment.
V2-->V3
	* No Change.
V3-->V4
	* No Change.
---
 Documentation/devicetree/bindings/rtc/pcf85363.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/pcf85363.txt b/Documentation/devicetree/bindings/rtc/pcf85363.txt
index 76fdabc..94adc1c 100644
--- a/Documentation/devicetree/bindings/rtc/pcf85363.txt
+++ b/Documentation/devicetree/bindings/rtc/pcf85363.txt
@@ -1,8 +1,8 @@
-NXP PCF85363 Real Time Clock
+NXP PCF85263/PCF85363 Real Time Clock
 ============================
 
 Required properties:
-- compatible: Should contain "nxp,pcf85363".
+- compatible: Should contain "nxp,pcf85263" or "nxp,pcf85363".
 - reg: I2C address for chip.
 
 Optional properties:
-- 
2.7.4


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

* [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
  2018-12-07 11:27 ` [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write} Biju Das
  2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
@ 2018-12-07 11:27 ` Biju Das
  2018-12-11 11:15   ` Alexandre Belloni
  2018-12-07 11:27 ` [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
  2018-12-07 11:27 ` [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
  4 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Alessandro Zummo, Geert Uytterhoeven, Alexandre Belloni
  Cc: Biju Das, linux-rtc, Simon Horman, Chris Paterson,
	Srinivas Kandagatla, Fabrizio Castro, linux-renesas-soc

Add support for NXP pcf85263 real-time clock. pcf85263 rtc is compatible
with pcf85363,except that pcf85363 has additional 64 bytes of RAM.

1 byte of nvmem is supported and exposed in sysfs (# is the instance
number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
---
V1-->V2
	* Incorporated Alexandre and Geert's review comment.
V2-->V3
	* Incorporated Geert's review comment.
V3-->V4
	* Incorporated Geert's and Alexandre's review comment.
---
 drivers/rtc/rtc-pcf85363.c | 94 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 76 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index c04a1ed..a398807 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -120,6 +120,11 @@ struct pcf85363 {
 	struct regmap		*regmap;
 };
 
+struct pcf85x63_config {
+	struct regmap_config regmap;
+	unsigned int num_nvram;
+};
+
 static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	struct pcf85363 *pcf85363 = dev_get_drvdata(dev);
@@ -311,25 +316,75 @@ static int pcf85363_nvram_write(void *priv, unsigned int offset, void *val,
 				 val, bytes);
 }
 
-static const struct regmap_config regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-	.max_register = 0x7f,
+static int pcf85x63_nvram_read(void *priv, unsigned int offset, void *val,
+			       size_t bytes)
+{
+	struct pcf85363 *pcf85363 = priv;
+	unsigned int tmp_val;
+	int ret;
+
+	ret = regmap_read(pcf85363->regmap, CTRL_RAMBYTE, &tmp_val);
+	(*(unsigned char *) val) = (unsigned char) tmp_val;
+
+	return ret;
+}
+
+static int pcf85x63_nvram_write(void *priv, unsigned int offset, void *val,
+				size_t bytes)
+{
+	struct pcf85363 *pcf85363 = priv;
+	unsigned char tmp_val;
+
+	tmp_val = *((unsigned char *)val);
+	return regmap_write(pcf85363->regmap, CTRL_RAMBYTE,
+				(unsigned int)tmp_val);
+}
+
+static const struct pcf85x63_config pcf_85263_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x2f,
+	},
+	.num_nvram = 1
+};
+
+static const struct pcf85x63_config pcf_85363_config = {
+	.regmap = {
+		.reg_bits = 8,
+		.val_bits = 8,
+		.max_register = 0x7f,
+	},
+	.num_nvram = 2
 };
 
 static int pcf85363_probe(struct i2c_client *client,
 			  const struct i2c_device_id *id)
 {
 	struct pcf85363 *pcf85363;
-	struct nvmem_config nvmem_cfg = {
-		.name = "pcf85363-",
-		.word_size = 1,
-		.stride = 1,
-		.size = NVRAM_SIZE,
-		.reg_read = pcf85363_nvram_read,
-		.reg_write = pcf85363_nvram_write,
+	const struct pcf85x63_config *config = &pcf_85363_config;
+	const void *data = of_device_get_match_data(&client->dev);
+	static struct nvmem_config nvmem_cfg[] = {
+		{
+			.name = "pcf85x63-",
+			.word_size = 1,
+			.stride = 1,
+			.size = 1,
+			.reg_read = pcf85x63_nvram_read,
+			.reg_write = pcf85x63_nvram_write,
+		}, {
+			.name = "pcf85363-",
+			.word_size = 1,
+			.stride = 1,
+			.size = NVRAM_SIZE,
+			.reg_read = pcf85363_nvram_read,
+			.reg_write = pcf85363_nvram_write,
+		},
 	};
-	int ret;
+	int ret, i;
+
+	if (data)
+		config = data;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
@@ -339,7 +394,7 @@ static int pcf85363_probe(struct i2c_client *client,
 	if (!pcf85363)
 		return -ENOMEM;
 
-	pcf85363->regmap = devm_regmap_init_i2c(client, &regmap_config);
+	pcf85363->regmap = devm_regmap_init_i2c(client, &config->regmap);
 	if (IS_ERR(pcf85363->regmap)) {
 		dev_err(&client->dev, "regmap allocation failed\n");
 		return PTR_ERR(pcf85363->regmap);
@@ -370,15 +425,18 @@ static int pcf85363_probe(struct i2c_client *client,
 
 	ret = rtc_register_device(pcf85363->rtc);
 
-	nvmem_cfg.priv = pcf85363;
-	rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg);
+	for (i = 0; i < config->num_nvram; i++) {
+		nvmem_cfg[i].priv = pcf85363;
+		rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]);
+	}
 
 	return ret;
 }
 
 static const struct of_device_id dev_ids[] = {
-	{ .compatible = "nxp,pcf85363" },
-	{}
+	{ .compatible = "nxp,pcf85263", .data = &pcf_85263_config },
+	{ .compatible = "nxp,pcf85363", .data = &pcf_85363_config },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dev_ids);
 
@@ -393,5 +451,5 @@ static struct i2c_driver pcf85363_driver = {
 module_i2c_driver(pcf85363_driver);
 
 MODULE_AUTHOR("Eric Nelson");
-MODULE_DESCRIPTION("pcf85363 I2C RTC driver");
+MODULE_DESCRIPTION("pcf85263/pcf85363 I2C RTC driver");
 MODULE_LICENSE("GPL");
-- 
2.7.4


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

* [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
                   ` (2 preceding siblings ...)
  2018-12-07 11:27 ` [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
@ 2018-12-07 11:27 ` Biju Das
  2018-12-10 12:13   ` Simon Horman
  2018-12-07 11:27 ` [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
  4 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Simon Horman
  Cc: Biju Das, Magnus Damm, Russell King, Alexandre Belloni,
	linux-rtc, linux-renesas-soc, linux-arm-kernel,
	Geert Uytterhoeven, Chris Paterson, Srinivas Kandagatla,
	Fabrizio Castro

The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase hardware
support enable the driver in the shmobile_defconfig multiplatform
configuration.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
V1-->V2
	* No change.
V2-->V3
	* No change.
V3-->V4
	* No Change.
---
 arch/arm/configs/shmobile_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig
index 9e5a5ad..fdac4e4 100644
--- a/arch/arm/configs/shmobile_defconfig
+++ b/arch/arm/configs/shmobile_defconfig
@@ -177,6 +177,7 @@ CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_RS5C372=y
+CONFIG_RTC_DRV_PCF85363=y
 CONFIG_RTC_DRV_BQ32K=y
 CONFIG_RTC_DRV_S35390A=y
 CONFIG_RTC_DRV_RX8581=y
-- 
2.7.4


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

* [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC
  2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
                   ` (3 preceding siblings ...)
  2018-12-07 11:27 ` [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
@ 2018-12-07 11:27 ` Biju Das
  2018-12-10 12:15   ` Simon Horman
  4 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-07 11:27 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland
  Cc: Biju Das, Simon Horman, Magnus Damm, Alexandre Belloni,
	Srinivas Kandagatla, linux-rtc, linux-renesas-soc, devicetree,
	Geert Uytterhoeven, Chris Paterson, Fabrizio Castro

Enable NXP pcf85263 real time clock for the iWave SBC based on RZ/G1C.

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
V1-->V2
	* No change
V2-->V3
	* No change
V3-->V4
	* No change
---
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts b/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
index 40b7f98..77d1824 100644
--- a/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
+++ b/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
@@ -84,12 +84,30 @@
 	clock-frequency = <20000000>;
 };
 
+&i2c3 {
+	pinctrl-0 = <&i2c3_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+	clock-frequency = <400000>;
+
+	rtc@51 {
+		compatible = "nxp,pcf85263";
+		reg = <0x51>;
+	};
+};
+
 &pfc {
 	avb_pins: avb {
 		groups = "avb_mdio", "avb_gmii_tx_rx";
 		function = "avb";
 	};
 
+	i2c3_pins: i2c3 {
+		groups = "i2c3_c";
+		function = "i2c3";
+	};
+
 	mmc_pins_uhs: mmc_uhs {
 		groups = "mmc_data8", "mmc_ctrl";
 		function = "mmc";
-- 
2.7.4


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

* Re: [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
@ 2018-12-07 23:19   ` Rob Herring
  2018-12-10 12:16   ` Simon Horman
  2018-12-11 11:15   ` Alexandre Belloni
  2 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2018-12-07 23:19 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Alexandre Belloni, Geert Uytterhoeven,
	Mark Rutland, Biju Das, linux-rtc, devicetree, Simon Horman,
	Chris Paterson, Srinivas Kandagatla, Fabrizio Castro,
	linux-renesas-soc

On Fri,  7 Dec 2018 11:27:43 +0000, Biju Das wrote:
> The pcf85263 RTC is compatible with the pcf85363 RTC.
> 
> The difference between the pcf85263 and pcf85363 RTC is that the latter has
> 64 bytes more RAM. This renders them incompatible from a DT point of view.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> V1-->V2
> 	* Incorporated Simon's review comment.
> V2-->V3
> 	* No Change.
> V3-->V4
> 	* No Change.
> ---
>  Documentation/devicetree/bindings/rtc/pcf85363.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  2018-12-07 11:27 ` [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
@ 2018-12-10 12:13   ` Simon Horman
  2018-12-10 12:35     ` Biju Das
  0 siblings, 1 reply; 18+ messages in thread
From: Simon Horman @ 2018-12-10 12:13 UTC (permalink / raw)
  To: Biju Das
  Cc: Magnus Damm, Russell King, Alexandre Belloni, linux-rtc,
	linux-renesas-soc, linux-arm-kernel, Geert Uytterhoeven,
	Chris Paterson, Srinivas Kandagatla, Fabrizio Castro

On Fri, Dec 07, 2018 at 11:27:45AM +0000, Biju Das wrote:
> The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase hardware
> support enable the driver in the shmobile_defconfig multiplatform
> configuration.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks, applied for v4.22.

Is a similar change for multi_v7_defconfig also appropriate?

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

* Re: [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC
  2018-12-07 11:27 ` [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
@ 2018-12-10 12:15   ` Simon Horman
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2018-12-10 12:15 UTC (permalink / raw)
  To: Biju Das
  Cc: Rob Herring, Mark Rutland, Magnus Damm, Alexandre Belloni,
	Srinivas Kandagatla, linux-rtc, linux-renesas-soc, devicetree,
	Geert Uytterhoeven, Chris Paterson, Fabrizio Castro

On Fri, Dec 07, 2018 at 11:27:46AM +0000, Biju Das wrote:
> Enable NXP pcf85263 real time clock for the iWave SBC based on RZ/G1C.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks, applied for v4.22.

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

* Re: [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
  2018-12-07 23:19   ` Rob Herring
@ 2018-12-10 12:16   ` Simon Horman
  2018-12-11 11:15   ` Alexandre Belloni
  2 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2018-12-10 12:16 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Alexandre Belloni, Geert Uytterhoeven,
	Rob Herring, Mark Rutland, linux-rtc, devicetree, Chris Paterson,
	Srinivas Kandagatla, Fabrizio Castro, linux-renesas-soc

On Fri, Dec 07, 2018 at 11:27:43AM +0000, Biju Das wrote:
> The pcf85263 RTC is compatible with the pcf85363 RTC.
> 
> The difference between the pcf85263 and pcf85363 RTC is that the latter has
> 64 bytes more RAM. This renders them incompatible from a DT point of view.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>


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

* RE: [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  2018-12-10 12:13   ` Simon Horman
@ 2018-12-10 12:35     ` Biju Das
  2018-12-10 13:22       ` Simon Horman
  0 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-10 12:35 UTC (permalink / raw)
  To: Simon Horman
  Cc: Magnus Damm, Russell King, Alexandre Belloni, linux-rtc,
	linux-renesas-soc, linux-arm-kernel, Geert Uytterhoeven,
	Chris Paterson, Srinivas Kandagatla, Fabrizio Castro

Hi Simon,

Thanks for the feedback.

> Subject: Re: [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in
> shmobile_defconfig
>
> On Fri, Dec 07, 2018 at 11:27:45AM +0000, Biju Das wrote:
> > The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase hardware
> > support enable the driver in the shmobile_defconfig multiplatform
> > configuration.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Thanks, applied for v4.22.
>
> Is a similar change for multi_v7_defconfig also appropriate?

Will send a separate patch for adding it to the "multi_v7_defconfig"

CONFIG_RTC_DRV_PCF85363=m

Regards,
Biju


[https://www2.renesas.eu/media/email/unicef.jpg]

This Christmas, instead of sending out cards, Renesas Electronics Europe have decided to support Unicef with a donation. For further details click here<https://www.unicef.org/> to find out about the valuable work they do, helping children all over the world.
We would like to take this opportunity to wish you a Merry Christmas and a prosperous New Year.



Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered No. 04586709.

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

* Re: [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write}
  2018-12-07 11:27 ` [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write} Biju Das
@ 2018-12-10 12:37   ` Srinivas Kandagatla
  2018-12-10 12:45     ` Biju Das
  0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Kandagatla @ 2018-12-10 12:37 UTC (permalink / raw)
  To: Biju Das, Geert Uytterhoeven, Alexandre Belloni
  Cc: Simon Horman, Chris Paterson, Fabrizio Castro, Alessandro Zummo,
	linux-rtc, linux-renesas-soc

Thanks for the patch.

On 07/12/18 11:27, Biju Das wrote:
> Add check in nvmem_device_{read,write}()to ensure that nvmem core never
> passes an invalid number of bytes.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> ---
> V3-->V4
> 	* New patch.
> ---
>   drivers/nvmem/core.c | 26 +++++++++++++++++++++++++-
>   1 file changed, 25 insertions(+), 1 deletion(-)
> 

Its better to move checks from 
bin_attr_nvmem_read()/bin_attr_nvmem_write() into nvmem_reg_read() and 
nvmem_reg_write(), so its easy to maintain, rather than adding them to 
each function.

> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index d9fd110..db7de33 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1433,10 +1433,21 @@ int nvmem_device_read(struct nvmem_device *nvmem,
>   		      size_t bytes, void *buf)
>   {
>   	int rc;
> +	size_t new_bytes;
>   
>   	if (!nvmem)
>   		return -EINVAL;
>   
> +	/* Stop the user from reading */
> +	if ((offset >= nvmem->size) || (bytes == 0))
> +		return 0;
> +
> +	if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
> +		return -EOVERFLOW;
> +
> +	if (new_bytes > nvmem->size)
> +		bytes = nvmem->size - offset;
> +
>   	rc = nvmem_reg_read(nvmem, offset, buf, bytes);
>   
>   	if (rc)
> @@ -1461,16 +1472,29 @@ int nvmem_device_write(struct nvmem_device *nvmem,
>   		       size_t bytes, void *buf)
>   {
>   	int rc;
> +	size_t new_bytes;
>   
>   	if (!nvmem)
>   		return -EINVAL;
>   
> +	/* Stop the user from writing */
> +	if (offset >= nvmem->size)
> +		return -ENOSPC;
> +
> +	if (bytes == 0)
> +		return 0;
> +
> +	if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
> +		return -EOVERFLOW;
> +
> +	if (new_bytes > nvmem->size)
> +		bytes = nvmem->size - offset;
> +
>   	rc = nvmem_reg_write(nvmem, offset, buf, bytes);
>   
>   	if (rc)
>   		return rc;
>   
> -

Unrelated change!


--srini
>   	return bytes;
>   }
>   EXPORT_SYMBOL_GPL(nvmem_device_write);
> 

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

* RE: [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write}
  2018-12-10 12:37   ` Srinivas Kandagatla
@ 2018-12-10 12:45     ` Biju Das
  2018-12-10 12:55       ` Srinivas Kandagatla
  0 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2018-12-10 12:45 UTC (permalink / raw)
  To: Srinivas Kandagatla, Geert Uytterhoeven, Alexandre Belloni
  Cc: Simon Horman, Chris Paterson, Fabrizio Castro, Alessandro Zummo,
	linux-rtc, linux-renesas-soc

Hi Srinivas,

Thanks for the feedback.

> Subject: Re: [PATCH v4 1/5] nvmem: check invalid number of bytes in
> nvmem_device_{read,write}
>
> Thanks for the patch.
>
> On 07/12/18 11:27, Biju Das wrote:
> > Add check in nvmem_device_{read,write}()to ensure that nvmem core
> > never passes an invalid number of bytes.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > ---
> > V3-->V4
> > * New patch.
> > ---
> >   drivers/nvmem/core.c | 26 +++++++++++++++++++++++++-
> >   1 file changed, 25 insertions(+), 1 deletion(-)
> >
>
> Its better to move checks from
> bin_attr_nvmem_read()/bin_attr_nvmem_write() into nvmem_reg_read()
> and nvmem_reg_write(), so its easy to maintain, rather than adding them to
> each function.

Initially I also thought the same. But there are some RTC drivers which is using nvmem_device
interface  is not defining "word_size"  member. That is the reason we need to add it in separate function.
Can you please suggest how to handle the above drivers?

> > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index
> > d9fd110..db7de33 100644
> > --- a/drivers/nvmem/core.c
> > +++ b/drivers/nvmem/core.c
> > @@ -1433,10 +1433,21 @@ int nvmem_device_read(struct nvmem_device
> *nvmem,
> >         size_t bytes, void *buf)
> >   {
> >   int rc;
> > +size_t new_bytes;
> >
> >   if (!nvmem)
> >   return -EINVAL;
> >
> > +/* Stop the user from reading */
> > +if ((offset >= nvmem->size) || (bytes == 0))
> > +return 0;
> > +
> > +if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
> > +return -EOVERFLOW;
> > +
> > +if (new_bytes > nvmem->size)
> > +bytes = nvmem->size - offset;
> > +
> >   rc = nvmem_reg_read(nvmem, offset, buf, bytes);
> >
> >   if (rc)
> > @@ -1461,16 +1472,29 @@ int nvmem_device_write(struct
> nvmem_device *nvmem,
> >          size_t bytes, void *buf)
> >   {
> >   int rc;
> > +size_t new_bytes;
> >
> >   if (!nvmem)
> >   return -EINVAL;
> >
> > +/* Stop the user from writing */
> > +if (offset >= nvmem->size)
> > +return -ENOSPC;
> > +
> > +if (bytes == 0)
> > +return 0;
> > +
> > +if (unlikely(check_add_overflow(bytes, offset, &new_bytes)))
> > +return -EOVERFLOW;
> > +
> > +if (new_bytes > nvmem->size)
> > +bytes = nvmem->size - offset;
> > +
> >   rc = nvmem_reg_write(nvmem, offset, buf, bytes);
> >
> >   if (rc)
> >   return rc;
> >
> > -
>
> Unrelated change!

I  found an extra space in this function.  If it is a problem, I will send V2 for undoing this.
Please let me know.

Regards,
Biju


[https://www2.renesas.eu/media/email/unicef.jpg]

This Christmas, instead of sending out cards, Renesas Electronics Europe have decided to support Unicef with a donation. For further details click here<https://www.unicef.org/> to find out about the valuable work they do, helping children all over the world.
We would like to take this opportunity to wish you a Merry Christmas and a prosperous New Year.



Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered No. 04586709.

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

* Re: [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write}
  2018-12-10 12:45     ` Biju Das
@ 2018-12-10 12:55       ` Srinivas Kandagatla
  2018-12-10 15:35         ` Biju Das
  0 siblings, 1 reply; 18+ messages in thread
From: Srinivas Kandagatla @ 2018-12-10 12:55 UTC (permalink / raw)
  To: Biju Das, Geert Uytterhoeven, Alexandre Belloni
  Cc: Simon Horman, Chris Paterson, Fabrizio Castro, Alessandro Zummo,
	linux-rtc, linux-renesas-soc



On 10/12/18 12:45, Biju Das wrote:
>> Its better to move checks from
>> bin_attr_nvmem_read()/bin_attr_nvmem_write() into nvmem_reg_read()
>> and nvmem_reg_write(), so its easy to maintain, rather than adding them to
>> each function.
> Initially I also thought the same. But there are some RTC drivers which is using nvmem_device
> interface  is not defining "word_size"  member. That is the reason we need to add it in separate function.
> Can you please suggest how to handle the above drivers?

Word size is optional anyway, in the case where word_size is not 
specified, its considered as one byte word_size.

--srini

> 

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

* Re: [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig
  2018-12-10 12:35     ` Biju Das
@ 2018-12-10 13:22       ` Simon Horman
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2018-12-10 13:22 UTC (permalink / raw)
  To: Biju Das
  Cc: Magnus Damm, Russell King, Alexandre Belloni, linux-rtc,
	linux-renesas-soc, linux-arm-kernel, Geert Uytterhoeven,
	Chris Paterson, Srinivas Kandagatla, Fabrizio Castro

On Mon, Dec 10, 2018 at 12:35:35PM +0000, Biju Das wrote:
> Hi Simon,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in
> > shmobile_defconfig
> >
> > On Fri, Dec 07, 2018 at 11:27:45AM +0000, Biju Das wrote:
> > > The iWave RZ/G1C SBC supports RTC (NXP pcf85263). To increase hardware
> > > support enable the driver in the shmobile_defconfig multiplatform
> > > configuration.
> > >
> > > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > Thanks, applied for v4.22.
> >
> > Is a similar change for multi_v7_defconfig also appropriate?
> 
> Will send a separate patch for adding it to the "multi_v7_defconfig"
> 
> CONFIG_RTC_DRV_PCF85363=m

Great, thanks.

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

* RE: [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write}
  2018-12-10 12:55       ` Srinivas Kandagatla
@ 2018-12-10 15:35         ` Biju Das
  0 siblings, 0 replies; 18+ messages in thread
From: Biju Das @ 2018-12-10 15:35 UTC (permalink / raw)
  To: Srinivas Kandagatla, Geert Uytterhoeven, Alexandre Belloni
  Cc: Simon Horman, Chris Paterson, Fabrizio Castro, Alessandro Zummo,
	linux-rtc, linux-renesas-soc

Hi Srinivas,

Thanks for the feedback.

> Subject: Re: [PATCH v4 1/5] nvmem: check invalid number of bytes in
> nvmem_device_{read,write}
>
>
>
> On 10/12/18 12:45, Biju Das wrote:
> >> Its better to move checks from
> >> bin_attr_nvmem_read()/bin_attr_nvmem_write() into
> nvmem_reg_read()
> >> and nvmem_reg_write(), so its easy to maintain, rather than adding
> >> them to each function.
> > Initially I also thought the same. But there are some RTC drivers
> > which is using nvmem_device interface  is not defining "word_size"
> member. That is the reason we need to add it in separate function.
> > Can you please suggest how to handle the above drivers?
>
> Word size is optional anyway, in the case where word_size is not specified,
> its considered as one byte word_size.

Will send V2 for this.

Regards,
Biju


[https://www2.renesas.eu/media/email/unicef.jpg]

This Christmas, instead of sending out cards, Renesas Electronics Europe have decided to support Unicef with a donation. For further details click here<https://www.unicef.org/> to find out about the valuable work they do, helping children all over the world.
We would like to take this opportunity to wish you a Merry Christmas and a prosperous New Year.



Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered No. 04586709.

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

* Re: [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
  2018-12-07 23:19   ` Rob Herring
  2018-12-10 12:16   ` Simon Horman
@ 2018-12-11 11:15   ` Alexandre Belloni
  2 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2018-12-11 11:15 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Geert Uytterhoeven, Rob Herring, Mark Rutland,
	linux-rtc, devicetree, Simon Horman, Chris Paterson,
	Srinivas Kandagatla, Fabrizio Castro, linux-renesas-soc

On 07/12/2018 11:27:43+0000, Biju Das wrote:
> The pcf85263 RTC is compatible with the pcf85363 RTC.
> 
> The difference between the pcf85263 and pcf85363 RTC is that the latter has
> 64 bytes more RAM. This renders them incompatible from a DT point of view.
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> V1-->V2
> 	* Incorporated Simon's review comment.
> V2-->V3
> 	* No Change.
> V3-->V4
> 	* No Change.
> ---
>  Documentation/devicetree/bindings/rtc/pcf85363.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc
  2018-12-07 11:27 ` [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
@ 2018-12-11 11:15   ` Alexandre Belloni
  0 siblings, 0 replies; 18+ messages in thread
From: Alexandre Belloni @ 2018-12-11 11:15 UTC (permalink / raw)
  To: Biju Das
  Cc: Alessandro Zummo, Geert Uytterhoeven, linux-rtc, Simon Horman,
	Chris Paterson, Srinivas Kandagatla, Fabrizio Castro,
	linux-renesas-soc

On 07/12/2018 11:27:44+0000, Biju Das wrote:
> Add support for NXP pcf85263 real-time clock. pcf85263 rtc is compatible
> with pcf85363,except that pcf85363 has additional 64 bytes of RAM.
> 
> 1 byte of nvmem is supported and exposed in sysfs (# is the instance
> number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem
> 
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> ---
> V1-->V2
> 	* Incorporated Alexandre and Geert's review comment.
> V2-->V3
> 	* Incorporated Geert's review comment.
> V3-->V4
> 	* Incorporated Geert's and Alexandre's review comment.
> ---
>  drivers/rtc/rtc-pcf85363.c | 94 +++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 76 insertions(+), 18 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, back to index

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 11:27 [PATCH v4 0/5] Add NXP pcf85263 real-time clock support Biju Das
2018-12-07 11:27 ` [PATCH v4 1/5] nvmem: check invalid number of bytes in nvmem_device_{read,write} Biju Das
2018-12-10 12:37   ` Srinivas Kandagatla
2018-12-10 12:45     ` Biju Das
2018-12-10 12:55       ` Srinivas Kandagatla
2018-12-10 15:35         ` Biju Das
2018-12-07 11:27 ` [PATCH v4 2/5] dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock Biju Das
2018-12-07 23:19   ` Rob Herring
2018-12-10 12:16   ` Simon Horman
2018-12-11 11:15   ` Alexandre Belloni
2018-12-07 11:27 ` [PATCH v4 3/5] rtc: pcf85363: Add support for NXP pcf85263 rtc Biju Das
2018-12-11 11:15   ` Alexandre Belloni
2018-12-07 11:27 ` [PATCH v4 4/5] ARM: shmobile: Enable NXP pcf85363 rtc in shmobile_defconfig Biju Das
2018-12-10 12:13   ` Simon Horman
2018-12-10 12:35     ` Biju Das
2018-12-10 13:22       ` Simon Horman
2018-12-07 11:27 ` [PATCH v4 5/5] ARM: dts: iwg23s-sbc: Enable RTC Biju Das
2018-12-10 12:15   ` Simon Horman

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org linux-rtc@archiver.kernel.org
	public-inbox-index linux-rtc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox