Skip to content

Commit

Permalink
nvmem: qfprom: Allow single byte accesses for read/write
Browse files Browse the repository at this point in the history
The nvmem core driver supports to read and write single
byte. So, allow qfprom to support this feature.
This change 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>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
vivekgautam1 authored and gregkh committed Jan 4, 2017
1 parent e09ee85 commit 01d0d2c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/nvmem/qfprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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,
Expand Down

0 comments on commit 01d0d2c

Please sign in to comment.