Skip to contentSkip to conversation

libata: ata_{sff|std}_prereset() always return 0

PATCH Superseded Sergey Shtylyov 2 participants 2 messages Feb 1, 2022 – Feb 2, 2022 libata

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libata: ata_{sff|std}_prereset() always return 0

ata_std_prereset() always returns 0, hence the check in ata_sff_prereset() is pointless and thus it also can return only 0 (however, we cannot change the prototypes of ata_{sff|std}_prereset() as they implement the driver's prereset() method).

Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.

---
This patch is against the 'for-next' branch of Damien Le Moal's 'libata.git' repo.

Changes in version 2:
- fixed up the 'kernel-doc' comments on the function results.

 drivers/ata/libata-core.c |    2 +-
 drivers/ata/libata-sff.c  |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/ata/libata-core.c +1 -1
Index: libata/drivers/ata/libata-core.c
===================================================================
@@ -3568,7 +3568,7 @@ EXPORT_SYMBOL_GPL(ata_wait_after_reset);
  *	Kernel thread context (may sleep)
  *
  *	RETURNS:
- *	0 on success, -errno otherwise.
+ *	Always 0.
  */
 int ata_std_prereset(struct ata_link *link, unsigned long deadline)
 {
drivers/ata/libata-sff.c +2 -4
Index: libata/drivers/ata/libata-sff.c
===================================================================
@@ -1708,16 +1708,14 @@ EXPORT_SYMBOL_GPL(ata_sff_thaw);
  *	Kernel thread context (may sleep)
  *
  *	RETURNS:
- *	0 on success, -errno otherwise.
+ *	Always 0.
  */
 int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
 {
 	struct ata_eh_context *ehc = &link->eh_context;
 	int rc;
 
-	rc = ata_std_prereset(link, deadline);
-	if (rc)
-		return rc;
+	ata_std_prereset(link, deadline);
 
 	/* if we're about to do hardreset, nothing more to do */
 	if (ehc->i.action & ATA_EH_HARDRESET)
#1 lore raw
Quoted 44 lines · Sergey Shtylyov

ata_std_prereset() always returns 0, hence the check in ata_sff_prereset() is pointless and thus it also can return only 0 (however, we cannot change the prototypes of ata_{sff|std}_prereset() as they implement the driver's prereset() method).

Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.

---
This patch is against the 'for-next' branch of Damien Le Moal's 'libata.git' repo.

Changes in version 2:
- fixed up the 'kernel-doc' comments on the function results.

 drivers/ata/libata-core.c |    2 +-
 drivers/ata/libata-sff.c  |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

Index: libata/drivers/ata/libata-core.c
===================================================================

drivers/ata/libata-core.c +1 -1
@@ -3568,7 +3568,7 @@ EXPORT_SYMBOL_GPL(ata_wait_after_reset);
  *	Kernel thread context (may sleep)
  *
  *	RETURNS:
- *	0 on success, -errno otherwise.
+ *	Always 0.
  */
 int ata_std_prereset(struct ata_link *link, unsigned long deadline)
 {

Index: libata/drivers/ata/libata-sff.c
===================================================================

drivers/ata/libata-sff.c +1 -1
@@ -1708,16 +1708,14 @@ EXPORT_SYMBOL_GPL(ata_sff_thaw);
  *	Kernel thread context (may sleep)
  *
  *	RETURNS:
- *	0 on success, -errno otherwise.
+ *	Always 0.

drivers/ata/libata-sff.c EXPORT_SYMBOL_GPL(ata_sff_thaw); · line 1718

Quoted 10 lines
drivers/ata/libata-sff.c +1 -3
  */
 int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
 {
 	struct ata_eh_context *ehc = &link->eh_context;
 	int rc;
 
-	rc = ata_std_prereset(link, deadline);
-	if (rc)
-		return rc;
+	ata_std_prereset(link, deadline);

Not a fan of removing the check here unless ata_std_prereset() is turned into a void function. But doing that needs more changes with little value. So at least can you add a comment above this call ? Something like:

	/* Standard prereset is best-effort and always return 0 */
	ata_std_prereset(link, deadline);

So that it is clear that we are aware that the function is non-void ?

Quoted 3 lines
drivers/ata/libata-sff.c +0 -0
 	/* if we're about to do hardreset, nothing more to do */
 	if (ehc->i.action & ATA_EH_HARDRESET)
Signature · 2 lines
Damien Le Moal
Western Digital Research