Hi,
As CMOS has told if you make a combined read/write function, you may not need a separate routine for read and write. The software can always send a dummy code while only reading the data and it can as well neglect the returned value when only writing.
But in the code given by CMOS, it is necessary to add shift of retval and also picking up of the MISO bit has to be done when the clock is high. Your original code is perfect from that point of view. But you need to keep MISO pin high even while sending since the output from slave will be always there whether you want it or not. If you are only interested in writing, it is also not necessary that you have to read the MISO pin.
Regards,
Laktronics