'Major win' for mentally ill prisoners