ARM: tegra: tamonten: Fix potential oops when gpio_request() fails

Check the return value of gpio_request() before using the GPIOs.

Change-Id: I6b92e765e208ee18f5a3f4cad909184a96ef73e8
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/881
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
media: dvb: Backport dvb-usb-v2 framework.

Backport parts of the dvb-usb-v2 framework from recent kernels, which is
required for ad1456 DVB usb stick driver, which will follow in the next commits.

Change-Id: Iaae3a5997607ef9e6a3faa519abc36dc6dd155ec
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/915
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
tda18212: Make if-level configurable.

Expose the used interface voltage level through the tuner configuration, so that
it can be adapted to the requirements of different hardware.

Change-Id: Ie2d266c06946686fa7bcb71e13c53a03d1c785e3
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/917
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Update initial register settings.

Adapt some registers to match the requirements noted in the datasheet. Seems not
to affect functionality of the driver, but should avoid unexpected issues.

Change-Id: Ib5604629575a82c46707573a3169e5e5ce8d943f
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/918
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Fix typo in register names.

Change-Id: Idae9e509c17d4e29e0c6dee332d7f592ae01347f
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/921
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
cypress-firmware: Use DMA compatible buffers.

USB URB requests require DMA usable memory to be passed in. As it can not be
assured that the caller uses proper memory, allocate memory and make a copy of
the contents. As this is a one-time execution on driver startup the potential
overhead is negligible.

Change-Id: I7b6505757ec7d5d68a2ec21fb0fd55bab3cd78ff
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/916
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Configurable byte order.

Allow the TS_SWAP parameter of stv0367 be configured by the user. This allows to
use this driver for hardware where different byte order is required.

Change-Id: Ia101650881b20e804b5c4048bc3a87d6efdc932e
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/919
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Configurable adc mode.

Allow the drivers user to change the adc mode, to reflect the actual hardware
situation.

Change-Id: Ibdc21959e052609cbc56d3e33cd35630d634b510
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/920
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Add PLL setup for 16MHz clk.

Add a PLL configuration for setups where the stv0367 is driven by a 16MHz clock.

Change-Id: Ia3d797512afc4ed621f230ec298cd7ffa73c8892
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/922
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Setup PLL in cable mode.

Add PLL setup code to the cable frontend initialisiation. This has been done for
the DVB-T demodulator before, but was missing for the DVB-C demodulator.

Change-Id: I544254981c9f848617b2ed377e4a5a5cca11cc5a
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/923
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
stv0367: Fix DVB_CI clock mode.

Set the correct register value to enable DVB_CI clocking mode.

Change-Id: Idf58263fb8adbd4ef2ce541372e645f40a590a9e
Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-on: http://review.adnet.avionic-design.de/924
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
gpio: adnp: Only free the IRQ if it was requested

When the driver fails to detect the ADNP controller, free_irq() is
called even if the IRQ wasn't requested. Fix this by freeing the IRQ
only if GPIO to IRQ converter has been set, which happen after the IRQ
has been successfully requested.

Change-Id: I5c08103a68906aaef7216e1c61adb7727367433b
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/912
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
ARM: tegra: Only read the DDR MMR registers if needed

On the Tamonten platform reading these registers lead to a system
hang. However it is not needed at all as the Tamonten platform only
has one type of memory. Fix this problem by only reading the MMR
register really used to be match the DDR chip.

Change-Id: I0b43e42e8f110921d5d484d09ddd0c3971d43b23
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/913
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
ARM: tegra: tamonten: Add the DDR config table

To allow controlling the EMC clock from the clock API a table with the
config for each supported frequency is needed. So add the table with a
single entry for our default config.

This prevent various ugly warnings, fixing bug #2638.

Change-Id: I4872824984c94c13bf7994adacda5e1d3c96b042
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/914
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
staging: zsmalloc: Fix "map_vm_area" undefined reference errors.

Commit 8addac75a1ab0d8bd5fd25dbbc58e02ddfb089c9 upstream.

This patch adds a MMU dependency to configure the ZSMALLOC in
drivers/staging/zsmalloc/Kconfig. Without this patch, build
system can lead to build failure. This was observed during
randconfig testing, in which ZSMALLOC was enabled w/o MMU being
enabled. Following was the error:

LD      vmlinux
drivers/built-in.o: In function `__zs_map_object':
drivers/staging/zsmalloc/zsmalloc-main.c:650: undefined reference to `map_vm_area'
make: *** [vmlinux] Error 1

Change-Id: Ie20d2d97a5c5e127bb3da04b70839d20c629e9f1
Signed-off-by: Manjunath Goudar <csmanjuvijay@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.adnet.avionic-design.de/875
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
staging: zsmalloc: Ensure handle is never 0 on success

Commit 67296874eb1cc80317bf2a8fba22b494e21eb29b upstream.

zsmalloc encodes a handle using the pfn and an object index. On hardware
platforms with physical memory starting at 0x0 the pfn can be 0. This
causes the encoded handle to be 0 and is incorrectly interpreted as an
allocation failure.

This issue affects all current and future SoCs with physical memory
starting at 0x0. All MSM8974 SoCs which includes Google Nexus 5 devices are
affected.

To prevent this false error we ensure that the encoded handle will not be 0
when allocation succeeds.

Change-Id: I8538ba2a5f297cd7af36c0bc1160de098a8ddd23
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.adnet.avionic-design.de/876
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
Staging: zram: Fix variable dereferenced before check

Commit 59d3fe540454dd8fc48d4eda44e200f9c98bef10 upstream.

This patch fixes the following Smatch warning in zram_drv.c-
drivers/staging/zram/zram_drv.c:899
destroy_device() warn: variable dereferenced before check 'zram->disk' (see line 896)

Change-Id: If7c8c0dc16adec1ac8852a24c081a655196ddad9
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.adnet.avionic-design.de/877
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
Staging: zram: Fix access of NULL pointer

Commit 46a51c80216cb891f271ad021f59009f34677499 upstream.

This patch fixes the bug in reset_store caused by accessing NULL pointer.

The bdev gets its value from bdget_disk() which could fail when memory
pressure is severe and hence can return NULL because allocation of
inode in bdget could fail.

Hence, this patch introduces a check for bdev to prevent reference to a
NULL pointer in the later part of the code. It also removes unnecessary
check of bdev for fsync_bdev().

Change-Id: Ia31305a6c998acbcfd4f8b7a286ef5bd441c13b4
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.adnet.avionic-design.de/878
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>
Staging: zram: Fix memory leak by refcount mismatch

Commit 1b672224d128ec2570eb37572ff803cfe452b4f7 upstream.

As suggested by Minchan Kim and Jerome Marchand "The code in reset_store
get the block device (bdget_disk()) but it does not put it (bdput()) when
it's done using it. The usage count is therefore incremented but never
decremented."

This patch also puts bdput() for all error cases.

Change-Id: I461d8c73a7683706160111e271b0a9de72514c3e
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.adnet.avionic-design.de/879
Reviewed-by: Alban Bedel <alban.bedel@avionic-design.de>