Re: [PATCH 2/6] regmap: Add a magic bus type to handle quirks ofanalog devices ADIS sensors.

From: Jonathan Cameron
Date: Wed Sep 07 2011 - 14:18:00 EST


On 09/07/11 18:47, Mark Brown wrote:
> On Wed, Sep 07, 2011 at 05:19:43PM +0100, Jonathan Cameron wrote:
>> These devices look like 8 bit registers for writes and 16 bit registers for
>> reads. As you might imagine this causes some 'issues' hence this regmap
>> bus implementation claims they are always 16bit and does the mangling to
>> make the writes work.
>> ---
>
> You've not signed this off.
Indeed. Hence I'm not happy with it :) Just put it out there for comment.
Weird spi usage is hardly unusual so these issues were bound to pop up
at some point.

> To be honest I'm not terribly happy about
> pushing this into the regmap core code; if we start needing to do stuff
> like this we should expose the bus interface.
That's certainly an option, but I'd really like to use the regmap caching
stuff in here. These things can have quite a few registers that other than
their weird read / write quirks look much like any other register based
device. (particularly ignoring the burst reads but they tend to apply
to volatile registers only so caching is probably irrelevant).

At the moment, the only hooks AFAIKS to allow this are at the bus level.
I'm not sure where else they could go. (I haven't actually looked much
at the cache code yet though).

Actually I may have misunderstood, do you mean expose the bus interface
within regmap or just not use regmap at all?

>
>> +
>> +static int regmap_spi_write(struct device *dev, const void *data, size_t count)
>> +{
>> +/* Now this only works for 8 bit addresss 16 bit register first byte of data
>> + * is the lower address, second two the value */
>> + struct spi_device *spi = to_spi_device(dev);
>> + int ret;
>
> Indentation.
>
>> +static struct regmap_bus regmap_spi_adi = {
>> + .write = regmap_spi_write,
>> + .read = regmap_spi_read,
>> +};
>
> You want to implement the gather write too if you can.
Doesn't really exist other than by linearising them into a series
of calls to the write function. (assuming I understand what those
functions are doing right!)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/