flash/nor: consolidate flash protect/protect_check
[fw/openocd] / src / flash / nor / core.c
index 49412816c3a2449bae3beba33e508e9d1b4b9571..0aaa7d26f0b5e58c9f09a7f12f592dfb745ce24a 100644 (file)
@@ -68,6 +68,11 @@ int flash_driver_protect(struct flash_bank *bank, int set, int first, int last)
        /* force "set" to 0/1 */
        set = !!set;
 
+       if (bank->driver->protect == NULL) {
+               LOG_ERROR("Flash protection is not supported.");
+               return ERROR_FLASH_OPER_UNSUPPORTED;
+       }
+
        /* DANGER!
         *
         * We must not use any cached information about protection state!!!!