It can be a pain with negative numbers and looping back the number (so it goes up but goes back to 0 while still going up, etc).
To get around this, recently I dodged up a solution which uses colliders. Basically you have a roof and floor collider above and below the turret, and so when the turret bumps in to it, you then 'disconnect' the action which controls the movement. So for example your barrel moves up, touches the roof, then your FSM goes from a state which allows you to use input to move up and down, to one that only allows input to move down.
Works smoothly on a FPS character I made.