linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] rtc: moxart: switch to using gpiod API
@ 2023-02-01  5:48 Dmitry Torokhov
  2023-02-01  5:48 ` [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties Dmitry Torokhov
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-01  5:48 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Rob Herring, Krzysztof Kozlowski
  Cc: Arnd Bergmann, linux-rtc, linux-kernel, devicetree

Switch the driver from legacy gpio API that is deprecated to the newer
gpiod API that respects line polarities described in ACPI/DT.

This makes driver use standard property name for its gpios
("rtc-*-gpios" vs "gpios-rtc-*"), however there is a quirk in gpiolib
to also recognize legacy names and keep compatibility with older DTSes:
eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
RTC").

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/rtc/rtc-moxart.c | 89 ++++++++++++++++------------------------
 1 file changed, 36 insertions(+), 53 deletions(-)

diff --git a/drivers/rtc/rtc-moxart.c b/drivers/rtc/rtc-moxart.c
index 6b24ac9e1cfa..2247dd39ee4b 100644
--- a/drivers/rtc/rtc-moxart.c
+++ b/drivers/rtc/rtc-moxart.c
@@ -10,14 +10,15 @@
  * Moxa Technology Co., Ltd. <www.moxa.com>
  */
 
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/module.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/mod_devicetable.h>
+#include <linux/gpio/consumer.h>
 
 #define GPIO_RTC_RESERVED			0x0C
 #define GPIO_RTC_DATA_SET			0x10
@@ -55,7 +56,9 @@
 struct moxart_rtc {
 	struct rtc_device *rtc;
 	spinlock_t rtc_lock;
-	int gpio_data, gpio_sclk, gpio_reset;
+	struct gpio_desc *gpio_data;
+	struct gpio_desc *gpio_sclk;
+	struct gpio_desc *gpio_reset;
 };
 
 static int day_of_year[12] =	{ 0, 31, 59, 90, 120, 151, 181,
@@ -67,10 +70,10 @@ static void moxart_rtc_write_byte(struct device *dev, u8 data)
 	int i;
 
 	for (i = 0; i < 8; i++, data >>= 1) {
-		gpio_set_value(moxart_rtc->gpio_sclk, 0);
-		gpio_set_value(moxart_rtc->gpio_data, ((data & 1) == 1));
+		gpiod_set_value(moxart_rtc->gpio_sclk, 0);
+		gpiod_set_value(moxart_rtc->gpio_data, ((data & 1) == 1));
 		udelay(GPIO_RTC_DELAY_TIME);
-		gpio_set_value(moxart_rtc->gpio_sclk, 1);
+		gpiod_set_value(moxart_rtc->gpio_sclk, 1);
 		udelay(GPIO_RTC_DELAY_TIME);
 	}
 }
@@ -82,11 +85,11 @@ static u8 moxart_rtc_read_byte(struct device *dev)
 	u8 data = 0;
 
 	for (i = 0; i < 8; i++) {
-		gpio_set_value(moxart_rtc->gpio_sclk, 0);
+		gpiod_set_value(moxart_rtc->gpio_sclk, 0);
 		udelay(GPIO_RTC_DELAY_TIME);
-		gpio_set_value(moxart_rtc->gpio_sclk, 1);
+		gpiod_set_value(moxart_rtc->gpio_sclk, 1);
 		udelay(GPIO_RTC_DELAY_TIME);
-		if (gpio_get_value(moxart_rtc->gpio_data))
+		if (gpiod_get_value(moxart_rtc->gpio_data))
 			data |= (1 << i);
 		udelay(GPIO_RTC_DELAY_TIME);
 	}
@@ -101,15 +104,15 @@ static u8 moxart_rtc_read_register(struct device *dev, u8 cmd)
 
 	local_irq_save(flags);
 
-	gpio_direction_output(moxart_rtc->gpio_data, 0);
-	gpio_set_value(moxart_rtc->gpio_reset, 1);
+	gpiod_direction_output(moxart_rtc->gpio_data, 0);
+	gpiod_set_value(moxart_rtc->gpio_reset, 1);
 	udelay(GPIO_RTC_DELAY_TIME);
 	moxart_rtc_write_byte(dev, cmd);
-	gpio_direction_input(moxart_rtc->gpio_data);
+	gpiod_direction_input(moxart_rtc->gpio_data);
 	udelay(GPIO_RTC_DELAY_TIME);
 	data = moxart_rtc_read_byte(dev);
-	gpio_set_value(moxart_rtc->gpio_sclk, 0);
-	gpio_set_value(moxart_rtc->gpio_reset, 0);
+	gpiod_set_value(moxart_rtc->gpio_sclk, 0);
+	gpiod_set_value(moxart_rtc->gpio_reset, 0);
 	udelay(GPIO_RTC_DELAY_TIME);
 
 	local_irq_restore(flags);
@@ -124,13 +127,13 @@ static void moxart_rtc_write_register(struct device *dev, u8 cmd, u8 data)
 
 	local_irq_save(flags);
 
-	gpio_direction_output(moxart_rtc->gpio_data, 0);
-	gpio_set_value(moxart_rtc->gpio_reset, 1);
+	gpiod_direction_output(moxart_rtc->gpio_data, 0);
+	gpiod_set_value(moxart_rtc->gpio_reset, 1);
 	udelay(GPIO_RTC_DELAY_TIME);
 	moxart_rtc_write_byte(dev, cmd);
 	moxart_rtc_write_byte(dev, data);
-	gpio_set_value(moxart_rtc->gpio_sclk, 0);
-	gpio_set_value(moxart_rtc->gpio_reset, 0);
+	gpiod_set_value(moxart_rtc->gpio_sclk, 0);
+	gpiod_set_value(moxart_rtc->gpio_reset, 0);
 	udelay(GPIO_RTC_DELAY_TIME);
 
 	local_irq_restore(flags);
@@ -247,53 +250,33 @@ static int moxart_rtc_probe(struct platform_device *pdev)
 	if (!moxart_rtc)
 		return -ENOMEM;
 
-	moxart_rtc->gpio_data = of_get_named_gpio(pdev->dev.of_node,
-						  "gpio-rtc-data", 0);
-	if (!gpio_is_valid(moxart_rtc->gpio_data)) {
-		dev_err(&pdev->dev, "invalid gpio (data): %d\n",
-			moxart_rtc->gpio_data);
-		return moxart_rtc->gpio_data;
-	}
-
-	moxart_rtc->gpio_sclk = of_get_named_gpio(pdev->dev.of_node,
-						  "gpio-rtc-sclk", 0);
-	if (!gpio_is_valid(moxart_rtc->gpio_sclk)) {
-		dev_err(&pdev->dev, "invalid gpio (sclk): %d\n",
-			moxart_rtc->gpio_sclk);
-		return moxart_rtc->gpio_sclk;
-	}
-
-	moxart_rtc->gpio_reset = of_get_named_gpio(pdev->dev.of_node,
-						   "gpio-rtc-reset", 0);
-	if (!gpio_is_valid(moxart_rtc->gpio_reset)) {
-		dev_err(&pdev->dev, "invalid gpio (reset): %d\n",
-			moxart_rtc->gpio_reset);
-		return moxart_rtc->gpio_reset;
-	}
-
-	spin_lock_init(&moxart_rtc->rtc_lock);
-	platform_set_drvdata(pdev, moxart_rtc);
-
-	ret = devm_gpio_request(&pdev->dev, moxart_rtc->gpio_data, "rtc_data");
+	moxart_rtc->gpio_data = devm_gpiod_get(&pdev->dev, "rtc-data",
+					       GPIOD_IN);
+	ret = PTR_ERR_OR_ZERO(moxart_rtc->gpio_data);
 	if (ret) {
-		dev_err(&pdev->dev, "can't get rtc_data gpio\n");
+		dev_err(&pdev->dev, "can't get rtc data gpio: %d\n", ret);
 		return ret;
 	}
 
-	ret = devm_gpio_request_one(&pdev->dev, moxart_rtc->gpio_sclk,
-				    GPIOF_DIR_OUT, "rtc_sclk");
+	moxart_rtc->gpio_sclk = devm_gpiod_get(&pdev->dev, "rtc-sclk",
+					       GPIOD_ASIS);
+	ret = PTR_ERR_OR_ZERO(moxart_rtc->gpio_sclk);
 	if (ret) {
-		dev_err(&pdev->dev, "can't get rtc_sclk gpio\n");
+		dev_err(&pdev->dev, "can't get rtc sclk gpio: %d\n", ret);
 		return ret;
 	}
 
-	ret = devm_gpio_request_one(&pdev->dev, moxart_rtc->gpio_reset,
-				    GPIOF_DIR_OUT, "rtc_reset");
+	moxart_rtc->gpio_reset = devm_gpiod_get(&pdev->dev, "rtc-reset",
+						GPIOD_ASIS);
+	ret = PTR_ERR_OR_ZERO(moxart_rtc->gpio_reset);
 	if (ret) {
-		dev_err(&pdev->dev, "can't get rtc_reset gpio\n");
+		dev_err(&pdev->dev, "can't get rtc reset gpio: %d\n", ret);
 		return ret;
 	}
 
+	spin_lock_init(&moxart_rtc->rtc_lock);
+	platform_set_drvdata(pdev, moxart_rtc);
+
 	moxart_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
 						   &moxart_rtc_ops,
 						   THIS_MODULE);
-- 
2.39.1.456.gfc5497dd1b-goog


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

* [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01  5:48 [PATCH 1/3] rtc: moxart: switch to using gpiod API Dmitry Torokhov
@ 2023-02-01  5:48 ` Dmitry Torokhov
  2023-02-01  7:38   ` Krzysztof Kozlowski
  2023-02-01  5:48 ` [PATCH 3/3] ARM: dts: moxart: switch to proper names for RTC GPIOs Dmitry Torokhov
  2023-02-09 22:32 ` (subset) [PATCH 1/3] rtc: moxart: switch to using gpiod API Alexandre Belloni
  2 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-01  5:48 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Rob Herring, Krzysztof Kozlowski
  Cc: Arnd Bergmann, linux-rtc, linux-kernel, devicetree

MOXA ART RTC driver has been switched to gpiod API and is now using
properly named properties for its gpios (with gpiolib implementing a
quirk to recognize legacy names). Change binding document to use
proper names as well.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
index c9d3ac1477fe..1374df7bf9d6 100644
--- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
@@ -3,15 +3,15 @@ MOXA ART real-time clock
 Required properties:
 
 - compatible : Should be "moxa,moxart-rtc"
-- gpio-rtc-sclk : RTC sclk gpio, with zero flags
-- gpio-rtc-data : RTC data gpio, with zero flags
-- gpio-rtc-reset : RTC reset gpio, with zero flags
+- rtc-sclk-gpios : RTC sclk gpio, with zero flags
+- rtc-data-gpios : RTC data gpio, with zero flags
+- rtc-reset-gpios : RTC reset gpio, with zero flags
 
 Example:
 
 	rtc: rtc {
 		compatible = "moxa,moxart-rtc";
-		gpio-rtc-sclk = <&gpio 5 0>;
-		gpio-rtc-data = <&gpio 6 0>;
-		gpio-rtc-reset = <&gpio 7 0>;
+		rtc-sclk-gpios = <&gpio 5 0>;
+		rtc-data-gpios = <&gpio 6 0>;
+		rtc-reset-gpios = <&gpio 7 0>;
 	};
-- 
2.39.1.456.gfc5497dd1b-goog


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

* [PATCH 3/3] ARM: dts: moxart: switch to proper names for RTC GPIOs
  2023-02-01  5:48 [PATCH 1/3] rtc: moxart: switch to using gpiod API Dmitry Torokhov
  2023-02-01  5:48 ` [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties Dmitry Torokhov
@ 2023-02-01  5:48 ` Dmitry Torokhov
  2023-02-09 22:32 ` (subset) [PATCH 1/3] rtc: moxart: switch to using gpiod API Alexandre Belloni
  2 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-01  5:48 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Rob Herring, Krzysztof Kozlowski
  Cc: Arnd Bergmann, linux-rtc, linux-kernel, devicetree

Update DTS to use proper names for RTC GPIOs. While the driver/gpiolib
will still recognize the old variants of names, there is no reason why
we should not update DTS that is present in the kernel.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/boot/dts/moxart.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/moxart.dtsi b/arch/arm/boot/dts/moxart.dtsi
index 11cbea5b94d2..622742956b2b 100644
--- a/arch/arm/boot/dts/moxart.dtsi
+++ b/arch/arm/boot/dts/moxart.dtsi
@@ -74,9 +74,9 @@ gpio: gpio@98700000 {
 
 		rtc: rtc {
 			compatible = "moxa,moxart-rtc";
-			gpio-rtc-sclk = <&gpio 5 0>;
-			gpio-rtc-data = <&gpio 6 0>;
-			gpio-rtc-reset = <&gpio 7 0>;
+			rtc-sclk-gpios = <&gpio 5 0>;
+			rtc-data-gpios = <&gpio 6 0>;
+			rtc-reset-gpios = <&gpio 7 0>;
 		};
 
 		dma: dma@90500000 {
-- 
2.39.1.456.gfc5497dd1b-goog


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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01  5:48 ` [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties Dmitry Torokhov
@ 2023-02-01  7:38   ` Krzysztof Kozlowski
  2023-02-01 16:15     ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-01  7:38 UTC (permalink / raw)
  To: Dmitry Torokhov, Alessandro Zummo, Alexandre Belloni,
	Rob Herring, Krzysztof Kozlowski
  Cc: Arnd Bergmann, linux-rtc, linux-kernel, devicetree

On 01/02/2023 06:48, Dmitry Torokhov wrote:
> MOXA ART RTC driver has been switched to gpiod API and is now using
> properly named properties for its gpios (with gpiolib implementing a
> quirk to recognize legacy names). Change binding document to use
> proper names as well.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> index c9d3ac1477fe..1374df7bf9d6 100644
> --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> @@ -3,15 +3,15 @@ MOXA ART real-time clock
>  Required properties:
>  
>  - compatible : Should be "moxa,moxart-rtc"
> -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> -- gpio-rtc-data : RTC data gpio, with zero flags
> -- gpio-rtc-reset : RTC reset gpio, with zero flags
> +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> +- rtc-data-gpios : RTC data gpio, with zero flags
> +- rtc-reset-gpios : RTC reset gpio, with zero flags

Your driver breaks the ABI, doesn't it? If not, how are the old
properties parsed?

Best regards,
Krzysztof


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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01  7:38   ` Krzysztof Kozlowski
@ 2023-02-01 16:15     ` Dmitry Torokhov
  2023-02-01 17:55       ` Rob Herring
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-01 16:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Alessandro Zummo, Alexandre Belloni, Rob Herring,
	Krzysztof Kozlowski, Arnd Bergmann, linux-rtc, linux-kernel,
	devicetree

On Wed, Feb 01, 2023 at 08:38:48AM +0100, Krzysztof Kozlowski wrote:
> On 01/02/2023 06:48, Dmitry Torokhov wrote:
> > MOXA ART RTC driver has been switched to gpiod API and is now using
> > properly named properties for its gpios (with gpiolib implementing a
> > quirk to recognize legacy names). Change binding document to use
> > proper names as well.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > index c9d3ac1477fe..1374df7bf9d6 100644
> > --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > @@ -3,15 +3,15 @@ MOXA ART real-time clock
> >  Required properties:
> >  
> >  - compatible : Should be "moxa,moxart-rtc"
> > -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> > -- gpio-rtc-data : RTC data gpio, with zero flags
> > -- gpio-rtc-reset : RTC reset gpio, with zero flags
> > +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> > +- rtc-data-gpios : RTC data gpio, with zero flags
> > +- rtc-reset-gpios : RTC reset gpio, with zero flags
> 
> Your driver breaks the ABI, doesn't it? If not, how are the old
> properties parsed?

It does not. As I mentioned in the driver code patch, commit
eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
RTC") makes sure gpiolib falls back to trying old variants if it can't
locate properly formatted names.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01 16:15     ` Dmitry Torokhov
@ 2023-02-01 17:55       ` Rob Herring
  2023-02-01 19:02         ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2023-02-01 17:55 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Krzysztof Kozlowski, Alessandro Zummo, Alexandre Belloni,
	Krzysztof Kozlowski, Arnd Bergmann, linux-rtc, linux-kernel,
	devicetree

On Wed, Feb 01, 2023 at 08:15:26AM -0800, Dmitry Torokhov wrote:
> On Wed, Feb 01, 2023 at 08:38:48AM +0100, Krzysztof Kozlowski wrote:
> > On 01/02/2023 06:48, Dmitry Torokhov wrote:
> > > MOXA ART RTC driver has been switched to gpiod API and is now using
> > > properly named properties for its gpios (with gpiolib implementing a
> > > quirk to recognize legacy names). Change binding document to use
> > > proper names as well.
> > > 
> > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > ---
> > >  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
> > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > index c9d3ac1477fe..1374df7bf9d6 100644
> > > --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > @@ -3,15 +3,15 @@ MOXA ART real-time clock
> > >  Required properties:
> > >  
> > >  - compatible : Should be "moxa,moxart-rtc"
> > > -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> > > -- gpio-rtc-data : RTC data gpio, with zero flags
> > > -- gpio-rtc-reset : RTC reset gpio, with zero flags
> > > +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> > > +- rtc-data-gpios : RTC data gpio, with zero flags
> > > +- rtc-reset-gpios : RTC reset gpio, with zero flags
> > 
> > Your driver breaks the ABI, doesn't it? If not, how are the old
> > properties parsed?
> 
> It does not. As I mentioned in the driver code patch, commit
> eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
> RTC") makes sure gpiolib falls back to trying old variants if it can't
> locate properly formatted names.

A dtb with the new names and a kernel without the gpiod conversion would 
be broken. Up to the platform whether they care really.

Rob

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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01 17:55       ` Rob Herring
@ 2023-02-01 19:02         ` Dmitry Torokhov
  2023-02-02 23:27           ` Rob Herring
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-01 19:02 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Alessandro Zummo, Alexandre Belloni,
	Krzysztof Kozlowski, Arnd Bergmann, linux-rtc, linux-kernel,
	devicetree

On Wed, Feb 01, 2023 at 11:55:04AM -0600, Rob Herring wrote:
> On Wed, Feb 01, 2023 at 08:15:26AM -0800, Dmitry Torokhov wrote:
> > On Wed, Feb 01, 2023 at 08:38:48AM +0100, Krzysztof Kozlowski wrote:
> > > On 01/02/2023 06:48, Dmitry Torokhov wrote:
> > > > MOXA ART RTC driver has been switched to gpiod API and is now using
> > > > properly named properties for its gpios (with gpiolib implementing a
> > > > quirk to recognize legacy names). Change binding document to use
> > > > proper names as well.
> > > > 
> > > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > ---
> > > >  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
> > > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > index c9d3ac1477fe..1374df7bf9d6 100644
> > > > --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > @@ -3,15 +3,15 @@ MOXA ART real-time clock
> > > >  Required properties:
> > > >  
> > > >  - compatible : Should be "moxa,moxart-rtc"
> > > > -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> > > > -- gpio-rtc-data : RTC data gpio, with zero flags
> > > > -- gpio-rtc-reset : RTC reset gpio, with zero flags
> > > > +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> > > > +- rtc-data-gpios : RTC data gpio, with zero flags
> > > > +- rtc-reset-gpios : RTC reset gpio, with zero flags
> > > 
> > > Your driver breaks the ABI, doesn't it? If not, how are the old
> > > properties parsed?
> > 
> > It does not. As I mentioned in the driver code patch, commit
> > eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
> > RTC") makes sure gpiolib falls back to trying old variants if it can't
> > locate properly formatted names.
> 
> A dtb with the new names and a kernel without the gpiod conversion would 
> be broken. Up to the platform whether they care really.

Seriously? And I guess devices with DTS do not work with kernels v2.0 so
we should never have introduced it...

I understand wanting backward compatibility, but asking for both
backward and forward is a bit too much IMO.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-01 19:02         ` Dmitry Torokhov
@ 2023-02-02 23:27           ` Rob Herring
  2023-02-03 22:22             ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2023-02-02 23:27 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Krzysztof Kozlowski, Alessandro Zummo, Alexandre Belloni,
	Krzysztof Kozlowski, Arnd Bergmann, linux-rtc, linux-kernel,
	devicetree

On Wed, Feb 01, 2023 at 11:02:39AM -0800, Dmitry Torokhov wrote:
> On Wed, Feb 01, 2023 at 11:55:04AM -0600, Rob Herring wrote:
> > On Wed, Feb 01, 2023 at 08:15:26AM -0800, Dmitry Torokhov wrote:
> > > On Wed, Feb 01, 2023 at 08:38:48AM +0100, Krzysztof Kozlowski wrote:
> > > > On 01/02/2023 06:48, Dmitry Torokhov wrote:
> > > > > MOXA ART RTC driver has been switched to gpiod API and is now using
> > > > > properly named properties for its gpios (with gpiolib implementing a
> > > > > quirk to recognize legacy names). Change binding document to use
> > > > > proper names as well.
> > > > > 
> > > > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > > ---
> > > > >  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
> > > > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > > > 
> > > > > diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > index c9d3ac1477fe..1374df7bf9d6 100644
> > > > > --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > @@ -3,15 +3,15 @@ MOXA ART real-time clock
> > > > >  Required properties:
> > > > >  
> > > > >  - compatible : Should be "moxa,moxart-rtc"
> > > > > -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> > > > > -- gpio-rtc-data : RTC data gpio, with zero flags
> > > > > -- gpio-rtc-reset : RTC reset gpio, with zero flags
> > > > > +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> > > > > +- rtc-data-gpios : RTC data gpio, with zero flags
> > > > > +- rtc-reset-gpios : RTC reset gpio, with zero flags
> > > > 
> > > > Your driver breaks the ABI, doesn't it? If not, how are the old
> > > > properties parsed?
> > > 
> > > It does not. As I mentioned in the driver code patch, commit
> > > eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
> > > RTC") makes sure gpiolib falls back to trying old variants if it can't
> > > locate properly formatted names.
> > 
> > A dtb with the new names and a kernel without the gpiod conversion would 
> > be broken. Up to the platform whether they care really.
> 
> Seriously? And I guess devices with DTS do not work with kernels v2.0 so
> we should never have introduced it...

They would be fine because they would ignore the dtb. ;)

> I understand wanting backward compatibility, but asking for both
> backward and forward is a bit too much IMO.

Like I said, up to the platform to decide. I'm just defining what's an 
ABI break or not.

If the dtb ships with firmware, do you want new firmware with a newer 
dtb to break your OS? We can sometimes mitigate that with stable kernel 
updates. There are obvious cases that don't work such as adding 
providers such as clocks (instead of dummy fixed clocks) or pinctrl, 
where old kernels will never have the driver (but doesn't know that).

Rob

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

* Re: [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
  2023-02-02 23:27           ` Rob Herring
@ 2023-02-03 22:22             ` Dmitry Torokhov
  0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2023-02-03 22:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Alessandro Zummo, Alexandre Belloni,
	Krzysztof Kozlowski, Arnd Bergmann, linux-rtc, linux-kernel,
	devicetree

On Thu, Feb 02, 2023 at 05:27:34PM -0600, Rob Herring wrote:
> On Wed, Feb 01, 2023 at 11:02:39AM -0800, Dmitry Torokhov wrote:
> > On Wed, Feb 01, 2023 at 11:55:04AM -0600, Rob Herring wrote:
> > > On Wed, Feb 01, 2023 at 08:15:26AM -0800, Dmitry Torokhov wrote:
> > > > On Wed, Feb 01, 2023 at 08:38:48AM +0100, Krzysztof Kozlowski wrote:
> > > > > On 01/02/2023 06:48, Dmitry Torokhov wrote:
> > > > > > MOXA ART RTC driver has been switched to gpiod API and is now using
> > > > > > properly named properties for its gpios (with gpiolib implementing a
> > > > > > quirk to recognize legacy names). Change binding document to use
> > > > > > proper names as well.
> > > > > > 
> > > > > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > > > ---
> > > > > >  .../devicetree/bindings/rtc/moxa,moxart-rtc.txt      | 12 ++++++------
> > > > > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > > > > 
> > > > > > diff --git a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > > index c9d3ac1477fe..1374df7bf9d6 100644
> > > > > > --- a/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > > +++ b/Documentation/devicetree/bindings/rtc/moxa,moxart-rtc.txt
> > > > > > @@ -3,15 +3,15 @@ MOXA ART real-time clock
> > > > > >  Required properties:
> > > > > >  
> > > > > >  - compatible : Should be "moxa,moxart-rtc"
> > > > > > -- gpio-rtc-sclk : RTC sclk gpio, with zero flags
> > > > > > -- gpio-rtc-data : RTC data gpio, with zero flags
> > > > > > -- gpio-rtc-reset : RTC reset gpio, with zero flags
> > > > > > +- rtc-sclk-gpios : RTC sclk gpio, with zero flags
> > > > > > +- rtc-data-gpios : RTC data gpio, with zero flags
> > > > > > +- rtc-reset-gpios : RTC reset gpio, with zero flags
> > > > > 
> > > > > Your driver breaks the ABI, doesn't it? If not, how are the old
> > > > > properties parsed?
> > > > 
> > > > It does not. As I mentioned in the driver code patch, commit
> > > > eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
> > > > RTC") makes sure gpiolib falls back to trying old variants if it can't
> > > > locate properly formatted names.
> > > 
> > > A dtb with the new names and a kernel without the gpiod conversion would 
> > > be broken. Up to the platform whether they care really.
> > 
> > Seriously? And I guess devices with DTS do not work with kernels v2.0 so
> > we should never have introduced it...
> 
> They would be fine because they would ignore the dtb. ;)
> 
> > I understand wanting backward compatibility, but asking for both
> > backward and forward is a bit too much IMO.
> 
> Like I said, up to the platform to decide. I'm just defining what's an 
> ABI break or not.
> 
> If the dtb ships with firmware, do you want new firmware with a newer 
> dtb to break your OS? We can sometimes mitigate that with stable kernel 
> updates. There are obvious cases that don't work such as adding 
> providers such as clocks (instead of dummy fixed clocks) or pinctrl, 
> where old kernels will never have the driver (but doesn't know that).

When vendors ship firmware they target particular set of software that
runs on it, so they would not mindlessly jump to the very latest version
of binding. Doing that would be similar to a vendor that originally
shipped a system with Windows 7 out of sudden changing its firmware to
use latest and greatest mechanisms defined in ACPI 6.5 and removing
older ones.

Thanks.

-- 
Dmitry

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

* Re: (subset) [PATCH 1/3] rtc: moxart: switch to using gpiod API
  2023-02-01  5:48 [PATCH 1/3] rtc: moxart: switch to using gpiod API Dmitry Torokhov
  2023-02-01  5:48 ` [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties Dmitry Torokhov
  2023-02-01  5:48 ` [PATCH 3/3] ARM: dts: moxart: switch to proper names for RTC GPIOs Dmitry Torokhov
@ 2023-02-09 22:32 ` Alexandre Belloni
  2 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2023-02-09 22:32 UTC (permalink / raw)
  To: Alessandro Zummo, Rob Herring, Krzysztof Kozlowski, Dmitry Torokhov
  Cc: Arnd Bergmann, linux-rtc, linux-kernel, devicetree


On Tue, 31 Jan 2023 21:48:13 -0800, Dmitry Torokhov wrote:
> Switch the driver from legacy gpio API that is deprecated to the newer
> gpiod API that respects line polarities described in ACPI/DT.
> 
> This makes driver use standard property name for its gpios
> ("rtc-*-gpios" vs "gpios-rtc-*"), however there is a quirk in gpiolib
> to also recognize legacy names and keep compatibility with older DTSes:
> eaf1a29665cd ("gpiolib: of: add a quirk for legacy names in MOXA ART
> RTC").
> 
> [...]

Applied, thanks!

[1/3] rtc: moxart: switch to using gpiod API
      commit: 2985cda83b8107213e108f95c3cb8caa0da74918
[2/3] dt-bindings: rtc: moxart: use proper names for gpio properties
      commit: e8c9efd5d52f1da1c9e012466b9df94a38cc1c00

Best regards,

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

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

end of thread, other threads:[~2023-02-09 22:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01  5:48 [PATCH 1/3] rtc: moxart: switch to using gpiod API Dmitry Torokhov
2023-02-01  5:48 ` [PATCH 2/3] dt-bindings: rtc: moxart: use proper names for gpio properties Dmitry Torokhov
2023-02-01  7:38   ` Krzysztof Kozlowski
2023-02-01 16:15     ` Dmitry Torokhov
2023-02-01 17:55       ` Rob Herring
2023-02-01 19:02         ` Dmitry Torokhov
2023-02-02 23:27           ` Rob Herring
2023-02-03 22:22             ` Dmitry Torokhov
2023-02-01  5:48 ` [PATCH 3/3] ARM: dts: moxart: switch to proper names for RTC GPIOs Dmitry Torokhov
2023-02-09 22:32 ` (subset) [PATCH 1/3] rtc: moxart: switch to using gpiod API Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).