Skip to contentSkip to conversation

platform/x86: toshiba_haps: Remove unnecessary ret in toshiba_haps_resume()

PATCH In review Sang-Heon Jeon 2 participants 2 messages Jul 31 – Oct 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: toshiba_haps: Remove unnecessary ret in toshiba_haps_resume()

The return value of toshiba_haps_protection_level() is ignored because ret is immediately overwritten by the toshiba_haps_reset_protection() call.

And ret is only used by the check, which has no effect because both branches return the same value. So remove the check and ret, and return the value directly.

No functional change.

Found by the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.

---
The platform/x86 patch of the treewide v1 series [1] is posted separately. You can find the Coccinelle script in v1 [1].

---
Changes from v1 [1]
- Change base to platform-drivers-x86/for-next
- Filter only toshiba_haps changes
- Remove the unused ret variable
- Update the subject

[1] https://lore.kernel.org/all/[email protected]/
---

 drivers/platform/x86/toshiba_haps.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/platform/x86/toshiba_haps.c +3 -8
index c6633b74029f..b2eb91929d1d 100644
@@ -244,18 +244,13 @@ static int toshiba_haps_suspend(struct device *device)
 static int toshiba_haps_resume(struct device *device)
 {
 	struct toshiba_haps_dev *haps = dev_get_drvdata(device);
-	int ret;
 
 	/* Set the stored protection level */
-	ret = toshiba_haps_protection_level(haps->acpi_dev->handle,
-					    haps->protection_level);
+	toshiba_haps_protection_level(haps->acpi_dev->handle,
+				      haps->protection_level);
 
 	/* Reset the protection on resume */
-	ret = toshiba_haps_reset_protection(haps->acpi_dev->handle);
-	if (ret != 0)
-		return ret;
-
-	return ret;
+	return toshiba_haps_reset_protection(haps->acpi_dev->handle);
 }
 #endif
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 9 lines · Sang-Heon Jeon

The return value of toshiba_haps_protection_level() is ignored because ret is immediately overwritten by the toshiba_haps_reset_protection() call.

And ret is only used by the check, which has no effect because both branches return the same value. So remove the check and ret, and return the value directly.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: toshiba_haps: Remove unnecessary ret in toshiba_haps_resume()

      commit: a3d87f9f5408c137895667475ac730bbae829360

--
i.