From: Kevin Wolf <kwolf@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] ide/atapi: Use table instead of switch for commands
Date: Tue, 19 Apr 2011 15:34:07 +0200 [thread overview]
Message-ID: <4DAD8F4F.5090008@redhat.com> (raw)
In-Reply-To: <20110419132019.GH16567@amit-x200.redhat.com>
Am 19.04.2011 15:20, schrieb Amit Shah:
> On (Tue) 19 Apr 2011 [14:36:41], Kevin Wolf wrote:
>
>> +struct {
>> + void (*handler)(IDEState *s, uint8_t *buf);
>> + int flags;
>> +} atapi_cmd_table[0x100] = {
>> + [ 0x00 ] = { cmd_test_unit_ready, 0 },
>> + [ 0x03 ] = { cmd_request_sense, ALLOW_UA },
>> + [ 0x12 ] = { cmd_inquiry, ALLOW_UA },
>> + [ 0x1a ] = { cmd_mode_sense, /* (6) */ 0 },
>> + [ 0x1b ] = { cmd_start_stop_unit, 0 },
>> + [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 },
>> + [ 0x25 ] = { cmd_read_cdvd_capacity, 0 },
>> + [ 0x28 ] = { cmd_read, /* (10) */ 0 },
>> + [ 0x2b ] = { cmd_seek, 0 },
>> + [ 0x43 ] = { cmd_read_toc_pma_atip, 0 },
>> + [ 0x46 ] = { cmd_get_configuration, ALLOW_UA },
>> + [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA },
>> + [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 },
>> + [ 0xa8 ] = { cmd_read, /* (12) */ 0 },
>> + [ 0xad ] = { cmd_read_dvd_structure, 0 },
>> + [ 0xbb ] = { cmd_set_speed, 0 },
>> + [ 0xbd ] = { cmd_mechanism_status, 0 },
>> + [ 0xbe ] = { cmd_read_cd, 0 },
>> +};
>
> I'd prefer to use the GPCMD_TEST_UNIT_READY, etc., defines we already
> have in internal.h instead of using the command numbers here.
In fact, I was considering to remove the GPCMD_* definitions because
most of them are unused now (only cmd_mode_sense/cmd_read still use them
to distinguish the variants).
What I like about this table is that you have all information about a
command directly visible: Its opcode, its name and any flags. Using the
constants would hide the opcode again, duplicate the name and probably
make the lines longer than 80 characters.
Kevin
next prev parent reply other threads:[~2011-04-19 13:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 12:36 [Qemu-devel] [PATCH 0/5] atapi: Some code restructuring Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 1/5] ide: Split atapi.c out Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 2/5] ide/atapi: Factor some commands out Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 3/5] ide/atapi: Use table instead of switch for commands Kevin Wolf
2011-04-19 13:20 ` Amit Shah
2011-04-19 13:34 ` Kevin Wolf [this message]
2011-04-19 12:36 ` [Qemu-devel] [PATCH 4/5] ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors Kevin Wolf
2011-04-19 12:36 ` [Qemu-devel] [PATCH 5/5] ide/atapi: Introduce NEED_DISK flag for commands Kevin Wolf
2011-04-19 13:18 ` Amit Shah
2011-04-19 13:45 ` Kevin Wolf
2011-04-19 13:21 ` [Qemu-devel] [PATCH 0/5] atapi: Some code restructuring Amit Shah
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=4DAD8F4F.5090008@redhat.com \
--to=kwolf@redhat.com \
--cc=amit.shah@redhat.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).