wcd9xxx: core: Fix crash while headset insert and remove

When insert and remove headset continuously observe crash.
In the interrupt table for wcd9306, there is a interrupt
number of WCD9XXX_IRQ_RESERVED_2 (value 32).
In IRQ driver, irqs will be dispatched  based on this
interrupt table. But for WCD9XXX_IRQ_RESERVED_2, this
value being 32 and BIT_BYTE will be 4 whereas number
of interrupt registers are 0 to 3 only.
Here status array used to check interrupt set, access each
entry of interrupt table and see if bit mask is set.
so, when checking for WCD9XXX_IRQ_RESERVED_2 it will
access out of bound array status[4] which will return
unexpected value.
In failed case, status[4] matches bitmask for 32nd bit
and dispatches irq for invalid entry causing crash.
Remove the entry as it is not a valid entry and causing
out of bound access for wcd9306 and wcd9320.

Change-Id: I82ed3b47a3bd7cee7a3c90a4fba4981a0528702f
CRs-Fixed: 729475
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
CHROMIUM: arch/arm: Remove duplicated code in syscall_trace

This is breaking the ptrace syscall on ARM. Looks like a mismerge in
5ea62181 ("CHROMIUM: arch/arm: move secure_computing into trace").

TEST=ran "strace true"
BUG=chromium-os:36102

Change-Id: Ic377577216bed3672201ca71604f650c1b8b3f0c
Signed-off-by: Michael Spang <spang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/38602
Reviewed-by: Doug Anderson <dianders@chromium.org>
alarmtimers: Squash upstream changes

staging: android-alarm: Switch from wakelocks to wakeup sources

In their current AOSP tree, the Android in-kernel wakelock
infrastructure has been reimplemented in terms of wakeup
sources:
http://git.linaro.org/gitweb?p=people/jstultz/android.git;a=commitdiff;h=e9911f4efdc55af703b8b3bb8c839e6f5dd173bb

The Android alarm driver currently has stubbed out calls
to wakelock functionality. So this patch simply converts
the stubbed out wakelock calls to wakeup source calls, and
removes the empty wakelock macros

Greg, would you mind queuing this in staging-next?

CC: Colin Cross <ccross@android.com>
CC: Arve Hjønnevåg <arve@android.com>
CC: Greg KH <gregkh@linuxfoundation.org>
CC: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Staging: android: alarm: Rename pr_alarm to alarm_dbg

Rename a macro to make it explicit it's for debugging.

Use %s: __func__ instead of embedding function names.
Coalesce formats, align arguments.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: Android: Fix NULL pointer related warning in alarm-dev.c file

Fixes the following sparse warning:
drivers/staging/android/alarm-dev.c:259:35: warning: Using plain integer as NULL pointer

Cc: Brian Swetland <swetland@google.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: android: alarm: remove unnecessary goto statement

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Staging: android: Alarm driver cleanups

Little cleanups. Enum value ANDROID_ALARM_TYPE_COUNT was treated as
an alarm type within a switch statement. That condition was unreachable
though.

Signed-off-by: Dae S. Kim <dae@velatum.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: alarm-dev: Drop pre Android 1.0 _OLD ioctls

Per Colin's comment:
"The "support old userspace code" comment for those two ioctls has
been there since pre-Android 1.0.  Those apis are not exposed to
Android apps, I don't see any problem deleting them."

Thus this patch removes the ANDROID_ALARM_SET_OLD and
ANDROID_ALARM_SET_AND_WAIT_OLD ioctl compatability
logic.

Change-Id: I5138aaa3cdbfb758aaef2cc7591cb5340b3640a0
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: alarm-dev: Refactor alarm-dev ioctl code in prep for compat_ioctl

Cleanup the Android alarm-dev driver's ioctl code to refactor it
in preparation for compat_ioctl support.

Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: alarm-dev: Implement compat_ioctl support

Implement compat_ioctl support for the alarm-dev ioctl.

Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: alarm-dev: information leak in alarm_ioctl()

Smatch complains that if we pass an invalid clock type then "ts" is
never set.  We need to check for errors earlier, otherwise we end up
passing uninitialized stack data to userspace.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: alarm-dev: information leak in alarm_compat_ioctl()

If we pass an invalid clock type then "ts" is never set.  We need to
check for errors earlier, otherwise we end up passing uninitialized
stack data to userspace.

Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

rtc: alarm: Add power-on alarm feature

Android does not support powering up of phone through alarm.
Adding shutdown hook in alarm driver which will set alarm while phone
is going down so as to power-up the phone after alarm expiration.

Change-Id: Ic2611e33ae9c1f8e83f21efdb93e26ac9f9499de
Signed-off-by: Matthew Qin <yqin@codeaurora.org>

qpnp-rtc: clear alarm register when rtc irq is disabled

The rtc alarm register should be cleared when the rtc irq is
disabled

Change-Id: I97a8bf989ff610093240a6b308a297702da6cb89
Signed-off-by: Xiaocheng Li <lix@codeaurora.org>
Signed-off-by: Matthew Qin <yqin@codeaurora.org>

alarm : Fix the race conditions in alarm-dev.c

There will be race conditions between alarm set and alarm clear if
set_power_on_alarm is out of the lock.But set_power_on_alarm can't
be put into spin_lock. So add it into mutex_lock.

CRs-Fixed: 639115
Change-Id: I4226a95e499211c0d50ff7ce269467a57a410dc7
Signed-off-by: Mao Jinlong <c_jmao@codeaurora.org>

switch timerfd_[sg]ettime(2) to fget_light()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

time: Enable alarmtimers

Change-Id: I4d1ea553aa707ab0467e00dea86cedc8f6797b78
rtc: Remove old alarm driver and switch to new implementation

Change-Id: I603cf43809212763660f30ac477e09bdf35ea5b1
msm: thermal: Remove alarm support in KTM
power: Update a few drivers for alarmtimer changes

Change-Id: I4758b04922e4d99fe9c8af7812a3eae6b95fe8f7
power: bq27541: Convert wakelocks to wakeup sources

Change-Id: I1a66a7494aebe87ee2ebc1fd72066a130c0e9caf