[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Ve_WRAUyy=h9_F-tC1dDkb_=-F1uf7_h7R0p7xZgBAd-w@mail.gmail.com>
Date: Fri, 15 Jul 2022 18:51:27 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: ChiaEn Wu <peterwu.pub@...il.com>
Cc: Lee Jones <lee.jones@...aro.org>,
Daniel Thompson <daniel.thompson@...aro.org>,
Jingoo Han <jingoohan1@...il.com>, Pavel Machek <pavel@....cz>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Sebastian Reichel <sre@...nel.org>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Guenter Roeck <linux@...ck-us.net>,
"Krogerus, Heikki" <heikki.krogerus@...ux.intel.com>,
Helge Deller <deller@....de>,
ChiaEn Wu <chiaen_wu@...htek.com>,
Alice Chen <alice_chen@...htek.com>,
cy_huang <cy_huang@...htek.com>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Linux LED Subsystem <linux-leds@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux PM <linux-pm@...r.kernel.org>,
USB <linux-usb@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
"open list:FRAMEBUFFER LAYER" <linux-fbdev@...r.kernel.org>,
szuni chen <szunichen@...il.com>
Subject: Re: [PATCH v5 10/13] power: supply: mt6370: Add MediaTek MT6370
charger driver
On Fri, Jul 15, 2022 at 1:29 PM ChiaEn Wu <peterwu.pub@...il.com> wrote:
>
> From: ChiaEn Wu <chiaen_wu@...htek.com>
>
> MediaTek MT6370 is a SubPMIC consisting of a single cell battery charger
> with ADC monitoring, RGB LEDs, dual channel flashlight, WLED backlight
> driver, display bias voltage supply, one general purpose LDO, and the
> USB Type-C & PD controller complies with the latest USB Type-C and PD
> standards.
>
> This adds MediaTek MT6370 Charger driver support. The charger module
> of MT6370 supports High-Accuracy Voltage/Current Regulation,
> Average Input Current Regulation, Battery Temperature Sensing,
> Over-Temperature Protection, DPDM Detection for BC1.2.
...
> +static int mt6370_chg_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct mt6370_priv *priv;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = &pdev->dev;
> +
> + priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> + if (!priv->regmap)
> + return dev_err_probe(&pdev->dev, -ENODEV,
> + "Failed to get regmap\n");
> +
> + ret = mt6370_chg_init_rmap_fields(priv);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "Failed to init regmap fields\n");
> +
> + platform_set_drvdata(pdev, priv);
> +
> + priv->iio_adcs = devm_iio_channel_get_all(priv->dev);
> + if (IS_ERR(priv->iio_adcs))
> + return dev_err_probe(&pdev->dev, PTR_ERR(priv->iio_adcs),
> + "Failed to get iio adc\n");
> +
> + ret = mt6370_chg_init_otg_regulator(priv);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "Failed to init otg regulator\n");
> +
> + ret = mt6370_chg_init_psy(priv);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "Failed to init psy\n");
> +
> + mutex_init(&priv->attach_lock);
> + priv->attach = MT6370_ATTACH_STAT_DETACH;
> +
> + priv->wq = create_singlethread_workqueue(dev_name(priv->dev));
> + if (IS_ERR(priv->wq))
> + return dev_err_probe(priv->dev, PTR_ERR(priv->wq),
> + "Failed to create workqueue\n");
You need either wrap mutex to be deallocated by devm or don't use
dev_err_probe() here.
> + INIT_WORK(&priv->bc12_work, mt6370_chg_bc12_work_func);
> + INIT_DELAYED_WORK(&priv->mivr_dwork, mt6370_chg_mivr_dwork_func);
> +
> + ret = mt6370_chg_init_setting(priv);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to init mt6370 charger setting\n");
> + goto probe_out;
> + }
> +
> + ret = mt6370_chg_init_irq(priv);
> + if (ret)
> + goto probe_out;
> +
> + mt6370_chg_pwr_rdy_check(priv);
> +
> + return 0;
> +
> +probe_out:
> + cancel_delayed_work_sync(&priv->mivr_dwork);
> + flush_workqueue(priv->wq);
> + destroy_workqueue(priv->wq);
> + mutex_destroy(&priv->attach_lock);
> +
> + return ret;
> +}
> +
> +static int mt6370_chg_remove(struct platform_device *pdev)
> +{
> + struct mt6370_priv *priv = platform_get_drvdata(pdev);
> +
> + cancel_delayed_work_sync(&priv->mivr_dwork);
> + flush_workqueue(priv->wq);
> + destroy_workqueue(priv->wq);
> + mutex_destroy(&priv->attach_lock);
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists