Reversible DC motor with H-bridge and PWM.

I have DC motor controlled by H-bridge and two outputs. I am using digital outputs so motor controlled with full voltage range. It works fine, but I would like to migrate to use PWM to be able to control rotation speed.

I did now with this logic:
If motor stops: both outpups set PWM to sero.
If motor rotates: one output (depends on direction) sets PWM to zero, the other one with desired PWM to rotate.

Seems like it is also working, but in some code samples (in TI products, not really Arduino related) I saw the other logic: instead of setting PWM to zero, they are switching pin mode back do digital output and set it to logical "LOW".

Is it not the same?

How should I properly control these two outputs with PWM?
What is the "Coasting mode" in this context?

Yes its the same. analogWrite (pin, 0) simply calls digitalWrite (pin, false)

Coasting mode with a motor driver is when the motor terminals are carrying no current because at least
one of the terminals is not switched to anything. This means no torque to the motor.

For DC motors voltage == speed, current == torque, roughly speaking.