LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Cc: linux-arm-kernel <linux-arm-kernel@lists.arm.linux.org.uk>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: [UPDATED v3][PATCH 4/7] regulator: framework core
Date: Fri, 7 Mar 2008 00:39:10 -0800	[thread overview]
Message-ID: <20080307003910.72fb8043.akpm@linux-foundation.org> (raw)
In-Reply-To: <1204827115.15360.150.camel@a10323.wolfsonmicro.main>

On Thu, 06 Mar 2008 18:11:54 +0000 Liam Girdwood <lg@opensource.wolfsonmicro.com> wrote:

> This patch provides the regulator framework core. The core also provides a
> sysfs interface for userspace information.
> 
> +/* gets the regulator for a given consumer device */
> +static struct regulator *get_device_regulator(struct device *dev)
> +{
> +	struct regulator *regulator = NULL;
> +	struct regulator_cdev *rcdev;
> +
> +	mutex_lock(&regulator_list_mutex);
> +	list_for_each_entry(rcdev, &regulator_list, list) {
> +		mutex_lock(&rcdev->mutex);
> +		list_for_each_entry(regulator, &rcdev->consumer_list, list) {
> +			if (regulator->dev == dev) {
> +				mutex_unlock(&rcdev->mutex);
> +				return regulator;
> +			}
> +		}
> +		mutex_unlock(&rcdev->mutex);
> +	}
> +	mutex_unlock(&regulator_list_mutex);
> +	return NULL;
> +}

Is this really supposed to return with the list lock held?  If so, some
comment describing the overall locking design here would be better than
having to reverse-engineer it.

> +static inline int get_lowest_stable_voltage(struct regulator_cdev *rcdev)
> +{
> +	struct regulator *regulator;
> +	int highest_uV = 0;
> +
> +	/* lock is held by caller */
> +	list_for_each_entry(regulator, &rcdev->consumer_list, list) {
> +		if (regulator->enabled && regulator->uV_required > highest_uV)
> +			highest_uV = regulator->uV_required;
> +	}
> +	return highest_uV;
> +}

Too large to inline - the compiler will do this for you if it is a benefit
to do so.

> +/* Calculate the new optimum regulator operating mode based on the new total
> + * consumer load. All locks held by caller */
> +static void drms_uA_update(struct regulator_cdev *rcdev)
> +{
> +	struct regulator *sibling;
> +	int current_uA = 0, output_uV, input_uV, err;
> +	unsigned int mode;
> +
> +	err = regulator_check_drms(rcdev);
> +	if (err < 0 || !rcdev->desc->ops->get_optimum_mode ||
> +	    !rcdev->desc->ops->get_voltage || !rcdev->desc->ops->set_mode);
> +	return;
> +
> +	/* get output voltage */
> +	output_uV = rcdev->desc->ops->get_voltage(rcdev);
> +
> +	/* get input voltage */
> +	if (rcdev->parent && rcdev->parent->desc->ops->get_voltage)
> +		input_uV = rcdev->parent->desc->ops->get_voltage(rcdev->parent);
> +	else
> +		input_uV = rcdev->constraints->input_uV;
> +
> +	/* calc total requested load */
> +	list_for_each_entry(sibling, &rcdev->consumer_list, list)
> +	    current_uA += sibling->uA_load;

Should be indented with a tab, not spacespacespacespace

> +	/* now get the optimum mode for our new total regulator load */
> +	mode = rcdev->desc->ops->get_optimum_mode(rcdev, input_uV,
> +						  output_uV, current_uA);
> +
> +	/* check the new mode is allowed */
> +	err = regulator_check_mode(rcdev, mode);
> +	if (err == 0)
> +		rcdev->desc->ops->set_mode(rcdev, mode);
> +}
> +
> +#define REG_STR_SIZE	32
> +


  reply	other threads:[~2008-03-07  8:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 18:11 Liam Girdwood
2008-03-07  8:39 ` Andrew Morton [this message]
2008-03-08 17:24   ` Liam Girdwood
2008-03-08 18:30     ` Andrew Morton
2008-03-09 11:18       ` Liam Girdwood
2008-03-07 16:10 ` Greg KH
2008-03-07 22:19   ` Liam Girdwood
2008-03-08  7:41     ` Greg KH
2008-03-08 21:18       ` Liam Girdwood
2008-03-09  3:16         ` Greg KH

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=20080307003910.72fb8043.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lg@opensource.wolfsonmicro.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [UPDATED v3][PATCH 4/7] regulator: framework core' \
    /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

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).