Skip to contentSkip to conversation

pwm: pwm-meson: remove not needed check in meson_pwm_calc

PATCH In review Heiner Kallweit 3 participants 4 messages May 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: pwm-meson: remove not needed check in meson_pwm_calc

duty <= period implies that duty_cnt <= cnt. We verified before that cnt <= 0xffff, therefore we can omit the check here.

---
Note: Applies only after "pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX"

---
 drivers/pwm/pwm-meson.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/pwm/pwm-meson.c +0 -5
index 33107204a..aad4a0ed3 100644
@@ -204,12 +204,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
 		channel->hi = 0;
 		channel->lo = cnt;
 	} else {
-		/* Then check is we can have the duty with the same pre_div */
 		duty_cnt = div64_u64(fin_freq * duty, NSEC_PER_SEC * (pre_div + 1));
-		if (duty_cnt > 0xffff) {
-			dev_err(meson->chip.dev, "unable to get duty cycle\n");
-			return -EINVAL;
-		}
 
 		dev_dbg(meson->chip.dev, "duty=%llu pre_div=%u duty_cnt=%u\n",
 			duty, pre_div, duty_cnt);
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw

Hello Heiner,

Quoted 7 lines · Heiner Kallweit

duty <= period implies that duty_cnt <= cnt. We verified before that cnt <= 0xffff, therefore we can omit the check here.

---
Note: Applies only after "pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX"

Do you know there is git magic to express this that (at least some of) the build bots understand? Look at git format-patch's --base option.

Otherwise:

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw
Quoted 6 lines · Uwe Kleine-König

Hello Heiner,

Quoted 3 lines · Heiner Kallweit

duty <= period implies that duty_cnt <= cnt. We verified before that cnt <= 0xffff, therefore we can omit the check here.

Quoted 7 lines
Quoted 4 lines

---
Note: Applies only after "pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX"

Do you know there is git magic to express this that (at least some of) the build bots understand? Look at git format-patch's --base option.

I think --base is really only applicable if the base patch is applied to a well-known tree, otherwise the commit is unknown.

For things like this it's easier to just send them out as a series, which implies the dependency. Obviously sometimes you get situations where you send out a patch and only then realize there's cleanup you can do, so mentioning this is usually enough. Most bots will end up building this after I apply as well, so we'll get the coverage either way.

Thierry

#3 lore raw

Hello Thierry,

Quoted 10 lines · Thierry Reding
Quoted 9 lines · Uwe Kleine-König
Quoted 7 lines · Heiner Kallweit

duty <= period implies that duty_cnt <= cnt. We verified before that cnt <= 0xffff, therefore we can omit the check here.

---
Note: Applies only after "pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX"

Quoted 5 lines
Quoted 2 lines

Do you know there is git magic to express this that (at least some of) the build bots understand? Look at git format-patch's --base option.

I think --base is really only applicable if the base patch is applied to a well-known tree, otherwise the commit is unknown.

Yes, "base" should be something like v6.3. On a tree that has the patch under discussion applied on top of "pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX" on top of v6.3,

	git format-patch --base v6.3 -1

results in the footers:

	base-commit: 457391b0380335d5e9a5babdec90ac53928b23b4
	prerequisite-patch-id: 76d61171becf4a80716637610b6f33d9617eb9b9

Where 457391b0380335d5e9a5babdec90ac53928b23b4 is v6.3 and 76d61171becf4a80716637610b6f33d9617eb9b9 is the patch-id[1] of the UINT_MAX patch. While this doesn't replace some human readable hints, this is the machine-parsable information that this patch is supposed to be applied on top of that UINT patch. This doesn't help finding that patch, but at least it stops reports about broken stuff in v6.3 + this patch without the prerequisite patch. So if used in the right way, this is helpful also in Heiner's case here.

Best regards
Uwe

[1] git show @^{/"pwm: pwm-meson: fix handling of period/duty if greater than UINT_MAX"} | git patch-id

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |