diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-05 14:42:48 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-05 14:42:48 -0500 |
commit | be61a0d78449f53519905640ac3a9f24c197cbaf (patch) | |
tree | 216a7655e2d6dc8f751214aa93a4863a27954a98 /drivers/iio/inkern.c | |
parent | 7be921a226dcbbbd8fb6f5d63bea4856b3a11624 (diff) | |
parent | 4e4cd14e7cbead5ca20465f4a7ce973d42434a2f (diff) |
Merge tag 'iio-for-3.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First round of new drivers, features and cleanups for IIO in the 3.19 cycle.
New drivers / supported parts
* rockchip - rk3066-tsadc variant
* si7020 humidity and temperature sensor
* mcp320x - add mcp3001, mcp3002, mcp3004, mcp3008, mcp3201, mcp3202
* bmp280 pressure and temperature sensor
* Qualcomm SPMI PMIC current ADC driver
* Exynos_adc - support exynos7
New features
* vf610-adc - add temperature sensor support
* Documentation of current attributes, scaled pressure, offset and
scaled humidity, RGBC intensity gain factor and scale applied to
differential voltage channels.
* Bring iio_event_monitor up to date with newer modifiers.
* Add of_xlate function to allow for complex channel mappings from the
device tree.
* Add -g parameter to generic_buffer example to allow for devices with
directly fed (no trigger) buffers.
* Move exynos driver over to syscon for PMU register access.
Cleanups, fixes for new drivers
* lis3l02dq drop an unneeded else.
* st sensors - renam st_sensors to st_sensor_settings (for clarity)
* st sensors - drop an unused parameter from all the probe utility
functions.
* vf610 better error handling and tidy up.
* si7020 - cleanups following merge
* as3935 - drop some unnecessary semicolons.
* bmp280 - fix the pressure calculation.
Diffstat (limited to 'drivers/iio/inkern.c')
-rw-r--r-- | drivers/iio/inkern.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index f0846108d006..866fe904cba2 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
@@ -100,6 +100,28 @@ static int iio_dev_node_match(struct device *dev, void *data) | |||
100 | return dev->of_node == data && dev->type == &iio_device_type; | 100 | return dev->of_node == data && dev->type == &iio_device_type; |
101 | } | 101 | } |
102 | 102 | ||
103 | /** | ||
104 | * __of_iio_simple_xlate - translate iiospec to the IIO channel index | ||
105 | * @indio_dev: pointer to the iio_dev structure | ||
106 | * @iiospec: IIO specifier as found in the device tree | ||
107 | * | ||
108 | * This is simple translation function, suitable for the most 1:1 mapped | ||
109 | * channels in IIO chips. This function performs only one sanity check: | ||
110 | * whether IIO index is less than num_channels (that is specified in the | ||
111 | * iio_dev). | ||
112 | */ | ||
113 | static int __of_iio_simple_xlate(struct iio_dev *indio_dev, | ||
114 | const struct of_phandle_args *iiospec) | ||
115 | { | ||
116 | if (!iiospec->args_count) | ||
117 | return 0; | ||
118 | |||
119 | if (iiospec->args[0] >= indio_dev->num_channels) | ||
120 | return -EINVAL; | ||
121 | |||
122 | return iiospec->args[0]; | ||
123 | } | ||
124 | |||
103 | static int __of_iio_channel_get(struct iio_channel *channel, | 125 | static int __of_iio_channel_get(struct iio_channel *channel, |
104 | struct device_node *np, int index) | 126 | struct device_node *np, int index) |
105 | { | 127 | { |
@@ -122,18 +144,19 @@ static int __of_iio_channel_get(struct iio_channel *channel, | |||
122 | 144 | ||
123 | indio_dev = dev_to_iio_dev(idev); | 145 | indio_dev = dev_to_iio_dev(idev); |
124 | channel->indio_dev = indio_dev; | 146 | channel->indio_dev = indio_dev; |
125 | index = iiospec.args_count ? iiospec.args[0] : 0; | 147 | if (indio_dev->info->of_xlate) |
126 | if (index >= indio_dev->num_channels) { | 148 | index = indio_dev->info->of_xlate(indio_dev, &iiospec); |
127 | err = -EINVAL; | 149 | else |
150 | index = __of_iio_simple_xlate(indio_dev, &iiospec); | ||
151 | if (index < 0) | ||
128 | goto err_put; | 152 | goto err_put; |
129 | } | ||
130 | channel->channel = &indio_dev->channels[index]; | 153 | channel->channel = &indio_dev->channels[index]; |
131 | 154 | ||
132 | return 0; | 155 | return 0; |
133 | 156 | ||
134 | err_put: | 157 | err_put: |
135 | iio_device_put(indio_dev); | 158 | iio_device_put(indio_dev); |
136 | return err; | 159 | return index; |
137 | } | 160 | } |
138 | 161 | ||
139 | static struct iio_channel *of_iio_channel_get(struct device_node *np, int index) | 162 | static struct iio_channel *of_iio_channel_get(struct device_node *np, int index) |