Messages in this thread Patch in this message | | | From | Jose Diaz de Grenu <> | Subject | [PATCH 1/2] nvmem: imx-ocotp: use constant for write restriction | Date | Tue, 23 Jul 2019 17:32:42 +0200 |
| |
Use a new constant instead of reusing config->word_size, which applies both to read and writes. This allows to change config->word_size without affecting to the write size restriction.
Signed-off-by: Jose Diaz de Grenu <Jose.DiazdeGrenu@digi.com> --- drivers/nvmem/imx-ocotp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 42d4451e7d67..dc86d863563a 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -29,6 +29,7 @@ #define IMX_OCOTP_OFFSET_PER_WORD 0x10 /* Offset between the start addr * of two consecutive OTP words. */ +#define IMX_OTP_WORD_SIZE 4 #define IMX_OCOTP_ADDR_CTRL 0x0000 #define IMX_OCOTP_ADDR_CTRL_SET 0x0004 @@ -252,8 +253,8 @@ static int imx_ocotp_write(void *context, unsigned int offset, void *val, u8 word = 0; /* allow only writing one complete OTP word at a time */ - if ((bytes != priv->config->word_size) || - (offset % priv->config->word_size)) + if ((bytes != IMX_OTP_WORD_SIZE) || + (offset % IMX_OTP_WORD_SIZE)) return -EINVAL; mutex_lock(&ocotp_mutex); @@ -293,7 +294,7 @@ static int imx_ocotp_write(void *context, unsigned int offset, void *val, * see i.MX 7Solo Applications Processor Reference Manual, Rev. * 0.1 section 6.4.3.1 */ - offset = offset / priv->config->word_size; + offset = offset / IMX_OTP_WORD_SIZE; waddr = offset / priv->params->bank_address_words; word = offset & (priv->params->bank_address_words - 1); } else {
| |