Proper NAND detection code from current Linux