Re: [PATCH v4 4/8] power: power_supply: add battery info platform data retrieval

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

 




Hi,

On Sat, Jan 21, 2017 at 11:14:00PM -0800, Matt Ranostay wrote:
> Add power_supply_get_battery_info() to get battery platform data
> 
> Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
> ---
>  drivers/power/supply/power_supply_core.c | 41 ++++++++++++++++++++++++++++++++
>  include/linux/power_supply.h             |  4 ++++
>  2 files changed, 45 insertions(+)
> 
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 1e0960b646e8..21490b5e233f 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -17,6 +17,7 @@
>  #include <linux/device.h>
>  #include <linux/notifier.h>
>  #include <linux/err.h>
> +#include <linux/of.h>
>  #include <linux/power_supply.h>
>  #include <linux/thermal.h>
>  #include "power_supply.h"
> @@ -487,6 +488,46 @@ struct power_supply *devm_power_supply_get_by_phandle(struct device *dev,
>  EXPORT_SYMBOL_GPL(devm_power_supply_get_by_phandle);
>  #endif /* CONFIG_OF */
>  
> +int power_supply_get_battery_info(struct power_supply *psy,
> +				  struct power_supply_battery_info *info,
> +				  const char *property)
> +{
> +	struct device_node *np = psy->of_node;
> +	struct device_node *power_supply_battery_info_np;
> +	struct property *p;
> +	char *prefix = "fixed-battery";
> +	int ret;
> +
> +	if (!np)
> +		return -ENXIO;

I guess we can print a warning here, that fixed-battery is
currently only supported for DT.

> +	power_supply_battery_info_np = of_parse_phandle(np, property, 0);
> +	if (!power_supply_battery_info_np)
> +		return -ENODEV;

Let's enforce the "monitored-battery" name and remove the property
name as parameter. Iff we need another name, it could be added later.

-- Sebastian

Attachment: signature.asc
Description: PGP signature


[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