msm: jpeg: Handle ERESTARTSYS properly

ERESTARTSYS return code for wait_* functions should be
propogated all the way to ioctl call.

Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Use correct type for function return code

Using an unsigned integer to hold the signed return code
is wrong. So fix it by using the correct type to hold the
return code.

Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Fix various small issues in cci driver

Remove some unused ioctl exposed, Also add
some bound checks for ioctl user params.

Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera_v2: CCI release resources in case of timeout

Turn off the CCI clocks and release gpio if reset timeout error is
received in function_msm_cci_init()

Signed-off-by: Evgeniy Borisov <eborisov@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Reset CCI core based on I2C MASTER

CCI core is used by camera sensor, actuator and EEPROM. CCI core gets
reset first time when either one of hardware modules initializes it.
But, as per hardware requirement sensor has to be powered up before
CCI can be reset. This imposes limitation in the sequence in which
camera is opened. To remove this limitation, initialize CCI core
only for corresponding I2C MASTER everytime either of the hardware
modules initilizes it.

Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Checking an enum value greater than zero

An enum value cci_i2c_master is not checked to be greater than 0.
Add the check.

Signed-off-by: Xu Han <hanxu@codeaurora.org>
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
video: slimport: disable not-supported timings

Disable non-supported timings from the HDMI LUT. ANX7808 is able to
support for max 1080p60.

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
video: slimport: Fix slimport blinking issue

Link integrity check sometimes failed without external power.
This is a workaround for this failure. Enabling the USB clk prevent
this issue.

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
arm/dt: hammerhead: slimport: Fix slimport blinking issue

Link integrity check is sometimes failed without external the power.
This is a workaround for this failure. Enabling the USB clk prevent
this issue.

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Revert "mdss: hdmi: Wait for mdss iommu attached on boot with hdmi"

This reverts commit cdc6e7b7f83bceb9b099c56ac2e0c594634febae.

Signed-off-by: choongryeol.lee <choongryeol.lee@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
video: slimport: wait until boot done before start detection

If slimport cable inserted during boot up, slimport could not
work properly since other system is not ready yet. So, wait
until boot completion before start cable detection. The boot
completion should be notified by userspace.

Signed-off-by: choongryeol.lee <choongryeol.lee@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
arm/dt: hammerhead: Change the search order of dtb

bootloader searches the dtb matched with board id from appended DTBs.
So changed the order to search latest dtb first.

order:
kernel -> rev11 -> rev11j -> rev10 -> ...

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: modify the number of gpios

gpios such as SENSOR_GPIO_VANA, SENSOR_GPIO_VDIG,
SENSOR_GPIO_VIO, SENSOR_GPIO_VCM, SENSOR_GPIO_OIS_LDO_EN,
and SENSOR_GPIO_OIS_RESET in msm_camera_sensor.h, must be
considered in gpio_num value.

Signed-off-by: insup.choi <insup.choi@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera_v2: Handle vfe camif irq before axi irq

For each irq status, axi bits (image/stats) could be set as well
as camif sof bit. In this case, axi bits should be handled first
to better reflect the order of events: buf done of frame N before
SOF of frame N+1.

Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@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>

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@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

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: Pranav Vashi <neobuddy89@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)

Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
switch: hds_max1462x: Should handle release event

Previously, if headset is removed while pressing keys,
release key is ignored.  Upperlayer would know the event
still be pressed.

The release event should be reported to prevent the problem.

Signed-off-by: hyunsub.na <hyunsub.na@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
USB: gadget: mtp: Fix hang in ioctl(MTP_RECEIVE_FILE) for WritePartialObject

In receive_file_work, we now queue reads with length rounded up to
max packet size rather than mtp_rx_req_len.
Otherwise the read request will never complete.

Signed-off-by: Mike Lockwood <lockwood@google.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
arm/dt: hammerhead: change usb otg detection level

The vadc value on the USB ID pin should be less than 20 milivolts
when the otg cable has been connected.
However some devices return over 15 milivolts with PMIC ES 3.1
and couldn't recognize an otg cable connection in that case.
Fix this by adjusting vadc threshold value on the USB ID pin to 100 milivolts.

Signed-off-by: jude84.kim <jude84.kim@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>