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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 22, 2022 at 12:25 PM ChiaEn Wu <peterwu.pub@xxxxxxxxx> wrote:
>
> From: ChiaEn Wu <chiaen_wu@xxxxxxxxxxx>
>
> 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 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?

> +       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

...

> +               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.

> +               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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux