Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Guenter Roeck and committed by
Jonathan Cameron
ca7d98db 482bb4e6

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