staging:iio:sca3000: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:lis3l02dq: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7759: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7758: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7754: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:ade7753: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:adis16400: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:adis16200: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.
The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Kim, Milo [Tue, 18 Sep 2012 04:56:00 +0000 (05:56 +0100)]
iio: inkern: clean up error return code
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>
Kim, Milo [Tue, 18 Sep 2012 04:55:00 +0000 (05:55 +0100)]
iio: inkern: put the IIO device when it fails to allocate memory
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>
When hid sensor hub is unplugged, there is a crash in
iio_device_unregister_trigger_consumer.
In a typical IIO driver when remove is called, it will unregister and free
trigger and then it will call iio_device_free.
The function iio_trigger_free() will free the allocated memory for trigger.
If this trigger was assigned to iio_dev->trig, then it should be set to NULL.
Othewise when iio_device_free() is called later, it finally calls
iio_device_unregsister_trigger(), which checks for
if (indio_dev->trig)
iio_trigger_put(indio_dev->trig);
If indio_dev->trig is not set to NULL, it calls iio_trigger_put on a bad
pointer causing crash.
This scenerio can happen in any driver, which is storing trigger pointer in
iio_dev structure and following current procedure during remove.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This fixes up the usb1401.c file to remove the usage of err() (which is
gone), and the two-argument kmap_atomic() call, and the compat_ioctl
pointer warning.
The code now builds properly, there are lots of warnings still, but it's
a start.
Cc: Alois Schlögl <alois.schloegl@ist.ac.at> Cc: Greg P. Smith <greg@ced.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This was imported from the
http://pub.ist.ac.at/~schloegl/src/ced1401/.git git repo at the request
of Alois. The driver originally came from Cambridge Electronic Design
Ltd and was authored by Greg P Smith and others, but Alois did the
maintance work to get it into a semi-building state and pushed to get it
into the main kernel tree here.
Cc: Alois Schlögl <alois.schloegl@ist.ac.at> Cc: Greg P. Smith <greg@ced.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: pcmmio: remove kernel messages about IRQ
These messages are just added noise.
They also cause some sparse warnings due to MAX_ASICS evaluating
as 1. This causes the local variable 'irq' to be 'unsigned int irq[1]',
which makes the 'irq[1]' access invalid.
Just remove the messages.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: ni_mio_common: make internal functions static
The functions ni_release_gpct_mite_channel() and ni_prime_channelgain_list()
are only referenced in this file. Make it static.
The function ni_release_gpct_mite_channel() is also only called
when PCIDMA is enabled. Move the #ifdef to quite a sparse warning
about the function not being used.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Javier M. Mellid [Mon, 17 Sep 2012 14:12:47 +0000 (16:12 +0200)]
staging: sm7xxfb: clean fb_fix_screeninfo and fb_var_screeninfo initialization
Part of fb_fix_screeninfo and fb_var_screeninfo initialization happens
in smtc_alloc_fb_info. It duplicates code while hiding the real
functionality of smtc_alloc_fb_info. This patch groups initialization
together.
Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Randy Dunlap [Mon, 17 Sep 2012 17:33:18 +0000 (10:33 -0700)]
staging: fix csr printk format warning
Fix printk format warning on i386/X86_32 by using 't' for ptrdiff_t.
Also builds cleanly on x86_64.
drivers/staging/csr/csr_wifi_hip_udi.c: In function 'unifi_print_status':
drivers/staging/csr/csr_wifi_hip_udi.c:151:27: warning: format '%ld' expects type 'long int', but argument 5 has type 'int'
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Merge tag 'iio-for-v3.7d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
IIO new drivers, features and rework for the 3.7 cycle, 4th set.
Here we have
1) a set cleaning up and moving the ad7476 driver out of staging.
Support for a number of additional parts is also added to that driver.
2) cleanups from various people for the in kernel interface code as that
is getting more an more real use and hence people are picking up on
minor issues that made it through review. Also a related useful set
of utility functions to avoid duplicate code for converting IIO
representations to other forms.
3) a new fractional type for our read_raw / write_raw functions.
This allows avoiding loss of accuracy via the in kernel interfaces in some
cases as well as being rather convenient for a lot of range -> scale
conversions.
4) New AD5755 DAC driver.
5) Some Blackfin timer trigger improvements including hardware pulse control
for device triggering.
Add support for the ad7091r 12 bit ADC to the ad7476 driver. Although the
ad7091r is not really related to any of the other devices supported by this
driver, luckily for us there are not so many ways (which are not totally insane)
how sampling a single channel ADC via SPI can be implemented and support for the
ad7091r can be added to the driver with just a few adjustments.
The ad7091r requires an external "conversion start" pulse to start a sample
conversion. After the conversion has finished the result can be read via SPI. We
depend on a IIO trigger to generate this signal, as a result only sampling in
buffered mode and not in manual mode is available.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:trigger:bfintmr: Only enable timer when necessary
This patch hooks up the set_trigger_state callback for the blackfin timer
trigger driver and only enables the timer when a trigger consumer requests it to
be enabled. There really is no reason to keep the timer running and generate
interrupts if nobody is listening to them.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
If the timer frequency has not been configured yet get_gptimer_period() will
return 0. Handle this case instead of blindly dividing by the returned value.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
staging:iio:hwmon bridge: Use iio_read_channel_processed
Use the iio_read_channel_processed function to read the sample value in the
proper unit instead of using iio_read_channel_raw and iio_read_channel_scale and
doing the unit conversion manually.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio:inkern: Add function to read the processed value
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>
For the iio_read_channel_raw and iio_read_channel_scale the kerneldoc comment
refers to an argument called "channel", while the argument is called "chan" in
the function signature. This leads to the following warnings from kerneldoc:
Warning(include/linux/iio/consumer.h:71): No description found for parameter 'chan'
Warning(include/linux/iio/consumer.h:71): Excess function parameter 'channel' description in 'iio_read_channel_raw'
Warning(include/linux/iio/consumer.h:109): No description found for parameter 'chan'
Warning(include/linux/iio/consumer.h:109): Excess function parameter 'channel' description in 'iio_read_channel_scale'
This patch fixes the warnings by naming them consistently.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This patch adds support for the AD5755, AD5755-1, AD5757, AD5735, AD5737 16 and
14 bit quad-channel DACs. The AD5757/AD5737 only have current outputs, but
for the AD5755/AD5757 each of the outputs can be configured to either be a
voltage or a current output. We only allow to configure this at device probe
time since usually this needs to match the external circuitry and should not be
changed on the fly.
A few trivial formatting changes on merge.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Kim, Milo [Mon, 17 Sep 2012 08:44:00 +0000 (09:44 +0100)]
iio: inkern: add error case in iio_channel_get()
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>
Ben Hutchings [Sun, 16 Sep 2012 03:18:50 +0000 (04:18 +0100)]
staging: speakup_soft: Fix reading of init string
softsynth_read() reads a character at a time from the init string;
when it finds the null terminator it sets the initialized flag but
then repeats the last character.
Additionally, if the read() buffer is not big enough for the init
string, the next read() will start reading from the beginning again.
So the caller may never progress to reading anything else.
Replace the simple initialized flag with the current position in
the init string, carried over between calls. Switch to reading
real data once this reaches the null terminator.
(This assumes that the length of the init string can't change, which
seems to be the case. Really, the string and position belong together
in a per-file private struct.)
Tested-by: Samuel Thibault <sthibault@debian.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: silicom: fix a comparing proc_dir_entry pointer against 0
we should be using the NULL macro, not 0 to compare against
a pointer value, and also remove braces around the single
if conditional after the create_proc_entry
Dan Carpenter [Fri, 14 Sep 2012 08:11:35 +0000 (11:11 +0300)]
Staging: silicom: use kstrtoint_from_user()
The main problem with the hand rolled code was that there weren't any
range checks so you could corrupt memory by writing too much data to
the proc file.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Daniel Cotey <puff65537@bansheeslibrary.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 14 Sep 2012 16:34:35 +0000 (17:34 +0100)]
staging: comedi: mite: use module_init()/module_exit()
Rename the standard `init_module()` and `cleanup_module()` functions and
make them static. Use `module_init()` and `module_exit()` to mark the
renamed functions as the module init and exit functions.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 14 Sep 2012 16:34:34 +0000 (17:34 +0100)]
staging: comedi: mite: remove list of devices
All the drivers that use the "mite" module now allocate a `struct
mite_struct` dynamically instead of searching the `mite_devices` list
populated during initialization of the "mite" module.
Remove the list of devices and the function that prints available NI
devices on the list (`mite_list_devices()`). The list node and `used`
members in `struct mite_struct` are now redundant, so remove them.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This driver's comedi `detach` handler (`ni_670x_detach()`) calls
`free_irq()` but the driver doesn't call `request_irq()` anywhere.
Remove the spurious call.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 14 Sep 2012 16:34:25 +0000 (17:34 +0100)]
staging: comedi: mite: add mite_alloc() and mite_free()
Add `mite_alloc()` to allow drivers to allocate and initialize a `struct
mite_struct` dynamically and export it. Add `mite_free()`, which is
currently just an inline wrapper for `kfree()`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ian Abbott [Fri, 14 Sep 2012 16:34:23 +0000 (17:34 +0100)]
staging: comedi: mite: use ilog2()
The static inline functions `MITE_IODWBSR_1_WSIZE_bits()` and `CR_RL()`
in "mite.h" work out a base-2 logarithm using a `while` loop. Change
them to use `ilog2()`. Also change `CR_RL()` to clamp the maximum value
instead of printing an error.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>