All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] pwm: bcm2835: improve clock handling
@ 2015-12-01 22:55 ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: Thierry Reding, Stephen Warren, Lee Jones, Eric Anholt
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel,
	Stefan Wahren

With the upcoming PWM clock support the pwm-bcm2835 should take
more care about the clock handling. But this patch series doesn't
depend on these clock driver changes.

Stefan Wahren (3):
  pwm: bcm2835: calculate scaler in pwm_config
  pwm: bcm2835: prevent division by zero
  pwm: bcm2835: fix email address specifiction

 drivers/pwm/pwm-bcm2835.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

-- 
1.7.9.5

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

* [PATCH 0/3] pwm: bcm2835: improve clock handling
@ 2015-12-01 22:55 ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: linux-arm-kernel

With the upcoming PWM clock support the pwm-bcm2835 should take
more care about the clock handling. But this patch series doesn't
depend on these clock driver changes.

Stefan Wahren (3):
  pwm: bcm2835: calculate scaler in pwm_config
  pwm: bcm2835: prevent division by zero
  pwm: bcm2835: fix email address specifiction

 drivers/pwm/pwm-bcm2835.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

-- 
1.7.9.5

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

* [PATCH 1/3] pwm: bcm2835: calculate scaler in pwm_config
  2015-12-01 22:55 ` Stefan Wahren
@ 2015-12-01 22:55   ` Stefan Wahren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: Thierry Reding, Stephen Warren, Lee Jones, Eric Anholt
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel,
	Stefan Wahren

Currently pwm-bcm2835 assumes a fixed clock rate and stores the
resulting scaler in the driver structure. But with the upcoming
PWM clock support for clk-bcm2835 the rate could change.
So calculate the scaler in pwm_config.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index b4c7f95..174cca9 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -29,7 +29,6 @@
 struct bcm2835_pwm {
 	struct pwm_chip chip;
 	struct device *dev;
-	unsigned long scaler;
 	void __iomem *base;
 	struct clk *clk;
 };
@@ -66,6 +65,7 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			      int duty_ns, int period_ns)
 {
 	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
+	unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
 
 	if (period_ns <= MIN_PERIOD) {
 		dev_err(pc->dev, "period %d not supported, minimum %d\n",
@@ -73,8 +73,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 		return -EINVAL;
 	}
 
-	writel(duty_ns / pc->scaler, pc->base + DUTY(pwm->hwpwm));
-	writel(period_ns / pc->scaler, pc->base + PERIOD(pwm->hwpwm));
+	writel(duty_ns / scaler, pc->base + DUTY(pwm->hwpwm));
+	writel(period_ns / scaler, pc->base + PERIOD(pwm->hwpwm));
 
 	return 0;
 }
@@ -156,8 +156,6 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	pc->scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
-
 	pc->chip.dev = &pdev->dev;
 	pc->chip.ops = &bcm2835_pwm_ops;
 	pc->chip.npwm = 2;
-- 
1.7.9.5

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

* [PATCH 1/3] pwm: bcm2835: calculate scaler in pwm_config
@ 2015-12-01 22:55   ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: linux-arm-kernel

Currently pwm-bcm2835 assumes a fixed clock rate and stores the
resulting scaler in the driver structure. But with the upcoming
PWM clock support for clk-bcm2835 the rate could change.
So calculate the scaler in pwm_config.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index b4c7f95..174cca9 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -29,7 +29,6 @@
 struct bcm2835_pwm {
 	struct pwm_chip chip;
 	struct device *dev;
-	unsigned long scaler;
 	void __iomem *base;
 	struct clk *clk;
 };
@@ -66,6 +65,7 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			      int duty_ns, int period_ns)
 {
 	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
+	unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
 
 	if (period_ns <= MIN_PERIOD) {
 		dev_err(pc->dev, "period %d not supported, minimum %d\n",
@@ -73,8 +73,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 		return -EINVAL;
 	}
 
-	writel(duty_ns / pc->scaler, pc->base + DUTY(pwm->hwpwm));
-	writel(period_ns / pc->scaler, pc->base + PERIOD(pwm->hwpwm));
+	writel(duty_ns / scaler, pc->base + DUTY(pwm->hwpwm));
+	writel(period_ns / scaler, pc->base + PERIOD(pwm->hwpwm));
 
 	return 0;
 }
@@ -156,8 +156,6 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	pc->scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
-
 	pc->chip.dev = &pdev->dev;
 	pc->chip.ops = &bcm2835_pwm_ops;
 	pc->chip.npwm = 2;
-- 
1.7.9.5

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-01 22:55 ` Stefan Wahren
@ 2015-12-01 22:55   ` Stefan Wahren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: Thierry Reding, Stephen Warren, Lee Jones, Eric Anholt
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel,
	Stefan Wahren

It's possible that the pwm clock become an orphan. So better
check the result of clk_get_rate in order to prevent a division
by zero.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 174cca9..31a6992 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			      int duty_ns, int period_ns)
 {
 	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
-	unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
+	unsigned long rate = clk_get_rate(pc->clk);
+	unsigned long scaler;
+
+	if (!rate) {
+		dev_err(pc->dev, "failed to get clock rate\n");
+		return -EINVAL;
+	}
+
+	scaler = NSEC_PER_SEC / rate;
 
 	if (period_ns <= MIN_PERIOD) {
 		dev_err(pc->dev, "period %d not supported, minimum %d\n",
-- 
1.7.9.5

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-01 22:55   ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: linux-arm-kernel

It's possible that the pwm clock become an orphan. So better
check the result of clk_get_rate in order to prevent a division
by zero.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 174cca9..31a6992 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			      int duty_ns, int period_ns)
 {
 	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
-	unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
+	unsigned long rate = clk_get_rate(pc->clk);
+	unsigned long scaler;
+
+	if (!rate) {
+		dev_err(pc->dev, "failed to get clock rate\n");
+		return -EINVAL;
+	}
+
+	scaler = NSEC_PER_SEC / rate;
 
 	if (period_ns <= MIN_PERIOD) {
 		dev_err(pc->dev, "period %d not supported, minimum %d\n",
-- 
1.7.9.5

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

* [PATCH 3/3] pwm: bcm2835: fix email address specifiction
  2015-12-01 22:55 ` Stefan Wahren
@ 2015-12-01 22:55   ` Stefan Wahren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: Thierry Reding, Stephen Warren, Lee Jones, Eric Anholt
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel,
	Stefan Wahren

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 31a6992..c5dbf16 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -206,6 +206,6 @@ static struct platform_driver bcm2835_pwm_driver = {
 };
 module_platform_driver(bcm2835_pwm_driver);
 
-MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be");
+MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be>");
 MODULE_DESCRIPTION("Broadcom BCM2835 PWM driver");
 MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

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

* [PATCH 3/3] pwm: bcm2835: fix email address specifiction
@ 2015-12-01 22:55   ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-01 22:55 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pwm/pwm-bcm2835.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 31a6992..c5dbf16 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -206,6 +206,6 @@ static struct platform_driver bcm2835_pwm_driver = {
 };
 module_platform_driver(bcm2835_pwm_driver);
 
-MODULE_AUTHOR("Bart Tanghe <bart.tanghe at thomasmore.be");
+MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be>");
 MODULE_DESCRIPTION("Broadcom BCM2835 PWM driver");
 MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

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

* Re: [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-01 22:55   ` Stefan Wahren
@ 2015-12-01 23:16     ` Eric Anholt
  -1 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-01 23:16 UTC (permalink / raw)
  To: Thierry Reding, Stephen Warren, Lee Jones
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel,
	Stefan Wahren

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

> It's possible that the pwm clock become an orphan. So better
> check the result of clk_get_rate in order to prevent a division
> by zero.

How would we lose our clock when we're keeping the clock enabled from
driver probe until remove?

Patches 1 and 3 are:

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-01 23:16     ` Eric Anholt
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-01 23:16 UTC (permalink / raw)
  To: linux-arm-kernel

Stefan Wahren <stefan.wahren@i2se.com> writes:

> It's possible that the pwm clock become an orphan. So better
> check the result of clk_get_rate in order to prevent a division
> by zero.

How would we lose our clock when we're keeping the clock enabled from
driver probe until remove?

Patches 1 and 3 are:

Reviewed-by: Eric Anholt <eric@anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151201/646cc66d/attachment.sig>

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

* Re: [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-01 22:55   ` Stefan Wahren
@ 2015-12-02 15:23     ` Mathieu Poirier
  -1 siblings, 0 replies; 24+ messages in thread
From: Mathieu Poirier @ 2015-12-02 15:23 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Thierry Reding, Stephen Warren, Lee Jones, Eric Anholt, linux-pwm,
	Remi Pommarel, linux-rpi-kernel,
	linux-arm-kernel@lists.infradead.org

On 1 December 2015 at 15:55, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> It's possible that the pwm clock become an orphan. So better
> check the result of clk_get_rate in order to prevent a division
> by zero.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> index 174cca9..31a6992 100644
> --- a/drivers/pwm/pwm-bcm2835.c
> +++ b/drivers/pwm/pwm-bcm2835.c
> @@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>                               int duty_ns, int period_ns)
>  {
>         struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> -       unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
> +       unsigned long rate = clk_get_rate(pc->clk);
> +       unsigned long scaler;
> +
> +       if (!rate) {
> +               dev_err(pc->dev, "failed to get clock rate\n");
> +               return -EINVAL;
> +       }
> +
> +       scaler = NSEC_PER_SEC / rate;

Stefan,

Please merge this code into patch 1/3.  That way it is done the right
way the first time around.

Thanks,
Mathieu

>
>         if (period_ns <= MIN_PERIOD) {
>                 dev_err(pc->dev, "period %d not supported, minimum %d\n",
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-02 15:23     ` Mathieu Poirier
  0 siblings, 0 replies; 24+ messages in thread
From: Mathieu Poirier @ 2015-12-02 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 1 December 2015 at 15:55, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> It's possible that the pwm clock become an orphan. So better
> check the result of clk_get_rate in order to prevent a division
> by zero.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> index 174cca9..31a6992 100644
> --- a/drivers/pwm/pwm-bcm2835.c
> +++ b/drivers/pwm/pwm-bcm2835.c
> @@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>                               int duty_ns, int period_ns)
>  {
>         struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> -       unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
> +       unsigned long rate = clk_get_rate(pc->clk);
> +       unsigned long scaler;
> +
> +       if (!rate) {
> +               dev_err(pc->dev, "failed to get clock rate\n");
> +               return -EINVAL;
> +       }
> +
> +       scaler = NSEC_PER_SEC / rate;

Stefan,

Please merge this code into patch 1/3.  That way it is done the right
way the first time around.

Thanks,
Mathieu

>
>         if (period_ns <= MIN_PERIOD) {
>                 dev_err(pc->dev, "period %d not supported, minimum %d\n",
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-01 23:16     ` Eric Anholt
@ 2015-12-02 17:08       ` Stefan Wahren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-02 17:08 UTC (permalink / raw)
  To: Eric Anholt, Thierry Reding, Stephen Warren, Lee Jones
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel

Am 02.12.2015 um 00:16 schrieb Eric Anholt:
> Stefan Wahren <stefan.wahren@i2se.com> writes:
>
>> It's possible that the pwm clock become an orphan. So better
>> check the result of clk_get_rate in order to prevent a division
>> by zero.
> How would we lose our clock when we're keeping the clock enabled from
> driver probe until remove?

It's not the problem that we lose the clock inside this driver. The pwm
clock could be initial assigned to a unregistered parent clock like "GND".

I'm refering to this discussion:

http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-November/002603.html

>
> Patches 1 and 3 are:
>
> Reviewed-by: Eric Anholt <eric@anholt.net>

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-02 17:08       ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-02 17:08 UTC (permalink / raw)
  To: linux-arm-kernel

Am 02.12.2015 um 00:16 schrieb Eric Anholt:
> Stefan Wahren <stefan.wahren@i2se.com> writes:
>
>> It's possible that the pwm clock become an orphan. So better
>> check the result of clk_get_rate in order to prevent a division
>> by zero.
> How would we lose our clock when we're keeping the clock enabled from
> driver probe until remove?

It's not the problem that we lose the clock inside this driver. The pwm
clock could be initial assigned to a unregistered parent clock like "GND".

I'm refering to this discussion:

http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-November/002603.html

>
> Patches 1 and 3 are:
>
> Reviewed-by: Eric Anholt <eric@anholt.net>

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

* Re: [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-02 15:23     ` Mathieu Poirier
@ 2015-12-02 19:41       ` Eric Anholt
  -1 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-02 19:41 UTC (permalink / raw)
  To: Mathieu Poirier, Stefan Wahren
  Cc: Thierry Reding, Stephen Warren, Lee Jones, linux-pwm,
	Remi Pommarel, linux-rpi-kernel,
	linux-arm-kernel@lists.infradead.org

[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]

Mathieu Poirier <mathieu.poirier@linaro.org> writes:

> On 1 December 2015 at 15:55, Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> It's possible that the pwm clock become an orphan. So better
>> check the result of clk_get_rate in order to prevent a division
>> by zero.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>  drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
>> index 174cca9..31a6992 100644
>> --- a/drivers/pwm/pwm-bcm2835.c
>> +++ b/drivers/pwm/pwm-bcm2835.c
>> @@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>>                               int duty_ns, int period_ns)
>>  {
>>         struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
>> -       unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
>> +       unsigned long rate = clk_get_rate(pc->clk);
>> +       unsigned long scaler;
>> +
>> +       if (!rate) {
>> +               dev_err(pc->dev, "failed to get clock rate\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       scaler = NSEC_PER_SEC / rate;
>
> Stefan,
>
> Please merge this code into patch 1/3.  That way it is done the right
> way the first time around.

They're separate changes and are good as separate patches.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-02 19:41       ` Eric Anholt
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-02 19:41 UTC (permalink / raw)
  To: linux-arm-kernel

Mathieu Poirier <mathieu.poirier@linaro.org> writes:

> On 1 December 2015 at 15:55, Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> It's possible that the pwm clock become an orphan. So better
>> check the result of clk_get_rate in order to prevent a division
>> by zero.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>  drivers/pwm/pwm-bcm2835.c |   10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
>> index 174cca9..31a6992 100644
>> --- a/drivers/pwm/pwm-bcm2835.c
>> +++ b/drivers/pwm/pwm-bcm2835.c
>> @@ -65,7 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>>                               int duty_ns, int period_ns)
>>  {
>>         struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
>> -       unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
>> +       unsigned long rate = clk_get_rate(pc->clk);
>> +       unsigned long scaler;
>> +
>> +       if (!rate) {
>> +               dev_err(pc->dev, "failed to get clock rate\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       scaler = NSEC_PER_SEC / rate;
>
> Stefan,
>
> Please merge this code into patch 1/3.  That way it is done the right
> way the first time around.

They're separate changes and are good as separate patches.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151202/f419b922/attachment-0001.sig>

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

* Re: [PATCH 2/3] pwm: bcm2835: prevent division by zero
  2015-12-02 17:08       ` Stefan Wahren
@ 2015-12-02 19:43         ` Eric Anholt
  -1 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-02 19:43 UTC (permalink / raw)
  To: Stefan Wahren, Thierry Reding, Stephen Warren, Lee Jones
  Cc: Remi Pommarel, linux-pwm, linux-arm-kernel, linux-rpi-kernel

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

> Am 02.12.2015 um 00:16 schrieb Eric Anholt:
>> Stefan Wahren <stefan.wahren@i2se.com> writes:
>>
>>> It's possible that the pwm clock become an orphan. So better
>>> check the result of clk_get_rate in order to prevent a division
>>> by zero.
>> How would we lose our clock when we're keeping the clock enabled from
>> driver probe until remove?
>
> It's not the problem that we lose the clock inside this driver. The pwm
> clock could be initial assigned to a unregistered parent clock like "GND".
>
> I'm refering to this discussion:
>
> http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-November/002603.html

I actually would have expected that the prepare would error out on a
clock with no rate set.  Interesting.  This seems like a good safety
measure, so this one is also:

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* [PATCH 2/3] pwm: bcm2835: prevent division by zero
@ 2015-12-02 19:43         ` Eric Anholt
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-02 19:43 UTC (permalink / raw)
  To: linux-arm-kernel

Stefan Wahren <stefan.wahren@i2se.com> writes:

> Am 02.12.2015 um 00:16 schrieb Eric Anholt:
>> Stefan Wahren <stefan.wahren@i2se.com> writes:
>>
>>> It's possible that the pwm clock become an orphan. So better
>>> check the result of clk_get_rate in order to prevent a division
>>> by zero.
>> How would we lose our clock when we're keeping the clock enabled from
>> driver probe until remove?
>
> It's not the problem that we lose the clock inside this driver. The pwm
> clock could be initial assigned to a unregistered parent clock like "GND".
>
> I'm refering to this discussion:
>
> http://lists.infradead.org/pipermail/linux-rpi-kernel/2015-November/002603.html

I actually would have expected that the prepare would error out on a
clock with no rate set.  Interesting.  This seems like a good safety
measure, so this one is also:

Reviewed-by: Eric Anholt <eric@anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151202/dd15c55a/attachment.sig>

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

* Re: [PATCH 0/3] pwm: bcm2835: improve clock handling
  2015-12-01 22:55 ` Stefan Wahren
@ 2015-12-15 17:59   ` Stefan Wahren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-15 17:59 UTC (permalink / raw)
  To: Lee Jones, Eric Anholt, Thierry Reding, Stephen Warren
  Cc: linux-pwm, linux-rpi-kernel, linux-arm-kernel, Remi Pommarel


> Stefan Wahren <stefan.wahren@i2se.com> hat am 1. Dezember 2015 um 23:55
> geschrieben:
>
>
> With the upcoming PWM clock support the pwm-bcm2835 should take
> more care about the clock handling. But this patch series doesn't
> depend on these clock driver changes.
>
> Stefan Wahren (3):
> pwm: bcm2835: calculate scaler in pwm_config
> pwm: bcm2835: prevent division by zero
> pwm: bcm2835: fix email address specifiction
>
> drivers/pwm/pwm-bcm2835.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>

gently ping

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

* [PATCH 0/3] pwm: bcm2835: improve clock handling
@ 2015-12-15 17:59   ` Stefan Wahren
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Wahren @ 2015-12-15 17:59 UTC (permalink / raw)
  To: linux-arm-kernel


> Stefan Wahren <stefan.wahren@i2se.com> hat am 1. Dezember 2015 um 23:55
> geschrieben:
>
>
> With the upcoming PWM clock support the pwm-bcm2835 should take
> more care about the clock handling. But this patch series doesn't
> depend on these clock driver changes.
>
> Stefan Wahren (3):
> pwm: bcm2835: calculate scaler in pwm_config
> pwm: bcm2835: prevent division by zero
> pwm: bcm2835: fix email address specifiction
>
> drivers/pwm/pwm-bcm2835.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>

gently ping

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

* Re: [PATCH 0/3] pwm: bcm2835: improve clock handling
  2015-12-15 17:59   ` Stefan Wahren
@ 2015-12-15 18:24     ` Eric Anholt
  -1 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-15 18:24 UTC (permalink / raw)
  To: Stefan Wahren, Lee Jones, Thierry Reding, Stephen Warren
  Cc: linux-pwm, linux-rpi-kernel, linux-arm-kernel, Remi Pommarel

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

>> Stefan Wahren <stefan.wahren@i2se.com> hat am 1. Dezember 2015 um 23:55
>> geschrieben:
>>
>>
>> With the upcoming PWM clock support the pwm-bcm2835 should take
>> more care about the clock handling. But this patch series doesn't
>> depend on these clock driver changes.
>>
>> Stefan Wahren (3):
>> pwm: bcm2835: calculate scaler in pwm_config
>> pwm: bcm2835: prevent division by zero
>> pwm: bcm2835: fix email address specifiction
>>
>> drivers/pwm/pwm-bcm2835.c | 18 ++++++++++++------
>> 1 file changed, 12 insertions(+), 6 deletions(-)
>>
>
> gently ping

Thierry, do you want to fold in my r-bs and apply, or should Stefan
resend with them?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

* [PATCH 0/3] pwm: bcm2835: improve clock handling
@ 2015-12-15 18:24     ` Eric Anholt
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Anholt @ 2015-12-15 18:24 UTC (permalink / raw)
  To: linux-arm-kernel

Stefan Wahren <stefan.wahren@i2se.com> writes:

>> Stefan Wahren <stefan.wahren@i2se.com> hat am 1. Dezember 2015 um 23:55
>> geschrieben:
>>
>>
>> With the upcoming PWM clock support the pwm-bcm2835 should take
>> more care about the clock handling. But this patch series doesn't
>> depend on these clock driver changes.
>>
>> Stefan Wahren (3):
>> pwm: bcm2835: calculate scaler in pwm_config
>> pwm: bcm2835: prevent division by zero
>> pwm: bcm2835: fix email address specifiction
>>
>> drivers/pwm/pwm-bcm2835.c | 18 ++++++++++++------
>> 1 file changed, 12 insertions(+), 6 deletions(-)
>>
>
> gently ping

Thierry, do you want to fold in my r-bs and apply, or should Stefan
resend with them?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151215/b74ba940/attachment-0001.sig>

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

* Re: [PATCH 0/3] pwm: bcm2835: improve clock handling
  2015-12-01 22:55 ` Stefan Wahren
@ 2015-12-16 15:38   ` Thierry Reding
  -1 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-12-16 15:38 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Stephen Warren, Lee Jones, Eric Anholt, Remi Pommarel, linux-pwm,
	linux-arm-kernel, linux-rpi-kernel

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

On Tue, Dec 01, 2015 at 10:55:38PM +0000, Stefan Wahren wrote:
> With the upcoming PWM clock support the pwm-bcm2835 should take
> more care about the clock handling. But this patch series doesn't
> depend on these clock driver changes.
> 
> Stefan Wahren (3):
>   pwm: bcm2835: calculate scaler in pwm_config
>   pwm: bcm2835: prevent division by zero
>   pwm: bcm2835: fix email address specifiction
> 
>  drivers/pwm/pwm-bcm2835.c |   18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)

All three patches applied with Eric's Reviewed-by, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 0/3] pwm: bcm2835: improve clock handling
@ 2015-12-16 15:38   ` Thierry Reding
  0 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-12-16 15:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 01, 2015 at 10:55:38PM +0000, Stefan Wahren wrote:
> With the upcoming PWM clock support the pwm-bcm2835 should take
> more care about the clock handling. But this patch series doesn't
> depend on these clock driver changes.
> 
> Stefan Wahren (3):
>   pwm: bcm2835: calculate scaler in pwm_config
>   pwm: bcm2835: prevent division by zero
>   pwm: bcm2835: fix email address specifiction
> 
>  drivers/pwm/pwm-bcm2835.c |   18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)

All three patches applied with Eric's Reviewed-by, thanks.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151216/973a08fa/attachment-0001.sig>

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

end of thread, other threads:[~2015-12-16 15:38 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 22:55 [PATCH 0/3] pwm: bcm2835: improve clock handling Stefan Wahren
2015-12-01 22:55 ` Stefan Wahren
2015-12-01 22:55 ` [PATCH 1/3] pwm: bcm2835: calculate scaler in pwm_config Stefan Wahren
2015-12-01 22:55   ` Stefan Wahren
2015-12-01 22:55 ` [PATCH 2/3] pwm: bcm2835: prevent division by zero Stefan Wahren
2015-12-01 22:55   ` Stefan Wahren
2015-12-01 23:16   ` Eric Anholt
2015-12-01 23:16     ` Eric Anholt
2015-12-02 17:08     ` Stefan Wahren
2015-12-02 17:08       ` Stefan Wahren
2015-12-02 19:43       ` Eric Anholt
2015-12-02 19:43         ` Eric Anholt
2015-12-02 15:23   ` Mathieu Poirier
2015-12-02 15:23     ` Mathieu Poirier
2015-12-02 19:41     ` Eric Anholt
2015-12-02 19:41       ` Eric Anholt
2015-12-01 22:55 ` [PATCH 3/3] pwm: bcm2835: fix email address specifiction Stefan Wahren
2015-12-01 22:55   ` Stefan Wahren
2015-12-15 17:59 ` [PATCH 0/3] pwm: bcm2835: improve clock handling Stefan Wahren
2015-12-15 17:59   ` Stefan Wahren
2015-12-15 18:24   ` Eric Anholt
2015-12-15 18:24     ` Eric Anholt
2015-12-16 15:38 ` Thierry Reding
2015-12-16 15:38   ` Thierry Reding

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.