Commit graph

42928 commits

Author SHA1 Message Date
Greg Kroah-Hartman
148e0b8f48 staging: greybus: spi: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus SPI and spilib
driver, so remove the checks as needed, we can now rely on all of the
correct SPI core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:43:27 +02:00
Greg Kroah-Hartman
3e4b5b8837 staging: greybus: gpio: it's CONFIG_GPIOLIB, not CONFIG_GPIO
The GPIO dependancy is CONFIG_GPIOLIB, not CONFIG_GPIO, no wonder it
wasn't building properly...

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:41:54 +02:00
Greg Kroah-Hartman
b14bb97626 staging: greybus: gpio: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus GPIO driver, so
remove the checks as needed, we can now rely on all of the correct
GPIO core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:41:45 +02:00
Greg Kroah-Hartman
06000c0317 staging: greybus: vibrator: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus Vibrator driver,
so remove the checks as needed, we can now rely on all of the correct
driver core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:41 +02:00
Greg Kroah-Hartman
be21106d67 staging: greybus: hid: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus HID driver, so
remove the checks as needed, we can now rely on all of the "new" apis
being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:41 +02:00
Greg Kroah-Hartman
887520884b staging: greybus: kernel_ver.h: remove lots of stuff
Now that we do not care about the kernel version we are building
against, we can strip out lots of backward compatibilty that was added
to kernel_ver.h in order to write semi-portable driver code.

To start with, remove the functions and #defines that are now in the
kernel tree, no need to have duplicate copies of them all.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:40 +02:00
Greg Kroah-Hartman
d4f56b47a8 staging: greybus: Add drivers/staging/greybus to the build
This adds a proper Kconfig file for drivers/staging/greybus and fixes up
the Makefile to work correctly within the kernel build system (modules
depend on the .config options, etc.)

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:30:37 +02:00
Greg Kroah-Hartman
526dec0642 staging: greybus: remove old es1 endpoint description
The Toshiba ES1 chip is no longer around, so remove the USB descriptor
documentation for it as no one cares anymore.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:40:33 +02:00
Greg Kroah-Hartman
ecfea541e6 staging: greybus: remove .gitignore file
Only the tools subdirectory needs a .gitignore entry, so move it there
and fix it up to only list the needed file.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:37:09 +02:00
Greg Kroah-Hartman
0be6dfc296 staging: greybus: remove README and LICENSE
We don't need yet-another-copy of the GPLv2 in the tree, and the README
is now pointless, so remove both of these files.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:36:24 +02:00
Greg Kroah-Hartman
bc5aa3a079 staging: greybus: Documentation: remove sysfs tree
We do not need an example of the sysfs tree in the kernel code itself,
so remove these files, as they are now pointless.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:35:16 +02:00
Greg Kroah-Hartman
dae0901111 greybus: remove local checkpatch.pl copy
When the greybus tree was external, it contained a copy of checkpatch.pl
to keep everyone "in line".  This is no longer needed and can now be
removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:33:38 +02:00
Greg Kroah-Hartman
f44dd18463 Merge greybus driver tree into 4.8-rc6
This pulls the external greybus driver tree into 4.8-rc6 as it should be
part of the main kernel tree and not live outside in some lonely github
repo, never to be reunited with it's true love...

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-19 12:29:33 +02:00
Axel Haslam
7398a66f10 greybus: gbphy: fix compile error with CONFIG_PM_RUNTIME disabled
gb_phy runtime functions use struct gbphy_device *gbphy_dev,
and not struct device. When CONFIG_PM_RUNTIME is not enabled
a compile error will show.

Fix this by passing struct gbphy_device * as parameter

Testing Done: compile with CONFIG_PM_RUNTIME disabled

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-08 19:50:57 +02:00
Viresh Kumar
88f6ba61f2 greybus: gpio: create irqdomain before registering gpio controller
If a gpio line is getting used for an irq, gpio core will create
/proc/irq/X/gpiolib/ directory for it. This directory gets removed while
the gpio controller is unregistered.

In case of greybus, gb_gpio_irqchip_add() creates an irqdomain and
creates irq mappings for the gpio lines. Currently they are added after
registering the gpio controller and removed before the gpio controller
is removed. On the removal path, while the core tries to remove the irq
directory (/proc/irq/X), it finds that the irq is still getting used and
a "gpiolib" directory is present within it and so it gives this warning:

Steps to reproduce:

    $ cd /sys/class/gpio
    $ echo X > export
    $ echo both > gpioX/edge
    $ echo <interface-number> > /sys/bus/greybus/devices/1-svc/intf_eject

[  139.171436] ------------[ cut here ]------------
[  139.171468] WARNING: at /home/vireshk/all/work/repos/ara/arche/kernel/arche/fs/proc/generic.c:552 remove_proc_entry+0x154/0x188()
[  139.171476] remove_proc_entry: removing non-empty directory 'irq/683', leaking at least 'gpiolib'
[  139.171589] Modules linked in: gb_vibrator(O) gb_usb(O) gb_uart(O) gb_spi(O) gb_sdio(O) gb_raw(O) gb_pwm(O) gb_power_supply(O) gb_loopback(O) gb_log(O) gb_light(O) gb_i2c(O) gb_hid(O) gb_gpio(O) gb_gbphy(O) gb_firmware(O) gb_spilib(O) gb_es2(O) gb_camera(O) gb_bootrom(O) gb_audio_module(O) gb_audio_manager(O) gb_audio_codec(O) gb_audio_gb(O) gb_audio_apbridgea(O) gb_arche(O) greybus(O)
[  139.171605] CPU: 1 PID: 280 Comm: kworker/u16:4 Tainted: G        W  O 3.10.83-g9771b10cbeed #107
[  139.171652] Workqueue: greybus1:svc gb_svc_intf_set_power_mode [greybus]
[  139.171657] Call trace:
[  139.171677] [<ffffffc000207b40>] dump_backtrace+0x0/0x268
[  139.171689] [<ffffffc000207db8>] show_stack+0x10/0x1c
[  139.171707] [<ffffffc000ccad78>] dump_stack+0x1c/0x28
[  139.171723] [<ffffffc00021f9dc>] warn_slowpath_common+0x74/0x9c
[  139.171735] [<ffffffc00021fa60>] warn_slowpath_fmt+0x5c/0x80
[  139.171747] [<ffffffc00035fa38>] remove_proc_entry+0x150/0x188
[  139.171763] [<ffffffc00027464c>] unregister_irq_proc+0xb4/0xdc
[  139.171779] [<ffffffc00026e3f4>] free_desc+0x2c/0x70
[  139.171791] [<ffffffc00026e48c>] irq_free_descs+0x54/0x9c
[  139.171802] [<ffffffc000273448>] irq_dispose_mapping+0x54/0x64
[  139.171814] [<ffffffbffc0621e8>] 0xffffffbffc0621e8
[  139.171825] [<ffffffbffc05e01c>] 0xffffffbffc05e01c
[  139.171843] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[  139.171854] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[  139.171867] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[  139.171878] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[  139.171888] [<ffffffc0005d1d64>] device_unregister+0x50/0x68
[  139.171901] [<ffffffbffc05e2bc>] gb_gbphy_deregister_driver+0xf0/0x4ec [gb_gbphy]
[  139.171924] [<ffffffbffc0014c4>] greybus_disabled+0x14c4/0x1760 [greybus]
[  139.171936] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[  139.171948] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[  139.171959] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[  139.171969] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[  139.171992] [<ffffffbffc004cec>] gb_bundle_destroy+0x7c/0x1b0 [greybus]
[  139.172017] [<ffffffbffc004074>] gb_interface_disable+0xb4/0x178 [greybus]
[  139.172040] [<ffffffbffc002ae4>] gb_module_del+0x5c/0xf8 [greybus]
[  139.172063] [<ffffffbffc008418>] gb_svc_intf_set_power_mode+0xea0/0xfe8 [greybus]
[  139.172078] [<ffffffc00023888c>] process_one_work+0x268/0x3c8
[  139.172089] [<ffffffc000239a64>] worker_thread+0x204/0x358
[  139.172108] [<ffffffc00023f43c>] kthread+0xb8/0xc4
[  139.172114] ---[ end trace 6fa3314e8c6157ca ]---

Also note that registering the gpio controller before creating irqdomain
is incorrect as well and may lead to kernel panic, as a gpio may get
requested as an interrupt source right after the controller is
registered, and the greybus gpio driver wouldn't be fully ready by then.

This patch changes the sequence in both probe() and remove() to fix it.

Fixes: 426e88a47d39 ("greybus: gpio: add interrupt handling support")
Reported-by: David Hsu <davidhsu@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-05 09:16:47 +02:00
Greg Kroah-Hartman
272291008f greybus: es2: fix up usb probe error messages
Properly report which endpoints are being ignored and which ones are
"unknown" to the driver.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
1521eb6b69 greybus: es2: No need to check before freeing an urb
usb_kill_urb() and usb_free_urb() can be called with NULL pointers, so
no need to check before calling them.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
fc994f0f83 greybus: es2: remove unneeded BULK_* #defines
We don't need the defines for the number of bulk in or out endpoints
anymore, as the driver just grabs the first ones it finds and runs with
it.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
7330c48ec0 greybus: es2: remove bulk_in array
We only care about one bulk IN endpoint for cports, and one for ARPC, so
drop the array of bulk IN endpoints to simplify things.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
403074b50b greybus: es2: remove bulk_out array
We only care about one bulk out endpoint, the first one, so remove
the pretense of keeping an array of these things.  Just grab the first
one in the list and run away!

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
84d5077cae greybus: es2: remove struct cport_to_ep
We were not really using this structure at all, it was only returning
'0' when asked what cport matched to what pair, so remove it all.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Greg Kroah-Hartman
b6c1bd3a8e greybus: es2: remove #if 0 code
These functions were never used, and we are about to remove the
structures it was trying to reference, so let's remove it to get it out
of the way.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Sandeep Patil
4de02894a2 greybus: es2: use a single bulk ep pair for all greybus data
This matches a corresponding firmware change to declare a single
BULK EP pair for all greybus traffic and 1 BULK IN ep for ARPC.

Thus, avoiding URB submittions for all the other unused BULK IN
endpoints on the HOST side that took considerable amount
of bus time.

Testing Done:
Tested with modified AP<->APB1 loopback test and also with GPBridge
modules to ensure there are no regressions

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:20:56 +02:00
Johan Hovold
6fa4d3d5bb greybus: greybus_protocols: remove svc key-event type
Remove the deprecated svc key-event type, which has already been removed
from the specification.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Philip Yang
4e013b64c1 greybus: power_supply: Add runtime pm support
Modify Power_supply greybus driver to support runtime PM framework.

During charging state, the driver will block remote device of suspending,
and then enables runtime suspend when remote device is in none chargin
state.

Testing Done: Compiled and verified on EVT2, EVT2 1x2 GPB test module
              and Device class daughter board.

Signed-off-by: Philip Yang <yang_philip@projectara.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
6a57ddc97a greybus: audio: Avoid reporting spurious button events
Now jack-button are registered to snd framework based on capabilities
populated by codec module's topology data. Thus, valid ids for button
events can also vary for different modules. This patch modifies existing
button reporting mechanism to avoid reporting spurious button events for
invalid button ids.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
cec89df446 greybus: audio: Report jack events conditionally
Now jack & jack-buttons are registered to snd_jack framework based on
the capability shared by module's topology data. Thus, jack events
should be reported to above snd framework only in case corresponding
jack type is registered. This patch adds additional checks to avoid
reporting fake jack events.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
847175e8e6 greybus: audio: Fetch jack_mask, button_mask from module's topology data
Added extra fields namely jack_mask & button_mask for each module_info.
These fields are required while registering jack & reporting jack
events.

Earlier, these were hard coded values assuming fixed capabilities say
HEADSET, LINEOUT, etc. supported by GB-codec driver. Now these are
computed dynamically based on module's jack capability shared via
topology data.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
a695c302b4 greybus: audio: Added jack_type support in topology struct
This patch adds extra field jack_type to gb_audio_topology struct. Also,
it defines bit fields to be used by module while defining it's jack and
jack-button capabilities.

Currently, module can populate a single jack and associated buttons. In
case multiple jacks are supported data routing (say duplicating, etc.)
should be handled within module's FW. It can populate additional mixer
controls to do so.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Vaibhav Agarwal
79c222bcb7 greybus: audio: Remove unnecessary num_jack field from module_info
snd_jack will be registered based on real capabilities shared by
module's FW instead of parsing widgets and register it with fixed
capabilities. Remove module_info->num_jack, since it is no more
required.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-02 14:13:39 +02:00
Johan Hovold
1f3e09e759 greybus: svc: fix timeout indentation
Make sure the timeout values are aligned.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
1b1732c4c4 greybus: es2: remove obsolete cport-reset ARPC
Remove the now obsolete and redundant cport-reset ARPC, along with the
consequently unused cport_disable callback.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
2045c9f265 greybus: hd/es2: remove obsolete callbacks
Remove the now obsolete ping and cport_features_enable/disable
callbacks.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
aac0839ea2 greybus: connection: implement new connection handling
Implement the new connection setup and tear-down sequences for control
connections and bundle connections (offloaded and non-offloaded).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
77e52b3b0b greybus: es2: implement shutdown callback
Implement the shutdown callback which is used to execute shutdown
operations on offloaded connections.

This adds a new shutdown ARPC.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Johan Hovold
d2dee94b66 greybus: es2: implement flush callback
Implement the flush callback which is called as part of connection tear
down to flush host-device queues and stop any ongoing transfers.

Note that this should be considered an optimisation of sort since if
the CPort is stuck waiting for credit, the CPort is likely still stuck
when we try to send the cport_shutdown request over it after the
callback returns.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:21:13 +02:00
Rui Miguel Silva
6ac9166d4e greybus: power_supply: fix name setting location
We were checking for existing power supply names in the wrong place,
i.e, we were checking before any of the module power supply were
registered, because of that of course no name collision was detected.

Move the check to the register loop and with that we guarantee that this
mechanism works for greybus power supply naming.

Tested: using gbsim and using power supply with the same name and check
that: 1. no problems creating sysfs entries; 2. naming is done following
the desired rules.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:16:11 +02:00
Kris Huang
cc43368a3c greybus: lights: Control runtime pm suspend/resume on AP side
According to runtime pm architecture, the kernel side driver should be
as smart as needed to know when the module is idle or active, so that it can
issue the suspend/resume operations to the firmware side at the right time.
To add logics prevents AP from issuing the suspend request to the firmware
when a channel turning to active state, and put it to suspend if the state
is going to inactive with still holding a reference.

Testing Done: Compiled and verified on EVT2 and gpbridge-test module
              with device class daughter board.

Signed-off-by: Kris Huang <huang_kris@projectara.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:16:11 +02:00
David Lin
0e352343c2 greybus: light: fix incorrect led attribute files allocation
Fix incorrect attribute size when the channel supports fader, as well as
fixing the issue that the attribute list is not null terminated.

Testing Done:
 - Verified by setting brightness and color on red/green/blue leds
   of the device class test board.

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:16:11 +02:00
Mark Greer
f0ec8cd5eb greybus: audio: Fix incorrect direction value when enabling RX
The direction value passed to gb_audio_apbridgea_register_cport()
in the gbaudio_module_enable_rx() routine is TX and not RX like
it should be so fix it.

Testing Done: Recorded microphone data from a headset.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Fixes: c80e7c6fafa5 ("audio: Split helper APIs based on stream direction")
Tested-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewd-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-26 13:16:11 +02:00
Greg Kroah-Hartman
eafe5cfe71 First round of IIO fixes for the 4.8 cycle.
This is somewhat of a bumper set due to my unavailabilty earlier in the
 month.  The only slightly unusual ones are the dts updates for the
 rockchip adc reset.  The fix in the driver only makes sense with these
 and the rockchip maintainer is happy with them going through IIO to
 reach mainline.
 
 Core stuff
 
 * Fix an issue with a blocking op when !TASK_RUNNING. This been there
   a while and snuck in with seemingly minor additions to some core
   code paths.
 * Tools
   - generic_buffer failed to initialize the channel array pointer thus
     in the case of no channels blows up trying to free a random memory
     address.
 * sw-trigger:
   - Fix config group initialization when configfs is built as a module.
 
 Drivers
 
 * ad5933
   - Fix an incorrect overwrite of an error value.
 * ad799x
   - A missed assignment of the update_scan_mode callback means buffered mode
     doesn't work on the ad7991, ad7995 or ad7999.
 * ads1015
   - wrong pointer returned from i2c_get_clientdata (missmatch of assumptions)
 * am2315
   - Timestamps are reported, but never actually acquired from anywhere
     (so always 0)
   - missing buffer selects in Kconfig
 * am335x adc
   - Protect fifo1 from concurrent access.
   - Increase timeout waiting for ADC to be long enough in all cases.
 * as3935
   - Timestamps are reported, but never actually acquired from anywhere
     (so always 0)
 * at91
   - Fix reading of channel 3.
 * atlas-ph-sensor
   - Typo means that the scale of electrical conductivity readings is way off.
 * bma220
   - Timestamps are reported, but never actually acquired from anywhere
     (so always 0)
   - Missing buffer selects in Kconfig
 * bmp280
   - pass the write pointer to PTR_ERR (i.e. the one that was just checked
     with IS_ERR).
   - suspend /resume crash due to wrong assumption about what dev_get_drvdata
     would return.
 * hdc100x
   - It superficially appeared that smbus_read_byte commands would allow
   reading of the outputs in two goes.  In reality it doesn't work, but
   instead returns the same for the upper and lower bytes (nice catch from
   Alison!)
 * kxsd9
   - Fix raw read return value to ensure it actually reports the value rather
   than a blank string.
 * max44000
   - Missing buffer selects in Kconfig
 * rockchip_saradc
   - Add use of reset controller to enforce a clean state of the ADC.
     Some bootloaders can leave it in an 'intersting' state and effectively
     frozen without this. A couple of associated dts updates.
 * stk8ba50
   - Missing buffer selects in Kconfig
 * stx104
   - Fix a possible race due to use of devm_iio_device_register when there
     was other stuff in the remove function.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIuBAABCAAYBQJXvJbQERxqaWMyM0BrZXJuZWwub3JnAAoJEFSFNJnE9BaIgQoP
 /05c7WzyhRxobrQGMIJShTA5/SMwrZa8Lc9z5rbjc7WEB0oPk+gw53ajWoEJYrj0
 oC5V2iYWhqsQOQ52OgD7jng85Z1LOXW2gWZW/rd4H27iCpBJqDQNjdOo8tbFjfDe
 oOVyhXvqmq8TPddAjX1gWJS9QC46rMAbTQpKtyJ75acttsRS+Hmn12ZdTiz6SDjm
 SGKgZM9RvhBephb33u75S4u8kkcsv3M+1dAOz4Uf1lSzTZq2wBdSoePwaPCb35sL
 9fbo8qTGUUa85rkwWmnGqnds0/v6ZNW0rcLaChb5YE8eQBQ+JCNDDF+p9HqQestj
 gzBHKOGampc/feNY4kB/aClzq/9fmS+eYPGUOiCM5Lv5Ck9lko/kUbequJbXgOoS
 87/BOTytNMmd5K4Sagm92vOl0piXSZAzhxiq2njaipIeqo0nfdNSrpWn91pEKWag
 sjcoPKhHukxXXJutaWRXNey1pGGJjflkFC9T6RJUVBS4/IuBvRCTQGvxVidzsgrT
 2bZ3ZIzz/nFjQ0dub+YEtN2t+tESKZDBuFgyYefULIpUKTmoSgrq0R8Pa8XZLNxq
 BpHbHQuJjL/hcFz6h8wgv16IFhjK3qT71VcGF78XQDyQhHXdwHAr/ioZ5M6kIgU4
 tRzBe0+wQsVqAr0cryptlWXsMskDzC9prRf5viYYiNuu
 =Hra7
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-linus

Jonathan writes:

First round of IIO fixes for the 4.8 cycle.

This is somewhat of a bumper set due to my unavailabilty earlier in the
month.  The only slightly unusual ones are the dts updates for the
rockchip adc reset.  The fix in the driver only makes sense with these
and the rockchip maintainer is happy with them going through IIO to
reach mainline.

Core stuff

* Fix an issue with a blocking op when !TASK_RUNNING. This been there
  a while and snuck in with seemingly minor additions to some core
  code paths.
* Tools
  - generic_buffer failed to initialize the channel array pointer thus
    in the case of no channels blows up trying to free a random memory
    address.
* sw-trigger:
  - Fix config group initialization when configfs is built as a module.

Drivers

* ad5933
  - Fix an incorrect overwrite of an error value.
* ad799x
  - A missed assignment of the update_scan_mode callback means buffered mode
    doesn't work on the ad7991, ad7995 or ad7999.
* ads1015
  - wrong pointer returned from i2c_get_clientdata (missmatch of assumptions)
* am2315
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
  - missing buffer selects in Kconfig
* am335x adc
  - Protect fifo1 from concurrent access.
  - Increase timeout waiting for ADC to be long enough in all cases.
* as3935
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
* at91
  - Fix reading of channel 3.
* atlas-ph-sensor
  - Typo means that the scale of electrical conductivity readings is way off.
* bma220
  - Timestamps are reported, but never actually acquired from anywhere
    (so always 0)
  - Missing buffer selects in Kconfig
* bmp280
  - pass the write pointer to PTR_ERR (i.e. the one that was just checked
    with IS_ERR).
  - suspend /resume crash due to wrong assumption about what dev_get_drvdata
    would return.
* hdc100x
  - It superficially appeared that smbus_read_byte commands would allow
  reading of the outputs in two goes.  In reality it doesn't work, but
  instead returns the same for the upper and lower bytes (nice catch from
  Alison!)
* kxsd9
  - Fix raw read return value to ensure it actually reports the value rather
  than a blank string.
* max44000
  - Missing buffer selects in Kconfig
* rockchip_saradc
  - Add use of reset controller to enforce a clean state of the ADC.
    Some bootloaders can leave it in an 'intersting' state and effectively
    frozen without this. A couple of associated dts updates.
* stk8ba50
  - Missing buffer selects in Kconfig
* stx104
  - Fix a possible race due to use of devm_iio_device_register when there
    was other stuff in the remove function.
2016-08-23 17:39:31 -04:00
Colin Ian King
6c08fda030 staging: wilc1000: correctly check if associatedsta has not been found
The current check for associatedsta being set to -1 to indicate it has
not been found is not working because associatedsta is initialized to
zero and will never be -1.  Fix this by initializing it to ~0 and checking
for ~0 instead.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:28:21 +02:00
Dan Carpenter
23436825e6 staging: wilc1000: NULL dereference on error
We can't pass NULL pointers to destroy_workqueue().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:28:21 +02:00
Binoy Jayan
23535c1322 staging: wilc1000: txq_event: Fix coding error
Fix incorrect usage of completion interface by replacing
'wait_for_completion' with 'complete'. This error was introduced
accidentally while replacing semaphores with mutexes.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:28:21 +02:00
Ian Abbott
f0f4b0cc3a staging: comedi: ni_mio_common: fix AO inttrig backwards compatibility
Commit ebb657babf ("staging: comedi: ni_mio_common: clarify the
cmd->start_arg validation and use") introduced a backwards compatibility
issue in the use of asynchronous commands on the AO subdevice when
`start_src` is `TRIG_EXT`.  Valid values for `start_src` are `TRIG_INT`
(for internal, software trigger), and `TRIG_EXT` (for external trigger).
When set to `TRIG_EXT`.  In both cases, the driver relies on an
internal, software trigger to set things up (allowing the user
application to write sufficient samples to the data buffer before the
trigger), so it acts as a software "pre-trigger" in the `TRIG_EXT` case.
The software trigger is handled by `ni_ao_inttrig()`.

Prior to the above change, when `start_src` was `TRIG_INT`, `start_arg`
was required to be 0, and `ni_ao_inttrig()` checked that the software
trigger number was also 0.  After the above change, when `start_src` was
`TRIG_INT`, any value was allowed for `start_arg`, and `ni_ao_inttrig()`
checked that the software trigger number matched this `start_arg` value.
The backwards compatibility issue is that the internal trigger number
now has to match `start_arg` when `start_src` is `TRIG_EXT` when it
previously had to be 0.

Fix the backwards compatibility issue in `ni_ao_inttrig()` by always
allowing software trigger number 0 when `start_src` is something other
than `TRIG_INT`.

Thanks to Spencer Olson for reporting the issue.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reported-by: Spencer Olson <olsonse@umich.edu>
Fixes: ebb657babf ("staging: comedi: ni_mio_common: clarify the cmd->start_arg validation and use")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00
Dan Carpenter
5ac5c3bcf5 staging: comedi: dt2811: fix a precedence bug
Bitwise | has higher precedence than ?: so we need to add some
parenthesis for this to work as intended.

Fixes: 7c9574090d ('staging: comedi: dt2811: simplify A/D reference configuration')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00
Phil Turnbull
c71f20ee76 staging: comedi: adv_pci1760: Do not return EINVAL for CMDF_ROUND_DOWN.
The CMDF_ROUND_DOWN case falls through and so always returns -EINVAL.

Fixes: 14b93bb6bb ("staging: comedi: adv_pci_dio: separate out PCI-1760 support")
Signed-off-by: Phil Turnbull <phil.turnbull@oracle.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00
Ian Abbott
5ca05345c5 staging: comedi: ni_mio_common: fix wrong insn_write handler
For counter subdevices, the `s->insn_write` handler is being set to the
wrong function, `ni_tio_insn_read()`.  It should be
`ni_tio_insn_write()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reported-by: Éric Piel <piel@delmic.com>
Fixes: 10f74377ee ("staging: comedi: ni_tio: make ni_tio_winsn() a
  proper comedi (*insn_write)"
Cc: <stable@vger.kernel.org> # 3.17+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00
Ian Abbott
403fe7f34e staging: comedi: comedi_test: fix timer race conditions
Commit 73e0e4dfed ("staging: comedi: comedi_test: fix timer lock-up")
fixed a lock-up in the timer routine `waveform_ai_timer()` (which was
called `waveform_ai_interrupt()` at the time) caused by
commit 2405124744 ("staging: comedi: comedi_test: use
comedi_handle_events()").  However, it introduced a race condition that
can result in the timer routine misbehaving, such as accessing freed
memory or dereferencing a NULL pointer.

73e0... changed the timer routine to do nothing unless a
`WAVEFORM_AI_RUNNING` flag was set, and changed `waveform_ai_cancel()`
to clear the flag and replace a call to `del_timer_sync()` with a call
to `del_timer()`.  `waveform_ai_cancel()` may be called from the timer
routine itself (via `comedi_handle_events()`), or from `do_cancel()`.
(`do_cancel()` is called as a result of a file operation (usually a
`COMEDI_CANCEL` ioctl command, or a release), or during device removal.)
When called from `do_cancel()`, the call to `waveform_ai_cancel()` is
followed by a call to `do_become_nonbusy()`, which frees up stuff for
the current asynchronous command under the assumption that it is now
safe to do so.  The race condition occurs when the timer routine
`waveform_ai_timer()` checks the `WAVEFORM_AI_RUNNING` flag just before
it is cleared by `waveform_ai_cancel()`, and is still running during the
call to `do_become_nonbusy()`.  In particular, it can lead to a NULL
pointer dereference:

BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffffc0c63add>] waveform_ai_timer+0x17d/0x290 [comedi_test]

That corresponds to this line in `waveform_ai_timer()`:

		unsigned int chanspec = cmd->chanlist[async->cur_chan];

but `do_become_nonbusy()` frees `cmd->chanlist` and sets it to `NULL`.

Fix the race by calling `del_timer_sync()` instead of `del_timer()` in
`waveform_ai_cancel()` when not in an interrupt context.  The only time
`waveform_ai_cancel()` is called in an interrupt context is when it is
called from the timer routine itself, via `comedi_handle_events()`.

There is no longer any need for the `WAVEFORM_AI_RUNNING` flag, so get
rid of it.

The bug was copied from the AI subdevice to the AO when support for
commands on the AO subdevice was added by commit 0cf55bbef2 ("staging:
comedi: comedi_test: implement commands on AO subdevice").  That
involves the timer routine `waveform_ao_timer()`, the comedi "cancel"
routine `waveform_ao_cancel()`, and the flag `WAVEFORM_AO_RUNNING`.  Fix
it in the same way as for the AI subdevice.

Fixes: 73e0e4dfed ("staging: comedi: comedi_test: fix timer lock-up")
Fixes: 0cf55bbef2 ("staging: comedi: comedi_test: implement commands
 on AO subdevice")
Reported-by: Éric Piel <piel@delmic.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 4.4+
Cc: Éric Piel <piel@delmic.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00
Ian Abbott
80e162ee9b staging: comedi: daqboard2000: bug fix board type matching code
`daqboard2000_find_boardinfo()` is supposed to check if the
DaqBoard/2000 series model is supported, based on the PCI subvendor and
subdevice ID.  The current code is wrong as it is comparing the PCI
device's subdevice ID to an expected, fixed value for the subvendor ID.
It should be comparing the PCI device's subvendor ID to this fixed
value.  Correct it.

Fixes: 7e8401b23e ("staging: comedi: daqboard2000: add back
subsystem_device check")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.7+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 17:07:19 +02:00