diff options
-rw-r--r-- | drivers/iio/buffer_cb.c | 4 | ||||
-rw-r--r-- | drivers/iio/inkern.c | 6 | ||||
-rw-r--r-- | drivers/staging/iio/iio_hwmon.c | 9 | ||||
-rw-r--r-- | include/linux/iio/consumer.h | 9 |
4 files changed, 17 insertions, 11 deletions
diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c index 4d40e24f3721..9201022945e9 100644 --- a/drivers/iio/buffer_cb.c +++ b/drivers/iio/buffer_cb.c | |||
@@ -25,7 +25,7 @@ static struct iio_buffer_access_funcs iio_cb_access = { | |||
25 | .store_to = &iio_buffer_cb_store_to, | 25 | .store_to = &iio_buffer_cb_store_to, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, | 28 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, |
29 | int (*cb)(u8 *data, | 29 | int (*cb)(u8 *data, |
30 | void *private), | 30 | void *private), |
31 | void *private) | 31 | void *private) |
@@ -46,7 +46,7 @@ struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, | |||
46 | cb_buff->buffer.access = &iio_cb_access; | 46 | cb_buff->buffer.access = &iio_cb_access; |
47 | INIT_LIST_HEAD(&cb_buff->buffer.demux_list); | 47 | INIT_LIST_HEAD(&cb_buff->buffer.demux_list); |
48 | 48 | ||
49 | cb_buff->channels = iio_channel_get_all(name); | 49 | cb_buff->channels = iio_channel_get_all(dev); |
50 | if (IS_ERR(cb_buff->channels)) { | 50 | if (IS_ERR(cb_buff->channels)) { |
51 | ret = PTR_ERR(cb_buff->channels); | 51 | ret = PTR_ERR(cb_buff->channels); |
52 | goto error_free_cb_buff; | 52 | goto error_free_cb_buff; |
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index d55e98fb300e..58d0ffe856b6 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
@@ -167,16 +167,18 @@ void iio_channel_release(struct iio_channel *channel) | |||
167 | } | 167 | } |
168 | EXPORT_SYMBOL_GPL(iio_channel_release); | 168 | EXPORT_SYMBOL_GPL(iio_channel_release); |
169 | 169 | ||
170 | struct iio_channel *iio_channel_get_all(const char *name) | 170 | struct iio_channel *iio_channel_get_all(struct device *dev) |
171 | { | 171 | { |
172 | const char *name; | ||
172 | struct iio_channel *chans; | 173 | struct iio_channel *chans; |
173 | struct iio_map_internal *c = NULL; | 174 | struct iio_map_internal *c = NULL; |
174 | int nummaps = 0; | 175 | int nummaps = 0; |
175 | int mapind = 0; | 176 | int mapind = 0; |
176 | int i, ret; | 177 | int i, ret; |
177 | 178 | ||
178 | if (name == NULL) | 179 | if (dev == NULL) |
179 | return ERR_PTR(-EINVAL); | 180 | return ERR_PTR(-EINVAL); |
181 | name = dev_name(dev); | ||
180 | 182 | ||
181 | mutex_lock(&iio_map_list_lock); | 183 | mutex_lock(&iio_map_list_lock); |
182 | /* first count the matching maps */ | 184 | /* first count the matching maps */ |
diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c index d4ef34fe0341..93af756ba48c 100644 --- a/drivers/staging/iio/iio_hwmon.c +++ b/drivers/staging/iio/iio_hwmon.c | |||
@@ -71,14 +71,17 @@ static int iio_hwmon_probe(struct platform_device *pdev) | |||
71 | int ret, i; | 71 | int ret, i; |
72 | int in_i = 1, temp_i = 1, curr_i = 1; | 72 | int in_i = 1, temp_i = 1, curr_i = 1; |
73 | enum iio_chan_type type; | 73 | enum iio_chan_type type; |
74 | struct iio_channel *channels; | ||
75 | |||
76 | channels = iio_channel_get_all(dev); | ||
77 | if (IS_ERR(channels)) | ||
78 | return PTR_ERR(channels); | ||
74 | 79 | ||
75 | st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); | 80 | st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); |
76 | if (st == NULL) | 81 | if (st == NULL) |
77 | return -ENOMEM; | 82 | return -ENOMEM; |
78 | 83 | ||
79 | st->channels = iio_channel_get_all(dev_name(dev)); | 84 | st->channels = channels; |
80 | if (IS_ERR(st->channels)) | ||
81 | return PTR_ERR(st->channels); | ||
82 | 85 | ||
83 | /* count how many attributes we have */ | 86 | /* count how many attributes we have */ |
84 | while (st->channels[st->num_channels].indio_dev) | 87 | while (st->channels[st->num_channels].indio_dev) |
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 16c35ac045bd..a85787ac66ab 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | struct iio_dev; | 16 | struct iio_dev; |
17 | struct iio_chan_spec; | 17 | struct iio_chan_spec; |
18 | struct device; | ||
18 | 19 | ||
19 | /** | 20 | /** |
20 | * struct iio_channel - everything needed for a consumer to use a channel | 21 | * 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 | 49 | ||
49 | /** | 50 | /** |
50 | * iio_channel_get_all() - get all channels associated with a client | 51 | * iio_channel_get_all() - get all channels associated with a client |
51 | * @name: name of consumer device. | 52 | * @dev: Pointer to consumer device. |
52 | * | 53 | * |
53 | * Returns an array of iio_channel structures terminated with one with | 54 | * Returns an array of iio_channel structures terminated with one with |
54 | * null iio_dev pointer. | 55 | * null iio_dev pointer. |
55 | * This function is used by fairly generic consumers to get all the | 56 | * This function is used by fairly generic consumers to get all the |
56 | * channels registered as having this consumer. | 57 | * channels registered as having this consumer. |
57 | */ | 58 | */ |
58 | struct iio_channel *iio_channel_get_all(const char *name); | 59 | struct iio_channel *iio_channel_get_all(struct device *dev); |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * iio_channel_release_all() - reverse iio_channel_get_all | 62 | * iio_channel_release_all() - reverse iio_channel_get_all |
@@ -66,7 +67,7 @@ void iio_channel_release_all(struct iio_channel *chan); | |||
66 | struct iio_cb_buffer; | 67 | struct iio_cb_buffer; |
67 | /** | 68 | /** |
68 | * iio_channel_get_all_cb() - register callback for triggered capture | 69 | * iio_channel_get_all_cb() - register callback for triggered capture |
69 | * @name: Name of client device. | 70 | * @dev: Pointer to client device. |
70 | * @cb: Callback function. | 71 | * @cb: Callback function. |
71 | * @private: Private data passed to callback. | 72 | * @private: Private data passed to callback. |
72 | * | 73 | * |
@@ -74,7 +75,7 @@ struct iio_cb_buffer; | |||
74 | * So if the channels requested come from different devices this will | 75 | * So if the channels requested come from different devices this will |
75 | * fail. | 76 | * fail. |
76 | */ | 77 | */ |
77 | struct iio_cb_buffer *iio_channel_get_all_cb(const char *name, | 78 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, |
78 | int (*cb)(u8 *data, | 79 | int (*cb)(u8 *data, |
79 | void *private), | 80 | void *private), |
80 | void *private); | 81 | void *private); |