Thanks, Brian - that all looks very useful to make the pi more amenable to hardware tinkering.
One small suggested amendment: your spiclock() says this - /* * According the Broadcom docs, the divisor has to * be a power of 2. This code rounds up so that the * resulting clock is the highest value no greater than * what's requested. */ but http://raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md has an erratum suggesting "power of 2" should be "multiple of 2". I have been using a default divisor of 250 for a 1MHz clock, and that's the frequency I see on my oscilloscope.