Skip to content

Commit 5aaa096

Browse files
committed
Merge tag 'extcon-fixes-for-4.16-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-linus
Chanwoo writes: Update extcon for v4.16-rc3 This patch fixes issue of X-power extcon-axp288 and Intel extcon-int3496 driver. - For extcon-int3496 driver, Process id-pin first so that we start with the right status in order to fix a race where the initial work might still be running while other drivers were already calling extcon_get_state(). - For extcon-axp288 driver, Revert the patch[1] which were applied to v4.16-rc1 because there are better ways with usb-role-switch and constify the axp288_pwr_up_down_info array. [1] 60ed999 ("extcon: axp288: Redo charger type detection a couple of seconds after probe()")
2 parents 7ae079a + 0434352 commit 5aaa096

2 files changed

Lines changed: 6 additions & 33 deletions

File tree

‎drivers/extcon/extcon-axp288.c‎

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
22
* extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
33
*
4-
* Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com>
54
* Copyright (C) 2015 Intel Corporation
65
* Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
76
*
@@ -98,15 +97,13 @@ struct axp288_extcon_info {
9897
struct device *dev;
9998
struct regmap *regmap;
10099
struct regmap_irq_chip_data *regmap_irqc;
101-
struct delayed_work det_work;
102100
int irq[EXTCON_IRQ_END];
103101
struct extcon_dev *edev;
104102
unsigned int previous_cable;
105-
bool first_detect_done;
106103
};
107104

108105
/* Power up/down reason string array */
109-
static char *axp288_pwr_up_down_info[] = {
106+
static const char * const axp288_pwr_up_down_info[] = {
110107
"Last wake caused by user pressing the power button",
111108
"Last wake caused by a charger insertion",
112109
"Last wake caused by a battery insertion",
@@ -124,7 +121,7 @@ static char *axp288_pwr_up_down_info[] = {
124121
*/
125122
static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
126123
{
127-
char **rsi;
124+
const char * const *rsi;
128125
unsigned int val, i, clear_mask = 0;
129126
int ret;
130127

@@ -140,25 +137,6 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
140137
regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
141138
}
142139

143-
static void axp288_chrg_detect_complete(struct axp288_extcon_info *info)
144-
{
145-
/*
146-
* We depend on other drivers to do things like mux the data lines,
147-
* enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has
148-
* not set these things up correctly resulting in the initial charger
149-
* cable type detection giving a wrong result and we end up not charging
150-
* or charging at only 0.5A.
151-
*
152-
* So we schedule a second cable type detection after 2 seconds to
153-
* give the other drivers time to load and do their thing.
154-
*/
155-
if (!info->first_detect_done) {
156-
queue_delayed_work(system_wq, &info->det_work,
157-
msecs_to_jiffies(2000));
158-
info->first_detect_done = true;
159-
}
160-
}
161-
162140
static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
163141
{
164142
int ret, stat, cfg, pwr_stat;
@@ -223,8 +201,6 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
223201
info->previous_cable = cable;
224202
}
225203

226-
axp288_chrg_detect_complete(info);
227-
228204
return 0;
229205

230206
dev_det_ret:
@@ -246,11 +222,8 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
246222
return IRQ_HANDLED;
247223
}
248224

249-
static void axp288_extcon_det_work(struct work_struct *work)
225+
static void axp288_extcon_enable(struct axp288_extcon_info *info)
250226
{
251-
struct axp288_extcon_info *info =
252-
container_of(work, struct axp288_extcon_info, det_work.work);
253-
254227
regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
255228
BC_GLOBAL_RUN, 0);
256229
/* Enable the charger detection logic */
@@ -272,7 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
272245
info->regmap = axp20x->regmap;
273246
info->regmap_irqc = axp20x->regmap_irqc;
274247
info->previous_cable = EXTCON_NONE;
275-
INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work);
276248

277249
platform_set_drvdata(pdev, info);
278250

@@ -318,7 +290,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
318290
}
319291

320292
/* Start charger cable type detection */
321-
queue_delayed_work(system_wq, &info->det_work, 0);
293+
axp288_extcon_enable(info);
322294

323295
return 0;
324296
}

‎drivers/extcon/extcon-intel-int3496.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ static int int3496_probe(struct platform_device *pdev)
153153
return ret;
154154
}
155155

156-
/* queue initial processing of id-pin */
156+
/* process id-pin so that we start with the right status */
157157
queue_delayed_work(system_wq, &data->work, 0);
158+
flush_delayed_work(&data->work);
158159

159160
platform_set_drvdata(pdev, data);
160161

0 commit comments

Comments
 (0)