From: Felipe Ferreri Tonello <eu@felipetonello.com>
To: Clemens Ladisch <clemens@ladisch.de>, linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Felipe Balbi <balbi@kernel.org>,
Michal Nazarewicz <mina86@mina86.com>
Subject: Re: [PATCH 1/5] usb: gadget: f_midi: refactor state machine
Date: Thu, 3 Mar 2016 16:30:25 +0000 [thread overview]
Message-ID: <56D866A1.5060303@felipetonello.com> (raw)
In-Reply-To: <56D82237.2080705@ladisch.de>
[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]
Hi Clemens,
On 03/03/16 11:38, Clemens Ladisch wrote:
> Felipe Ferreri Tonello wrote:
>> On 02/03/16 21:09, Clemens Ladisch wrote:
>>> Felipe F. Tonello wrote:
>>>> This refactor results in a cleaner state machine code
>>>
>>> It increases the number of states, and now juggles two state variables.
>>> I cannot agree to it being cleaner.
>>
>> Yes, it increases the number of states. That was done in order to
>> actually implement a proper finite state machine with one state at a
>> time and a transition state.
>
> I know, "clean" is subjective.
Clean is subjective, yes. However, based on our common sense and
experience we can discern on what is clean and what is not. There is
also good literature about the subject that we can always consider.
> But in what way was the old state
> machine not "proper"?
Because it didn't reflect all the correct and possible MIDI states and
there was no transitional state.
>
> And how is handling two states (port->state and next_state) cleaner?
> As far as I can tell, the requirement for a separate variable comes not
> from any inherent complexity of the state machine itself, but only
> because the transmit_packet function was inlined.
next_state is a transitional state, thus the temporal nature.
This patch doesn't change any functionality. But the important thing
here is that it improves the driver maintainability by making the state
machine cleaner (which is one of the most important pieces of code of
the driver). I call it clean because on each circumstance of each state
it's clear on what is about to happen to the USB request and to the
port's buffers.
I confess I would not spend the time on it just for puritanisms, but I
found myself a hard time while debugging it.
--
Felipe
[-- Attachment #2: 0x92698E6A.asc --]
[-- Type: application/pgp-keys, Size: 7310 bytes --]
next prev parent reply other threads:[~2016-03-03 16:28 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 19:40 [PATCH 0/5] MIDI USB Gadget improvements Felipe F. Tonello
2016-03-02 19:40 ` [PATCH 1/5] usb: gadget: f_midi: refactor state machine Felipe F. Tonello
2016-03-02 21:09 ` Clemens Ladisch
2016-03-03 8:57 ` Felipe Ferreri Tonello
2016-03-03 11:38 ` Clemens Ladisch
2016-03-03 16:30 ` Felipe Ferreri Tonello [this message]
2016-03-04 8:07 ` Clemens Ladisch
2016-03-04 18:39 ` Felipe Ferreri Tonello
2016-03-04 18:43 ` Clemens Ladisch
2016-03-02 19:40 ` [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe F. Tonello
2016-03-04 7:20 ` Felipe Balbi
2016-03-04 18:49 ` Felipe Ferreri Tonello
2016-03-07 7:32 ` Felipe Balbi
2016-03-07 9:28 ` Felipe Ferreri Tonello
2016-03-08 7:37 ` Felipe Balbi
2016-03-08 13:46 ` Felipe Ferreri Tonello
2016-03-08 14:01 ` Felipe Balbi
2016-03-08 15:40 ` Felipe Ferreri Tonello
2016-03-09 7:22 ` Felipe Balbi
2016-03-02 19:40 ` [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Felipe F. Tonello
2016-03-04 7:16 ` Felipe Balbi
2016-03-04 18:46 ` Felipe Ferreri Tonello
2016-03-07 7:34 ` Felipe Balbi
2016-03-07 9:40 ` Felipe Ferreri Tonello
2016-03-07 10:59 ` Felipe Balbi
2016-03-07 11:13 ` Felipe Ferreri Tonello
2016-03-08 7:43 ` Felipe Balbi
2016-03-08 10:14 ` Krzysztof Opasiak
2016-03-08 10:34 ` Felipe Balbi
2016-03-08 13:54 ` Felipe Ferreri Tonello
2016-03-08 14:04 ` Felipe Balbi
2016-03-08 14:15 ` Krzysztof Opasiak
2016-03-08 14:20 ` Felipe Balbi
2016-03-08 15:24 ` Felipe Ferreri Tonello
2016-03-02 19:40 ` [PATCH 4/5] usb: gadget: f_midi: cleanups and typos fixes Felipe F. Tonello
2016-03-04 7:13 ` Felipe Balbi
2016-03-04 19:17 ` Michal Nazarewicz
2016-03-04 20:17 ` Felipe Ferreri Tonello
2016-03-05 16:28 ` Michal Nazarewicz
2016-03-05 19:39 ` Greg KH
2016-03-05 23:53 ` Felipe Ferreri Tonello
2016-03-06 3:02 ` Greg KH
2016-03-05 23:57 ` Felipe Ferreri Tonello
2016-03-07 7:35 ` Felipe Balbi
2016-03-07 9:32 ` Felipe Ferreri Tonello
2016-03-08 7:44 ` Felipe Balbi
2016-03-02 19:40 ` [PATCH 5/5] usb: gadget: f_midi: updated copyright Felipe F. Tonello
2016-03-04 7:13 ` Felipe Balbi
2016-03-04 18:41 ` Felipe Ferreri Tonello
2016-03-07 7:36 ` Felipe Balbi
2016-03-07 9:23 ` Felipe Ferreri Tonello
2016-03-04 7:11 ` [PATCH 0/5] MIDI USB Gadget improvements Felipe Balbi
2016-03-04 18:43 ` Felipe Ferreri Tonello
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=56D866A1.5060303@felipetonello.com \
--to=eu@felipetonello.com \
--cc=balbi@kernel.org \
--cc=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.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