qcom-charger: use mutex instead of spinlock when calling the regmap API
Slow buses regmap holds a mutex lock, while for fast buses regmap holds a spinlock. In order to remain compatible with slow buses spinlocks should not be held before calling the regmap API. CRs-Fixed: 1017800 Change-Id: I93aa6df8c7ec1916ba23d21d92e477510db949da Signed-off-by: Harry Yang <harryy@codeaurora.org>
This commit is contained in:
parent
6a70911936
commit
ebfad685ef
2 changed files with 6 additions and 8 deletions
|
@ -47,10 +47,9 @@ int smblib_read(struct smb_charger *chg, u16 addr, u8 *val)
|
|||
|
||||
int smblib_masked_write(struct smb_charger *chg, u16 addr, u8 mask, u8 val)
|
||||
{
|
||||
unsigned long flags;
|
||||
int rc = 0;
|
||||
|
||||
spin_lock_irqsave(&chg->write_lock, flags);
|
||||
mutex_lock(&chg->write_lock);
|
||||
if (is_secure(chg, addr)) {
|
||||
rc = regmap_write(chg->regmap, (addr & 0xFF00) | 0xD0, 0xA5);
|
||||
if (rc < 0)
|
||||
|
@ -60,16 +59,15 @@ int smblib_masked_write(struct smb_charger *chg, u16 addr, u8 mask, u8 val)
|
|||
rc = regmap_update_bits(chg->regmap, addr, mask, val);
|
||||
|
||||
unlock:
|
||||
spin_unlock_irqrestore(&chg->write_lock, flags);
|
||||
mutex_unlock(&chg->write_lock);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int smblib_write(struct smb_charger *chg, u16 addr, u8 val)
|
||||
{
|
||||
unsigned long flags;
|
||||
int rc = 0;
|
||||
|
||||
spin_lock_irqsave(&chg->write_lock, flags);
|
||||
mutex_lock(&chg->write_lock);
|
||||
|
||||
if (is_secure(chg, addr)) {
|
||||
rc = regmap_write(chg->regmap, (addr & ~(0xFF)) | 0xD0, 0xA5);
|
||||
|
@ -80,7 +78,7 @@ int smblib_write(struct smb_charger *chg, u16 addr, u8 val)
|
|||
rc = regmap_write(chg->regmap, addr, val);
|
||||
|
||||
unlock:
|
||||
spin_unlock_irqrestore(&chg->write_lock, flags);
|
||||
mutex_unlock(&chg->write_lock);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1281,7 +1279,7 @@ int smblib_init(struct smb_charger *chg)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
spin_lock_init(&chg->write_lock);
|
||||
mutex_init(&chg->write_lock);
|
||||
INIT_DELAYED_WORK(&chg->hvdcp_detect_work, smblib_hvdcp_detect_work);
|
||||
|
||||
chg->usb_suspend_votable = create_votable(chg->dev,
|
||||
|
|
|
@ -62,7 +62,7 @@ struct smb_charger {
|
|||
int *debug_mask;
|
||||
|
||||
/* locks */
|
||||
spinlock_t write_lock;
|
||||
struct mutex write_lock;
|
||||
struct mutex ps_change_lock;
|
||||
|
||||
/* power supplies */
|
||||
|
|
Loading…
Add table
Reference in a new issue