From: Joe Perches <joe@perches.com>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
devel@driverdev.osuosl.org, ss@aao.gov.au, gregkh@suse.de
Subject: Re: [PATCH] Staging: d53155_drv.c: cleanup fbuffer usage
Date: Thu, 24 Jun 2010 10:37:32 -0700 [thread overview]
Message-ID: <1277401052.1654.59.camel@Joe-Laptop.home> (raw)
In-Reply-To: <201006240931.13833.hartleys@visionengravers.com>
On Thu, 2010-06-24 at 09:31 -0700, H Hartley Sweeten wrote:
> The global symbol dt3155_fbuffer[], declared in dt3155_isr.c, is really
> just a pointer to dt3155_status[].fbuffer. To improve readability, make
> some of the really long lines shorter, and make the buffer access more
> consistent, use &dt3155_status[].fbuffer to access the buffer structure.
I think this would be more consistent/intelligible
if the temporary wasn't
struct dt3155_fbuffer *fb = &dt3155_status[minor].fbuffer;
but was
struct dt3155_status *dts = &dt3155_status[minor];
> @@ -146,11 +148,11 @@ static void quick_stop (int minor)
> dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff);
> /* mark the system stopped: */
> dt3155_status[minor].state |= DT3155_STATE_IDLE;
> - dt3155_fbuffer[minor]->stop_acquire = 0;
> - dt3155_fbuffer[minor]->even_stopped = 0;
> + fb->stop_acquire = 0;
> + fb->even_stopped = 0;
> #else
> dt3155_status[minor].state |= DT3155_STATE_STOP;
> - dt3155_status[minor].fbuffer.stop_acquire = 1;
> + fb->stop_acquire = 1;
> #endif
becomes
dts->state &= ~(DT3155_STATE_STOP|0xff);
/* mark the system stopped: */
dts->state |= DT3155_STATE_IDLE;
dts->fbuffer.stop_acquire = 0;
dts->fbuffer.even_stopped = 0;
#else
dts->fbuffer.stop_acquire = 1;
#endif
Another option might be to use dereferencing inlines.
static inline struct dt3155_status *dts(int index)
{
return &dt3155_status[index];
}
static inline struct dt3155_fbuffer *fb(int index)
{
return &(dts(index)->fbuffer);
}
I think this isn't as good as the temporary because the
compiler sometimes doesn't reuse the intermediate addresses
and the inlines have file rather than function scope.
It becomes something like:
dts(minor)->state &= ~(DT3155_STATE_STOP|0xff);
/* mark the system stopped: */
dts(minor)->state |= DT3155_STATE_IDLE;
fb(minor)->stop_acquire = 0;
fb(minor)->even_stopped = 0;
#else
fb(minor)->stop_acquire = 1;
#endif
I think this isn't as good as the temporary because the
compiler sometimes doesn't reuse the intermediate addresses
and the macros have file rather than function scope.
next prev parent reply other threads:[~2010-06-24 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 16:31 H Hartley Sweeten
2010-06-24 17:37 ` Joe Perches [this message]
2010-06-24 17:54 ` H Hartley Sweeten
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=1277401052.1654.59.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=hartleys@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ss@aao.gov.au \
/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
all inboxes | Powered by JetHome®