[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdCgdTOu-CdNo9XGY+PrhPh93v_CkAHJC6hkArsKeiXbA@mail.gmail.com>
Date: Fri, 15 Jul 2022 15:10:42 +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 08/13] usb: typec: tcpci_mt6370: Add MediaTek MT6370
tcpci driver
On Fri, Jul 15, 2022 at 1:28 PM ChiaEn Wu <peterwu.pub@...il.com> wrote:
> The MT6370 is a highly-integrated smart power management IC, which
> includes a single cell Li-Ion/Li-Polymer switching battery charger,
> a USB Type-C & Power Delivery (PD) controller, dual Flash LED current
> sources, a RGB LED driver, a backlight WLED driver, a display bias
> driver and a general LDO for portable devices.
>
> This commit add support for the Type-C & Power Delivery controller in
This commit add -> Add
> MediaTek MT6370 IC.
> +static int mt6370_tcpc_probe(struct platform_device *pdev)
> +{
> + struct mt6370_priv *priv;
> + struct device *dev = &pdev->dev;
> + int ret;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = dev;
> + platform_set_drvdata(pdev, priv);
> +
> + priv->tcpci_data.regmap = dev_get_regmap(dev->parent, NULL);
> + if (!priv->tcpci_data.regmap)
> + return dev_err_probe(dev, -ENODEV, "Failed to init regmap\n");
> +
> + ret = mt6370_check_vendor_info(priv);
> + if (ret)
> + return ret;
> +
> + priv->irq = platform_get_irq(pdev, 0);
> + if (priv->irq < 0)
> + return priv->irq;
> +
> + /* Assign TCPCI feature and ops */
> + priv->tcpci_data.auto_discharge_disconnect = 1;
> + priv->tcpci_data.init = mt6370_tcpc_init;
> + priv->tcpci_data.set_vconn = mt6370_tcpc_set_vconn;
> +
> + priv->vbus = devm_regulator_get_optional(dev, "vbus");
> + if (!IS_ERR(priv->vbus))
> + priv->tcpci_data.set_vbus = mt6370_tcpc_set_vbus;
> +
> + priv->tcpci = tcpci_register_port(dev, &priv->tcpci_data);
> + if (IS_ERR(priv->tcpci))
> + return dev_err_probe(dev, PTR_ERR(priv->tcpci),
> + "Failed to register tcpci port\n");
> +
> + ret = devm_request_threaded_irq(dev, priv->irq, NULL,
> + mt6370_irq_handler, IRQF_ONESHOT,
> + dev_name(dev), priv);
> + if (ret) {
> + tcpci_unregister_port(priv->tcpci);
This is wrong.
You mixed devm_ with non-devm. Either drop devm_ *after* the first
non-devm_ call, or convert everything to be managed.
> + return dev_err_probe(dev, ret, "Failed to allocate irq\n");
> + }
> +
> + device_init_wakeup(dev, true);
> + dev_pm_set_wake_irq(dev, priv->irq);
> +
> + return 0;
> +}
> +
> +static int mt6370_tcpc_remove(struct platform_device *pdev)
> +{
> + struct mt6370_priv *priv = platform_get_drvdata(pdev);
> + disable_irq(priv->irq);
Why?
An ugly workaround due to ordering issues in ->probe()?
> + tcpci_unregister_port(priv->tcpci);
> + dev_pm_clear_wake_irq(&pdev->dev);
> + device_init_wakeup(&pdev->dev, false);
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists