public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: "Alex A. Mihaylov" <minimumlaw@rambler.ru>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, zbr@ioremap.net
Subject: Re: [PATCH 2/2] Add driver for MAX17211/MAX17215 fuel gauge
Date: Sat, 29 Apr 2017 18:40:53 +0200	[thread overview]
Message-ID: <20170429164053.olynja4kyqpwhfpk@earth> (raw)
In-Reply-To: <20170429143429.5685-3-minimumlaw@rambler.ru>

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

Hi,

Please make sure you Cc the relevant people / mailing lists. You
can use ./scripts/get_maintainer.pl to find out who should receive
the patches.

On Sat, Apr 29, 2017 at 05:34:29PM +0300, Alex A. Mihaylov wrote:
> Maxim Semiconductor MAX17211/MAX17215 single/multi-cell fuel gauge
> monitor with M5 Fuel Gauge algorithm
> 
> This driver provide userspace access to MAX17211/MAX17215 data with
> power_supply class drivers.

> ---
>  drivers/power/supply/Kconfig            |   8 +
>  drivers/power/supply/Makefile           |   1 +

Please move the entries in both files before CONFIG_BATTERY_MAX17040.

> [...]
>
> +	 * FixMe:
> +	 * Device without no_thermal = true not register (err -22)
> +	 * Len of platform device name "max17211-battery.X.auto"
> +	 * more than 20 chars limit in THERMAL_NAME_LENGTH from
> +	 * include/uapi/linux/thermal.h
> +	 */

IIRC we already had problems with small THERMAL_NAME_LENGTH before.
I suggest to add another patch, that increases THERMAL_NAME_LENGTH
(don't forget to Cc/To the thermal subsystem people).

> +	info->bat_desc.no_thermal = true;
> +	psy_cfg.drv_data = info;
> +
> +	if (w1_max1721x_reg_get(info->w1_dev,
> +			MAX1721X_REG_NRSENSE, &info->rsense))
> +		return -ENODEV;
> +
> +	if (!info->rsense) {
> +		dev_warn(info->dev, "RSenese not calibrated, set 10 mOhms!\n");
> +		info->rsense = 1000; /* in regs in 10^-5 */
> +	}
> +	dev_dbg(info->dev, "RSense: %d mOhms.\n", info->rsense / 100);
> +
> +	if (get_string(info->w1_dev, MAX1721X_REG_MFG_STR,
> +			MAX1721X_REG_MFG_NUMB, info->ManufacturerName)) {
> +		dev_err(info->dev, "Can't read manufacturer. Hardware error.\n");
> +		return -ENODEV;
> +	}
> +
> +	if (!info->ManufacturerName[0])
> +		strncpy(info->ManufacturerName, DEF_MFG_NAME,
> +			2 * MAX1721X_REG_MFG_NUMB);
> +
> +	if (get_string(info->w1_dev, MAX1721X_REG_DEV_STR,
> +			MAX1721X_REG_DEV_NUMB, info->DeviceName)) {
> +		dev_err(info->dev, "Can't read device. Hardware error.\n");
> +		return -ENODEV;
> +	}
> +	if (!info->DeviceName[0]) {
> +		uint16_t dev_name;
> +
> +		if (w1_max1721x_reg_get(info->w1_dev,
> +				MAX172XX_REG_DEVNAME, &dev_name)) {
> +			dev_err(info->w1_dev, "Can't read device name reg.\n");
> +			return -ENODEV;
> +		}
> +
> +		switch (dev_name & MAX172XX_DEV_MASK) {
> +		case MAX172X1_DEV:
> +			strncpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
> +				2 * MAX1721X_REG_DEV_NUMB);
> +			break;
> +		case MAX172X5_DEV:
> +			strncpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
> +				2 * MAX1721X_REG_DEV_NUMB);
> +			break;
> +		default:
> +			strncpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
> +				2 * MAX1721X_REG_DEV_NUMB);
> +		}
> +	}
> +
> +	if (get_sn_string(info->w1_dev, info->SerialNumber)) {
> +		dev_err(info->dev, "Can't read serial. Hardware error.\n");
> +		return -ENODEV;
> +	}
> +
> +	info->bat = power_supply_register(&pdev->dev, &info->bat_desc,
> +						&psy_cfg);
> +	if (IS_ERR(info->bat)) {
> +		dev_err(info->dev, "failed to register battery\n");
> +		return PTR_ERR(info->bat);
> +	}

Please use devm_power_supply_register() and drop the remove
function.

> +	return 0;
> +}
> +
> +static int max1721x_battery_remove(struct platform_device *pdev)
> +{
> +	struct max17211_device_info *info = platform_get_drvdata(pdev);
> +
> +	power_supply_unregister(info->bat);
> +
> +	return 0;
> +}
> +
> +static struct platform_driver max1721x_battery_driver = {
> +	.driver = {
> +		.name = "max1721x-battery",
> +	},
> +	.probe	  = max1721x_battery_probe,
> +	.remove   = max1721x_battery_remove,
> +};
> +module_platform_driver(max1721x_battery_driver);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Alex A. Mihaylov <minimumlaw@rambler.ru>");
> +MODULE_DESCRIPTION("Maxim MAX17211/MAX17215 Fuel Gauage IC driver");
> +MODULE_ALIAS("platform:max1721x-battery");

-- Sebastian

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

  parent reply	other threads:[~2017-04-29 16:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170429143429.5685-1-minimumlaw@rambler.ru>
     [not found] ` <20170429143429.5685-2-minimumlaw@rambler.ru>
2017-04-29 15:59   ` [PATCH 1/2] Add support for OneWire (W1) devices family 0x26 (MAX17211/MAX17215) Sebastian Reichel
2017-04-30  5:21     ` Alex A. Mihaylov
2017-04-30 20:53       ` Sebastian Reichel
2017-05-01  6:13         ` Alex A. Mihaylov
     [not found] ` <20170429143429.5685-3-minimumlaw@rambler.ru>
2017-04-29 16:40   ` Sebastian Reichel [this message]
2017-04-30 17:32     ` [PATCH 2/2] Add driver for MAX17211/MAX17215 fuel gauge Михайлов Алексей Анатольевич
2017-04-30 20:44       ` Sebastian Reichel

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=20170429164053.olynja4kyqpwhfpk@earth \
    --to=sre@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=minimumlaw@rambler.ru \
    --cc=zbr@ioremap.net \
    /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