msm: ultrasound: support multiple devices, conflicting with USF

The USF input device can have a number of devices,
conflicting with it.
The first registered device (primary) is real TSC device.
Optionally, later registered devices are simulated ones.
The input events from the multiple devices should be
controlled by USF.

Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: ultrasound: add verifications of some input parameters

Some security vulnerabilities were found.
To fix them, additional verifications of some input parameters
are required.

Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: ultrasound: Add support for general button events

The side buttons bitmap was expanded to allow sending button
events for tool type buttons (stylus, rubber) and also for a new
button which signals that the hovering icon should be displayed.

The event source field was removed as it was previously used to
set the tool type, which is now done explicitly via the buttons
bitmap.

Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Add support for bam pipe flush on timeout

BAM pipes must be flushed when a transfer timeout
leaving dangling descriptors.

Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Verify pointers prior to redirection

Redirection on a NULL pointer leads to a system crash.
Here we verify pointers which potentially may be NULL
before a redirection.

Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: set device's runtime PM status to 'suspended'

Sometimes system suspend is initiated before runtime
PM's auto-suspend delay expires and causing devices to
not suspended runtime. As part of system suspend if
device is not suspended runtime then clocks and gpios
are manages by system suspend.

If spi client does initiate transaction request immediately
after system resume then spi doesn't resume run-time
immediately as spi controller's device state is not in
'suspended state'.

Keep device's runtime PM status to suspended during
system suspend.

Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Correct an error reporting check

When reading values from the device tree, the error
check on BAM producer pipe must be negated.

Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Remove redundant input first setting in bam mode

The HW is not mandating the use of input first in bam mode,
therefore, that statement is removed.

Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
spi_qsd: Fix SPI L2 Crash

Work queue is scheduled to process
SPI messages  during system suspend
state which leads to crash.

This patch make sure all the messages
in queue are processed before system
suspends.

Signed-off-by: Sana Venkat Raju <c_vsana@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Fix unterminated of_device_id table

Add a NULL table entry at end for msm, ispif and
msm_generic_buf_mgr device tree match tables.

Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Add defensive check in ISPIF driver

In case of error handling, call ispif release only if ispif handle
is valid. In case of mm-qcamara-daemon crash when camera is not open,
these handles are not valid. Hence it leads to kernel crash in ispif
release handler.

Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: Fix RDI1 interface for VFE32

The RDI registers are not defined properly
for VFE32. Fixing this issue by making the
register addresses properly.

Signed-off-by: Abhishek Kondaveeti <akondave@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
USB: gadget: ether: Fix memory corruption issues with multi_pkt_xfers

If gadget xmits packets before host sends RNDIS_MSG_INIT to update
maximum packets supported per transfer, then there is a possibility
of using freed skb memory later from xmit function. Fix such
races which may arise between tx_complete and start_xmit routines
depending on when multi_pkt_transfers are enabled.
Other option is to defer starting TX transfers until RNDIS_MSG_INIT
is received, but then it makes it difficult to handle scenarios
where host doesn't support this message or just doesn't send it.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Perform CRC check on incoming HDLC encoded packet

Diag driver receives HDLC encoded data from the tools and decodes
them. This patch adds checks to the received data. It discards the
packet if the CRC is not correct.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: dci: Fix timestamps on dci events

The first event generated by diag on the peripherals will have a
valid timestamp bytes and the subsequent events generated at the
same time will have reduced timestamp bytes to conserve
space in the buffer. Diag driver zeroed out the timestamp bytes
when it encounters DCI events with reduced timestamp bytes. This
patch adds the valid timestamp for those events.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Check correct status variable to send log mask

Diag driver was incorrectly checking the message mask status to
send the log mask control packet to the peripherals. This patch
checks the correct status variable to send the log mask to the
peripherals.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: NRT read wakelocks held for very long time

During on-device logging with '-b' option,
NRT read wakelocks i.e. diag_nrt_modem_read
and diag_nrt_wcnss_read were held for more than
a day's time. This patch releases the wakelocks
even if SMD channel will be closed.

Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Fix for CRC check for Control byte

0x7E packets can be sent twice in a row.The first 0x7E
is the terminator of the previous command and the next
is a null frame that we should ignore. This patch treats
the 0x7E bytes as packet end only.

Signed-off-by: Katish Paran <kparan@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add new polling command

Diag driver should now support a new polling command for the tools
to recognize the target.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Change format used for printing pointers

Currently, when printing a pointer address the format does not
take advantage of using the pointer conversion specifier. Make
changes to use the pointer conversion specifier.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>