rtc: pm8xxx: Sync up to upstream version

Changes from upstream code-review during submission weren't
backported. Backport them now.

Change-Id: Id9f3f6316268bf12b9b11e35b18e1866e7cda542
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Conflicts:
	drivers/rtc/rtc-pm8xxx.c
drivers: rtc-pm8xxx: Clear alarm register when IRQ is disabled

Based on
https://github.com/CyanogenMod/android_kernel_samsung_d2/commit/0287c9698a6e09fd22aabfc7536d8b503aaa27d4

QCOM never anticipated people turning the RTC on on this class of
devices.

Change-Id: Ia151e1ddb737ed4a3e4c68540f2882285460d8b9
rtc: pm8xxx: move device_init_wakeup() before rtc_register

Setup wakeup capability before rtc_register to ensure the rtc class core
properly sets up our 'wakealarm' sysfs attribute.

Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Conflicts:
	drivers/rtc/rtc-pm8xxx.c
rtc-pm8xxx: fixed for not used AUTO_PWRON config.
REVERT: Custom Faux Cpufreq table for all cores. before updating!

reverting:
https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/58ff858f1a612affb39b6d58930aae69e7ff0e79
https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/d1b63ccab6b35cc6104e72c6a1139f0b84e7d87b
https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/2217ba587948e8aba989c15604e92a97ea4d8a2b
cpufreq / stats: fix race between stats allocation and first usage

This patch forces complete struct cpufreq_stats allocation for all cpus before
registering CPUFREQ_TRANSITION_NOTIFIER notifier, otherwise in some conditions
cpufreq_stat_notifier_trans() can be called in the middle of stats allocation,
in this case cpufreq_stats_table already exists, but stat->freq_table is NULL.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq / stats: Get rid of CPUFREQ_STATDEVICE_ATTR

Macro "CPUFREQ_STATDEVICE_ATTR" is defined local to cpufreq_stats.c file and is
almost a copy of the generic version present in cpufreq.h file. Lets use the
generic version instead.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq_stats: do not remove sysfs files if frequency table is not present

The sysfs files for cpufreq_stats are created in cpufreq_stats_create_table()
called from cpufreq_stat_notifier_policy() when a policy is added to
the cpu. cpufreq_stats_create_table() will not be called if the
scaling driver does not export a frequency table to cpufreq.  Use the
same fence on tear down.

Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: Preserve sysfs files across suspend/resume

The file permissions of cpufreq per-cpu sysfs files are not preserved
across suspend/resume because we internally go through the CPU
Hotplug path which reinitializes the file permissions on CPU online.

But the user is not supposed to know that we are using CPU hotplug
internally within suspend/resume (IOW, the kernel should not silently
wreck the user-set file permissions across a suspend cycle).
Therefore, we need to preserve the file permissions as they are
across suspend/resume.

The simplest way to achieve that is to just not touch the sysfs files
at all - ie., just ignore the CPU hotplug notifications in the
suspend/resume path (_FROZEN) in the cpufreq hotplug callback.

Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
Reported-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
CPUFREQ STATS: Merged some checks from 3.10.y kernel.
CPUFREQ STATS: once again remove commit https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/40cf2f818f45784bab7f81406291b5c28469f8f0 it's not working.

and commit https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/3c9e49908b882631f3737022e707ffddf0b7c230

Interface just show empty table. i dont really need that.
Config. cleanup after driver remove.
rtc-pm8xxx: removed duplicated pm8xxx_rtc_remove function code. My mistake!
mmc: core: Avoid infinite retries of failed mmc command

With some bad SD cards, it is possible that the error recovery
procedure goes into a state where it retries the failed command
infinitely leading to CPU hog.

Fix inifinite retries when the bad SD card isn't responding to
a command even when the SD card reset mechanism is successful.

CRs-Fixed: 671153
Change-Id: Ic6db66b571aa425aec32c82d52789c68fe0cb0e9
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
mmc: card: quirk: disable cache for Hynix card

This change prevents enabling cache during card init for Hynix cards.
This change is workaround the problem of Hynix cards behavior for
adb reboot flow, when as a result of power cycle with cache enabled,
ext4 journal get aborted, because of meta data corruption.

Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>

Conflicts:

	drivers/mmc/card/block.c
	include/linux/mmc/card.h

Change-Id: I721689da65e803965f1c7dd148754c4f19a64857
Signed-off-by: Maya Erez <merez@codeaurora.org>
alarmtimer: Implement minimum alarm interval for allowing suspend

alarmtimer suspend return -EBUSY if the next alarm will fire in less
than 2 seconds.  This allows one RTC seconds tick to occur subsequent
to this check before the alarm wakeup time is set, ensuring the wakeup
time is still in the future (assuming the RTC does not tick one more
second prior to setting the alarm).

If suspend is rejected due to an imminent alarm, hold a wakeup source
for 2 seconds to process the alarm prior to reattempting suspend.

If setting the alarm incurs an -ETIME for an alarm set in the past,
or any other problem setting the alarm, abort suspend and hold a
wakelock for 1 second while the alarm is allowed to be serviced or
other hopefully transient conditions preventing the alarm clear up.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>

Conflicts:
	kernel/time/alarmtimer.c
alarmtimer: Rename alarmtimer_remove to alarmtimer_dequeue

Now that alarmtimer_remove has been simplified, change
its name to _dequeue to better match its paired _enqueue
function.

Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@android.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
alarmtimer: Export symbols of functions declared in linux/alarmtimer.h

Export symbols so they can be used by
drivers/staging/android/alarm-dev.c if it is built as a module.
So far alarm-dev is built-in but module support is planned (see
drivers/staging/android/TODO).

Signed-off-by: Marcus Gelderie <redmnic@gmail.com>
[jstultz: tweaked commit message, also export newly added functions]
Signed-off-by: John Stultz <john.stultz@linaro.org>
alarmtimer: Export symbols of alarmtimer_get_rtcdev

Export symbol of alarmtimer_get_rtcdev so that it is used by
any driver when built as module like,
drivers/staging/android/alarm-dev.c.

CC: John Stultz <john.stultz@linaro.org>
CC: Marcus Gelderie <redmnic@gmail.com>
Signed-off-by: Pramod Gurav <pramod.gurav.etc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
alarmtimer: Return relative times in timer_gettime

Returns the time remaining for an alarm timer, rather than the time at
which it is scheduled to expire.  If the timer has already expired or it
is not currently scheduled, the it_value's members are set to zero.

This new behavior matches that of the other posix-timers and the POSIX
specifications.

This is a change in user-visible behavior, and may break existing
applications.  Hopefully, few users rely on the old incorrect behavior.

Cc: stable@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Sharvil Nanavati <sharvil@google.com>
Signed-off-by: Richard Larocque <rlarocque@google.com>
[jstultz: minor style tweak]
Signed-off-by: John Stultz <john.stultz@linaro.org>