lge_touch_core.c: Fix broken indent

Fix broken indent and coding style in lge_touch_core.c.
dt2w: Fix touchpad not working if dt2w is enabled when the screen is off

If doubletap_to_wake is set while the touch device is off, the driver
thinks there's no need to enable to device on resume operation.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Fix detection of double touch

The double touch detection was not working since there is no state
ABS_RELEASE.

This patch tries another approach: we rely on the fact that the first
touch event has a nul state ("DO_NOT_ANYTHING" [sic]).

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Add a parameter to control the doubletap_to_wake timeout value

Add sysfs entry "doubletap_delay" to let userspace change the doubletap
timeout.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Add an option to disable d2tw when the power button is used

This patch adds the variable doubletap_pwrkey_suspend to prevent the
touch device from staying enabled when the power button is used.

It has been inspired by the implementation for the Nexus 5 (Hammerhead)
by "flar2" <asegaert@gmail.com> and "showp1984" <showp1984@gmail.com>.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Restrict the touchscreen area used to wake up the device

Only the bottom area of the screen can be "double-tapped" to wake up the
device; this should reduce false positives.
Left and right margins are excluded as well.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Add option to use the whole screen for dt2w

This patch adds the /sys entry "doubletap_full_window".

When its value is true, the whole touchscreen can be used to wake up the
device.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Add an option to enable doubletap2wake when on charger

The sys option "doubletap_charger" can have 3 values:
- 0 (default): no check on charger's presence;
- 1: same as default behaviour, but dt2w is also enable when charger is
  present;
- 2: dt2w is enabled only when charger is present.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Release TS events before suspend and on resume

Let's release the TS events on late resume when the touch device was
not suspended.  Hopefully it will fix casual extra touch events on wake
up.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
lge_touch_core: i2c_read: retry a few times before erroring out

Patch from Dennis Rassmann (showp1984) -- I've reduced the number of
retries to 4.

Initial commit message:

--
The i2c devices we are connecting to may not be ready yet, or just
busy. Retry with a 10ms pause in order to still obtain touch data.
This improves overall touch data robustness, but the main thing it
does:
WE CAN FINALLY GET TOUCH DATA IN SUSPEND ALL THE TIME.
--

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Add an option to specify the dt2w touch area

The previous option doubletap_full_window is replaced with a more
generic option: "doubletap_area" can have 3 values:
- 0 (default): no check on touch area (i.e. full screen);
- 1: bottom area (left/right margins excluded);
- 2: top area (left/right margins excluded);
- 3: center of the screen.

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
Remove old FIXMEs

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
lge_touch_core.c: Remove unused global variable

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
dt2w: Check the second tap is close to the first one

Signed-off-by: Mikael Berthe <mikael@lilotux.net>
msm: mdp: Free secure memory based on pipe config

When there is no secure pipe configured, we can unmap secure
memory instead of relying on unset with secure flag set from
userspace.

Bug: 11857675

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
seq_file: always update file->f_pos in seq_lseek()

This issue was first pointed out by Jiaxing Wang several months ago, but no
further comments:
https://lkml.org/lkml/2013/6/29/41

As we know pread() does not change f_pos, so after pread(), file->f_pos
and m->read_pos become different. And seq_lseek() does not update file->f_pos
if offset equals to m->read_pos, so after pread() and seq_lseek()(lseek to
m->read_pos), then a subsequent read may read from a wrong position, the
following program produces the problem:

    char str1[32] = { 0 };
    char str2[32] = { 0 };
    int poffset = 10;
    int count = 20;

    /*open any seq file*/
    int fd = open("/proc/modules", O_RDONLY);

    pread(fd, str1, count, poffset);
    printf("pread:%s\n", str1);

    /*seek to where m->read_pos is*/
    lseek(fd, poffset+count, SEEK_SET);

    /*supposed to read from poffset+count, but this read from position 0*/
    read(fd, str2, count);
    printf("read:%s\n", str2);

out put:
pread:
 ck_netbios_ns 12665
read:
 nf_conntrack_netbios

/proc/modules:
nf_conntrack_netbios_ns 12665 0 - Live 0xffffffffa038b000
nf_conntrack_broadcast 12589 1 nf_conntrack_netbios_ns, Live 0xffffffffa0386000

So we always update file->f_pos to offset in seq_lseek() to fix this issue.

cherry-picked from https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/seq_file.c?id=05e16745c0c471bba313961b605b6da3b21a853d

Signed-off-by: Jiaxing Wang <hello.wjx@gmail.com>
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Conflicts:
	fs/seq_file.c

Change-Id: If419b92498e2c3e08669a4342e9b9ebf99ad3768
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
seq_file: always clear m->count when we free m->buf

Once we'd freed m->buf, m->count should become zero - we have no valid
contents reachable via m->buf.

cherry-picked from https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/seq_file.c?id=801a76050bcf8d4e500eb8d048ff6265f37a61c8

Change-Id: I4c1d3e69db4ecf5362e2a5d05bfd7db754dc6dc6
Reported-by: Charley (Hao Chuan) Chu <charley.chu@broadcom.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
fs/dcache.c: Fix the too small buffer for dname

temp[64] is used for internal temporary buffer in dynamic_dname().
This is for dname. But It's too small. dname's size may be > 64.
In that case, it returns as -ENAMETOOLONG. So Increase the buffer size
to 256 for avoiding this issue.

The following was caused by the small buffer.
WARNING: at /kernel/mm/page_alloc.c:2470 __alloc_pages_nodemask+0x24c/0x938()
CPU: 2 PID: 505 Comm: android.bg Not tainted 3.10.0-g2f73780-00003-g2ff41d9-dirty #13
[<c010ba3c>] (unwind_backtrace+0x0/0x11c) from [<c0109cac>] (show_stack+0x10/0x14)
[<c0109cac>] (show_stack+0x10/0x14) from [<c01939a0>] (warn_slowpath_common+0x48/0x68)
[<c01939a0>] (warn_slowpath_common+0x48/0x68) from [<c0193a7c>] (warn_slowpath_null+0x18/0x20)
[<c0193a7c>] (warn_slowpath_null+0x18/0x20) from [<c0222454>] (__alloc_pages_nodemask+0x24c/0x938)
[<c0222454>] (__alloc_pages_nodemask+0x24c/0x938) from [<c0222b50>] (__get_free_pages+0x10/0x24)
[<c0222b50>] (__get_free_pages+0x10/0x24) from [<c024faf8>] (kmalloc_order_trace+0x24/0xf0)
[<c024faf8>] (kmalloc_order_trace+0x24/0xf0) from [<c024fe20>] (__kmalloc+0x30/0x244)
[<c024fe20>] (__kmalloc+0x30/0x244) from [<c02723c8>] (seq_read+0x270/0x464)
[<c02723c8>] (seq_read+0x270/0x464) from [<c0256a18>] (vfs_read+0xa4/0x134)
[<c0256a18>] (vfs_read+0xa4/0x134) from [<c0256de8>] (SyS_read+0x38/0x68)
[<c0256de8>] (SyS_read+0x38/0x68) from [<c0106140>] (ret_fast_syscall+0x0/0x30)

Change-Id: I74f5217ba3c4be73e91f33f900f1f0c26810cc05
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
SELinux: include definition of new capabilities

The kernel has added CAP_WAKE_ALARM and CAP_EPOLLWAKEUP.  We need to
define these in SELinux so they can be mediated by policy.

Change-Id: I8a3e0db15ec5f4eb05d455a57e8446a8c2b484c2
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
[sds: rename epollwakeup to block_suspend to match upstream merge]
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
(cherry picked from commit c6a020c889756568d0e2f3ab0c1f04ad9fcb320c)

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
tcp: add a sysctl to config the tcp_default_init_rwnd

The default initial rwnd is hardcoded to 10.

Now we allow it to be controlled via
  /proc/sys/net/ipv4/tcp_default_init_rwnd
which limits the values from 3 to 100

This is somewhat needed because ipv6 routes are
autoconfigured by the kernel.

See "An Argument for Increasing TCP's Initial Congestion Window"
in https://developers.google.com/speed/articles/tcp_initcwnd_paper.pdf

Change-Id: I386b2a9d62de0ebe05c1ebe1b4bd91b314af5c54
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>