Thread (38 messages) 38 messages, 8 authors, 2022-07-21

Re: [PATCH v5 08/13] usb: typec: tcpci_mt6370: Add MediaTek MT6370 tcpci driver

From: Andy Shevchenko <hidden>
Date: 2022-07-18 11:39:21
Also in: dri-devel, linux-arm-kernel, linux-devicetree, linux-iio, linux-leds, linux-mediatek, linux-pm, linux-usb, lkml

On Mon, Jul 18, 2022 at 10:08 AM ChiYuan Huang [off-list ref] wrote:
On Fri, Jul 15, 2022 at 03:10:42PM +0200, Andy Shevchenko wrote:
quoted
On Fri, Jul 15, 2022 at 1:28 PM ChiaEn Wu [off-list ref] wrote:
...
quoted
quoted
This commit add support for the Type-C & Power Delivery controller in
This commit add -> Add
Upper case? Or rewrite it as 'This commit is to add .....'?
Please, read this documentation [1] for better understanding. It
should clarify this and perhaps other possible questions.

[1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes
quoted
quoted
MediaTek MT6370 IC.
...
quoted
quoted
+       ret = devm_request_threaded_irq(dev, priv->irq, NULL,
+                                       mt6370_irq_handler, IRQF_ONESHOT,
+                                       dev_name(dev), priv);
+       if (ret) {
quoted
+               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.
How about to add 'devm_add_action_or_reset' for tcpci_unregister_port?
This will convert all as 'devm_' version.
I think it would work, that wrapper was designed to cover cases like this.
quoted
quoted
+               return dev_err_probe(dev, ret, "Failed to allocate irq\n");
+       }
...
quoted
quoted
+static int mt6370_tcpc_remove(struct platform_device *pdev)
+{
+       struct mt6370_priv *priv = platform_get_drvdata(pdev);
quoted
+       disable_irq(priv->irq);
Why?
An ugly workaround due to ordering issues in ->probe()?
Yes, due to the ordering in probe.
'bus remove' will be called before device resource releases.

Like as you said, another way is to convert all as non-devm
version after 'tcpci_unregister_port'.

If to keep the original order, 'disable_irq' before
'tcpci_unregister_port' can make the flow more safe.

Or you can think one case if irq triggers after
'tcpci_unregister_port'. Null pointer occurs.

Anyway, in next revision, I'll convert all to be 'devm_' version.
For this remove callback, only 'dev_pm_clear_wake_irq' and
'device_init_wakeup' will be kept.

Is this better?
Sounds like a plan!
quoted
quoted
+       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help