From: "Peter 'p2' De Schrijver" <peter.de-schrijver@nokia.com>
To: ext David Brownell <david-b@pacbell.net>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] TWL4030: add function to send PB messages
Date: Fri, 24 Apr 2009 12:25:33 +0300 [thread overview]
Message-ID: <20090424092533.GA4720@codecarver.research.nokia.com> (raw)
In-Reply-To: <200904231503.47287.david-b@pacbell.net>
> > @@ -81,6 +82,69 @@ twl4030reg_write(struct twlreg_info *info, unsigned offset, u8 value)
> > value, info->base + offset);
> > }
> >
> > +static int twl4030_wait_pb_ready(void)
> > +{
> > +
> > + u8 pb_status;
> > + int status, timeout = 10;
> > +
> > + do {
> > + status = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER,
> > + &pb_status, 0x14);
> > + if (status < 0)
> > + return status;
> > +
>
> Worth a comment that PB_CFG.BIT(0) == PB_I2C_BUSY ... true if there's
> a word queued for the power bus, but not yet sent. And that we assume
> no other I2C master is sending such events...
>
The multi master situation seems inherently racy to me anyway as you
need to write 2 bytes to 2 different registers to send 1 message. Or is there
a way to keep mastership of the bus between transactions ?
> > + /* Enable I2C access to powerbus */
> > + status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
> > + pb_state | (1<<1), 0x14);
> > + if (status < 0)
> > + return status;
> > +
> > + status = twl4030_wait_pb_ready();
>
> I'd probably combine wait_pb_ready() with this; not that
> this is wrong, but you should only need to set BIT(1) once,
> and there's no need to re-read that byte to test BIT(0).
>
> Minor point ... I hate needless I/O. This isn't a critical
> path though.
>
Indeed. Exactly why I didn't try to optimize on I/O here :)
Cheers,
Peter.
--
goa is a state of mind
next prev parent reply other threads:[~2009-04-24 9:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1240407833-28060-1-git-send-email-peter.de-schrijver@nokia.com>
2009-04-23 22:03 ` [PATCH] TWL4030: add function to send PB messages David Brownell
2009-04-24 9:25 ` Peter 'p2' De Schrijver [this message]
2009-04-23 13:08 Peter 'p2' De Schrijver
2009-04-23 14:52 ` Mark Brown
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=20090424092533.GA4720@codecarver.research.nokia.com \
--to=peter.de-schrijver@nokia.com \
--cc=david-b@pacbell.net \
--cc=linux-kernel@vger.kernel.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