nvme: Eliminate redundant code
get_admin_opcode_string and get_io_opcode_string are identical, but start with different tables. Use a helper routine that takes an argument to implement these instead. A future commit will refine this further. Sponsored by: Netflix Reviewed by: chuck, mav, jhb Differential Revision: https://reviews.freebsd.org/D41310
This commit is contained in:
parent
7be0b06885
commit
edd23e4dc0
@ -99,12 +99,8 @@ static struct nvme_opcode_string io_opcode[] = {
|
||||
};
|
||||
|
||||
static const char *
|
||||
get_admin_opcode_string(uint16_t opc)
|
||||
get_opcode_string(struct nvme_opcode_string *entry, uint16_t opc)
|
||||
{
|
||||
struct nvme_opcode_string *entry;
|
||||
|
||||
entry = admin_opcode;
|
||||
|
||||
while (entry->opc != 0xFFFF) {
|
||||
if (entry->opc == opc)
|
||||
return (entry->str);
|
||||
@ -113,19 +109,16 @@ get_admin_opcode_string(uint16_t opc)
|
||||
return (entry->str);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_admin_opcode_string(uint16_t opc)
|
||||
{
|
||||
return (get_opcode_string(admin_opcode, opc));
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_io_opcode_string(uint16_t opc)
|
||||
{
|
||||
struct nvme_opcode_string *entry;
|
||||
|
||||
entry = io_opcode;
|
||||
|
||||
while (entry->opc != 0xFFFF) {
|
||||
if (entry->opc == opc)
|
||||
return (entry->str);
|
||||
entry++;
|
||||
}
|
||||
return (entry->str);
|
||||
return (get_opcode_string(io_opcode, opc));
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user