Skip to content

Commit

Permalink
ata: libata: revamp ata_get_cmd_descript()
Browse files Browse the repository at this point in the history
Rename ata_get_cmd_descrip() to ata_get_cmd_name() and simplify
it to return "unknown" instead of NULL.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
  • Loading branch information
Hannes Reinecke authored and Damien Le Moal committed Jan 5, 2022
1 parent 742bef4 commit d452090
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 1 addition & 3 deletions drivers/ata/libata-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,
pptf = &ptf;
}

descr = ata_get_cmd_descript(tf.command);
if (!descr)
descr = "unknown";
descr = ata_get_cmd_name(tf.command);

if (!ata_acpi_filter_tf(dev, &tf, pptf)) {
rtf = tf;
Expand Down
22 changes: 9 additions & 13 deletions drivers/ata/libata-eh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,16 +2080,15 @@ void ata_eh_autopsy(struct ata_port *ap)
}

/**
* ata_get_cmd_descript - get description for ATA command
* @command: ATA command code to get description for
* ata_get_cmd_name - get name for ATA command
* @command: ATA command code to get name for
*
* Return a textual description of the given command, or NULL if the
* command is not known.
* Return a textual name of the given command or "unknown"
*
* LOCKING:
* None
*/
const char *ata_get_cmd_descript(u8 command)
const char *ata_get_cmd_name(u8 command)
{
#ifdef CONFIG_ATA_VERBOSE_ERROR
static const struct
Expand Down Expand Up @@ -2197,9 +2196,9 @@ const char *ata_get_cmd_descript(u8 command)
return cmd_descr[i].text;
#endif

return NULL;
return "unknown";
}
EXPORT_SYMBOL_GPL(ata_get_cmd_descript);
EXPORT_SYMBOL_GPL(ata_get_cmd_name);

/**
* ata_eh_link_report - report error handling to user
Expand Down Expand Up @@ -2348,12 +2347,9 @@ static void ata_eh_link_report(struct ata_link *link)
}
__scsi_format_command(cdb_buf, sizeof(cdb_buf),
cdb, cdb_len);
} else {
const char *descr = ata_get_cmd_descript(cmd->command);
if (descr)
ata_dev_err(qc->dev, "failed command: %s\n",
descr);
}
} else
ata_dev_err(qc->dev, "failed command: %s\n",
ata_get_cmd_name(cmd->command));

ata_dev_err(qc->dev,
"cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,
unsigned int action);
extern void ata_eh_autopsy(struct ata_port *ap);
const char *ata_get_cmd_descript(u8 command);
const char *ata_get_cmd_name(u8 command);
extern void ata_eh_report(struct ata_port *ap);
extern int ata_eh_reset(struct ata_link *link, int classify,
ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
Expand Down

0 comments on commit d452090

Please sign in to comment.