From: maramaopercheseimorto@gmail.com (Alberto Panizzo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] regulator: mc13783: consider Power Gates as digital regulators.
Date: Mon, 18 Jan 2010 18:26:10 +0100 [thread overview]
Message-ID: <1263835570.3632.33.camel@realization> (raw)
In-Reply-To: <20100118163212.GA32045@rakim.wolfsonmicro.main>
On lun, 2010-01-18 at 16:32 +0000, Mark Brown wrote:
> On Mon, Jan 18, 2010 at 05:02:03PM +0100, Alberto Panizzo wrote:
>
> > +int mc13783_state_powermisc_pwgt;
> > +int mc13783_reg_rmw_powermisc(struct mc13783 *mc13783, u32 mask, u32 val)
>
> You're missing some statics here and some whitespace to separate the
> function from the variable.
Ok, mc13783_state_powermisc_pwgt will be static (and u32..)
>
> > + /* Update the stored state for Power Gates.
> > + * As from specs the meaning is inverted (0: en, 1: dis) */
> > + if (mask & MC13783_REG_POWERMISC_PWGTSPI_M)
> > + mc13783_state_powermisc_pwgt =
> > + (mc13783_state_powermisc_pwgt & ~mask) |
> > + ((val ^ mask) & MC13783_REG_POWERMISC_PWGTSPI_M);
>
> Could this code be written in a clearer fashion? The bit manipluation
> isn't entirely obvious, especially given the multiple masks in use...
Something like this?
if (mask & MC13783_REG_POWERMISC_PWGTSPI_M) {
u32 new_state = (val & MC13783_REG_POWERMISC_PWGTSPI_M) ^ mask;
mc13783_state_powermisc_pwgt =
(mc13783_state_powermisc_pwgt & ~mask) | new_state;
}
I use the EXOR with one to negate bits.
The state stored in mc13783_state_powermisc_pwgt would be what the next
functions write.
>
> > + ret = mc13783_reg_read(mc13783, MC13783_REG_POWERMISC, &valread);
> > + if (ret)
> > + return ret;
> > +
> > + valread = (valread & ~mask) | val;
> > +
> > + /* Re propose the stored state for Power Gates */
> > + valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) |
> > + mc13783_state_powermisc_pwgt;
>
> ...and this further mainpulation.
What is obscure in this? it is the same operation as the previous
MC13783_REG_POWERMISC_PWGTSPI_M is the mask for PWGT1 and 2 bits and in
mc13783_state_powermisc_pwgt there is the stored state for those two
bits.
WARNING: multiple messages have this Message-ID (diff)
From: Alberto Panizzo <maramaopercheseimorto@gmail.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Samuel Ortiz" <sameo@linux.intel.com>,
"Liam Girdwood" <lrg@slimlogic.co.uk>,
"Sascha linux-arm" <s.hauer@pengutronix.de>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-arm-kernel-infradead <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] regulator: mc13783: consider Power Gates as digital regulators.
Date: Mon, 18 Jan 2010 18:26:10 +0100 [thread overview]
Message-ID: <1263835570.3632.33.camel@realization> (raw)
In-Reply-To: <20100118163212.GA32045@rakim.wolfsonmicro.main>
On lun, 2010-01-18 at 16:32 +0000, Mark Brown wrote:
> On Mon, Jan 18, 2010 at 05:02:03PM +0100, Alberto Panizzo wrote:
>
> > +int mc13783_state_powermisc_pwgt;
> > +int mc13783_reg_rmw_powermisc(struct mc13783 *mc13783, u32 mask, u32 val)
>
> You're missing some statics here and some whitespace to separate the
> function from the variable.
Ok, mc13783_state_powermisc_pwgt will be static (and u32..)
>
> > + /* Update the stored state for Power Gates.
> > + * As from specs the meaning is inverted (0: en, 1: dis) */
> > + if (mask & MC13783_REG_POWERMISC_PWGTSPI_M)
> > + mc13783_state_powermisc_pwgt =
> > + (mc13783_state_powermisc_pwgt & ~mask) |
> > + ((val ^ mask) & MC13783_REG_POWERMISC_PWGTSPI_M);
>
> Could this code be written in a clearer fashion? The bit manipluation
> isn't entirely obvious, especially given the multiple masks in use...
Something like this?
if (mask & MC13783_REG_POWERMISC_PWGTSPI_M) {
u32 new_state = (val & MC13783_REG_POWERMISC_PWGTSPI_M) ^ mask;
mc13783_state_powermisc_pwgt =
(mc13783_state_powermisc_pwgt & ~mask) | new_state;
}
I use the EXOR with one to negate bits.
The state stored in mc13783_state_powermisc_pwgt would be what the next
functions write.
>
> > + ret = mc13783_reg_read(mc13783, MC13783_REG_POWERMISC, &valread);
> > + if (ret)
> > + return ret;
> > +
> > + valread = (valread & ~mask) | val;
> > +
> > + /* Re propose the stored state for Power Gates */
> > + valread = (valread & ~MC13783_REG_POWERMISC_PWGTSPI_M) |
> > + mc13783_state_powermisc_pwgt;
>
> ...and this further mainpulation.
What is obscure in this? it is the same operation as the previous
MC13783_REG_POWERMISC_PWGTSPI_M is the mask for PWGT1 and 2 bits and in
mc13783_state_powermisc_pwgt there is the stored state for those two
bits.
next prev parent reply other threads:[~2010-01-18 17:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-18 16:02 [PATCH] regulator: mc13783: consider Power Gates as digital regulators Alberto Panizzo
2010-01-18 16:02 ` Alberto Panizzo
2010-01-18 16:32 ` Mark Brown
2010-01-18 16:32 ` Mark Brown
2010-01-18 17:26 ` Alberto Panizzo [this message]
2010-01-18 17:26 ` Alberto Panizzo
2010-01-18 17:37 ` Mark Brown
2010-01-18 17:37 ` Mark Brown
[not found] ` <1263834473.3632.31.camel@realization>
[not found] ` <20100118172002.GB6889@rakim.wolfsonmicro.main>
2010-01-18 17:50 ` Alberto Panizzo
2010-01-18 17:50 ` Alberto Panizzo
2010-01-18 17:56 ` Mark Brown
2010-01-18 17:56 ` Mark Brown
2010-01-18 19:04 ` Uwe Kleine-König
2010-01-18 19:04 ` Uwe Kleine-König
2010-01-18 21:01 ` Alberto Panizzo
2010-01-18 21:01 ` Alberto Panizzo
2010-01-19 10:26 ` Liam Girdwood
2010-01-19 10:26 ` Liam Girdwood
2010-01-19 11:12 ` Alberto Panizzo
2010-01-19 11:12 ` Alberto Panizzo
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=1263835570.3632.33.camel@realization \
--to=maramaopercheseimorto@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.