[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKnu2MrUkY2upFh5d6GGTNUr-=r_JKcxh5OQNV63bdOCa4F+zg@mail.gmail.com>
Date: Sun, 16 Oct 2011 20:45:06 +0200
From: Linus Walleij <linus.ml.walleij@...il.com>
To: Jonathan Cameron <jic23@....ac.uk>
Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
zdevai@...il.com
Subject: Re: [PATCH] staging:iio:proof of concept in kernel interface.
2011/10/14 Jonathan Cameron <jic23@....ac.uk>:
> I'm trying to work out what our equivalent of the clk finding api is.
Judging from the ideal use of our in-tree driver
drivers/mfd/ab8500-gpadc.c a map like this would be
great
struct adc_map {
struct device *adc_dev;
const char *adc_dev_name;
const char *channel;
struct device *dev;
const char *dev_name;
};
{ adc_dev, adc_dev_name } are alternative-compulsory identifiers for
the ADC
channel: string identifying the channel on the ADC, strings have
been shown to be good for identifying things.
{ dev, dev_name } are alternative-compulsory identifiers for the
ADC client.
struct device * pointers take precedence, fallback to names if device
pointers are unavailable.
adc_dev_name is the name of the ADC and then I mean what is returned
from it's struct device *dev when you do dev_name() on it. dev_name is
well dev_name(dev);
Then this API feels comfortable:
struct adc *adc_get(struct device *dev, const char *channel);
void adc_put(struct adc *adc);
int adc_read_raw(struct adc *adc, int *val);
We can then add adc_read_voltage(), adc_read_temperature(), adc_read_foo() ...
Usage in say a hwmon driver or whatever:
struct adc *mr_adc = adc_get(dev, NULL);
/*
* Optional channel parameter used only when a single
* device use more than one channel, as with clock names
* or regulator names, so pass in NULL for the one channel
* tied to this device.
*/
ret = adc_read_raw(mr_adc, &val);
(...)
adc_put(mr_adc);
But this is just what looks useful to us.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists