Re: [PATCH 1/2] platform/x86/intel: bytcrc_pwrsrc: Optionally register a power_supply dev

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

 



On Mon, Nov 4, 2024 at 10:36 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> On some Android tablets with Crystal Cove PMIC the DSDT lacks an ACPI AC
> device to indicate whether a charger is plugged in or not.
>
> Add support for registering a "crystal_cove_pwrsrc" power_supply class
> device to indicate charger online status. This is made conditional on
> a "linux,register-pwrsrc-power_supply" boolean device-property to avoid
> registering a duplicate power_supply class device on devices where this
> is already handled by an ACPI AC device.
>
> Note the "linux,register-pwrsrc-power_supply" property is only used on
> x86/ACPI (non devicetree) devs and the devicetree-bindings maintainers
> have requested properties like these to not be added to the devicetree
> bindings, so the new property is deliberately not added to any bindings.

Reviewed-by: Andy Shevchenko <andy@xxxxxxxxxx>

...

+ array_size.h

> +#include <linux/bits.h>
>  #include <linux/debugfs.h>
> +#include <linux/interrupt.h>
>  #include <linux/mfd/intel_soc_pmic.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/power_supply.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>

...

> +       if (device_property_read_bool(pdev->dev.parent, "linux,register-pwrsrc-power_supply")) {

Btw, is that property type of boolean? If not,
device_property_present() has to be used.

...

> +               irq = platform_get_irq(pdev, 0);
> +               if (irq < 0)
> +                       return dev_err_probe(&pdev->dev, irq, "getting IRQ\n");

This dups the embedded error message.

...

> +               data->psy = devm_power_supply_register(&pdev->dev, &crc_pwrsrc_psy_desc, &psy_cfg);
> +               if (IS_ERR(data->psy))
> +                       return dev_err_probe(&pdev->dev, PTR_ERR(data->psy),
> +                                            "registering power-supply\n");
> +
> +               ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> +                                               crc_pwrsrc_irq_handler,
> +                                               IRQF_ONESHOT, KBUILD_MODNAME, data);
> +               if (ret)
> +                       return dev_err_probe(&pdev->dev, ret, "requesting IRQ\n");

With

    struct device *dev = &pdev->dev;

at the top of the function you may make lines shorten and neater.

> +       }

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux