On 05/09/2016 06:33 PM, Chen-Yu Tsai wrote:

>> +
>> +       power->supply = devm_power_supply_register(&pdev->dev,
>> +                                       &axp20x_ac_power_desc, &psy_cfg);
>> +       if (IS_ERR(power->supply))
>> +               return PTR_ERR(power->supply);
>> +
>> +       /* Request irqs after registering, as irqs may trigger immediately */
>> +       for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
>> +               irq = platform_get_irq_byname(pdev, irq_names[i]);
>> +               if (irq < 0) {
>> +                       dev_warn(&pdev->dev, "No IRQ for %s: %d\n",
>> +                                irq_names[i], irq);
>> +                       continue;
>> +               }
>> +               irq = regmap_irq_get_virq(axp20x->regmap_irqc, irq);
>> +               r = devm_request_any_context_irq(&pdev->dev, irq,
>> +                               axp20x_irq_ac_handler, 0, DRVNAME, power);
>> +               if (r < 0)
>> +                       dev_warn(&pdev->dev, "Error requesting %s IRQ: %d\n",
>> +                                irq_names[i], r);
> 
> Won't missing IRQs hinder the usage of this driver / hardware?
> A power supply isn't much use if the system isn't told when
> it's gone.
> 

That's a good point. The real question is: how would you handle missing
IRQs? I have looked at other uses of devm_request_any_context_irq, e.g.
in rtc-pm8xxx.c [0]. These other users often return an error code in the
probe function. That doesn't help the system, though: it still won't
notice if the power is unplugged in addition to missing the driver
completely.

It's probably best to provide the remaining (functional) parts of the
driver (reading from /sys/class..) even if the IRQs cannot be
registered. The code is pretty much the same in  the axp20x-usb-power.

Michael

[0] http://lxr.free-electrons.com/source/drivers/rtc/rtc-pm8xxx.c#L490

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to