It depends what type of workout you're looking for. If I want to do anaerobic work I do short hill repeats up a steep hill about 1:30 to 2:00 up and whatever rest I need. VO2Max intervals (3-5min) also work well on hills.
If you have a 40 minute hill and ride it at your FTP or threshold that's a good workout. Most find it easier to do that type of work on a hill but the flats work just as well if you're sufficiently motivated.