public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Ashish Jangam <ashish.jangam@kpitcummins.com>
Cc: "randy.dunlap@oracle.com" <randy.dunlap@oracle.com>,
	"linaro-dev@lists.linaro.org" <linaro-dev@lists.linaro.org>,
	"dchen@diasemi.com" <dchen@diasemi.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>
Subject: Re: [PATCH 6/11] HWMON: DA9052 hwmon driver v1
Date: Wed, 29 Jun 2011 07:27:20 -0700	[thread overview]
Message-ID: <20110629142720.GA5915@ericsson.com> (raw)
In-Reply-To: <1309347848.4210.14.camel@dhruva>

On Wed, Jun 29, 2011 at 07:44:08AM -0400, Ashish Jangam wrote:
> On Tue, 2011-06-28 at 23:05 +0530, Guenter Roeck wrote:
> > On Tue, 2011-06-28 at 10:24 -0400, ashish jangam wrote:
> > > +static ssize_t da9052_read_vddout(struct device *dev,
> > > +                                  struct device_attribute *devattr, char *buf)
> > > +{
> > > +       struct da9052_hwmon *hwmon = dev_get_drvdata(dev);
> > > +       int ret, vdd = -1;
> > > +
> > > +       mutex_lock(&hwmon->hwmon_lock);
> > > +
> > > +       ret = da9052_enable_vddout_channel(hwmon->da9052);
> > > +       if (ret < 0)
> > > +               goto hwmon_err;
> > > +
> > > +       ret = da9052_reg_read(hwmon->da9052, DA9052_VDD_RES_REG);
> > > +       if (ret < 0)
> > > +               pr_err("failed to read VDD_RES_REG\n");
> > > +       else
> > > +               vdd = ret;
> > > +
> > > +       ret = da9052_disable_vddout_channel(hwmon->da9052);
> > > +       if (ret < 0)
> > > +               goto hwmon_err;
> > > +
> > > +       if (vdd >= 0) {
> > > +               mutex_unlock(&hwmon->hwmon_lock);
> > > +               return sprintf(buf, "%d\n", vdd);
> > > +       }
> > > +
> > > +hwmon_err:
> > > +       mutex_unlock(&hwmon->hwmon_lock);
> > > +       return ret;
> > > +}
> > 
> > This function still produces a bad result if the call to
> > da9052_reg_read() fails and the call to da9052_disable_vddout_channel()
> > doesn't. 
> Thanks much for comments and patience. When vddout channel is enabled
> and then read from this channel fails then, in this case should vddout
> channel get disabled? Is this correct understanding.

Hmm, yes, you are right there. You should try to disable it. But you would have 
to do that such that you don't override the original error. One possibility would
be to add an unconditional call to da9052_disable_vddout_channel() into the error 
path.

	ret = da9052_reg_read(hwmon->da9052, DA9052_VDD_RES_REG);
	if (ret < 0)
		goto hwmon_err_release;

	...
hwmon_err_release:
	da9052_disable_vddout_channel(hwmon->da9052);
hwmon_err:
	...

Guenter

      reply	other threads:[~2011-06-29 14:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28 14:24 [PATCH 6/11] HWMON: DA9052 hwmon driver v1 ashishj3
2011-06-28 17:35 ` Guenter Roeck
2011-06-29 11:44   ` Ashish Jangam
2011-06-29 14:27     ` Guenter Roeck [this message]

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=20110629142720.GA5915@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --cc=ashish.jangam@kpitcummins.com \
    --cc=dchen@diasemi.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=randy.dunlap@oracle.com \
    /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