Skip to content

Commit

Permalink
extcon: ptn5150: Add queue work sync before driver release
Browse files Browse the repository at this point in the history
[ Upstream commit 782cd93 ]

Add device managed action to sync pending queue work, otherwise
the queued work may run after the work is destroyed.

Fixes: 4ed754d ("extcon: Add support for ptn5150 extcon driver")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Junlisuzhou authored and gregkh committed Jun 14, 2022
1 parent 9758a66 commit 3bb777a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/extcon/extcon-ptn5150.c
Expand Up @@ -194,6 +194,13 @@ static int ptn5150_init_dev_type(struct ptn5150_info *info)
return 0;
}

static void ptn5150_work_sync_and_put(void *data)
{
struct ptn5150_info *info = data;

cancel_work_sync(&info->irq_work);
}

static int ptn5150_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
Expand Down Expand Up @@ -284,6 +291,10 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
if (ret)
return -EINVAL;

ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info);
if (ret)
return ret;

/*
* Update current extcon state if for example OTG connection was there
* before the probe
Expand Down

0 comments on commit 3bb777a

Please sign in to comment.