linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Gautam <vivek.gautam@codeaurora.org>
To: srinivas.kandagatla@linaro.org, maxime.ripard@free-electrons.com
Cc: gregkh@linuxfoundation.org, sboyd@codeaurora.org,
	rnayak@codeaurora.org, linux-kernel@vger.kernel.org,
	Vivek Gautam <vivek.gautam@codeaurora.org>
Subject: [PATCH] nvmem: qfprom: Fix to support single byte read/write
Date: Tue, 15 Nov 2016 19:34:42 +0530	[thread overview]
Message-ID: <1479218682-15948-1-git-send-email-vivek.gautam@codeaurora.org> (raw)

The nvmem core driver supports to read and write single
byte. This helps in extracting a required value based
on bit-offset and number of bits for the required value
in the nvmem cell.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
---

Based on torvalds's master branch.

 - Tested on db410c for thermal sensors, and
   on db820c for qusb2 phy with tree [1] based on linaro qcom landing
   team's integration tree.

[1] https://github.com/vivekgautam1/linux/tree/linaro/integration-linux-qcomlt-qcom-phy-upstream

 drivers/nvmem/qfprom.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
index b5305f0..2bdb6c3 100644
--- a/drivers/nvmem/qfprom.c
+++ b/drivers/nvmem/qfprom.c
@@ -21,11 +21,11 @@ static int qfprom_reg_read(void *context,
 			unsigned int reg, void *_val, size_t bytes)
 {
 	void __iomem *base = context;
-	u32 *val = _val;
-	int i = 0, words = bytes / 4;
+	u8 *val = _val;
+	int i = 0, words = bytes;
 
 	while (words--)
-		*val++ = readl(base + reg + (i++ * 4));
+		*val++ = readb(base + reg + i++);
 
 	return 0;
 }
@@ -34,11 +34,11 @@ static int qfprom_reg_write(void *context,
 			 unsigned int reg, void *_val, size_t bytes)
 {
 	void __iomem *base = context;
-	u32 *val = _val;
-	int i = 0, words = bytes / 4;
+	u8 *val = _val;
+	int i = 0, words = bytes;
 
 	while (words--)
-		writel(*val++, base + reg + (i++ * 4));
+		writeb(*val++, base + reg + i++);
 
 	return 0;
 }
@@ -53,7 +53,7 @@ static int qfprom_remove(struct platform_device *pdev)
 static struct nvmem_config econfig = {
 	.name = "qfprom",
 	.owner = THIS_MODULE,
-	.stride = 4,
+	.stride = 1,
 	.word_size = 1,
 	.reg_read = qfprom_reg_read,
 	.reg_write = qfprom_reg_write,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

             reply	other threads:[~2016-11-15 14:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 14:04 Vivek Gautam [this message]
2016-11-15 18:59 ` [PATCH] nvmem: qfprom: Fix to support single byte read/write Stephen Boyd
2016-11-16  4:30   ` Vivek Gautam
2016-11-16 22:23     ` Stephen Boyd
2016-11-17  5:59       ` [PATCH v2] nvmem: qfprom: Allow single byte accesses for read/write Vivek Gautam
2017-01-04 14:07         ` Srinivas Kandagatla
2017-01-05  4:27           ` Vivek Gautam

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=1479218682-15948-1-git-send-email-vivek.gautam@codeaurora.org \
    --to=vivek.gautam@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=rnayak@codeaurora.org \
    --cc=sboyd@codeaurora.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).