Magnetic reversals of Jupiter and Saturn