A South Yorkshire mental health hospital has been moved out of special measures following an inspection, a watchdog said.