msm_bam_rmnet: Fix potential memory corruption

Usage of legacy string manipulation function sprintf could lead to
memory corruption as the number of bytes to be written to the
destination is not bounded. Replace sprintf with snprintf where the
number of bytes to be written is explicitly specified.

CRs-fixed: 672202
Change-Id: Iab7516ad0e2540eb619fe96e26a3516c7adf86cc
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
msm: mpm-of: Remove explicit freeing managed resources

The platform model takes care of free'ing managed resources when probe
fails. Remove explicit calls to free managed resources. This will ensure
that all mananged resources are handled correclty by the platform
device framework.

Change-Id: I6062b1dab55c468ee224f0ca7c8e47631a1ff3c7
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: mpm-of: set wakeup interrupt as NO_SUSPEND

The MPM wakeup interrupt is used to wakeup the Apps processor from
a system wide low power mode when the GIC isn't operational.

The MPM interrupt is configured as a wakeup interrupt by calling into
irq_set_irq_wake().It also needs to be configured with the
IRQF_NO_SUSPEND to prevent the irq from getting disabled during
suspend_device_irqs() in the suspend path. The interrupt is not
re-enabled until after gic_suspend() is executed as a part of the
syscore_suspend() callback.

If the CPU's idle thread enters RPM assisted power collapse between
suspend_device_irqs() and syscore_suspend, the masking of the RPM wakeup
interrupt could prevent wakeup by RPM.

Change-Id: I0d5f0d7277774ddef6817eac10156f92174ec15f
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: mpm-of: Bug fixes.

When traversing the hlist, the driver incorrectly checks for NULL of
list node instead of the loop cursor to return an mpm pin mapping. Fix
by checking the NULL value of the loop cursor before return the MPM pin
mapping.

Also, when the pin corresponds to a bypassed interrupt, there could
potentially be a out of bounds access on the msm_mpm_irqs_m2a array. Fix
by adding a check for Bypass interrupt value before updating the array
with a linux irq mapping.

Change-Id: Ie6bc201a443d1d038f3680af1cc64f5b32fb47a4
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: mpm-of: Fix buffer overflow errors.

Fix accessing an out of bound index in an array during certain error
scenarios.

Change-Id: I624beda60316fc9ab40bdedc17ed9d993714a516
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: mpm-of: Fix incorrect setting of edge control

The edge control register was being set incorrectly assuming continuous
2 bit values in detect control register.Per the Hardware Programming
guide, two different registers are used to configure the rising/falling
properties of the interrupts.

CRs-fixed: 471545
Change-Id: I60036b34a41e560fe8ce38c563cd276ed5e2e080
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>