diff mbox series

[13/68] libata: revamp ata_get_cmd_descript()

Message ID 20211210072905.15666-14-hare@suse.de
State New
Headers show
Series libata: rework logging, take II | expand

Commit Message

Hannes Reinecke Dec. 10, 2021, 7:28 a.m. UTC
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>
---
 drivers/ata/libata-acpi.c |  4 +---
 drivers/ata/libata-eh.c   | 20 ++++++++------------
 drivers/ata/libata.h      |  2 +-
 3 files changed, 10 insertions(+), 16 deletions(-)

Comments

Sergey Shtylyov Dec. 12, 2021, 9:33 a.m. UTC | #1
On 10.12.2021 10:28, Hannes Reinecke wrote:

> Rename ata_get_cmd_descrip() to ata_get_cmd_name() and simplify
> it to return 'unknown' instead of NULL.

    "unknown"?

> Signed-off-by: Hannes Reinecke <hare@suse.de>

[...]
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 69f51616d8bd..29a64059d3a1 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -2080,16 +2080,15 @@ void ata_eh_autopsy(struct ata_port *ap)
>   }
>   
>   /**
> - *	ata_get_cmd_descript - get description for ATA command
> + *	ata_get_cmd_name - get description for ATA command

    s/description/name/?

>    *	@command: ATA command code to get description for

    Here as well?

>    *
> - *	Return a textual description of the given command, or NULL if the
> - *	command is not known.
> + *	Return a textual description of the given command or "unknown"

    And here?

>    *
>    *	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
[...]

MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 7007377880ce..9e1e62b9cf63 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -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;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 69f51616d8bd..29a64059d3a1 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2080,16 +2080,15 @@  void ata_eh_autopsy(struct ata_port *ap)
 }
 
 /**
- *	ata_get_cmd_descript - get description for ATA command
+ *	ata_get_cmd_name - get description for ATA command
  *	@command: ATA command code to get description for
  *
- *	Return a textual description of the given command, or NULL if the
- *	command is not known.
+ *	Return a textual description 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
@@ -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
@@ -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 "
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 4a8f4623cfe5..2144065e762c 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -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,