Skip to content

Commit 52487e2

Browse files
Jungseung-Leeambarus
authored andcommitted
mtd: spi-nor: Rename SR_TB to indicate the bit used
Each vendor uses different bits for SR_TB of flash. To avoid ambiguity, rename SR_TB to indicate the bit used. Signed-off-by: Jungseung Lee <js07.lee@samsung.com> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent 01916e0 commit 52487e2

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎drivers/mtd/spi-nor/spi-nor.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs,
17711771
} else {
17721772
pow = ((sr & mask) ^ mask) >> shift;
17731773
*len = mtd->size >> pow;
1774-
if (nor->flags & SNOR_F_HAS_SR_TB && sr & SR_TB)
1774+
if (nor->flags & SNOR_F_HAS_SR_TB && sr & SR_TB_BIT5)
17751775
*ofs = 0;
17761776
else
17771777
*ofs = mtd->size - *len;
@@ -1903,13 +1903,13 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
19031903
if (!(val & mask))
19041904
return -EINVAL;
19051905

1906-
status_new = (status_old & ~mask & ~SR_TB) | val;
1906+
status_new = (status_old & ~mask & ~SR_TB_BIT5) | val;
19071907

19081908
/* Disallow further writes if WP pin is asserted */
19091909
status_new |= SR_SRWD;
19101910

19111911
if (!use_top)
1912-
status_new |= SR_TB;
1912+
status_new |= SR_TB_BIT5;
19131913

19141914
/* Don't bother if they're the same */
19151915
if (status_new == status_old)
@@ -1987,14 +1987,14 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
19871987
return -EINVAL;
19881988
}
19891989

1990-
status_new = (status_old & ~mask & ~SR_TB) | val;
1990+
status_new = (status_old & ~mask & ~SR_TB_BIT5) | val;
19911991

19921992
/* Don't protect status register if we're fully unlocked */
19931993
if (lock_len == 0)
19941994
status_new &= ~SR_SRWD;
19951995

19961996
if (!use_top)
1997-
status_new |= SR_TB;
1997+
status_new |= SR_TB_BIT5;
19981998

19991999
/* Don't bother if they're the same */
20002000
if (status_new == status_old)

‎include/linux/mtd/spi-nor.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
#define SR_BP0 BIT(2) /* Block protect 0 */
129129
#define SR_BP1 BIT(3) /* Block protect 1 */
130130
#define SR_BP2 BIT(4) /* Block protect 2 */
131-
#define SR_TB BIT(5) /* Top/Bottom protect */
131+
#define SR_TB_BIT5 BIT(5) /* Top/Bottom protect */
132+
#define SR_TB_BIT6 BIT(6) /* Top/Bottom protect */
132133
#define SR_SRWD BIT(7) /* SR write protect */
133134
/* Spansion/Cypress specific status bits */
134135
#define SR_E_ERR BIT(5)

0 commit comments

Comments
 (0)