Re: [PATCH 2/4] regmap: Make internal read/write functions reentrantfrom themselves.

From: Mark Brown
Date: Thu May 31 2012 - 12:40:41 EST


On Thu, May 31, 2012 at 04:19:36PM +0200, Krystian Garbaciak wrote:

> Functions _regmap_update_bits() and _regmap_write() are modified
> so they can be recurrently entered from the inside.

You should describe what you're doing here in more detail...

> The internal reading functions need no modification for current implementation
> of indirect access.

So the subject should really be "Make internal write functions
reentrant"?

> - map->format.format_val(map->work_buf + map->format.reg_bytes
> - + map->format.pad_bytes, val);
> - return _regmap_raw_write(map, reg,
> - map->work_buf +
> - map->format.reg_bytes +
> - map->format.pad_bytes,
> + /* Using stack for value data, to make function reentrant */
> + map->format.format_val(&val, val);
> + return _regmap_raw_write(map, reg, &val,

We can't safely do this for all buses, some want to DMA and you can't
DMA from stack. This also means that we'll no longer be able to send a
single buffer to the device as we'll never have the value immediately
following the register address and padding any more. That'll increase
overhead on many systems, you can often see the handover on gathers on a
scope.

I don't understand why we can't take the decision to write the page
register before we start using the buffer?

Also, it seems like your mailing setup is a bit broken - these messages
aren't being threaded with each other.

Attachment: signature.asc
Description: Digital signature