diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-10-07 10:11:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-10-12 07:41:07 -0400 |
commit | 7e97e7bd1f394f2032621d396e6603eada610719 (patch) | |
tree | a443510b1c138c5a81370b36421c938b1abcd6ac /drivers/iio/light | |
parent | 6d59747eb08092d65c186728938a5dcf329b03f0 (diff) |
iio:apds9300: Use new event config interface
Switch the apds9300 driver to the new IIO event config interface as the old one
is going to be removed.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/light')
-rw-r--r-- | drivers/iio/light/apds9300.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c index 66a58bda6dc8..51097bbd59c9 100644 --- a/drivers/iio/light/apds9300.c +++ b/drivers/iio/light/apds9300.c | |||
@@ -273,12 +273,14 @@ static int apds9300_read_raw(struct iio_dev *indio_dev, | |||
273 | return ret; | 273 | return ret; |
274 | } | 274 | } |
275 | 275 | ||
276 | static int apds9300_read_thresh(struct iio_dev *indio_dev, u64 event_code, | 276 | static int apds9300_read_thresh(struct iio_dev *indio_dev, |
277 | int *val) | 277 | const struct iio_chan_spec *chan, enum iio_event_type type, |
278 | enum iio_event_direction dir, enum iio_event_info info, | ||
279 | int *val, int *val2) | ||
278 | { | 280 | { |
279 | struct apds9300_data *data = iio_priv(indio_dev); | 281 | struct apds9300_data *data = iio_priv(indio_dev); |
280 | 282 | ||
281 | switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { | 283 | switch (dir) { |
282 | case IIO_EV_DIR_RISING: | 284 | case IIO_EV_DIR_RISING: |
283 | *val = data->thresh_hi; | 285 | *val = data->thresh_hi; |
284 | break; | 286 | break; |
@@ -289,17 +291,19 @@ static int apds9300_read_thresh(struct iio_dev *indio_dev, u64 event_code, | |||
289 | return -EINVAL; | 291 | return -EINVAL; |
290 | } | 292 | } |
291 | 293 | ||
292 | return 0; | 294 | return IIO_VAL_INT; |
293 | } | 295 | } |
294 | 296 | ||
295 | static int apds9300_write_thresh(struct iio_dev *indio_dev, u64 event_code, | 297 | static int apds9300_write_thresh(struct iio_dev *indio_dev, |
296 | int val) | 298 | const struct iio_chan_spec *chan, enum iio_event_type type, |
299 | enum iio_event_direction dir, enum iio_event_info info, int val, | ||
300 | int val2) | ||
297 | { | 301 | { |
298 | struct apds9300_data *data = iio_priv(indio_dev); | 302 | struct apds9300_data *data = iio_priv(indio_dev); |
299 | int ret; | 303 | int ret; |
300 | 304 | ||
301 | mutex_lock(&data->mutex); | 305 | mutex_lock(&data->mutex); |
302 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) | 306 | if (dir == IIO_EV_DIR_RISING) |
303 | ret = apds9300_set_thresh_hi(data, val); | 307 | ret = apds9300_set_thresh_hi(data, val); |
304 | else | 308 | else |
305 | ret = apds9300_set_thresh_low(data, val); | 309 | ret = apds9300_set_thresh_low(data, val); |
@@ -309,7 +313,9 @@ static int apds9300_write_thresh(struct iio_dev *indio_dev, u64 event_code, | |||
309 | } | 313 | } |
310 | 314 | ||
311 | static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, | 315 | static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, |
312 | u64 event_code) | 316 | const struct iio_chan_spec *chan, |
317 | enum iio_event_type type, | ||
318 | enum iio_event_direction dir) | ||
313 | { | 319 | { |
314 | struct apds9300_data *data = iio_priv(indio_dev); | 320 | struct apds9300_data *data = iio_priv(indio_dev); |
315 | 321 | ||
@@ -317,7 +323,8 @@ static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, | |||
317 | } | 323 | } |
318 | 324 | ||
319 | static int apds9300_write_interrupt_config(struct iio_dev *indio_dev, | 325 | static int apds9300_write_interrupt_config(struct iio_dev *indio_dev, |
320 | u64 event_code, int state) | 326 | const struct iio_chan_spec *chan, enum iio_event_type type, |
327 | enum iio_event_direction dir, int state) | ||
321 | { | 328 | { |
322 | struct apds9300_data *data = iio_priv(indio_dev); | 329 | struct apds9300_data *data = iio_priv(indio_dev); |
323 | int ret; | 330 | int ret; |
@@ -337,10 +344,24 @@ static const struct iio_info apds9300_info_no_irq = { | |||
337 | static const struct iio_info apds9300_info = { | 344 | static const struct iio_info apds9300_info = { |
338 | .driver_module = THIS_MODULE, | 345 | .driver_module = THIS_MODULE, |
339 | .read_raw = apds9300_read_raw, | 346 | .read_raw = apds9300_read_raw, |
340 | .read_event_value = apds9300_read_thresh, | 347 | .read_event_value_new = apds9300_read_thresh, |
341 | .write_event_value = apds9300_write_thresh, | 348 | .write_event_value_new = apds9300_write_thresh, |
342 | .read_event_config = apds9300_read_interrupt_config, | 349 | .read_event_config_new = apds9300_read_interrupt_config, |
343 | .write_event_config = apds9300_write_interrupt_config, | 350 | .write_event_config_new = apds9300_write_interrupt_config, |
351 | }; | ||
352 | |||
353 | static const struct iio_event_spec apds9300_event_spec[] = { | ||
354 | { | ||
355 | .type = IIO_EV_TYPE_THRESH, | ||
356 | .dir = IIO_EV_DIR_RISING, | ||
357 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | ||
358 | BIT(IIO_EV_INFO_ENABLE), | ||
359 | }, { | ||
360 | .type = IIO_EV_TYPE_THRESH, | ||
361 | .dir = IIO_EV_DIR_FALLING, | ||
362 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | ||
363 | BIT(IIO_EV_INFO_ENABLE), | ||
364 | }, | ||
344 | }; | 365 | }; |
345 | 366 | ||
346 | static const struct iio_chan_spec apds9300_channels[] = { | 367 | static const struct iio_chan_spec apds9300_channels[] = { |
@@ -355,10 +376,8 @@ static const struct iio_chan_spec apds9300_channels[] = { | |||
355 | .channel2 = IIO_MOD_LIGHT_BOTH, | 376 | .channel2 = IIO_MOD_LIGHT_BOTH, |
356 | .indexed = true, | 377 | .indexed = true, |
357 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), | 378 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
358 | .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, | 379 | .event_spec = apds9300_event_spec, |
359 | IIO_EV_DIR_RISING) | | 380 | .num_event_specs = ARRAY_SIZE(apds9300_event_spec), |
360 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, | ||
361 | IIO_EV_DIR_FALLING)), | ||
362 | }, { | 381 | }, { |
363 | .type = IIO_INTENSITY, | 382 | .type = IIO_INTENSITY, |
364 | .channel = 1, | 383 | .channel = 1, |