power: pm8921-charger: enable DCIN_VALID_IRQ as wake irq

When the device is in suspend the DCIN_VALID_IRQ is not
used as a wake up interrupt.

Fix this by configuring the DCIN_VALID_IRQ as a wake up
interrupt.

CRs-Fixed: 389524
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 8d7b8f7264da504cc10b7d987a9ab6c62dafc9c0)

Conflicts:

	drivers/power/pm8921-charger.c

Change-Id: I56ad75068cadb658554f86ab2ddda9b008d1eb54
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-charger: Start unplug check worker for DC

It could happen that the device is powered up with a dc charger.
We should start the unplug check worker when the device starts with
dc charger or else we run the risk of not detecting the dc charger
removal.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 90e49c590fccdae53933f7a8fa62a7f0d65c4a0f)

Change-Id: Iaa9e6c56c5766addbf26f1a5052c6ee923ae1013
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-bms: reintroduce hkadc calibration during probe

The hkadc calibration process takes only one sample. This should be
a quick procedure to be done during probe. Without calibration the
voltage readings are skewed which affect the accuracy of BMS.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 067b0f024744f04b25766437fbd13718c71e76c7)

Change-Id: I1862c7df17f7aa9fbf339ddf9f47718b54e725f2
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
lib: genalloc: Change chunk allocation to vmalloc

Change the chunk allocation from kmalloc to vmalloc for
allocations greater than a page. This allows large
chunks to be allocated from physically non-contiguous
memory and increases the chance of the allocation
succeeding.

(cherry picked from commit 0614b96dc8e4c8a0dd0db41aec5a79daa3bdf091)

Conflicts:

	lib/genalloc.c

(cherry picked from commit 64cf7183f37df623bec8f46348b11c5781d3b0cc)

Change-Id: Ied97c888b967c4433519cb47e972f7a0f2281d71
CRs-fixed: 387655
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm_serial_hs_hwreg.h: Correcting the even parity and odd parity bits

Currently parity bits are defined to be used with UART_DM_MR2
register with PARITY_MODE Bit as below :
EVEN_PARTIY = 1 and ODD_PARITY = 2
With these values, UART functionality doesn't work after enabling parity.
Hence adding correct used PARITY_MODE bits value as
EVEN_PARITY = 2 and ODD_PARITY = 1
after confirming with UART hardware programming guide.

(cherry picked from commit fd40e5f6313fbc74e8897927be1004faa5d9df08)

Change-Id: I90fa8384d434abd42dc46c917d39e8de1f540993
CRs-Fixed: 410377
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Revert "power: pm8921-charger: Add power supply property"

This reverts commit 753ddad790b8c2c5536c71ffb9794ed8130712a8.

Change-Id: Ib34598c3c932d264a622f5bff411f722c7354767
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
power: pm8921-charger: resume charging based on SOC

At EOC, the battery is disconnected from the charger and starts
discharging. This can result in SOC dropping to around 93% before
charging starts again.

Manually set the CHG_VBAT_DET threshold high to restart charging once SOC
drops below keep_charge_percent.

CRs-Fixed: 404909
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
(cherry picked from commit 14e8fa1e42c02ea643d16d3f833b5d8e1b5753e6)

Conflicts:

	arch/arm/mach-msm/board-8064-pmic.c
	arch/arm/mach-msm/board-8930-pmic.c
	arch/arm/mach-msm/board-8960-pmic.c
	drivers/power/pm8921-charger.c

Change-Id: Iceb49784ec6be2c45076e33d04aac73cb9992a03
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
spi_qsd: Runtime configuration of spi gpio's

Configure the spi clk, mosi, miso, cs gpio's on per
transaction basis and unconfigure otherwise.
It will remove the conflicts if same gpio's are
being used by different modules if no SPI device
is present.

CRs-Fixed: 387043
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
(cherry picked from commit 66554a1317d40fbacd1a7e1e3210de8fb947ad57)

Conflicts:

	drivers/spi/spi_qsd.c

Change-Id: I7f121d1b663af352162064c0387e5bdf34276fec
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks()

Use the observation that it is more efficient to check the wakeup
variable once before the loop reporting tasks that were not
frozen in try_to_freeze_tasks() than to do that in every step of that
loop.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Conflicts:

	kernel/power/process.c

Change-Id: I2abf3a9ef06c5b90beb12bbc542a87f79e42a14a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Bluetooth: Fix for LE cancel Create Connection not working

Added management method to send LE cancel create connection
HCI command

(cherry picked from commit 907d523eaeab6e6fda9589191b5684f26a502a10)

Change-Id: Iab2d8dc909b618036496f1c6abb9478d61b1e031
CRs-fixed: 366284
Signed-off-by: Archana Ramachandran <archanar@codeaurora.org>

Conflicts:
	net/bluetooth/mgmt.c
Revert "PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks()"

This reverts commit 9b276da61ab9827f99b9fc836ae78d6fd4649bec.

Change-Id: I2a89c4ba7c914d2b87e3ac6ad309fa832cbf7b35
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks()

Use the observation that it is more efficient to check the wakeup
variable once before the loop reporting tasks that were not
frozen in try_to_freeze_tasks() than to do that in every step of that
loop.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Conflicts:

	kernel/power/process.c

Change-Id: I0bd9e71b638e565773f4861899ca175f82f2a4cc
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
USB: msm_otg: Acknowledge PMIC BSV events, if ID is set

Currently not all the PMIC BSV events are handled due to check
that was introduced for handling spurious interrupts in Host Mode.
Rather than checking the OTG state as apart of these spurious interrupts
which gets updated in workqueue context, check for ID state and return
only, if ID is clear. This will fix all the corner cases and race
conditions as part of handling ACA use cases as well.

CRs-Fixed: 411036
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
(cherry picked from commit 2e1048bfda3f7eec6b9ba21ad9962f6b9388d89f)

Conflicts:

	drivers/usb/otg/msm_otg.c

Change-Id: Ie8c6f68bfd6111d9f8ad95b24e66856967b07e72
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
diag: Improve handling of IOCTLs

DIAG kernel driver interacts with user space processes using
IOCTLS. This change adds conditions to avoid potential integer
over/underflow, incorrect buffer copy.

CVE-2012-4220
CVE-2012-4221

Change-Id: If62cbdc953d67436a0a785f43f263a2cb0a76973
CRs-Fixed: 385352
CRs-Fixed: 385349
Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
msm: kgsl: Set sysfs max clock for devices with no power scale policy

When the sysfs entry for max clock is updated, set it immediately for the
devices that has no power scale policy. This prevents the device from
running with undesired clock.

(cherry picked from commit 6ca8011b4feb30c29e8e6fb5b3571fd2314879e0)

Change-Id: I3a4d689d90036edc243fa97562a79394ace94c2a
CRs-fixed: 408963
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
msm: vidc: Avoid memset of list elements in the buffer entry.

- Due to race condition between free buffer and flush output buffers,
  invalid buffer is getting accessed sometimes.
- Reset all the members in buffer entry except list elements.

(cherry picked from commit 8105df366cf6b9f1ddbc15d561fb6a5f12540416)

Change-Id: Ia3eaebdae102e4dff513cfffe31850350176d25f
CRs-Fixed: 411197
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
power: pm8921-charger: disable battery temperature wakeup

The battery temperature interrupts are functional only when there is a
valid charger source present. There is no point making it a wakeup
interrupt, since if the charger is absent the interrupt wont be
triggered (if it is triggered it should be ignored).

Note that for 8921 charging, the software does not take any action if
the battery gets hot/cold. The 8921 hardware state machine stops
charging if the battery temperature goes out of the limits.

For external chargers which depend on the temperature monitoring of
8921, we rely on the fact that the external charger will hold a wakelock
and avoid sleep as long as charging is in progress.

In cases when external charging is finished and the system did go into
suspend, we don't want to wakeup the device only to realize that external
charging was not in progress.

Basically no case requires that we wakeup from battery temperature
interrupts.

(cherry picked from commit a845ec32e6cd85db01c9c5706c0677226e4854b9)

Change-Id: I435e9b4840d5a96d7bca498bee29e49af265dfd3
CRs-Fixed: 395312
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
msm: kgsl: Turn off the CP_DEBUG dynamic clock

The CP dynamic clock seems to be glitchy when the CP clocks are turned
back on after a power event. Turn off said dynamic clock control at
init time. The impact of leaving the dynamic clock control off is
negligible since the CP clock is only on when the CP is actually in
use.

CRs-fixed: 402119
CRs-fixed: 409253
CRs-fixed: 413224
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit ed201aa291dfe13629d8c6cfa1d6e6f229b0c3c2)

Conflicts:

	drivers/gpu/msm/adreno_ringbuffer.c

Change-Id: I97d82ab71def370c16d4a5504087467aba82e4bb
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: vidc: Add support for H263 PlusPType flag

Some video players does not support pluptype
flag in H263 video format. This change adds
support in video driver to enable or disable
plusptype flag for H263 format.

CRs-fixed: 420970
Signed-off-by: Shobhit Pandey <cshopan@codeaurora.org>
(cherry picked from commit 8084f4f40b8b6d66d2b5c6a572b4f22c6817d75b)

Conflicts:

	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c
	include/linux/msm_vidc_enc.h
	include/media/msm/vcd_property.h

Change-Id: Ic4c8c5c3ebbb5208a5adaa96ec92dd8d969a7e83
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
kernel/sys.c: fix stack memory content leak via UNAME26

Calling uname() with the UNAME26 personality set allows a leak of kernel
stack contents.  This fixes it by defensively calculating the length of
copy_to_user() call, making the len argument unsigned, and initializing
the stack buffer to zero (now technically unneeded, but hey, overkill).

CVE-2012-0957

Reported-by: PaX Team <pageexec@freemail.hu>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Change-Id: I363b83f37e681fcb0c03e1d122b3c6638eb5209d
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>