staging: iio_simple_dummy: fix init function
[deliverable/linux.git] / drivers / staging / iio / iio_simple_dummy.h
CommitLineData
e6477000
JC
1/**
2 * Copyright (c) 2011 Jonathan Cameron
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * Join together the various functionality of iio_simple_dummy driver
9 */
10
f3f883b4
RD
11#ifndef _IIO_SIMPLE_DUMMY_H_
12#define _IIO_SIMPLE_DUMMY_H_
e6477000
JC
13#include <linux/kernel.h>
14
15struct iio_dummy_accel_calibscale;
356ae946 16struct iio_dummy_regs;
e6477000
JC
17
18/**
19 * struct iio_dummy_state - device instance specific state.
20 * @dac_val: cache for dac value
21 * @single_ended_adc_val: cache for single ended adc value
22 * @differential_adc_val: cache for differential adc value
23 * @accel_val: cache for acceleration value
24 * @accel_calibbias: cache for acceleration calibbias
25 * @accel_calibscale: cache for acceleration calibscale
26 * @lock: lock to ensure state is consistent
27 * @event_irq: irq number for event line (faked)
69e98df7 28 * @event_val: cache for event threshold value
e6477000
JC
29 * @event_en: cache of whether event is enabled
30 */
31struct iio_dummy_state {
32 int dac_val;
33 int single_ended_adc_val;
34 int differential_adc_val[2];
35 int accel_val;
36 int accel_calibbias;
3e34e650
DB
37 int activity_running;
38 int activity_walking;
e6477000
JC
39 const struct iio_dummy_accel_calibscale *accel_calibscale;
40 struct mutex lock;
356ae946 41 struct iio_dummy_regs *regs;
3e34e650
DB
42 int steps_enabled;
43 int steps;
44 int height;
e6477000
JC
45#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
46 int event_irq;
47 int event_val;
48 bool event_en;
49#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
50};
51
52#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
53
54struct iio_dev;
55
56int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
57 const struct iio_chan_spec *chan,
58 enum iio_event_type type,
59 enum iio_event_direction dir);
e6477000
JC
60
61int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
62 const struct iio_chan_spec *chan,
63 enum iio_event_type type,
64 enum iio_event_direction dir,
e6477000
JC
65 int state);
66
67int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
68 const struct iio_chan_spec *chan,
69 enum iio_event_type type,
70 enum iio_event_direction dir,
71 enum iio_event_info info, int *val,
72 int *val2);
e6477000
JC
73
74int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
75 const struct iio_chan_spec *chan,
76 enum iio_event_type type,
77 enum iio_event_direction dir,
78 enum iio_event_info info, int val,
79 int val2);
e6477000
JC
80
81int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
82int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
83
84#else /* Stubs for when events are disabled at compile time */
85
86static inline int
87iio_simple_dummy_events_register(struct iio_dev *indio_dev)
88{
89 return 0;
90};
91
92static inline int
93iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
94{
95 return 0;
96};
97
98#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
99
9ad2e2e1
JC
100/**
101 * enum iio_simple_dummy_scan_elements - scan index enum
102 * @voltage0: the single ended voltage channel
103 * @diffvoltage1m2: first differential channel
104 * @diffvoltage3m4: second differenial channel
105 * @accelx: acceleration channel
106 *
107 * Enum provides convenient numbering for the scan index.
108 */
109enum iio_simple_dummy_scan_elements {
110 voltage0,
111 diffvoltage1m2,
112 diffvoltage3m4,
113 accelx,
114};
e6477000 115
9ad2e2e1 116#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
4ae03019 117int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev);
9ad2e2e1
JC
118void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
119#else
75d44ce0 120static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
9ad2e2e1
JC
121{
122 return 0;
123};
124static inline
125void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
126{};
f3f883b4 127
9ad2e2e1 128#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
f3f883b4 129#endif /* _IIO_SIMPLE_DUMMY_H_ */
This page took 0.289496 seconds and 5 git commands to generate.