Skip to contentSkip to conversation

pwm: brcmstb: Don't set can_sleep flag

PATCH Superseded Axel Lin 3 participants 5 messages Nov 3, 2015 – Nov 4, 2015

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 pwm: brcmstb: Don't set can_sleep flag

The .can_sleep flag is used for some PWM controllers that can't be used in atomic context. Not such case for this driver, so don't set the can_sleep flag.

---
 drivers/pwm/pwm-brcmstb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pwm/pwm-brcmstb.c +0 -1
index 423ce08..f58039b 100644
@@ -270,7 +270,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 	p->chip.ops = &brcmstb_pwm_ops;
 	p->chip.base = -1;
 	p->chip.npwm = 2;
-	p->chip.can_sleep = true;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->base = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Axel Lin

The .can_sleep flag is used for some PWM controllers that can't be used in atomic context. Not such case for this driver, so don't set the can_sleep flag.

Thanks!

Quoted 17 lines
---
 drivers/pwm/pwm-brcmstb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pwm/pwm-brcmstb.c +0 -1
index 423ce08..f58039b 100644
@@ -270,7 +270,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 	p->chip.ops = &brcmstb_pwm_ops;
 	p->chip.base = -1;
 	p->chip.npwm = 2;
-	p->chip.can_sleep = true;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->base = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
Florian
Reviewed-by on v1 1/1
#2 lore raw
In reply to Axel Lin
Quoted 5 lines · Axel Lin

The .can_sleep flag is used for some PWM controllers that can't be used in atomic context. Not such case for this driver, so don't set the can_sleep flag.

Looks sane to me, though I've never touched this driver.

BTW just a comment from an outsider here, the "can sleep" terminology seems a bit misleading here. Just IMO of course, but saying something "can sleep" sounds like a permissive statement, when actually it's a restrictive statement being made by the driver (which is in this case unnecessarily restrictive). The "might sleep" terminology used in one other place would (again IMO) better communicate what I think is intended here.

Though this problem is most likely result of mindless copy-and-paste, it's possible that the terminology made it easier to gloss over. Or I could just be blowing smoke.

Regards,
Brian

Quoted 21 lines
---
 drivers/pwm/pwm-brcmstb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pwm/pwm-brcmstb.c +0 -1
index 423ce08..f58039b 100644
@@ -270,7 +270,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 	p->chip.ops = &brcmstb_pwm_ops;
 	p->chip.base = -1;
 	p->chip.npwm = 2;
-	p->chip.can_sleep = true;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->base = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
2.1.4
#3 lore raw
Quoted 19 lines · Brian Norris
Quoted 5 lines · Axel Lin

The .can_sleep flag is used for some PWM controllers that can't be used in atomic context. Not such case for this driver, so don't set the can_sleep flag.

Looks sane to me, though I've never touched this driver.

BTW just a comment from an outsider here, the "can sleep" terminology seems a bit misleading here. Just IMO of course, but saying something "can sleep" sounds like a permissive statement, when actually it's a restrictive statement being made by the driver (which is in this case unnecessarily restrictive). The "might sleep" terminology used in one other place would (again IMO) better communicate what I think is intended here.

Quoted 3 lines

Though this problem is most likely result of mindless copy-and-paste, it's possible that the terminology made it easier to gloss over. Or I could just be blowing smoke.

Well, in this particular case, I have to admit this was copy and paste which resulted in setting can_sleep initially.

Now, I do agree that the terminology is a little confusing here. If you look at the GPIO API there are gpio_*_cansleep() accessors, which in their case, convey the correct meaning: the operation can/might sleep.

Should we prepare a coccinelle script which fixes that at least for the PWM subsystem?

Signature · 1 line
Florian
#4 lore raw
Quoted 3 lines · Florian Fainelli

Now, I do agree that the terminology is a little confusing here. If you look at the GPIO API there are gpio_*_cansleep() accessors, which in their case, convey the correct meaning: the operation can/might sleep.

Perhaps I'm misreading, but that actually sounds exactly the same as the pwm_can_sleep() API. It sounds OK from a consumer/API perspective, but I was just commenting on the perspective of the driver writer.

Maybe it's not worth much change, then, if several subsystems have similar naming.

Brian