Commit ca7d98db authored by Guenter Roeck's avatar Guenter Roeck Committed by Jonathan Cameron

iio: Update iio_channel_get_all and iio_channel_get_all_cb API

Pass device pointer instead of device name as parameter to iio_channel_get_all
and iio_channel_get_all_cb. This will enable us to use OF information to
retrieve consumer channel information.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 482bb4e6
...@@ -25,7 +25,7 @@ static struct iio_buffer_access_funcs iio_cb_access = { ...@@ -25,7 +25,7 @@ static struct iio_buffer_access_funcs iio_cb_access = {
.store_to = &iio_buffer_cb_store_to, .store_to = &iio_buffer_cb_store_to,
}; };
struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
int (*cb)(u8 *data, int (*cb)(u8 *data,
void *private), void *private),
void *private) void *private)
...@@ -46,7 +46,7 @@ struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, ...@@ -46,7 +46,7 @@ struct iio_cb_buffer *iio_channel_get_all_cb(const char *name,
cb_buff->buffer.access = &iio_cb_access; cb_buff->buffer.access = &iio_cb_access;
INIT_LIST_HEAD(&cb_buff->buffer.demux_list); INIT_LIST_HEAD(&cb_buff->buffer.demux_list);
cb_buff->channels = iio_channel_get_all(name); cb_buff->channels = iio_channel_get_all(dev);
if (IS_ERR(cb_buff->channels)) { if (IS_ERR(cb_buff->channels)) {
ret = PTR_ERR(cb_buff->channels); ret = PTR_ERR(cb_buff->channels);
goto error_free_cb_buff; goto error_free_cb_buff;
......
...@@ -167,16 +167,18 @@ void iio_channel_release(struct iio_channel *channel) ...@@ -167,16 +167,18 @@ void iio_channel_release(struct iio_channel *channel)
} }
EXPORT_SYMBOL_GPL(iio_channel_release); EXPORT_SYMBOL_GPL(iio_channel_release);
struct iio_channel *iio_channel_get_all(const char *name) struct iio_channel *iio_channel_get_all(struct device *dev)
{ {
const char *name;
struct iio_channel *chans; struct iio_channel *chans;
struct iio_map_internal *c = NULL; struct iio_map_internal *c = NULL;
int nummaps = 0; int nummaps = 0;
int mapind = 0; int mapind = 0;
int i, ret; int i, ret;
if (name == NULL) if (dev == NULL)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
name = dev_name(dev);
mutex_lock(&iio_map_list_lock); mutex_lock(&iio_map_list_lock);
/* first count the matching maps */ /* first count the matching maps */
......
...@@ -71,14 +71,17 @@ static int iio_hwmon_probe(struct platform_device *pdev) ...@@ -71,14 +71,17 @@ static int iio_hwmon_probe(struct platform_device *pdev)
int ret, i; int ret, i;
int in_i = 1, temp_i = 1, curr_i = 1; int in_i = 1, temp_i = 1, curr_i = 1;
enum iio_chan_type type; enum iio_chan_type type;
struct iio_channel *channels;
channels = iio_channel_get_all(dev);
if (IS_ERR(channels))
return PTR_ERR(channels);
st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
if (st == NULL) if (st == NULL)
return -ENOMEM; return -ENOMEM;
st->channels = iio_channel_get_all(dev_name(dev)); st->channels = channels;
if (IS_ERR(st->channels))
return PTR_ERR(st->channels);
/* count how many attributes we have */ /* count how many attributes we have */
while (st->channels[st->num_channels].indio_dev) while (st->channels[st->num_channels].indio_dev)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
struct iio_dev; struct iio_dev;
struct iio_chan_spec; struct iio_chan_spec;
struct device;
/** /**
* struct iio_channel - everything needed for a consumer to use a channel * struct iio_channel - everything needed for a consumer to use a channel
...@@ -48,14 +49,14 @@ void iio_channel_release(struct iio_channel *chan); ...@@ -48,14 +49,14 @@ void iio_channel_release(struct iio_channel *chan);
/** /**
* iio_channel_get_all() - get all channels associated with a client * iio_channel_get_all() - get all channels associated with a client
* @name: name of consumer device. * @dev: Pointer to consumer device.
* *
* Returns an array of iio_channel structures terminated with one with * Returns an array of iio_channel structures terminated with one with
* null iio_dev pointer. * null iio_dev pointer.
* This function is used by fairly generic consumers to get all the * This function is used by fairly generic consumers to get all the
* channels registered as having this consumer. * channels registered as having this consumer.
*/ */
struct iio_channel *iio_channel_get_all(const char *name); struct iio_channel *iio_channel_get_all(struct device *dev);
/** /**
* iio_channel_release_all() - reverse iio_channel_get_all * iio_channel_release_all() - reverse iio_channel_get_all
...@@ -66,7 +67,7 @@ void iio_channel_release_all(struct iio_channel *chan); ...@@ -66,7 +67,7 @@ void iio_channel_release_all(struct iio_channel *chan);
struct iio_cb_buffer; struct iio_cb_buffer;
/** /**
* iio_channel_get_all_cb() - register callback for triggered capture * iio_channel_get_all_cb() - register callback for triggered capture
* @name: Name of client device. * @dev: Pointer to client device.
* @cb: Callback function. * @cb: Callback function.
* @private: Private data passed to callback. * @private: Private data passed to callback.
* *
...@@ -74,7 +75,7 @@ struct iio_cb_buffer; ...@@ -74,7 +75,7 @@ struct iio_cb_buffer;
* So if the channels requested come from different devices this will * So if the channels requested come from different devices this will
* fail. * fail.
*/ */
struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
int (*cb)(u8 *data, int (*cb)(u8 *data,
void *private), void *private),
void *private); void *private);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment