Skip to contentSkip to conversation

HID: playstation: fix unused variable in ps_battery_get_property.

PATCH Applied Roderick Colenbrander 2 participants 2 messages Feb 12, 2021

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

PATCH 1/1 HID: playstation: fix unused variable in ps_battery_get_property.

From: Roderick Colenbrander <[email protected]>

The ret variable in ps_battery_get_property is set in an error path, but never actually returned. Change the function to return ret.

---
 drivers/hid/hid-playstation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-playstation.c +2 -2
index cc93c16cc822..408b651174cf 100644
@@ -391,7 +391,7 @@ static int ps_battery_get_property(struct power_supply *psy,
 	uint8_t battery_capacity;
 	int battery_status;
 	unsigned long flags;
-	int ret;
+	int ret = 0;
 
 	spin_lock_irqsave(&dev->lock, flags);
 	battery_capacity = dev->battery_capacity;
@@ -416,7 +416,7 @@ static int ps_battery_get_property(struct power_supply *psy,
 		break;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int ps_device_register_battery(struct ps_device *dev)
Signature · 1 line
2.26.2
#1 lore raw
Quoted 9 lines · Roderick Colenbrander

From: Roderick Colenbrander <[email protected]>

The ret variable in ps_battery_get_property is set in an error path, but never actually returned. Change the function to return ret.

---

Applied, thanks for the quick fix.

Cheers,
Benjamin

Quoted 28 lines
 drivers/hid/hid-playstation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-playstation.c +2 -3
index cc93c16cc822..408b651174cf 100644
@@ -391,7 +391,7 @@ static int ps_battery_get_property(struct power_supply *psy,
        uint8_t battery_capacity;
        int battery_status;
        unsigned long flags;
-       int ret;
+       int ret = 0;
 
        spin_lock_irqsave(&dev->lock, flags);
        battery_capacity = dev->battery_capacity;
@@ -416,7 +416,7 @@ static int ps_battery_get_property(struct power_supply *psy,
                break;
        }
 
-       return 0;
+       return ret;
 }
 
 static int ps_device_register_battery(struct ps_device *dev)
--

2.26.2