Re: [PATCH 3/3] Add "no-bus" option for regmap API

From: Mark Brown
Date: Thu Dec 27 2012 - 13:23:51 EST


On Fri, Dec 21, 2012 at 01:47:18AM -0800, Andrey Smirnov wrote:

This looks really good, the issues and questions I have below are pretty
detailed.

> - int (*reg_read)(struct regmap *map, unsigned int reg, unsigned int *val);
> - int (*reg_write)(struct regmap *map, unsigned int reg, unsigned int val);
> + int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
> + int (*reg_write)(void *context, unsigned int reg, unsigned int val);

I'd be inclined to just do this in the initial refectoring patches
rather than rerefactoring here.

> + if (!bus || !bus->fast_io) {
> mutex_init(&map->mutex);
> map->lock = regmap_lock_mutex;
> map->unlock = regmap_unlock_mutex;
> + } else {
> + spin_lock_init(&map->spinlock);
> + map->lock = regmap_lock_spinlock;
> + map->unlock = regmap_unlock_spinlock;

It's not immediately obvious to me that no-bus should be forced to use
mutexes - is there any great reason for tying the two together? I'd add
a flag to allow no-bus devices to choose, possibly as part of a separate
"bus" configuration thing that gets configured with a separate init
function.

> + if (!bus) {
> + map->cache_registers = true;
> + goto skip_format_initialization;
> + } else {
> + map->reg_read = _regmap_bus_read;
> + }

Not sure I understand cache_registers here. Why has this flag been
added?

> + * @reg_read: Optional callback that if filled will be used to perform
> + * all the reads from the registers.
> + * @reg_write: Optional callback that if filled will be used to perform
> + * all the writes to the registers.

I'd probably add some comment about not using this in conjunction with
SPI or I2C.

Attachment: signature.asc
Description: Digital signature