devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Krzysztof Kozlowski
	<k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: MyungJoo Ham
	<myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Chanwoo Choi <cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Anton Vorontsov <anton-9xeibp6oKSgdnm+yROfE0A@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Liam Girdwood <lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Bartlomiej Zolnierkiewicz
	<b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Marek Szyprowski
	<m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Kyungmin Park
	<kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [PATCH 4/4] regulator: max14577: Add regulator driver for Maxim 14577
Date: Wed, 13 Nov 2013 13:23:38 +0000	[thread overview]
Message-ID: <20131113132338.GG878@sirena.org.uk> (raw)
In-Reply-To: <1384328457-5147-5-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

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

On Wed, Nov 13, 2013 at 08:40:57AM +0100, Krzysztof Kozlowski wrote:

> +static inline int max14577_reg_set_safeout(struct regmap *rmap, int on)
> +{
> +	u8 reg_data = (on ? 0x1 << CTRL2_SFOUTORD_SHIFT : 0x0);

The ternery operator is rarely helpful for legibility.

> +	case MAX14577_SAFEOUT:
> +		max14577_read_reg(rmap, MAX14577_REG_CONTROL2, &reg_data);
> +		return (reg_data & CTRL2_SFOUTORD_MASK) != 0;

regulator_is_enabled_regmap() and the other helpers should be used for
this regulator.

> +static int max14577_reg_disable(struct regulator_dev *rdev)
> +{
> +	int rid = rdev_get_id(rdev);
> +
> +	switch (rid) {
> +	case MAX14577_CHARGER:
> +		return max14577_reg_set_charging(rdev->regmap, 0);
> +	case MAX14577_SAFEOUT:
> +		return max14577_reg_set_safeout(rdev->regmap, 0);
> +	default:
> +		return -EINVAL;
> +	}
> +}

This sort of indirection isn't adding anything, just make the ops
directly callable (and in the case of SAFEOUT use the helpers).

> +static int max14577_reg_get_current_limit(struct regulator_dev *rdev)
> +{
> +	if (rdev_get_id(rdev) != MAX14577_CHARGER)
> +		return -EINVAL;
> +
> +	return max14577_reg_calc_charge_current(rdev->regmap);

Just inline the function, it's only called once.

> +	if (rdev_get_id(rdev) != MAX14577_CHARGER)
> +		return -EINVAL;
> +
> +	dev_info(max14577->dev, "Requested current <%d, %d>\n", min_uA, max_uA);

Don't spam the logs like this, there's problems like this throughout the
rest of the code.

> +static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
> +					struct max14577_platform_data *pdata)

No DT binding document.

> +static int max14577_regulator_probe(struct platform_device *pdev)
> +{
> +	struct max14577_regulator *max14577_reg;
> +	struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
> +	struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev);
> +	int i, ret, size;
> +	struct regulator_config config = {};
> +
> +	if (!pdata) {
> +		dev_err(&pdev->dev, "No platform data found.\n");
> +		return -ENODEV;
> +	}
> +
> +	if (max14577->dev->of_node) {
> +		ret = max14577_regulator_dt_parse_pdata(pdev, pdata);
> +		if (ret)
> +			return ret;
> +	}

The driver insists on platform data but then requires DT...

> +	size = sizeof(struct regulator_dev *) * pdata->num_regulators;
> +	max14577_reg->regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);

You shouldn't be getting the number of regulators from platform data,
the number of regulators physically present in the silicon isn't going
to vary.

> +		max14577_reg->regulators[i] =
> +			regulator_register(&supported_regulators[id], &config);

devm_regulator_register().

> +subsys_initcall(max14577_regulator_init);

Why is this subsys_initcall()?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2013-11-13 13:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13  7:40 [PATCH 0/4] mfd: max14577: Add max14577 MFD drivers Krzysztof Kozlowski
2013-11-13  7:40 ` [PATCH 1/4] mfd: max14577: Add max14577 MFD driver core Krzysztof Kozlowski
     [not found]   ` <1384328457-5147-2-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-13 11:50     ` Mark Rutland
     [not found]       ` <20131113115018.GE21713-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-11-14  8:32         ` Krzysztof Kozlowski
2013-11-13 13:13   ` Mark Brown
     [not found]     ` <20131113131328.GF878-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-14  1:33       ` Kyungmin Park
     [not found]         ` <CAH9JG2U9VDnRW9JZ7j7OyRmVhSXWJ5Yp_gNqUPK=xCST7SY=xg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-14 10:24           ` Mark Brown
     [not found]             ` <20131114102419.GE26614-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-14 10:53               ` Marek Szyprowski
2013-11-14 11:22                 ` Mark Brown
2013-11-14  8:15       ` Krzysztof Kozlowski
     [not found] ` <1384328457-5147-1-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-13  7:40   ` [PATCH 2/4] extcon: max77693: Add extcon-max14577 driver to support MUIC device Krzysztof Kozlowski
2013-11-13  7:40 ` [PATCH 3/4] charger: max14577: Add charger support for Maxim 14577 Krzysztof Kozlowski
2013-11-13  7:40 ` [PATCH 4/4] regulator: max14577: Add regulator driver " Krzysztof Kozlowski
     [not found]   ` <1384328457-5147-5-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-13 13:23     ` Mark Brown [this message]
2013-11-14  9:17       ` Krzysztof Kozlowski

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=20131113132338.GG878@sirena.org.uk \
    --to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=anton-9xeibp6oKSgdnm+yROfE0A@public.gmane.org \
    --cc=b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).