From: Maxim Levitsky <maximlevitsky@gmail.com>
To: Alex Dubov <oakad@yahoo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Results of my work on memorystick subsystem
Date: Thu, 14 Oct 2010 23:01:12 +0200 [thread overview]
Message-ID: <1287090073.4301.20.camel@maxim-laptop> (raw)
In-Reply-To: <8497.77981.qm@web37601.mail.mud.yahoo.com>
On Thu, 2010-10-14 at 01:00 -0700, Alex Dubov wrote:
> > From: Maxim Levitsky <maximlevitsky@gmail.com>
> >
> > and patch #6 contines adds even more cleanups, and makes
> > whole
> > memctick subsystem look nice and clean.
> > Many non obivous functions were removen.
>
> Replacing functional state handlers with nasty 3-page long switches on
> undiscriminated integer state variables does not count either "cleaner"
> nor "more obvious" in my notebook.
Yes it is.
In the original state machines, the switch value was a TPC that was
already sent, and therefore it usually wasn't related to code inside
switch block.
In addition to that if one tries to send same TPC and treat it
differently he is for a big surprise.
With my scheme the states are clearly marked.
'nasty 3-page long switches' - what are you taking about?
h_mspro_block_transfer_data - 89 lines before
h_mspro_block_transfer_data - 129 lines after
Sure the new handler is a bit longer, but I moved there a chunk of
request processing code, so that mspro_block_issue_req and
mspro_block_complete_req
do now one thing only and used only for block requests.
>
> This is a matter of personal preference, I suppose.
>
> Yet, at the very least, you should define an appropriate enum and give
> your states readable names.
I didn't use a enum on purpose.
This allows me to go to previous/next state by doing card->state++ or
card->state--;
enum will hide the numeric values and thus make this dangerous.
I explicitly jump to a state very rarely, and it is obvious from code
when I do so.
Also states are private to each state machine, so it is easy to locate a
state within it.
Since I introduced the helpers to read/write the regs which make code
simpler and safer (less assumptions about what current window is)
and function to read the INT register which removes a chunk of redundant
code (and a goto), and most importantly guard against infinite INT poll
(which can happen with old code), I can't really use a TPC switch
anyway.
And what I had to go through to understand the
mspro_block_read_attributes....
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2010-10-14 21:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 0:39 Results of my work on memorystick subsystem Maxim Levitsky
2010-10-14 0:40 ` [PATCH 1/6] memstick: core: add series of common helpers Maxim Levitsky
2010-10-14 0:40 ` [PATCH 2/6] memstick: Add driver for Ricoh R5C592 Card reader Maxim Levitsky
2010-10-14 0:40 ` [PATCH 3/6] memstick: jmb38x: Driver rework Maxim Levitsky
2010-10-14 0:40 ` [PATCH 4/6] memstick: add support for legacy memorysticks Maxim Levitsky
2010-10-14 0:40 ` [PATCH 5/6] memstick: mspro_block: refactoring Maxim Levitsky
2010-10-14 0:40 ` [PATCH 6/6] memstick: stop passing useless pointer to card->current_mrq + refactoring Maxim Levitsky
2010-10-14 8:00 ` Results of my work on memorystick subsystem Alex Dubov
2010-10-14 21:01 ` Maxim Levitsky [this message]
2010-10-15 6:45 ` Alex Dubov
2010-10-15 13:34 ` Maxim Levitsky
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=1287090073.4301.20.camel@maxim-laptop \
--to=maximlevitsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oakad@yahoo.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