Lines Matching refs:ofs
585 static int sst26_lock_ctl(struct spi_flash *flash, u32 ofs, size_t len, enum lock_ctl ctl) in sst26_lock_ctl() argument
593 if ((ofs & (SZ_64K - 1)) || (len & (SZ_64K - 1))) in sst26_lock_ctl()
596 if (ofs + len > flash->size) in sst26_lock_ctl()
614 rptr_64k = min_t(u32, ofs + len , flash->size - SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
615 lptr_64k = max_t(u32, ofs, SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
617 upper_64k = ((ofs + len) > (flash->size - SST26_BOUND_REG_SIZE)); in sst26_lock_ctl()
618 lower_64k = (ofs < SST26_BOUND_REG_SIZE); in sst26_lock_ctl()
683 static int sst26_unlock(struct spi_flash *flash, u32 ofs, size_t len) in sst26_unlock() argument
685 return sst26_lock_ctl(flash, ofs, len, SST26_CTL_UNLOCK); in sst26_unlock()
688 static int sst26_lock(struct spi_flash *flash, u32 ofs, size_t len) in sst26_lock() argument
690 return sst26_lock_ctl(flash, ofs, len, SST26_CTL_LOCK); in sst26_lock()
697 static int sst26_is_locked(struct spi_flash *flash, u32 ofs, size_t len) in sst26_is_locked() argument
705 ofs -= ofs & (SZ_64K - 1); in sst26_is_locked()
708 return sst26_lock_ctl(flash, ofs, len, SST26_CTL_CHECK); in sst26_is_locked()
838 static void stm_get_locked_range(struct spi_flash *flash, u8 sr, loff_t *ofs, in stm_get_locked_range() argument
847 *ofs = 0; in stm_get_locked_range()
852 *ofs = flash->size - *len; in stm_get_locked_range()
859 static int stm_is_locked_sr(struct spi_flash *flash, loff_t ofs, u64 len, in stm_is_locked_sr() argument
867 return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); in stm_is_locked_sr()
877 int stm_is_locked(struct spi_flash *flash, u32 ofs, size_t len) in stm_is_locked() argument
886 return stm_is_locked_sr(flash, ofs, len, sr); in stm_is_locked()
912 int stm_lock(struct spi_flash *flash, u32 ofs, size_t len) in stm_lock() argument
924 if (ofs + len != flash->size) { in stm_lock()
926 if (!stm_is_locked_sr(flash, ofs + len, flash->size - ofs - len, in stm_lock()
929 len = flash->size - ofs; in stm_lock()
966 int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len) in stm_unlock() argument
978 if (stm_is_locked_sr(flash, ofs - flash->erase_size, flash->erase_size, in stm_unlock()
990 pow = ilog2(flash->size) - order_base_2(flash->size - (ofs + len)); in stm_unlock()
991 if (ofs + len == flash->size) { in stm_unlock()