From: Jose Diaz de Grenu <Jose.DiazdeGrenu@digi.com>
To: <Jose.DiazdeGrenu@digi.com>
Cc: <srinivas.kandagatla@linaro.org>, <shawnguo@kernel.org>,
<s.hauer@pengutronix.de>, <kernel@pengutronix.de>,
<festevam@gmail.com>, <linux-imx@nxp.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] nvmem: imx-ocotp: use constant for write restriction
Date: Tue, 23 Jul 2019 17:32:42 +0200 [thread overview]
Message-ID: <1563895963-19526-2-git-send-email-Jose.DiazdeGrenu@digi.com> (raw)
In-Reply-To: <1563895963-19526-1-git-send-email-Jose.DiazdeGrenu@digi.com>
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 {
next prev parent reply other threads:[~2019-07-23 15:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 15:32 [PATCH 0/2] nvmem: imx-ocotp: allow reads with arbitrary size and offset Jose Diaz de Grenu
2019-07-23 15:32 ` Jose Diaz de Grenu [this message]
2019-07-23 15:32 ` [PATCH 2/2] " Jose Diaz de Grenu
2019-08-06 10:05 ` [PATCH 0/2] " Srinivas Kandagatla
2019-08-21 12:11 ` Diaz de Grenu, Jose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1563895963-19526-2-git-send-email-Jose.DiazdeGrenu@digi.com \
--to=jose.diazdegrenu@digi.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).