Re: [PATCH v6 10/13] power: supply: mt6370: Add MediaTek MT6370 charger driver

From
Andy Shevchenko <hidden>
Date
2022-07-25 08:25:50
Also in
dri-devel, linux-arm-kernel, linux-devicetree, linux-iio, linux-leds, linux-mediatek, linux-pm, linux-usb, lkml
Reply to
ChiaEn Wu, 2022-07-22
On Fri, Jul 22, 2022 at 12:25 PM ChiaEn Wu [off-list ref] wrote:
From: ChiaEn Wu <redacted>

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.
...
quoted hunk ↗ jump to hunk
+static inline void mt6370_chg_enable_irq(struct mt6370_priv *priv,
+                                        const char *irq_name, bool en)
+{
+       int irq_num;
+       struct platform_device *pdev = to_platform_device(priv->dev);
+
+       irq_num = platform_get_irq_byname(pdev, irq_name);
Every time the IRQ is not found you will get an error message printed here.
1) Is IRQ optional?
2) If not, can't you do validation only once?
quoted hunk ↗ jump to hunk
+       if (irq_num < 0)
+               return;
+
+       if (en)
+               enable_irq(irq_num);
+       else
+               disable_irq_nosync(irq_num);
+}

...
+       ret = mt6370_chg_field_set(priv, F_USBCHGEN, 0);
+       if (ret < 0) {
+       ret = mt6370_chg_field_set(priv, F_ICHG, 900000);
+       if (ret < 0) {
+       ret = mt6370_chg_field_set(priv, F_IINLMTSEL, 3);
+       if (ret < 0) {
Do all these ' < 0' parts make sense?
(Not only these cases, but in many in the entire driver)

...
+       /* Check in otg mode or not */
OTG

...
quoted hunk ↗ jump to hunk
+               ret = devm_request_threaded_irq(priv->dev, ret, NULL,
+                                               mt6370_chg_irqs[i].handler,
+                                               IRQF_TRIGGER_FALLING,
+                                               dev_name(priv->dev), priv);
+
Redundant blank line.
quoted hunk ↗ jump to hunk
+               if (ret < 0)
+                       return dev_err_probe(priv->dev, ret,
+                                            "Failed to request irq %s\n",
+                                            mt6370_chg_irqs[i].name);
+       }
-- 
With Best Regards,
Andy Shevchenko
Thread (52 messages) 52 messages, 8 authors, last reply 2022-08-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help