tty: n_smux: After receiving OPEN_ACK flush tx_queue

If a local SMUX client re-opens the channel and tries to send data before
receiving the OPEN_ACK, the transaction will get stuck because the
channel local state is not OPENED.

Add the channel to ready list if tx_queue is not empty after receiving
the OPEN_ACK.

CRs-Fixed: 507379
Change-Id: I357b6edc340c404c890da0c415ed3aeba96dcfe8
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
msm_serial_hs: Fix the unbalanced clk_count

If clock vote is failed, clk_count is added. It may cause the unbalanced
clk_count. Also it's possible to be nagative clk_count on unvote. So do
not decrease the clk_count if it's already zero.

Change-Id: Ic63efd9447a18caaa8fabada4d4cae90558c8785
Signed-off-by: Devin Kim <dojip.kim@lge.com>
msm_serial_hs: check the returned value of clock vote

If voting clock is failed, we should not access the registers.
It may cause a crash to access the unclocked register.

Change-Id: Ifb75dd68696719905b373c4a276c4dc2d917f2fe
Signed-off-by: Devin Kim <dojip.kim@lge.com>
msm_serial_hs: vote for clocks in tty functions

to avoid accessing the unclocked registers.

Change-Id: I17af31b54e2c6288a5284b51670506c44a344fe8
Signed-off-by: Devin Kim <dojip.kim@lge.com>
msm_serial_hs: Fix race condition with BAM rx pipe

Crash observed due to the race condition with bam
rx pipe during sps_disconnect and sps_transfer_one
operations executed at the same time on two CPUs.

Because of this race condition rx bam descriptor
pointer becomes NULL and accessing of this pointer
leads to crash.

This patch waits for sps_transfer_one function to
complete, if it is in progress, before calling
sps_disconnect function from the set_termios.

https://www.codeaurora.org/cgit/quic/la/kernel/msm-3.10/commit/drivers/tty/serial/msm_serial_hs.c?h=msm-3.10&id=478fe086cb075301da4488e3e9e02683b2409084

CRs-Fixed: 534029
Change-Id: I7581062a17a3dc7ede8eb58e4d25e3b517812ab2
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Patrick Tjin <pattjin@google.com>
thermal: qpnp-adc: add tm channel irq disable feature

The tm channel interrupt disable feature was not implemented.
So add this feature to qpnp_adc_tm_channel_configure().

Change-Id: I9b4b708fbaef5db0e5cfc3bf1eaaa400ac2585e5
Signed-off-by: choongryeol.lee <choongryeol.lee@lge.com>
msm: thermal: Refactor core control mitigation only for smp

Refactor core control mitigation only for smp target otherwise it
leads to compilation issue for non smp since cpu_up and cpu_down
functions are not defined.

Change-Id: I73d3792fd9c4ce6d16132b55eb2446dd4bcdfbce
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
msm: thermal: Replace __cpuinit with __ref to support non smp

__cpuinit is causing issues on non smp targets and it also leads to
compilation issues if __cpuinit is completely removed on smp targets
as modpost will complain for calling removable sections from non
removable sections. Replace __cpuinit data with __ref which will
silence the modpost and works fine for non smp targets as well.

Change-Id: Ifa413f6708935b1dcae9438bf39a194372eb0c61
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
hwmon: qpnp-adc: Fix potential errors

There is a possibility of potential out of bound array
access errors and uninitialized variable access from code
inspection. Add additional checks in voltage ADC and
TSENS to check for such errors.

Change-Id: I1213cd76fb636aa457c88d3bdc3740b692f01cce
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
msm: thermal: add wakelock for prevent repeat suspend

when device enters suspend after heating,
device will wake up by low threshold. and send notify
to userspace. however, sometimes It enters into suspend
before setting new threshold value by userspace.
It may cause to repeat suspend/resume cycle.
So, add wakelock for preventing it.

Change-Id: I4a90a74eb0ef8514ec4ee6b3c7bb1cb58372c53a
Signed-off-by: darren.kang <darren.kang@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
msm: thermal: set the core_control_enabled after offline cores update

The variable for offline core is not yet updated in the initial state, but
msm_thermal try to control core at that time and may access the
offlined core(s). It would cause the watchdog bite due to this.

Change-Id: I6abd55b22f3e09ab44e8df0d6fbb8e82cd9e482c
Signed-off-by: Devin Kim <dojip.kim@lge.com>
switch: hds_max1462x: Add maxim headset detection(max1462x) driver

Change-Id: I8df8303126d4b380aa6f33f6b0bcd4b12679714d
Author: Hyunsub Na <hyunsub.na@lge.com>
Signed-off-by: Hyunsub Na <hyunsub.na@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
switch: hds_max1462x: fix the mismatch enable/disable of key_irq

irq_key is automatically enabled in request_threaded_irq function.
So, the duplicated IRQ warning message is displayed in kmsg.
Therefore, it's changed to disable irq_key after irq request.
Because the irq_key is need only 4-pole.

Change-Id: I6eee5a0c8372884305c3878f13bed22d5bb09cbd
Signed-off-by: sangwoo <sangwoo2.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Sensors: Invensense 5.1.6 IIO driver release

-- Patches provided to handle poll function better in Kfifo situation in
   industrialio-buffer.c
-- the new IIO MPU6515 (Accelerometer/Gyro) driver
-- secondary bus support of AKM8963 (compass)
-- secondary bus support of BMP280 (pressure)

Change-Id: I0c16e032723894951ee3fe1e0ad21a74208780b7
Signed-off-by: chohee.park <chohee.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Sensors: Fix permission of iio:device0 nodes

sysfs nodes should not be world writable.

Change-Id: Ia22378c48aff6db87f006f006c0d924329431d3e
Signed-off-by: Devin Kim <dojip.kim@lge.com>
ashmem: avoid deadlock between read and mmap calls

Avoid holding ashmem_mutex across code that can page fault.  Page faults
grab the mmap_sem for the process, which are also held by mmap calls
prior to calling ashmem_mmap, which locks ashmem_mutex.  The reversed
order of locking between the two can deadlock.

The calls that can page fault are read() and the ASHMEM_SET_NAME and
ASHMEM_GET_NAME ioctls.  Move the code that accesses userspace pages
outside the ashmem_mutex.

Bug: 9261835
Change-Id: If1322e981d29c889a56cdc9dfcbc6df2729a45e9
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Sensors: Invensense Motion Apps 5.1.6 Release Candidate 25

- Added multi-rate support for sensors in batch mode.
- Fix step detector and step counter bugs.
- Calib-bias entries are now updated after executing self_test.
- Fix batching mode bug where timeout greater than buffer size was not being handled correctly.
- Ensure MPU goes into sleep mode when idle.
- Fifo overflows checks added to batch mode.
- Batch mode takes priority over continuous mode when concurrent requests are made.

Change-Id: I0cb827df09dd9eda3b6f981280f6d05802853721
Signed-off-by: chohee.park <chohee.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Revert "staging: android: ram_console: honor dmesg_restrict"

This reverts commit dd09979346813357200adf71b07003fc0a778089.

Signed-off-by: Patrick Tjin <pattjin@google.com>
Sensors: Invensense Motion Apps 5.1.6 Release Candidate 33

Changes:
- Improved the handling of the biases both for factory calibration and
  runtime calibration via the gyro and accel offset and dmp_bias sysfs
  entries
- Prevented a possible race condition in batch mode settings
- Improved the data flow handling for some sensors and sensor scenarios
- Keep track of the batch mode requests for sensors even if the system
  proceeds in continuous mode - necessary when batch mode is restored
- Changed pressure values to floating point for better resolution
- Pedometer time and steps representation is now 64 bits
- Fixes a number of sensor combination corner cases involving Pedometer
  Step Detector
- Fixed long term drift issue in batched Game Rotation Vector
- Fixed misconfiguration caused by Significant Motion getting detected
  while working with other sensors
- Fixed Linear Accelerometer sample count in batching
- Fixed handling of the rates with combination of sensors involving
  virtual sensors
- Output all the data in the FIFO when a Significant Motion is detected.
  Do the same when the system comes back up from suspended.
- Fixed sensors getting left wrongly configured and not outputting any
  data when other sensors are enabled or disabled
- Fixed duplicated timestamp issues with Gravity vector sensor
- Fixed problems with the sensor rates in continuous and batch mode
- Fixed a problem causing high timestamp variance for the Gyroscope sensor
  while running the Step Detector sensor
- Applied patch to self-test fail on heamerhead

Change-Id: I6c54e5aadd9a57fc38a8de8015fc009f1652a90c
Signed-off-by: chohee.park <chohee.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Motion Apps 5.1.6 Release Candidate 54

Changes since MA 5.1.6 RC33

- Integrated flush feature within batching support with FLUSH_COMPLETE
  metadata indicator
- Handling accelerometer biases through the device's offset registers
  as for the gyroscope
- Added ability to write the accelerometer and gyroscope biases
  on the offset registers directly after self-test test execution
  for more seamless production floor handling
- Fixed batch mode timestamps across system suspend and resumes
- Estimate the timestamps using the devices's clock more reliably;
- Output the data in the FIFO when switching data mode (batching
  to continuous and vice versa, change of rate, addition/removal of a sensor)
- Accelerometer auto calibration does not overwrite the self-test accelerometer
  biases unless they are improving
- Added dynamic control of the HAL and SensorService logging
  using Android properties.

Change-Id: I94cf6eaedeb719f0bc2292c1dcfd20e24d8134f7
Signed-off-by: chohee.park <chohee.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>