summaryrefslogtreecommitdiffstats
path: root/drivers/iio/inkern.c
Commit message (Collapse)AuthorAgeFilesLines
* staging:iio:in kernel users: Add a data field for channel specific info.Jonathan Cameron2012-11-101-0/+1
| | | | | | | Used to allow information about a given channel mapping to be passed through from board files to the consumer drivers. Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: Add a logarithmic fractional value typeLars-Peter Clausen2012-10-191-0/+3
| | | | | | | | | | | For ADCs or DACs the denominator for fractional types often is a power of two. In this case we can use a shift operation instead of the rather expensive 64 bit division. This patch adds a new fractional type which expects the denominator to be specified as the log2 of the actual denominator. E.g. for ADCs and DACs this will usually be the number of significant bits. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: Don't compare boolean values to true/falseLars-Peter Clausen2012-10-191-1/+1
| | | | | | | | | Fixes the following warnings from coccicheck: drivers/iio/inkern.c:81:6-14: WARNING: Comparison to bool drivers/iio/dac/ad5686.c:191:5-11: WARNING: Comparison to bool Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: inkern: clean up error return codeKim, Milo2012-09-221-5/+8
| | | | | | | | | | | | | | | | | | | | | When the IIO consumer tries to get specific IIO channel, few error cases can be happened. (a) Memory allocation failure (b) No matched ADC channel error (c) Invalid input arguments This patch enables cleaning up error handling in case of (a) and (b). In error handling code, (a): the reference count of the IIO device should be decreased. (b): the allocated memory should be freed with restoring the reference count. Therefore iio_deivce_put() is called in both cases. This can be handled in the last error statement. Additionally, integer variable is used for stating each error case explicitly. Then, the error returns as ERR_PTR() with this value. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: inkern: put the IIO device when it fails to allocate memoryKim, Milo2012-09-221-1/+4
| | | | | | | | | | | | The reference count of the IIO device is increased if the IIO map has matched consumer name. After then, it tries to allocate the iio_channel which is used by the consumer. If it fails to allocate memory, the reference count should be decreased. This patch enables restoring the reference count of the IIO device. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio:inkern: Add function to read the processed valueLars-Peter Clausen2012-09-171-9/+109
| | | | | | | | | | | | | Add a function to read a processed value from a channel. The function will first attempt to read the IIO_CHAN_INFO_PROCESSED attribute. If that fails it will read the IIO_CHAN_INFO_RAW attribute and convert the result from a raw value to a processed value. The patch also introduces a function to convert raw value to a processed value and exports it, in case a user needs or wants to do the conversion by itself. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: inkern: add error case in iio_channel_get()Kim, Milo2012-09-171-1/+10
| | | | | | | | | | | | | | | | | | | | The datasheet name is defined in the IIO driver. On the other hand, the adc_channel_label is configured in the platform side. If the datasheet name is not matched with any adc_channel_label, the iio_channel_get() should be returned as error for preventing invalid channel data access. This can be handled either way. (a) checking null data when using it : in the xxx_read_raw() or (b) error returns when the channel is requested : this patch The IIO consumer can't use the channel with invalid channel spec. Therefore case (b) is more reasonable. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: inkern: allocate zeroed memoryKim, Milo2012-09-151-1/+1
| | | | | | | | | | | | | | | | Use kzalloc() rather than kmalloc() for initializing the iio_channel structure. This patch enables the iio_dev and iio_chan_spec are set to NULL. This may prevent the page fault problem because the pointer of iio_chan_spec is initialized as NULL. The iio_chan_spec is updated only in case that the IIO map has specific channel label. When the map has no ADC channel label, then the value of iio_chan_spec remains as invalid pointer. To prevent this problem, the pointer should be initialized as NULL. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: use IIO_CHAN_INFO_RAW rather than 0Kim, Milo2012-08-271-2/+4
| | | | | | | | | (a) For better readability, replace 0 with IIO_CHAN_INFO_RAW. (b) Make same line-format as other apis() : iio_read_channel_scale() and iio_read_channel_offset() Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: double unlock on error pathDan Carpenter2012-07-121-1/+2
| | | | | | | We should be holding the mutex when we goto error_free_chans. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: Fix inkern remove incorrect put of deviceJonathan Cameron2012-07-081-1/+0
| | | | | | | The device_get is after this point so on error we should not be removing it. Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: Rename _st_ functions to loose the bit that meant the staging version.Jonathan Cameron2012-06-301-18/+15
| | | | | | | | | These were originally introduced when the plan was to have parallel IIO cores in and out of staging with a slow move between them. Now we have reached the point where the whole core has moved, they need clearing up! Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio:inkern: Use iio_device_{get,put}Lars-Peter Clausen2012-06-041-7/+6
| | | | | | | | | Use iio_device_get and iio_device_put instead of open-coding it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 3.4-rc5 into staging-nextGreg Kroah-Hartman2012-05-021-0/+1
| | | | | | | This resolves the conflict in: drivers/staging/vt6656/ioctl.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* IIO: Move the core files to drivers/iioJonathan Cameron2012-04-251-0/+292
Take the core support + the kfifo buffer implentation out of staging. Whilst we are far from done in improving this subsystem it is now at a stage where the userspae interfaces (provided by the core) can be considered stable. Drivers will follow over a longer time scale. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
OpenPOWER on IntegriCloud