mmc: core: enhance card removal judgement for slow removal

Function _mmc_detect_card_removed will be called to know whether
the card is still present when host->bus_ops->detect is called.
In current code, the return value of this function generally only
depend on the result of sending cmd13 to card, which may not safe
for card with detection support like slot gpio detection.
Because the communication status between host and card may out of
sync with the detect status if remove the card slowly or hands shake
during the process. The direct reason is the async between card
detect switch and card/slot pad contaction in hardware, which is
defined by spec.

The spec define card insert/remove sequence as below (both standard size
SD card and MicroSD card have the same sequence):
"Part 1 Standard Size SD Card Mechanical Addendum Ver4.00 Final,
Appendix C: Card Detection Switch" (Take normally open type as example)
a)SD card insertion sequence:
  The card detection switch should be turned on after all SD card
  contact pads are connected to the host connector contact pads.
b)SD removal sequence:
  The card detection switch should be turned off when the SD card
  is just going to be removed and before any SD card contact pad is
  disconnected from the host connector contact pad.

Below is the sequence when this issue occur (Take slot gpio detection
as example and remove the card slowly during the process):
1. gpio level changed and card detect interrupt triggered.
2. mmc_rescan was launched.
3. the card pads were still contacted with the slot pads because of slow
   removal. So _mmc_detect_card_removed and mmc_rescan think card was
   still present (cmd13 succeed).
4. card pads were discontacted from the card slot pads.
So the card was actually removed finally but the card removal event
has been missed by system.
The interval length between step 1 and step 4 depends on the
card removal speed. If it's longer than the detect work schedule
delay which is 200ms, this issue will likely happen.

This patch add the card detect status check in function
_mmc_detect_card_removed if cmd13 check succeed and host->ops->get_cd
provided. If get_cd detect no card present then schedule another detect
work 200ms later.

CRs-fixed: 655754
Change-Id: I167309242c9937b023d14797177deb0e6be8838d
Signed-off-by: Kevin Liu <kliu5@marvell.com>
Git-commit: 1450734ec61cda7bbb77afc8cb412b9d64c62d9a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git
Tested-by: Johan Rudholm <johan.rudholm@stericsson.com>
Reviewed-by: Philip Rakity <prakity@nvidia.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
mmc: core: invoke low power mode if card is not present

If get_cd is defined and card is not present mmc_rescan
returns without invoking mmc_power_off. This would prevent
low-power modes.
Hence, invoke mmc_power_off if card is not present before
exiting mmc_rescan.

CRs-fixed: 655754
Change-Id: Id148fdf48e7f112da1251f8b60ac5d4c89a89e9f
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
misc: qseecom: fix wipe-key api for PFE key

The qseecom_wipe_key() api allows both FDE and PFE usage,
It is calling  __qseecom_delete_saved_key()  api
that should also allow both.

Change-Id: I2ae583977e7e4958e6dd8a939af74ac62a147895
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
qseecom: change return value to 0 if app id exists when loading app

Currently qseecom will return the app_id (>0) instead of 0 if the
app id already exists when loading app. Then the userspace client
will release qseecom handle if an non-zero return value is obtained.
Make a change to let qseecom return 0 when app id exist so as to
avoid the incorrect qseecom release.

Change-Id: I03b0b0ae95b2e043fda972aa3b613e7df585154a
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm_bam_rmnet: Fix potential memory corruption

Usage of legacy string manipulation function sprintf could lead to
memory corruption as the number of bytes to be written to the
destination is not bounded. Replace sprintf with snprintf where the
number of bytes to be written is explicitly specified.

CRs-fixed: 672202
Change-Id: Iab7516ad0e2540eb619fe96e26a3516c7adf86cc
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Bluetooth: Cancel power_on and power_off work

* This is not exact upstream patch but replica
  functions that will do similar function.
* Thanks to Dorimanx.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
avtimer: Update avtimer driver to parse driver tree data

LPASS exposes registers from which timestamp can be
read by clients for audio & video synchronization.
Change adds to retrieve the register address of AV
timer in LPASS passing from driver tree data.

CRs-fixed: 677082
Change-Id: Id7cf3455e22ddc27f5350a7a37c3b40d44eb0873
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
avtimer: Update avtimer driver to support Qdsp6v2

AVtimer in Qdsp6 provides the timer ticks for synchronization
of audio and video streams for capture and playback use cases.
Qdsp6 AVtimer interface has been updated for v2 version.
Update avtimer driver to support Qdsp6v2.

CRs-fixed: 677082
Change-Id: Ia68b04421edf13a96685654761bb71b866a5327b
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
avtimer: fix uninitialized variable compilation warning

Fix the following compilation warning in the avtimer driver:

kernel/drivers/platform/msm/avtimer.c:
	In function 'dev_avtimer_probe':
kernel/drivers/platform/msm/avtimer.c:316:
	warning: 'result' may be used uninitialized in this function
error, forbidden warning: avtimer.c:316
make[5]: *** [drivers/platform/msm/avtimer.o] Error 1

CRs-fixed: 677082
Change-Id: Ia760ba174e36bbcd63ed1c18cfcdce4308c825e1
Signed-off-by: David Collins <collinsd@codeaurora.org>
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ARM: dt: msm8974: Add AV timer specific data

LPASS exposes registers from which timestamp can be
read by clients for audio & video synchronization.
Change adds the register address of AV timer in LPASS.

CRs-fixed: 677082
Change-Id: Idee2aeb3cb73fcbca37976629c798abeae544774
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock: Fix invalid pointer dereferences on error condition

Check whether a clock pointer is an error value before deferencing it.

Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: clock: Check arguments to clk_set_parent

Verify that the struct clk pointer is valid before accessing
its members.

Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
workqueue: Fix permission for power_efficient

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
defconfig: Enable AVTimer
Build v3.79 EXP1