diff options
author | Pantelis Antoniou <panto@antoniou-consulting.com> | 2012-10-13 09:37:24 -0400 |
---|---|---|
committer | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-06-12 12:50:20 -0400 |
commit | c80df483f61d0464224dc4386ced470c7275d78f (patch) | |
tree | dd82608840876c8ffe0d51d87b2bd892206a6867 /drivers/iio | |
parent | 9e5775f31289fc9915e4a2e4077950ea9a5da0b4 (diff) |
iio: ti_tscadc: provide datasheet_name and scan_type
This patch provides the members "datasheet_name" and scan_type. This is
the remaining part of the earlier patch where I (bigeasy) removed iio_map
because it is now supplied by the device tree. It also static names as
suggested by Jonathan.
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/ti_am335x_adc.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 2868c0c1b7e0..9939810954f1 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/iio/iio.h> | 24 | #include <linux/iio/iio.h> |
25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
26 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
27 | #include <linux/iio/machine.h> | ||
28 | #include <linux/iio/driver.h> | ||
27 | 29 | ||
28 | #include <linux/mfd/ti_am335x_tscadc.h> | 30 | #include <linux/mfd/ti_am335x_tscadc.h> |
29 | 31 | ||
@@ -84,29 +86,46 @@ static void tiadc_step_config(struct tiadc_device *adc_dev) | |||
84 | am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en); | 86 | am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en); |
85 | } | 87 | } |
86 | 88 | ||
89 | static const char * const chan_name_ain[] = { | ||
90 | "AIN0", | ||
91 | "AIN1", | ||
92 | "AIN2", | ||
93 | "AIN3", | ||
94 | "AIN4", | ||
95 | "AIN5", | ||
96 | "AIN6", | ||
97 | "AIN7", | ||
98 | }; | ||
99 | |||
87 | static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) | 100 | static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) |
88 | { | 101 | { |
102 | struct tiadc_device *adc_dev = iio_priv(indio_dev); | ||
89 | struct iio_chan_spec *chan_array; | 103 | struct iio_chan_spec *chan_array; |
104 | struct iio_chan_spec *chan; | ||
90 | int i; | 105 | int i; |
91 | 106 | ||
92 | indio_dev->num_channels = channels; | 107 | indio_dev->num_channels = channels; |
93 | chan_array = kcalloc(indio_dev->num_channels, | 108 | chan_array = kcalloc(channels, |
94 | sizeof(struct iio_chan_spec), GFP_KERNEL); | 109 | sizeof(struct iio_chan_spec), GFP_KERNEL); |
95 | |||
96 | if (chan_array == NULL) | 110 | if (chan_array == NULL) |
97 | return -ENOMEM; | 111 | return -ENOMEM; |
98 | 112 | ||
99 | for (i = 0; i < (indio_dev->num_channels); i++) { | 113 | chan = chan_array; |
100 | struct iio_chan_spec *chan = chan_array + i; | 114 | for (i = 0; i < channels; i++, chan++) { |
115 | |||
101 | chan->type = IIO_VOLTAGE; | 116 | chan->type = IIO_VOLTAGE; |
102 | chan->indexed = 1; | 117 | chan->indexed = 1; |
103 | chan->channel = i; | 118 | chan->channel = i; |
104 | chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); | 119 | chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); |
120 | chan->datasheet_name = chan_name_ain[i]; | ||
121 | chan->scan_type.sign = 'u'; | ||
122 | chan->scan_type.realbits = 12; | ||
123 | chan->scan_type.storagebits = 32; | ||
105 | } | 124 | } |
106 | 125 | ||
107 | indio_dev->channels = chan_array; | 126 | indio_dev->channels = chan_array; |
108 | 127 | ||
109 | return indio_dev->num_channels; | 128 | return 0; |
110 | } | 129 | } |
111 | 130 | ||
112 | static void tiadc_channels_remove(struct iio_dev *indio_dev) | 131 | static void tiadc_channels_remove(struct iio_dev *indio_dev) |