]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: mt6370: Simplify with devm_alloc_ordered_workqueue()
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Thu, 5 Mar 2026 21:45:44 +0000 (22:45 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 11 Mar 2026 05:58:00 +0000 (06:58 +0100)
Simplify the driver probe function by using
devm_alloc_ordered_workqueue() which handles the cleanup already.

Change is not equivalent in the workqueue itself: use non-legacy API
which does not set (__WQ_LEGACY | WQ_MEM_RECLAIM).  The workqueue is
used to update power supply data (power_supply_changed()) status, thus
there is no point to run it for memory reclaim.  Note that dev_name() is
not directly used in second argument to prevent possible unlikely
parsing any "%" character in device name as format.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260305-workqueue-devm-v2-5-66a38741c652@oss.qualcomm.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/mt6370-charger.c

index e6db961d5818d767cadf54b6905029f866e08667..916556baa854a10bf22dcf564196ea9750f555cc 100644 (file)
@@ -761,13 +761,6 @@ static int mt6370_chg_init_psy(struct mt6370_priv *priv)
        return PTR_ERR_OR_ZERO(priv->psy);
 }
 
-static void mt6370_chg_destroy_wq(void *data)
-{
-       struct workqueue_struct *wq = data;
-
-       destroy_workqueue(wq);
-}
-
 static irqreturn_t mt6370_attach_i_handler(int irq, void *data)
 {
        struct mt6370_priv *priv = data;
@@ -893,14 +886,10 @@ static int mt6370_chg_probe(struct platform_device *pdev)
 
        priv->attach = MT6370_ATTACH_STAT_DETACH;
 
-       priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
+       priv->wq = devm_alloc_ordered_workqueue(dev, "%s", 0, dev_name(priv->dev));
        if (!priv->wq)
                return -ENOMEM;
 
-       ret = devm_add_action_or_reset(dev, mt6370_chg_destroy_wq, priv->wq);
-       if (ret)
-               return ret;
-
        ret = devm_work_autocancel(dev, &priv->bc12_work, mt6370_chg_bc12_work_func);
        if (ret)
                return dev_err_probe(dev, ret, "Failed to init bc12 work\n");