[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1563895963-19526-2-git-send-email-Jose.DiazdeGrenu@digi.com>
Date: Tue, 23 Jul 2019 17:32:42 +0200
From: Jose Diaz de Grenu <Jose.DiazdeGrenu@...i.com>
To: <Jose.DiazdeGrenu@...i.com>
CC: <srinivas.kandagatla@...aro.org>, <shawnguo@...nel.org>,
<s.hauer@...gutronix.de>, <kernel@...gutronix.de>,
<festevam@...il.com>, <linux-imx@....com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH 1/2] nvmem: imx-ocotp: use constant for write restriction
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@...i.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 {
Powered by blists - more mailing lists