linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Carl Philipp Klemm <philipp@uvos.xyz>
Cc: linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
	Arthur Demchenkov <spinal.by@gmail.com>,
	Tony Lindgren <tony@atomide.com>,
	Merlijn Wajer <merlijn@wizzup.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH v2] power: supply: cpcap-charger: get the battery inserted infomation from cpcap-battery
Date: Fri, 4 Jun 2021 14:37:43 +0200	[thread overview]
Message-ID: <20210604123743.ydkxnyspueapxn7p@earth.universe> (raw)
In-Reply-To: <20210423150057.97e0a2b43f20fdc3513f4fea@uvos.xyz>

[-- Attachment #1: Type: text/plain, Size: 2527 bytes --]

Hi,

On Fri, Apr 23, 2021 at 03:00:57PM +0200, Carl Philipp Klemm wrote:
> This avoids reimplementing the detection logic twice and removes the
> possibility of activating charging with 500mA even if a battery is not
> detected.
> 
> Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/cpcap-charger.c | 39 ++++++++++++++--------------
>  1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c
> index 641dcad1133f..a5983365b81a 100644
> --- a/drivers/power/supply/cpcap-charger.c
> +++ b/drivers/power/supply/cpcap-charger.c
> @@ -173,23 +173,6 @@ static enum power_supply_property cpcap_charger_props[] = {
>  	POWER_SUPPLY_PROP_CURRENT_NOW,
>  };
>  
> -/* No battery always shows temperature of -40000 */
> -static bool cpcap_charger_battery_found(struct cpcap_charger_ddata *ddata)
> -{
> -	struct iio_channel *channel;
> -	int error, temperature;
> -
> -	channel = ddata->channels[CPCAP_CHARGER_IIO_BATTDET];
> -	error = iio_read_channel_processed(channel, &temperature);
> -	if (error < 0) {
> -		dev_warn(ddata->dev, "%s failed: %i\n", __func__, error);
> -
> -		return false;
> -	}
> -
> -	return temperature > -20000 && temperature < 60000;
> -}
> -
>  static int cpcap_charger_get_charge_voltage(struct cpcap_charger_ddata *ddata)
>  {
>  	struct iio_channel *channel;
> @@ -697,11 +680,29 @@ static void cpcap_usb_detect(struct work_struct *work)
>  
>  	if (!ddata->feeding_vbus && cpcap_charger_vbus_valid(ddata) &&
>  	    s.chrgcurr1) {
> -		int max_current = 532000;
> +		int max_current;
>  		int vchrg, ichrg;
> +		union power_supply_propval val;
> +		struct power_supply *battery;
>  
> -		if (cpcap_charger_battery_found(ddata))
> +		battery = power_supply_get_by_name("battery");
> +		if (IS_ERR_OR_NULL(battery)) {
> +			dev_err(ddata->dev, "battery power_supply not available %li\n",
> +					PTR_ERR(battery));
> +			return;
> +		}
> +
> +		error = power_supply_get_property(battery, POWER_SUPPLY_PROP_PRESENT, &val);
> +		power_supply_put(battery);
> +		if (error)
> +			goto out_err;
> +
> +		if (val.intval) {
>  			max_current = 1596000;
> +		} else {
> +			dev_info(ddata->dev, "battery not inserted charging disabled\n");
> +			max_current = 0;
> +		}
>  
>  		if (max_current > ddata->limit_current)
>  			max_current = ddata->limit_current;
> -- 
> 2.31.0
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2021-06-04 12:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 13:00 [PATCH v2] power: supply: cpcap-charger: get the battery inserted infomation from cpcap-battery Carl Philipp Klemm
2021-06-04 12:37 ` Sebastian Reichel [this message]

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=20210604123743.ydkxnyspueapxn7p@earth.universe \
    --to=sebastian.reichel@collabora.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=pavel@ucw.cz \
    --cc=philipp@uvos.xyz \
    --cc=spinal.by@gmail.com \
    --cc=tony@atomide.com \
    /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;
as well as URLs for NNTP newsgroup(s).