Skip to content

Commit

Permalink
mfd: Push byte swaps out of wm8994 bulk read path
Browse files Browse the repository at this point in the history
For consistency with the write path push byte swaps of the WM8994 register
data out of the bulk read data path into the per-register APIs. The only
user of the bulk register read is the interrupt code which is updated to
do the swaps itself part of this patch.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Mar 23, 2011
1 parent 8bd4d7c commit 316b6cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions drivers/mfd/wm8994-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
return ret;

for (i = 0; i < bytes / 2; i++) {
buf[i] = be16_to_cpu(buf[i]);

dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
buf[i], reg + i, reg + i);
be16_to_cpu(buf[i]), reg + i, reg + i);
}

return 0;
Expand All @@ -69,7 +67,7 @@ int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
if (ret < 0)
return ret;
else
return val;
return be16_to_cpu(val);
}
EXPORT_SYMBOL_GPL(wm8994_reg_read);

Expand All @@ -79,7 +77,7 @@ EXPORT_SYMBOL_GPL(wm8994_reg_read);
* @wm8994: Device to read from
* @reg: First register
* @count: Number of registers
* @buf: Buffer to fill.
* @buf: Buffer to fill. The data will be returned big endian.
*/
int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
int count, u16 *buf)
Expand Down Expand Up @@ -180,6 +178,8 @@ int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
if (ret < 0)
goto out;

r = be16_to_cpu(r);

r &= ~mask;
r |= val;

Expand Down
6 changes: 4 additions & 2 deletions drivers/mfd/wm8994-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ static irqreturn_t wm8994_irq_thread(int irq, void *data)
return IRQ_NONE;
}

/* Apply masking */
for (i = 0; i < WM8994_NUM_IRQ_REGS; i++)
/* Bit swap and apply masking */
for (i = 0; i < WM8994_NUM_IRQ_REGS; i++) {
status[i] = be16_to_cpu(status[i]);
status[i] &= ~wm8994->irq_masks_cur[i];
}

/* Report */
for (i = 0; i < ARRAY_SIZE(wm8994_irqs); i++) {
Expand Down

0 comments on commit 316b6cc

Please sign in to comment.