1
0
Fork 0
Commit Graph

602977 Commits (b26b4e91700ff45d033eeaac91597d6d479378a4)

Author SHA1 Message Date
Linus Walleij b26b4e9170 iio: pressure: bmp280: add SPI interface driver
This patch mimics the SPI functionality found in the misc driver in
drivers/misc/bh085-spi.c to make it possible to reuse the existing
BMP280/BMP180/BMP085 driver with all clients of the other driver.
The adoption is straight-forward since like the other driver, it is
a simple matter of using regmap.

This driver is also so obviously inspired/copied from the old misc
driver in drivers/misc/bmp085.c that I just took the liberty to
add in the authors of the other drivers + self in the core driver
file.

The MISC driver also supports a variant named "BMP181" so include
that here to be complete in comparison to the old driver.

The bus mapping code for SPI was written by Akinobu Mita.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Tested-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03 11:27:15 +01:00
Linus Walleij 17118843a5 iio: pressure: bmp280: split off an I2C Kconfig entry
This creates a separate BMP280_I2C Kconfig entry that gets selected
by BMP280 for I2C transport. As we currently only support I2C
transport there is not much practical change other than getting
a separate object file (or module) for the I2C driver part. The
old Kconfig symbol BMP280 will still select the stuff we need so
that oldconfig and old defconfigs works fine.

Tested-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03 11:27:14 +01:00
Linus Walleij 14e8015f85 iio: pressure: bmp280: split driver in logical parts
This splits the BMP280 driver in three logical parts: the core driver
bmp280-core that only operated on a struct device * and a struct regmap *,
the regmap driver bmp280-regmap that can be shared between I2C and other
transports and the I2C module driver bmp280-i2c.

Cleverly bake all functionality into a single object bmp280.o so that
we still get the same module binary built for the device in the end,
without any fuzz exporting symbols to the left and right.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03 11:27:11 +01:00
Linus Walleij bd525e6c75 iio: pressure: bmp280: support supply regulators
The BMP085/BMP180/BMP280 is supplied with two power sources:
VDDA (analog power) and VDDD (digital power). As these may come
from regulators (as on the APQ8060 Dragonboard) we need the driver
to attempt to fetch and enable these regulators.

We FAIL if we cannot: boards should either define:
- Proper regulators if present
- Define fixed regulators if power is hardwired to the component
- Rely on dummy regulators (will be present on all DT systems and
  any boardfile system that calls regulator_has_full_constraints().

Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03 11:26:24 +01:00
Bijosh Thykkoottathil 60b1addba2 drivers:iio:light:isl29125: added macros for sensing range
Added macros for sensing range as the corresponding magic numbers
were used at multiple places.
   - ISL29125_SENSING_RANGE_0 for 375 lux full range
   - ISL29125_SENSING_RANGE_1 for 10k lux full range

Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03 10:19:54 +01:00
Linus Walleij 90efe05562 iio: st_sensors: harden interrupt handling
Leonard Crestez observed the following phenomenon: when using
hard interrupt triggers (the DRDY line coming out of an ST
sensor) sometimes a new value would arrive while reading the
previous value, due to latencies in the system.

We discovered that the ST hardware as far as can be observed
is designed for level interrupts: the DRDY line will be held
asserted as long as there are new values coming. The interrupt
handler should be re-entered until we're out of values to
handle from the sensor.

If interrupts were handled as occurring on the edges (usually
low-to-high) new values could appear and the line be held
asserted after that, and these values would be missed, the
interrupt handler would also lock up as new data was
available, but as no new edges occurs on the DRDY signal,
nothing happens: the edge detector only detects edges.

To counter this, do the following:

- Accept interrupt lines to be flagged as level interrupts
  using IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW. If the line
  is marked like this (in the device tree node or ACPI
  table or similar) it will be utilized as a level IRQ.
  We mark the line with IRQF_ONESHOT and mask the IRQ
  while processing a sample, then the top half will be
  entered again if new values are available.

- If we are flagged as using edge interrupts with
  IRQF_TRIGGER_RISING or IRQF_TRIGGER_FALLING: remove
  IRQF_ONESHOT so that the interrupt line is not
  masked while running the thread part of the interrupt.
  This way we will never miss an interrupt, then introduce
  a loop that polls the data ready registers repeatedly
  until no new samples are available, then exit the
  interrupt handler. This way we know no new values are
  available when the interrupt handler exits and
  new (edge) interrupts will be triggered when data arrives.
  Take some extra care to update the timestamp in the poll
  loop if this happens. The timestamp will not be 100%
  perfect, but it will at least be closer to the actual
  events. Usually the extra poll loop will handle the new
  samples, but once in a blue moon, we get a new IRQ
  while exiting the loop, before returning from the
  thread IRQ bottom half with IRQ_HANDLED. On these rare
  occasions, the removal of IRQF_ONESHOT means the
  interrupt will immediately fire again.

- If no interrupt type is indicated from the DT/ACPI,
  choose IRQF_TRIGGER_RISING as default, as this is necessary
  for legacy boards.

Tested successfully on the LIS331DL and L3G4200D by setting
sampling frequency to 400Hz/800Hz and stressing the system:
extra reads in the threaded interrupt handler occurs.

Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Tested-by: Crestez Dan Leonard <cdleonard@gmail.com>
Reported-by: Crestez Dan Leonard <cdleonard@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-02 20:40:15 +01:00
Linus Walleij cde4cb5dd4 iio: magn: ak8975: deploy runtime and system PM
This adds runtime PM support to the AK8975 driver. It solves two
problems:

- After reading the first value the chip was left in MODE_ONCE,
  meaning (presumably) it may be consuming more power. Now the
  runtime PM hooks kick in and set it to POWER_DOWN.

- Regulators were simply enabled and left on, making it
  impossible to turn the power consuming regulators off because
  of the increased refcount. We now disable the regulators at
  autosuspend.

- We also handle system suspend: by using pm_runtime_force_suspend()
  and pm_runtime_force_resume() from the system PM sleep hooks,
  the runtime PM code is managing the power also for this case.
  It is currently not completely optimal: when the system resumes
  the AK8975 goes into active mode even if noone is going to use
  it: currently the force calls need to be paired, but the runtime
  PM people are working on making it possible to leave devices
  runtime suspended when coming back from sleep.

Inspired by my work on the BH1780 light sensor driver.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:40:16 +01:00
Linus Walleij 8d06cd25f7 iio: magn: ak8975: make sure to power down at remove()
The code was not powering the magnetometer down properly at
remove(): just cutting the regulators without first setting the
device in power off mode. Fix this.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:40:12 +01:00
Linus Walleij b1037c1a49 iio: magn: ak8975: allow a delay after enabling regulators
The datasheet actually specifies that we need to wait atleast
500us after powering on the device before trying to set mode.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:40:04 +01:00
Linus Walleij 9e6c16d989 iio: magn: ak8975: refactor regulator handlers
Move the regulator_get() calls directly into the probe() function,
keep only the power_on()/power_off() functions to flick the
regulators on/off.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:58 +01:00
Linus Walleij b21d3f3452 iio: magn: ak8975: add Vid regulator
The AK8975 has two power sources: Vdd (analog voltage supply)
and Vid (digital voltage supply). Optionally also obtain the Vid
supply regulator and enable it.

If an error occurs when enabling one of the regulators: bail out.

Cc: Gregor Boirie <gregor.boirie@parrot.com>
Cc: Richard Leitner <dev@g0hl1n.net>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:51 +01:00
Linus Walleij 90e96fdd01 iio: magn: ak8975: fix regulator usage
IS_ERR_OR_NULL() should never be used with regulators because
a NULL pointer may be a perfectly valid dummy regulator

We should always succeed to fetch and enable a regulator, but
it may be a dummy. That is fine, so bail out for any real
errors or probe deferrals

Include the error code in the warning print so we know what
kind of problem we're dealing with (for example it is nice to
see if it is a probe deferral).

As we will bail out of probe if the regulator is erroneous,
just issue regulator_disable() on the poweroff path: it will
succeed.

Cc: Mark Brown <broonie@kernel.org>
Cc: Lars-Peter Clausen Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:43 +01:00
Linus Walleij c5842b47b2 iio: pressure: bmp280: add reset GPIO line handling
On the APQ8060 Dragonboard the reset line to the BMP085 pressure
sensor is not deasserted on boot, so the driver needs to handle
this. For a simple GPIO line supplied as a descriptor (from a board
file, device tree or ACPI) this does the trick.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:40 +01:00
Linus Walleij 78f5027132 iio: pressure: bmp280: support device tree initialization
This adds device tree support to the BMP085, BMP180 and BMP280
pressure sensors. Tested on the Qualcomm APQ8060 Dragonboard:

iio:device1$ cat in_temp_input
26700
iio:device1$ cat in_pressure_input
99.185000000

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:36 +01:00
Linus Walleij 8d2c7ef80b iio: pressure: bmp280: augment DT bindings
This adds standard device tree bindings for a reset GPIO line, and
the VDDD and VDDA power regulators.

Cc: devicetree@vger.kernel.org
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 20:39:24 +01:00
Gregor Boirie bc2b7dab62 iio:core: timestamping clock selection support
Adds a new per-device sysfs attribute "current_timestamp_clock" to allow
userspace to select a particular POSIX clock for buffered samples and
events timestamping.

Following clocks, as listed in clock_gettime(2), are supported:
CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW,
CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and
CLOCK_TAI.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Acked-by: Sanchayan Maity <maitysanchayan@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 19:41:38 +01:00
Gregor Boirie eaaa7ec71b timekeeping: export get_monotonic_coarse64 symbol
EXPORT_SYMBOL() get_monotonic_coarse64 for new IIO timestamping clock
selection usage. This provides user apps the ability to request a
particular IIO device to timestamp samples using a monotonic coarse clock
granularity.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 19:41:23 +01:00
Greg Kroah-Hartman 3c9a6793bd Second round of new iio device support, features and cleanups in the 4.8 cycle
Firstly some contact detail updates:
 * NXP took over freescale. Update the mma8452 header to reflect this.
 * Martin Kepplinger email address change in mma8452 header.
 * Adriana Reus has changed email address. Update .mailmap.
 * Matt Ranostay has changed email address. Update .mailmap.
 
 New Device Support
 * max1363
   - add the missing i2c_device_ids for a couple of parts so they can actually
     be used.
 * ms5867
   - add device ids for ms5805 and ms5837 parts.
 
 New Features
 * ad5755
   - DT support.  This one was a bit controversial and under review for a long
     time.  Still no one could come up with a better solution.
 * stx104
   - add gpio support
 * ti-adc081c
   - Add ACPI device ID matching.
 
 Core changes
 * Refuse to register triggers with duplicate names.  There is no way to
   distinguish between them so this makes no sense.  A few drivers do not
   generate unique names for each instance of the device present.  We can't
   fix this without changing ABI so leave them and wait for someone to
   actually take the rare step of two identical accelerometers on the same
   board.
 * buffer-dma
   - use ARRAY_SIZE in a few appropriate locations.
 
 Tools
 * Fix the fact that the --trigger-num option in generic_buffer didn't allow
   0 which is perfectly valid in the ABI.
 
 Cleanups
 * as3935
   - improve error reporting.
   - remove redundant zeroing of a field in iio_priv.
 * gp2ap020a00f
   - use the iio_device_claim_*_mode helpers rather than open coding locking
   around mode changes.
 * isl29125
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * lidar
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * mma8452
   - more detail in devices supported description in comments (addresses and
   similar)
 * sca3000
   - add a missing error check.
 * tcs3414
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * tcs3472
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXdAT2AAoJEFSFNJnE9BaIq68P/3Z0q1lc1cb+K8HV5jgukEKw
 eoxZa5lFIOuHAGeXo9GAdJiH5oT/yAIhadf3gzuuQLaTJwWYKD51aPVwgpT5M2+x
 Bnu2XiYcaoIm/Foat70ycjeYaGxO/xO2vbLp5v0BJV2ujvjm/oCKw5pxYeU4Jm63
 iKaZo9jn/HoshOMpZBrcPZ7Q1TogRdopBNe2fsc8nXFFsv8ODjOZ9Nebs2lk36e+
 PWLUWfSkv2LMBSE2LOFyjSW8E4ItBBngBcyqBTFiiln7mpXU5Vv2QSvUhpP2YjUZ
 rxKvDiG7ADuxMr901whASxyCO180yCxTRIcBsN8oP73gTGHrJnMT0Sptfz7AUUVN
 gJneiy+iy3TecJ/R6w/DnNzqmZMiEVqlYGkdXVGu8SXrKWilvzcTp5iTmDVM5zLb
 1fDZxjbLdNJuHzoSYNiCBcnfzIixOAyKTGFi3jUaPPQ/Lc1qfmgerWWlOzKeUgCZ
 5Bzak8MvWuxcO7jkMG8mbARufy3Nu6eh8a39JXFhViGtTtySydMa8eXdYPjqoAtv
 vgwJNh9U53yYui8i7vU90dM3gJaGg5a4R6EjEKCYcEJf6kM9Go8xCvjU8YWPtIKk
 rfykpPkKcQzbax07YKvb4f015x7r0V6WCGJjPn0Fi14ugNGJJ6M88l+2UcXcx1zS
 RRtVRD49Le7pIDCs1Rqn
 =6Lja
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second round of new iio device support, features and cleanups in the 4.8 cycle

Firstly some contact detail updates:
* NXP took over freescale. Update the mma8452 header to reflect this.
* Martin Kepplinger email address change in mma8452 header.
* Adriana Reus has changed email address. Update .mailmap.
* Matt Ranostay has changed email address. Update .mailmap.

New Device Support
* max1363
  - add the missing i2c_device_ids for a couple of parts so they can actually
    be used.
* ms5867
  - add device ids for ms5805 and ms5837 parts.

New Features
* ad5755
  - DT support.  This one was a bit controversial and under review for a long
    time.  Still no one could come up with a better solution.
* stx104
  - add gpio support
* ti-adc081c
  - Add ACPI device ID matching.

Core changes
* Refuse to register triggers with duplicate names.  There is no way to
  distinguish between them so this makes no sense.  A few drivers do not
  generate unique names for each instance of the device present.  We can't
  fix this without changing ABI so leave them and wait for someone to
  actually take the rare step of two identical accelerometers on the same
  board.
* buffer-dma
  - use ARRAY_SIZE in a few appropriate locations.

Tools
* Fix the fact that the --trigger-num option in generic_buffer didn't allow
  0 which is perfectly valid in the ABI.

Cleanups
* as3935
  - improve error reporting.
  - remove redundant zeroing of a field in iio_priv.
* gp2ap020a00f
  - use the iio_device_claim_*_mode helpers rather than open coding locking
  around mode changes.
* isl29125
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* lidar
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* mma8452
  - more detail in devices supported description in comments (addresses and
  similar)
* sca3000
  - add a missing error check.
* tcs3414
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* tcs3472
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
2016-06-29 15:35:01 -07:00
Sean Nyekjaer 67626cc1a0 iio: ad5755: Add DT binding documentation
Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 21:09:08 +01:00
Sean Nyekjaer c947459979 iio: ad5755: add support for dt bindings
Devicetree can provide platform data

Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 21:09:00 +01:00
Phil Reid 29e3e06d89 iio: buffer-dma: Use ARRAY_SIZE in for loop range
Use the ARRAY_SIZE macro in the for loops that access queue->fileio.blocks.
Macro is already used in a couple of places where this access occurs,
but range was hardcoded in these locations.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 21:06:40 +01:00
Florian Vaussard c48c7b2e47 iio: adc: max1363: Fix missing i2c_device_id for MAX1164x parts
The driver supports MAX11644, MAX11645, MAX11646 and MAX11647 parts. But
the corresponding i2c_device_id are missing. Add them!

Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:13 +01:00
Matt Ranostay 4d462b85e7 iio: proximity: as3935: remove redundant zeroing of tune_cap
This is redundant as the containing stucture is allocated as part of
iio_device_alloc using kzalloc and hence is already 0.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:12 +01:00
William Breathitt Gray 765550e4d9 iio: stx104: Add GPIO support for the Apex Embedded Systems STX104
The Apex Embedded Systems STX104 device features eight lines of digital
I/O (four digital inputs and four digital outputs). This patch adds GPIO
support for these eight lines of digital I/O via GPIOLIB.

Cc: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:11 +01:00
Arnd Bergmann 22ed1a1c1c iio: as3935: improve error reporting in as3935_event_work
gcc warns about a potentially uninitialized variable use
in as3935_event_work:

drivers/iio/proximity/as3935.c: In function ‘as3935_event_work’:
drivers/iio/proximity/as3935.c:231:6: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This case specifically happens when spi_w8r8() fails with a
negative return code. We check all other users of this function
except this one.

As the error is rather unlikely to happen after the device
has already been initialized, this just adds a dev_warn().
Another warning already exists in the same function, but is
missing a trailing '\n' character, so I'm fixing that too.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:10 +01:00
Luis de Bethencourt aea7b1dc2b staging: iio: accel: add error check
Go to error_ret if sca3000_read_ctrl_reg() failed.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:10 +01:00
Dan O'Donovan 7feae871b2 iio: adc: ti-adc081c: add ACPI device ID matching
Add ACPI device ID matching for TI ADC081C/ADC101C/ADC121C ADCs.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:09 +01:00
Crestez Dan Leonard 3b8e73ec82 iio: Refuse to register triggers with duplicate names
The trigger name is documented as unique but drivers are currently
allowed to register triggers with duplicate names. This should be
considered a bug since it makes the 'current_trigger' interface
unusable.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:08 +01:00
Ioana Radulescu 9989b59961 staging: fsl-mc: convert mc command build/parse to use C structs
The layer abstracting the building of commands and extracting
responses is currently based on macros that shift and mask the command
fields and requires exposing offset/size values as macro parameters
and makes the code harder to read.

For clarity and maintainability, instead use an implementation based on
mapping the MC command definitions to C structures. These structures
contain the hardware command fields (which are naturally-aligned)
and individual fields are little-endian ordering (the byte ordering
of the hardware).

As such, there is no need to perform the conversion between core and
hardware (LE) endianness in mc_send_command(), but instead each
individual field in a command will be converted separately if needed
by the function building the command or extracting the response.

This patch does not introduce functional changes, both the hardware
ABIs and the APIs exposed for the DPAA2 objects remain the same.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder adf72b5ba3 staging: fsl-mc: properly set hwirq in msi set_desc
For an MSI domain the hwirq is an arbitrary but unique
id to identify an interrupt.  Previously the hwirq was set to
the MSI index of the interrupt, but that only works if there is
one DPRC.  Additional DPRCs require an expanded namespace.  Use
both the ICID (which is unique per DPRC) and the MSI index to
compose a hwirq value.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder a137fc8058 staging: fsl-mc: dprc: fix ordering problem freeing resources in remove of dprc
When unbinding a dprc from the dprc driver the cleanup of
the resource pools must happen after irq pool cleanup
is done.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder ae34934f9c staging: fsl-mc: dprc: add missing irq free
add missing free of the Linux irq when tearing down interrupts

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Bharat Bhushan f93627146f staging: fsl-mc: fix asymmetry in destroy of mc_io
An mc_io represents a mapped MC portal.  Previously, an mc_io was
created for the root dprc in fsl_mc_bus_probe() and for child dprcs
in dprc_probe().  But the free of that data structure happened in the
general bus remove callback.  This asymmetry resulted in some bugs due
to unwanted destroys of mc_io object in some scenarios (e.g. vfio).

Fix this bug by making things symmetric-- mc_io created in
fsl_mc_bus_probe() is freed in fsl_mc_bus_remove().  The mc_io created
in dprc_probe() is freed in dprc_remove().

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
[Stuart: added check for root dprc and reworded commit message]
Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder fde867d308 staging: fsl-mc: make fsl_mc_is_root_dprc() global
make fsl_mc_is_root_dprc() global so that the dprc driver
can use it

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder ec8d35d430 staging: fsl-mc: export mc_get_version
some drivers (built as modules) rely on mc_get_version()

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder 0afef45654 staging: fsl-mc: add support for device table matching
Move the definition of fsl_mc_device_id to its proper location in
mod_devicetable.h, and add fsl-mc bus support to devicetable-offsets.c
and file2alias.c to enable device table matching.  With this patch udev
based module loading of fsl-mc drivers is supported.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder 57538afb42 staging: fsl-mc: clean up the device id struct
-rename the struct used for fsl-mc device ids to be more
 consistent with other busses
-remove the now obsolete and unused version fields

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder d568b7679f staging: fsl-mc: implement uevent callback and set the modalias
Replace placeholder code in the uevent callback to properly
set the MODALIAS env variable.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Stuart Yoder 3d579c3508 staging: fsl-mc: add support for the modalias sysfs attribute
In order to support uevent based module loading implement modalias support
for the fsl-mc bus driver. Aliases are based on vendor and object/device
id and are of the form "fsl-mc:vNdN".

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-26 17:14:03 -07:00
Wei Yongjun b3e6916d6e staging: wilc1000: fix return value check in wlan_initialize_threads()
In case of error, the function kthread_run() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:41:18 -07:00
Luis de Bethencourt 4562d224ed staging: wilc1000: arrays can't be NULL
hif_drv->usr_scan_req.net.net_info[i] contains found_net_info structs
which have the following element:
u8 bssid[6];

pstrNetworkInfo, of type network_info, also contains an u8 array named
bssid.

request->ssids is an array of cfg80211_ssid structs. Making ssid:
u8 ssid[IEEE80211_MAX_SSID_LEN];

In these 3 cases the arrays are being checked against NULL, which can't
happen. Removing the checks since they will always be true.

Found with smatch:
drivers/staging/wilc1000/host_interface.c:1234 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[i].bssid'
drivers/staging/wilc1000/host_interface.c:1235 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid'
drivers/staging/wilc1000/host_interface.c:1253 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid'
drivers/staging/wilc1000/host_interface.c:1254 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid'

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:41:18 -07:00
Binoy Jayan a5c84b2f67 staging: wilc1000: Change interface wilc_mq_send to wilc_enqueue_cmd
Replace the interface 'wilc_mq_send' with 'wilc_enqueue_cmd'
and remove the now unused structures 'message' and 'message_queue'.
Restructure switch statement in the work queue helper function
host_if_work and remove unwanted indentation.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan 2518ac59eb staging: wilc1000: Replace kthread with workqueue for host interface
Deconstruct the kthread / message_queue logic, replacing it with
create_singlethread_workqueue() / queue_work() setup, by adding a
'struct work_struct' to 'struct host_if_msg'. The current kthread
hostIFthread() is converted to a work queue helper with the name
'host_if_work'.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan c6bb38a5e8 staging: wilc1000: message_queue: Move code to host interface
Move the contents of wilc_msgqueue.c and wilc_msgqueue.h into
host_interface.c, remove 'wilc_msgqueue.c' and 'wilc_msgqueue.h'.
This is done so as to restructure the implementation of the kthread
'hostIFthread' using a work queue.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan 77eebe82eb staging: wilc1000: Remove semaphore close_exit_sync
The semaphore 'close_exit_sync' does not serve any purpose other
than delaying the deregistration of the device which it is trying
to protect from shared access. 'up' is called only when a subdevice
is closed and not when it is opened. So, the semaphore count only
goes up when the device is used.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan 04247e7d65 staging: wilc1000: Replace semaphore sync_event with completion
The semaphore 'sync_event' is used as completion, so convert
it to a struct completion type. Also, return -ETIME if the return
value of wait_for_completion_timeout is 0.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan fa6596982f staging: wilc1000: Replace semaphore cfg_event with completion
The semaphore 'cfg_event' is used as completion, so convert
it to a struct completion type.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan 334bed089d staging: wilc1000: Replace semaphore txq_add_to_head_cs with mutex
The semaphore 'txq_add_to_head_cs' is a simple mutex, so it should be
written as one. Semaphores are going away in the future. Also, removing
the timeout scenario as the error handling code does not propagate the
timeout properly.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Binoy Jayan b27a6d5e63 staging: wilc1000: Replace semaphore txq_event with completion
The semaphore 'txq_event' is used as completion, so convert it
to a struct completion type.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:39:53 -07:00
Julia Lawall b9811891a9 staging: wilc1000: fix typo
firmare -> firmware

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-25 14:38:49 -07:00