Skip to contentSkip to conversation

PM / QoS: Use the correct variable to check the QoS request type

PATCH Applied Jan H. Schönherr 2 participants 2 messages Sep 5, 2017 – Sep 19, 2017

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

PATCH 1/1 PM / QoS: Use the correct variable to check the QoS request type

Use the actual function argument for the validation of the request type, instead of the type field in a fresh (supposedly zero-initialized) request structure.

---
 drivers/base/power/qos.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/base/power/qos.c +5 -5
index f850dae..277d43a 100644
@@ -277,11 +277,11 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
 	mutex_unlock(&dev_pm_qos_sysfs_mtx);
 }
 
-static bool dev_pm_qos_invalid_request(struct device *dev,
-				       struct dev_pm_qos_request *req)
+static bool dev_pm_qos_invalid_req_type(struct device *dev,
+					enum dev_pm_qos_req_type type)
 {
-	return !req || (req->type == DEV_PM_QOS_LATENCY_TOLERANCE
-			&& !dev->power.set_latency_tolerance);
+	return type == DEV_PM_QOS_LATENCY_TOLERANCE &&
+	       !dev->power.set_latency_tolerance;
 }
 
 static int __dev_pm_qos_add_request(struct device *dev,
@@ -290,7 +290,7 @@ static int __dev_pm_qos_add_request(struct device *dev,
 {
 	int ret = 0;
 
-	if (!dev || dev_pm_qos_invalid_request(dev, req))
+	if (!dev || !req || dev_pm_qos_invalid_req_type(dev, type))
 		return -EINVAL;
 
 	if (WARN(dev_pm_qos_request_active(req),
Signature · 1 line
2.3.1.dirty
#1 lore raw
Quoted 31 lines · CEST Jan H. Schönherr

Use the actual function argument for the validation of the request type, instead of the type field in a fresh (supposedly zero-initialized) request structure.

---
 drivers/base/power/qos.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/base/power/qos.c +4 -4
index f850dae..277d43a 100644
@@ -277,11 +277,11 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
 	mutex_unlock(&dev_pm_qos_sysfs_mtx);
 }
 
-static bool dev_pm_qos_invalid_request(struct device *dev,
-				       struct dev_pm_qos_request *req)
+static bool dev_pm_qos_invalid_req_type(struct device *dev,
+					enum dev_pm_qos_req_type type)
 {
-	return !req || (req->type == DEV_PM_QOS_LATENCY_TOLERANCE
-			&& !dev->power.set_latency_tolerance);
+	return type == DEV_PM_QOS_LATENCY_TOLERANCE &&
+	       !dev->power.set_latency_tolerance;
 }
 
 static int __dev_pm_qos_add_request(struct device *dev,

drivers/base/power/qos.c static int __dev_pm_qos_add_request(struct device *dev, · line 296

Quoted 8 lines
drivers/base/power/qos.c +1 -1
@@ -290,7 +290,7 @@ static int __dev_pm_qos_add_request(struct device *dev,
 {
 	int ret = 0;
 
-	if (!dev || dev_pm_qos_invalid_request(dev, req))
+	if (!dev || !req || dev_pm_qos_invalid_req_type(dev, type))
 		return -EINVAL;
 
 	if (WARN(dev_pm_qos_request_active(req),

Applied, thanks!