All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] pwm: support backward compatibility of DTB extending PWM args
@ 2014-10-10 15:50 ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

Please review this alternative in-house version of supporting backward
compatibility of DTB files, if pwms arguments of exisitng PWM drivers
are to be extended with polarity field.

Unfortunately I've firstly created the change and only after that
found that Lothar Waßmann is working on his version, so I won't insist
on formal preference, but still I like to share my variant since it
technically different from Lothar's one.

One visual benefit of my verison is that if this version is accepted,
then of_pwm_xlate_with_flags() can be removed from all touched PWM
drivers and pwm/core.c as a redundant interface and generally is looks
to be a more simple change.

The particular changes in iMX PWM driver and other PWM drivers are out
of this change scope.

Feel free to criticize the change.

Vladimir Zapolskiy (3):
  pwm: process pwm polarity argument in of_pwm_simple_xlate()
  pwm: push up dynamic printk level on errors in of_pwm_get()
  pwm: set the actual number of pwms arguments defined in board dts

 drivers/pwm/core.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
1.7.10.4


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

* [PATCH 0/3] pwm: support backward compatibility of DTB extending PWM args
@ 2014-10-10 15:50 ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

Please review this alternative in-house version of supporting backward
compatibility of DTB files, if pwms arguments of exisitng PWM drivers
are to be extended with polarity field.

Unfortunately I've firstly created the change and only after that
found that Lothar Wa?mann is working on his version, so I won't insist
on formal preference, but still I like to share my variant since it
technically different from Lothar's one.

One visual benefit of my verison is that if this version is accepted,
then of_pwm_xlate_with_flags() can be removed from all touched PWM
drivers and pwm/core.c as a redundant interface and generally is looks
to be a more simple change.

The particular changes in iMX PWM driver and other PWM drivers are out
of this change scope.

Feel free to criticize the change.

Vladimir Zapolskiy (3):
  pwm: process pwm polarity argument in of_pwm_simple_xlate()
  pwm: push up dynamic printk level on errors in of_pwm_get()
  pwm: set the actual number of pwms arguments defined in board dts

 drivers/pwm/core.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
1.7.10.4

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

* [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate()
  2014-10-10 15:50 ` Vladimir Zapolskiy
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
 
 	pwm_set_period(pwm, args->args[1]);
 
+	if (pc->of_pwm_n_cells > 2) {
+		if (args->args[2] & PWM_POLARITY_INVERTED)
+			pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+		else
+			pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+	}
+
 	return pwm;
 }
 
-- 
1.7.10.4


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

* [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate()
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
 
 	pwm_set_period(pwm, args->args[1]);
 
+	if (pc->of_pwm_n_cells > 2) {
+		if (args->args[2] & PWM_POLARITY_INVERTED)
+			pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+		else
+			pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+	}
+
 	return pwm;
 }
 
-- 
1.7.10.4

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

* [PATCH 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
  2014-10-10 15:50 ` Vladimir Zapolskiy
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..ccf1be7 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_warn("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4


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

* [PATCH 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..ccf1be7 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_warn("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4

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

* [PATCH 3/3] pwm: set the actual number of pwms arguments defined in board dts
  2014-10-10 15:50 ` Vladimir Zapolskiy
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

For backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, additional arguments shall
be considered as optional, update pc->of_pwm_n_cells according to the
actual data taken from device tree file.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ccf1be7..2b77322 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 		goto put;
 	}
 
-	if (args.args_count != pc->of_pwm_n_cells) {
+	if (args.args_count < pc->of_pwm_n_cells) {
 		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
 	}
+	pc->of_pwm_n_cells = args.args_count;
 
 	pwm = pc->of_xlate(pc, &args);
 	if (IS_ERR(pwm))
-- 
1.7.10.4


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

* [PATCH 3/3] pwm: set the actual number of pwms arguments defined in board dts
@ 2014-10-10 15:50   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-10 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

For backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, additional arguments shall
be considered as optional, update pc->of_pwm_n_cells according to the
actual data taken from device tree file.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ccf1be7..2b77322 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 		goto put;
 	}
 
-	if (args.args_count != pc->of_pwm_n_cells) {
+	if (args.args_count < pc->of_pwm_n_cells) {
 		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
 	}
+	pc->of_pwm_n_cells = args.args_count;
 
 	pwm = pc->of_xlate(pc, &args);
 	if (IS_ERR(pwm))
-- 
1.7.10.4

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

* Re: [PATCH 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
  2014-10-10 15:50   ` Vladimir Zapolskiy
@ 2014-10-13  6:12     ` Lothar Waßmann
  -1 siblings, 0 replies; 20+ messages in thread
From: Lothar Waßmann @ 2014-10-13  6:12 UTC (permalink / raw)
  To: Vladimir Zapolskiy
  Cc: linux-pwm, linux-arm-kernel, Sascha Hauer, Thierry Reding, Shawn Guo

Hi,

Vladimir Zapolskiy wrote:
> The changed three user messages on fault are printed under pr_debug(),
> however all of them are unrecoverable and result in failed pwm device
> registration, report this to a user.
> 
> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
> Cc: Lothar Waßmann <LW@KARO-electronics.de>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/pwm/core.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 681d154..ccf1be7 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
>  	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
>  					 &args);
>  	if (err) {
> -		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
> +		pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
>
As this is an error that leads to not loading the driver it should be
printed with ERROR level.

>  		return ERR_PTR(err);
>  	}
>  
>  	pc = of_node_to_pwmchip(args.np);
>  	if (IS_ERR(pc)) {
> -		pr_debug("%s(): PWM chip not found\n", __func__);
> +		pr_warn("%s(): PWM chip not found\n", __func__);
>
dto.

>  		goto put;
>  	}
>  
>  	if (args.args_count != pc->of_pwm_n_cells) {
> -		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
> +		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
>
dto.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

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

* [PATCH 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
@ 2014-10-13  6:12     ` Lothar Waßmann
  0 siblings, 0 replies; 20+ messages in thread
From: Lothar Waßmann @ 2014-10-13  6:12 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Vladimir Zapolskiy wrote:
> The changed three user messages on fault are printed under pr_debug(),
> however all of them are unrecoverable and result in failed pwm device
> registration, report this to a user.
> 
> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
> Cc: Lothar Wa?mann <LW@KARO-electronics.de>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/pwm/core.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 681d154..ccf1be7 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
>  	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
>  					 &args);
>  	if (err) {
> -		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
> +		pr_warn("%s(): can't parse \"pwms\" property\n", __func__);
>
As this is an error that leads to not loading the driver it should be
printed with ERROR level.

>  		return ERR_PTR(err);
>  	}
>  
>  	pc = of_node_to_pwmchip(args.np);
>  	if (IS_ERR(pc)) {
> -		pr_debug("%s(): PWM chip not found\n", __func__);
> +		pr_warn("%s(): PWM chip not found\n", __func__);
>
dto.

>  		goto put;
>  	}
>  
>  	if (args.args_count != pc->of_pwm_n_cells) {
> -		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
> +		pr_warn("%s: wrong #pwm-cells for %s\n", np->full_name,
>
dto.


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

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

* [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
  2014-10-10 15:50 ` Vladimir Zapolskiy
@ 2014-10-13 14:21   ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Waßmann.

 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_err("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_err("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4


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

* [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
@ 2014-10-13 14:21   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.

 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_err("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_err("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4

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

* [PATCHv2 0/3] pwm: support backward compatibility of DTB extending PWM args
  2014-10-13 14:21   ` Vladimir Zapolskiy
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

Please review this alternative in-house version of supporting backward
compatibility of DTB files, if pwms arguments of exisitng PWM drivers
are to be extended with polarity field.

Unfortunately I've firstly created the change and only after that
found that Lothar Waßmann is working on his version, so I won't insist
on formal preference, but still I like to share my variant since it
technically different from Lothar's one.

One visual benefit of my verison is that if this version is accepted,
then of_pwm_xlate_with_flags() can be removed from all touched PWM
drivers and pwm/core.c as a redundant interface, chip.of_pwm_n_cells
should not be updated also, and generally is looks to be a more simple
change.

The particular changes in iMX PWM driver and other PWM drivers are out
of this change scope.

Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Waßmann.

Vladimir Zapolskiy (3):
  pwm: process pwm polarity argument in of_pwm_simple_xlate()
  pwm: push up dynamic printk level on errors in of_pwm_get()
  pwm: set the actual number of pwms arguments defined in board dts

 drivers/pwm/core.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
1.7.10.4


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

* [PATCHv2 0/3] pwm: support backward compatibility of DTB extending PWM args
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

Please review this alternative in-house version of supporting backward
compatibility of DTB files, if pwms arguments of exisitng PWM drivers
are to be extended with polarity field.

Unfortunately I've firstly created the change and only after that
found that Lothar Wa?mann is working on his version, so I won't insist
on formal preference, but still I like to share my variant since it
technically different from Lothar's one.

One visual benefit of my verison is that if this version is accepted,
then of_pwm_xlate_with_flags() can be removed from all touched PWM
drivers and pwm/core.c as a redundant interface, chip.of_pwm_n_cells
should not be updated also, and generally is looks to be a more simple
change.

The particular changes in iMX PWM driver and other PWM drivers are out
of this change scope.

Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.

Vladimir Zapolskiy (3):
  pwm: process pwm polarity argument in of_pwm_simple_xlate()
  pwm: push up dynamic printk level on errors in of_pwm_get()
  pwm: set the actual number of pwms arguments defined in board dts

 drivers/pwm/core.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
1.7.10.4

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

* [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate()
  2014-10-13 14:21   ` Vladimir Zapolskiy
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
 
 	pwm_set_period(pwm, args->args[1]);
 
+	if (pc->of_pwm_n_cells > 2) {
+		if (args->args[2] & PWM_POLARITY_INVERTED)
+			pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+		else
+			pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+	}
+
 	return pwm;
 }
 
-- 
1.7.10.4


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

* [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate()
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

The third optional argument of pwms is well defined as polarity and it
is already used in a number of pwm drivers, so, to minimize changes in
the remaining drivers which are to be updated accordingly set polarity
in default of_xlate() function.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/pwm/core.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 966497d..681d154 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -174,6 +174,13 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
 
 	pwm_set_period(pwm, args->args[1]);
 
+	if (pc->of_pwm_n_cells > 2) {
+		if (args->args[2] & PWM_POLARITY_INVERTED)
+			pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
+		else
+			pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);
+	}
+
 	return pwm;
 }
 
-- 
1.7.10.4

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

* [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
  2014-10-13 14:21   ` Vladimir Zapolskiy
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Waßmann.

 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_err("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_err("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4


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

* [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get()
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

The changed three user messages on fault are printed under pr_debug(),
however all of them are unrecoverable and result in failed pwm device
registration, report this to a user.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- corrected the proper kernel log level, thanks to Lothar Wa?mann.

 drivers/pwm/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 681d154..f6231c6 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -532,19 +532,19 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 	err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
 					 &args);
 	if (err) {
-		pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
+		pr_err("%s(): can't parse \"pwms\" property\n", __func__);
 		return ERR_PTR(err);
 	}
 
 	pc = of_node_to_pwmchip(args.np);
 	if (IS_ERR(pc)) {
-		pr_debug("%s(): PWM chip not found\n", __func__);
+		pr_err("%s(): PWM chip not found\n", __func__);
 		pwm = ERR_CAST(pc);
 		goto put;
 	}
 
 	if (args.args_count != pc->of_pwm_n_cells) {
-		pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
+		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
-- 
1.7.10.4

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

* [PATCHv2 3/3] pwm: set the actual number of pwms arguments defined in board dts
  2014-10-13 14:21   ` Vladimir Zapolskiy
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  -1 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-pwm
  Cc: linux-arm-kernel, Lothar Waßmann, Sascha Hauer,
	Thierry Reding, Shawn Guo

For backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, which is specified by a
driver. Additional arguments shall be considered as optional, update
pc->of_pwm_n_cells according to the actual data taken from device tree
file.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Waßmann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- rebased on top of modified patch v2 2/3

 drivers/pwm/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index f6231c6..4d9fc7f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 		goto put;
 	}
 
-	if (args.args_count != pc->of_pwm_n_cells) {
+	if (args.args_count < pc->of_pwm_n_cells) {
 		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
 	}
+	pc->of_pwm_n_cells = args.args_count;
 
 	pwm = pc->of_xlate(pc, &args);
 	if (IS_ERR(pwm))
-- 
1.7.10.4


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

* [PATCHv2 3/3] pwm: set the actual number of pwms arguments defined in board dts
@ 2014-10-13 14:21     ` Vladimir Zapolskiy
  0 siblings, 0 replies; 20+ messages in thread
From: Vladimir Zapolskiy @ 2014-10-13 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

For backward compatibility board device tree has to define only a
minimal amount of mandatory pwms arguments, which is specified by a
driver. Additional arguments shall be considered as optional, update
pc->of_pwm_n_cells according to the actual data taken from device tree
file.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Lothar Wa?mann <LW@KARO-electronics.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
Changes from v1 to v2:
- rebased on top of modified patch v2 2/3

 drivers/pwm/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index f6231c6..4d9fc7f 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -543,12 +543,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
 		goto put;
 	}
 
-	if (args.args_count != pc->of_pwm_n_cells) {
+	if (args.args_count < pc->of_pwm_n_cells) {
 		pr_err("%s: wrong #pwm-cells for %s\n", np->full_name,
 			 args.np->full_name);
 		pwm = ERR_PTR(-EINVAL);
 		goto put;
 	}
+	pc->of_pwm_n_cells = args.args_count;
 
 	pwm = pc->of_xlate(pc, &args);
 	if (IS_ERR(pwm))
-- 
1.7.10.4

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

end of thread, other threads:[~2014-10-13 14:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-10 15:50 [PATCH 0/3] pwm: support backward compatibility of DTB extending PWM args Vladimir Zapolskiy
2014-10-10 15:50 ` Vladimir Zapolskiy
2014-10-10 15:50 ` [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate() Vladimir Zapolskiy
2014-10-10 15:50   ` Vladimir Zapolskiy
2014-10-10 15:50 ` [PATCH 2/3] pwm: push up dynamic printk level on errors in of_pwm_get() Vladimir Zapolskiy
2014-10-10 15:50   ` Vladimir Zapolskiy
2014-10-13  6:12   ` Lothar Waßmann
2014-10-13  6:12     ` Lothar Waßmann
2014-10-10 15:50 ` [PATCH 3/3] pwm: set the actual number of pwms arguments defined in board dts Vladimir Zapolskiy
2014-10-10 15:50   ` Vladimir Zapolskiy
2014-10-13 14:21 ` [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get() Vladimir Zapolskiy
2014-10-13 14:21   ` Vladimir Zapolskiy
2014-10-13 14:21   ` [PATCHv2 0/3] pwm: support backward compatibility of DTB extending PWM args Vladimir Zapolskiy
2014-10-13 14:21     ` Vladimir Zapolskiy
2014-10-13 14:21   ` [PATCH 1/3] pwm: process pwm polarity argument in of_pwm_simple_xlate() Vladimir Zapolskiy
2014-10-13 14:21     ` Vladimir Zapolskiy
2014-10-13 14:21   ` [PATCHv2 2/3] pwm: push up dynamic printk level on errors in of_pwm_get() Vladimir Zapolskiy
2014-10-13 14:21     ` Vladimir Zapolskiy
2014-10-13 14:21   ` [PATCHv2 3/3] pwm: set the actual number of pwms arguments defined in board dts Vladimir Zapolskiy
2014-10-13 14:21     ` Vladimir Zapolskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.