[PATCH v2 3/4] Refactor kernel image and initrd detection code