lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <1393934748.1222.10.camel@AMDC1943>
Date:	Tue, 04 Mar 2014 13:05:48 +0100
From:	Krzysztof Kozlowski <k.kozlowski@...sung.com>
To:	Vladimir Barinov <vladimir.barinov@...entembedded.com>
Cc:	anton@...msg.org, dwmw2@...radead.org,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	mk7.kang@...sung.com, mark.rutland@....com
Subject: Re: [PATCH v2 1/3] power_supply: modelgauge_battery: Maxim ModelGauge
 ICs gauge

And one more comment:

On Sun, 2014-02-02 at 02:23 +0400, Vladimir Barinov wrote:
> +static int modelgauge_get_property(struct power_supply *psy,
> +				   enum power_supply_property psp,
> +				   union power_supply_propval *val)
> +{
> +	struct modelgauge_priv *priv = container_of(psy,
> +						    struct modelgauge_priv,
> +						    battery);
> +	struct regmap *regmap = priv->regmap;
> +	struct modelgauge_platform_data *pdata = priv->pdata;
> +	int reg;
> +	int ret;
> +
> +	switch (psp) {
> +	case POWER_SUPPLY_PROP_STATUS:
> +		if (pdata && pdata->get_charging_status)
> +			val->intval = pdata->get_charging_status();
> +		else
> +			val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
> +		break;
> +	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> +		ret = regmap_read(regmap, MODELGAUGE_VCELL_REG, &reg);
> +		if (ret < 0)
> +			return ret;
> +
> +		val->intval = modelgauge_lsb_to_uvolts(priv, reg);
> +		break;
> +	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
> +		/* Unlock model access */
> +		regmap_write(regmap, MODELGAUGE_UNLOCK_REG,
> +			     MODELGAUGE_UNLOCK_VALUE);
> +		ret = regmap_read(regmap, MODELGAUGE_OCV_REG, &reg);
> +		/* Lock model access */
> +		regmap_write(regmap, MODELGAUGE_UNLOCK_REG, 0);
> +		if (ret < 0)
> +			return ret;
> +
> +		val->intval = modelgauge_lsb_to_uvolts(priv, reg);
> +		break;
> +	case POWER_SUPPLY_PROP_CAPACITY:
> +		ret = regmap_read(regmap, MODELGAUGE_SOC_REG, &reg);
> +		if (ret < 0)
> +			return ret;
> +
> +		val->intval = reg / (1 << priv->soc_shift);
> +		break;
> +	case POWER_SUPPLY_PROP_TEMP:
> +		if (pdata && pdata->get_temperature)
> +			val->intval = pdata->get_temperature();
> +		else
> +			val->intval = 25;

If pdata->get_temperature() is not supplied then probably the driver
should not support POWER_SUPPLY_PROP_TEMP at all. I think it is better
not to report any temperature than to report a wrong one.


Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ