Lines Matching refs:ofs
629 static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, in stm_get_locked_range() argument
639 *ofs = 0; in stm_get_locked_range()
645 *ofs = 0; in stm_get_locked_range()
647 *ofs = mtd->size - *len; in stm_get_locked_range()
655 static int stm_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, u64 len, in stm_check_lock_status_sr() argument
668 return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); in stm_check_lock_status_sr()
671 return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); in stm_check_lock_status_sr()
674 static int stm_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, in stm_is_locked_sr() argument
677 return stm_check_lock_status_sr(nor, ofs, len, sr, true); in stm_is_locked_sr()
680 static int stm_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, in stm_is_unlocked_sr() argument
683 return stm_check_lock_status_sr(nor, ofs, len, sr, false); in stm_is_unlocked_sr()
718 static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) in stm_lock() argument
733 if (stm_is_locked_sr(nor, ofs, len, status_old)) in stm_lock()
737 if (!stm_is_locked_sr(nor, 0, ofs, status_old)) in stm_lock()
741 if (!stm_is_locked_sr(nor, ofs + len, mtd->size - (ofs + len), in stm_lock()
753 lock_len = mtd->size - ofs; in stm_lock()
755 lock_len = ofs + len; in stm_lock()
798 static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) in stm_unlock() argument
813 if (stm_is_unlocked_sr(nor, ofs, len, status_old)) in stm_unlock()
817 if (!stm_is_unlocked_sr(nor, 0, ofs, status_old)) in stm_unlock()
821 if (!stm_is_unlocked_sr(nor, ofs + len, mtd->size - (ofs + len), in stm_unlock()
833 lock_len = mtd->size - (ofs + len); in stm_unlock()
835 lock_len = ofs; in stm_unlock()
883 static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) in stm_is_locked() argument
891 return stm_is_locked_sr(nor, ofs, len, status); in stm_is_locked()
1018 static int sst26_lock_ctl(struct spi_nor *nor, loff_t ofs, uint64_t len, enum lock_ctl ctl) in sst26_lock_ctl() argument
1027 if ((ofs & (SZ_64K - 1)) || (len & (SZ_64K - 1))) { in sst26_lock_ctl()
1032 if (ofs + len > mtd->size) { in sst26_lock_ctl()
1034 ofs, len, mtd->size); in sst26_lock_ctl()
1052 rptr_64k = min_t(u32, ofs + len, mtd->size - SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
1053 lptr_64k = max_t(u32, ofs, SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
1055 upper_64k = ((ofs + len) > (mtd->size - SST26_BOUND_REG_SIZE)); in sst26_lock_ctl()
1056 lower_64k = (ofs < SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
1120 static int sst26_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) in sst26_unlock() argument
1122 return sst26_lock_ctl(nor, ofs, len, SST26_CTL_UNLOCK); in sst26_unlock()
1125 static int sst26_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) in sst26_lock() argument
1127 return sst26_lock_ctl(nor, ofs, len, SST26_CTL_LOCK); in sst26_lock()
1134 static int sst26_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) in sst26_is_locked() argument
1142 ofs -= ofs & (SZ_64K - 1); in sst26_is_locked()
1145 return sst26_lock_ctl(nor, ofs, len, SST26_CTL_CHECK); in sst26_is_locked()