The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Bjorn Andersson <andersson@kernel.org>
To: Rakesh Kota <rakesh.kota@oss.qualcomm.com>
Cc: Konrad Dybcio <konradybcio@kernel.org>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Sebastian Reichel <sre@kernel.org>,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] power: supply: qcom_battmgr: Add support batteryless boards as MAINS
Date: Thu, 16 Jul 2026 19:12:32 -0500	[thread overview]
Message-ID: <allv5PQRd8kr2JG1@baldur> (raw)
In-Reply-To: <20260518-add_dc_in_support-v1-2-31fbaa329879@oss.qualcomm.com>

On Mon, May 18, 2026 at 07:19:40PM +0530, Rakesh Kota wrote:
> Add support for the "qcom,batteryless" device tree property.
> When this boolean property is present, the driver registers the power
> supply as POWER_SUPPLY_TYPE_MAINS instead of BATTERY. This prevents
> userspace from triggering battery power-saving sequences when using
> powered by 12V adapters.
> 
> Signed-off-by: Rakesh Kota <rakesh.kota@oss.qualcomm.com>
> ---
>  drivers/power/supply/qcom_battmgr.c | 47 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
> index 490137a23d00e97a9e6ced21d1e66fe637db6c9d..35d266375d8c46b161a64f9c2a8c6054dc2211de 100644
> --- a/drivers/power/supply/qcom_battmgr.c
> +++ b/drivers/power/supply/qcom_battmgr.c
> @@ -332,6 +332,7 @@ struct qcom_battmgr {
>  	struct qcom_battmgr_wireless wireless;
>  
>  	struct work_struct enable_work;
> +	bool batteryless;

This is a local variable used only within qcom_battmgr_probe()

>  
>  	/*
>  	 * @lock is used to prevent concurrent power supply requests to the
> @@ -930,6 +931,47 @@ static const struct power_supply_desc sm8550_bat_psy_desc = {
>  	.property_is_writeable = qcom_battmgr_bat_is_writeable,
>  };
>  
> +static int qcom_battmgr_dcin_get_property(struct power_supply *psy,
> +					  enum power_supply_property psp,
> +					  union power_supply_propval *val)
> +{
> +	struct qcom_battmgr *battmgr = power_supply_get_drvdata(psy);
> +	int ret;
> +
> +	if (!battmgr->service_up)
> +		return -EAGAIN;
> +
> +	ret = qcom_battmgr_bat_sm8350_update(battmgr, psp);
> +	if (ret < 0)
> +		return ret;
> +
> +	switch (psp) {
> +	case POWER_SUPPLY_PROP_STATUS:
> +		val->intval = battmgr->status.status;
> +		break;
> +	case POWER_SUPPLY_PROP_PRESENT:
> +		val->intval = battmgr->info.present;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static const enum power_supply_property dcin_props[] = {
> +	POWER_SUPPLY_PROP_STATUS,
> +	POWER_SUPPLY_PROP_PRESENT,
> +};
> +
> +static const struct power_supply_desc dcin_psy_desc = {

Everything else in this driver is prefixed based on which firmware
interface it's operating against, but you decided to ignore that
convention...

Don't do that.

> +	.name = "qcom-battmgr-dcin",

Isn't this what we call qcom-battmgr-ac for the compute targets?

Is there any reason to not unify the naming?

> +	.type = POWER_SUPPLY_TYPE_MAINS,
> +	.properties = dcin_props,
> +	.num_properties = ARRAY_SIZE(dcin_props),
> +	.get_property = qcom_battmgr_dcin_get_property,
> +};
> +
>  static int qcom_battmgr_ac_get_property(struct power_supply *psy,
>  					enum power_supply_property psp,
>  					union power_supply_propval *val)
> @@ -1652,6 +1694,7 @@ static int qcom_battmgr_probe(struct auxiliary_device *adev,
>  	mutex_init(&battmgr->lock);
>  	init_completion(&battmgr->ack);
>  
> +	battmgr->batteryless = device_property_read_bool(dev, "qcom,batteryless");
>  	match = of_match_device(qcom_battmgr_of_variants, dev->parent);
>  	if (match)
>  		battmgr->variant = (unsigned long)match->data;
> @@ -1690,7 +1733,9 @@ static int qcom_battmgr_probe(struct auxiliary_device *adev,
>  			return dev_err_probe(dev, PTR_ERR(battmgr->wls_psy),
>  					     "failed to register wireless charing power supply\n");
>  	} else {
> -		if (battmgr->variant == QCOM_BATTMGR_SM8550)
> +		if (battmgr->batteryless)
> +			psy_desc = &dcin_psy_desc;

The psy_desc here is what is used to register the bat_psy on the line
below. Why would you register "dcin" as your bat_psy?

Is there an actual reason or are you just lazy?

Regards,
Bjorn

> +		else if (battmgr->variant == QCOM_BATTMGR_SM8550)
>  			psy_desc = &sm8550_bat_psy_desc;
>  		else
>  			psy_desc = &sm8350_bat_psy_desc;
> 
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-07-17  0:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 13:49 [PATCH 0/2] qcom_battmgr: Add batteryless DC-adapter MAINS support Rakesh Kota
2026-05-18 13:49 ` [PATCH 1/2] dt-bindings: soc: qcom: pmic-glink: Document batteryless property Rakesh Kota
2026-05-18 15:27   ` Krzysztof Kozlowski
2026-05-19  8:25     ` Rakesh Kota
2026-05-19 10:35       ` Krzysztof Kozlowski
2026-05-19 10:47         ` Konrad Dybcio
2026-05-19 10:49           ` Krzysztof Kozlowski
2026-05-21  7:13         ` Kamal Wadhwa
2026-05-21  7:20           ` Krzysztof Kozlowski
2026-05-21  8:46             ` Konrad Dybcio
2026-05-21  9:58               ` Krzysztof Kozlowski
2026-05-22  9:24                 ` Konrad Dybcio
2026-05-22 10:32                   ` Krzysztof Kozlowski
2026-05-22 10:34                     ` Konrad Dybcio
2026-05-25 12:01                   ` Rakesh Kota
2026-07-02 11:30                     ` Rakesh Kota
2026-07-02 11:48                       ` Krzysztof Kozlowski
2026-07-02 11:49                       ` Dmitry Baryshkov
2026-07-17  0:14                         ` Bjorn Andersson
2026-05-21 12:38               ` Rakesh Kota
2026-05-21 23:34           ` Dmitry Baryshkov
2026-05-18 13:49 ` [PATCH 2/2] power: supply: qcom_battmgr: Add support batteryless boards as MAINS Rakesh Kota
2026-07-17  0:12   ` Bjorn Andersson [this message]
2026-05-18 14:36 ` [PATCH 0/2] qcom_battmgr: Add batteryless DC-adapter MAINS support Konrad Dybcio
2026-05-19  6:59   ` Rakesh Kota
2026-05-19 10:58     ` Konrad Dybcio
2026-05-21 12:28       ` Rakesh Kota
2026-05-21 22:56     ` Bjorn Andersson
2026-06-30 14:16       ` Konrad Dybcio
2026-07-02 11:17         ` Rakesh Kota
2026-07-02 11:28           ` Krzysztof Kozlowski
2026-07-03  9:13             ` Rakesh Kota
2026-07-03  9:16               ` Krzysztof Kozlowski
2026-07-16  8:48                 ` Rakesh Kota
2026-07-16 23:54                   ` Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=allv5PQRd8kr2JG1@baldur \
    --to=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rakesh.kota@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox