return -1;
        }
 
-       if (flash->flash_is_locked(flash, offset, len) > 0) {
-               printf("offset 0x%x is protected and cannot be erased\n", offset);
-               return -EINVAL;
+       if (flash->flash_is_locked) {
+               if (flash->flash_is_locked(flash, offset, len) > 0) {
+                       printf("offset 0x%x is protected and cannot be erased\n",
+                              offset);
+                       return -EINVAL;
+               }
        }
 
        cmd[0] = flash->erase_cmd;
 
        page_size = flash->page_size;
 
-       if (flash->flash_is_locked(flash, offset, len) > 0) {
-               printf("offset 0x%x is protected and cannot be written\n", offset);
-               return -EINVAL;
+       if (flash->flash_is_locked) {
+               if (flash->flash_is_locked(flash, offset, len) > 0) {
+                       printf("offset 0x%x is protected and cannot be written\n",
+                              offset);
+                       return -EINVAL;
+               }
        }
 
        cmd[0] = flash->write_cmd;
 
 static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
                                        bool prot)
 {
-       if (!flash->flash_lock)
+       if (!flash->flash_lock || !flash->flash_unlock)
                return -EOPNOTSUPP;
 
        if (prot)