Re: [PATCH v4 1/4] power: Add an axp20x-ac-power driver

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

 




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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux