summaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-axp288.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-12-18 19:13:09 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2017-01-08 20:04:10 -0500
commit5d2199ea340d158587b09e2ab95908c210fd4742 (patch)
tree0df9f2a7c9793dc4c37eacae6424688c5101a187 /drivers/extcon/extcon-axp288.c
parent3fe1e0e2ab509863c1e9809a085508d8bce3e079 (diff)
extcon: axp288: Fix possibly reporting 2 cables in state true
When the charger type changes from e.g. SDP to CDP, without Vbus being seen as low in between axp288_handle_chrg_det_event would set the state for the new cable type to true, without clearing the state of the previous cable type to false. This commit fixes this and also gets rid of the function local static cable variable, properly storing all drv state in the axp288_extcon_info struct. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-axp288.c')
-rw-r--r--drivers/extcon/extcon-axp288.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 43b3637a71a9..98289a266810 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -115,6 +115,7 @@ struct axp288_extcon_info {
115 int irq[EXTCON_IRQ_END]; 115 int irq[EXTCON_IRQ_END];
116 struct extcon_dev *edev; 116 struct extcon_dev *edev;
117 struct notifier_block extcon_nb; 117 struct notifier_block extcon_nb;
118 unsigned int previous_cable;
118}; 119};
119 120
120/* Power up/down reason string array */ 121/* Power up/down reason string array */
@@ -154,9 +155,9 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
154 155
155static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) 156static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
156{ 157{
157 static unsigned int cable;
158 int ret, stat, cfg, pwr_stat; 158 int ret, stat, cfg, pwr_stat;
159 u8 chrg_type; 159 u8 chrg_type;
160 unsigned int cable = info->previous_cable;
160 bool vbus_attach = false; 161 bool vbus_attach = false;
161 162
162 ret = regmap_read(info->regmap, AXP288_PS_STAT_REG, &pwr_stat); 163 ret = regmap_read(info->regmap, AXP288_PS_STAT_REG, &pwr_stat);
@@ -212,7 +213,11 @@ no_vbus:
212 vbus_attach ? EXTCON_GPIO_MUX_SEL_SOC 213 vbus_attach ? EXTCON_GPIO_MUX_SEL_SOC
213 : EXTCON_GPIO_MUX_SEL_PMIC); 214 : EXTCON_GPIO_MUX_SEL_PMIC);
214 215
215 extcon_set_state_sync(info->edev, cable, vbus_attach); 216 extcon_set_state_sync(info->edev, info->previous_cable, false);
217 if (vbus_attach) {
218 extcon_set_state_sync(info->edev, cable, vbus_attach);
219 info->previous_cable = cable;
220 }
216 221
217 return 0; 222 return 0;
218 223
@@ -263,6 +268,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
263 info->dev = &pdev->dev; 268 info->dev = &pdev->dev;
264 info->regmap = axp20x->regmap; 269 info->regmap = axp20x->regmap;
265 info->regmap_irqc = axp20x->regmap_irqc; 270 info->regmap_irqc = axp20x->regmap_irqc;
271 info->previous_cable = EXTCON_NONE;
266 if (pdata) 272 if (pdata)
267 info->gpio_mux_cntl = pdata->gpio_mux_cntl; 273 info->gpio_mux_cntl = pdata->gpio_mux_cntl;
268 274