Re: [PATCH] regulator: core: set current constraints while settingmachine constraints

From: Mark Brown
Date: Thu Sep 19 2013 - 10:50:16 EST


On Thu, Sep 19, 2013 at 08:16:28PM +0530, Laxman Dewangan wrote:

> + if (!rdev->desc->ops->set_current_limit ||
> + !rdev->desc->ops->get_current_limit)
> + return 0;
> +

The indentation here is odd and we probably ought to complain if someone
tries to set a current constarint on a regulator that doesn't support
the operation, if only to avoid surprises later on when the limits don't
take effect.

> + current_uA = rdev->desc->ops->get_current_limit(rdev);
> + if (current_uA < rdev->constraints->min_uA ||
> + current_uA > rdev->constraints->max_uA) {
> + ret = rdev->desc->ops->set_current_limit(rdev,
> + rdev->constraints->min_uA,
> + rdev->constraints->max_uA);
> + if (ret < 0) {
> + rdev_err(rdev,
> + "Failed to set current constraint, %d\n", ret);
> + return ret;
> + }

Why is this conditional on the existing setting? Just apply the
constraint.

> + }
> + return 0;

Missing blank.

Attachment: signature.asc
Description: Digital signature