Skip to contentSkip to conversation

platform/x86/amd/pmf: Use str_on_off() helper

PATCH In review Andy Shevchenko 4 participants 4 messages Aug 11, 2023 – Aug 21, 2023

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

PATCH 1/1 platform/x86/amd/pmf: Use str_on_off() helper

We have a common helper to represent a boolean value as "on"/"off" string. Use it for the sake of the unified style.

---
 drivers/platform/x86/amd/pmf/cnqf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmf/cnqf.c +3 -2
index 539b186e9027..bc8899e15c91 100644
@@ -8,6 +8,7 @@
  * Author: Shyam Sundar S K <[email protected]>
  */
 
+#include <linux/string_choices.h>
 #include <linux/workqueue.h>
 #include "pmf.h"
 
@@ -399,7 +400,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
 			amd_pmf_set_sps_power_limits(pdev);
 	}
 
-	dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
+	dev_dbg(pdev->dev, "Received CnQF %s\n", str_on_off(input));
 	return count;
 }
 
@@ -409,7 +410,7 @@ static ssize_t cnqf_enable_show(struct device *dev,
 {
 	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
 
-	return sysfs_emit(buf, "%s\n", pdev->cnqf_enabled ? "on" : "off");
+	return sysfs_emit(buf, "%s\n", str_on_off(pdev->cnqf_enabled));
 }
 
 static DEVICE_ATTR_RW(cnqf_enable);
Signature · 1 line
2.40.0.1.gaa8946217a0b
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Andy Shevchenko

We have a common helper to represent a boolean value as "on"/"off" string. Use it for the sake of the unified style.

---
 drivers/platform/x86/amd/pmf/cnqf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmf/cnqf.c +2 -1
index 539b186e9027..bc8899e15c91 100644
@@ -8,6 +8,7 @@
  * Author: Shyam Sundar S K <[email protected]>
  */
 
+#include <linux/string_choices.h>
 #include <linux/workqueue.h>
 #include "pmf.h"
 
@@ -399,7 +400,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
 			amd_pmf_set_sps_power_limits(pdev);
 	}
 
-	dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
+	dev_dbg(pdev->dev, "Received CnQF %s\n", str_on_off(input));
 	return count;
 }
 

drivers/platform/x86/amd/pmf/cnqf.c static ssize_t cnqf_enable_show(struct device *dev, · line 416

Quoted 8 lines
drivers/platform/x86/amd/pmf/cnqf.c +1 -1
@@ -409,7 +410,7 @@ static ssize_t cnqf_enable_show(struct device *dev,
 {
 	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
 
-	return sysfs_emit(buf, "%s\n", pdev->cnqf_enabled ? "on" : "off");
+	return sysfs_emit(buf, "%s\n", str_on_off(pdev->cnqf_enabled));
 }
 
 static DEVICE_ATTR_RW(cnqf_enable);
Signature · 1 line
 i.
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

We have a common helper to represent a boolean value as "on"/"off" string. Use it for the sake of the unified style.

Quoted 34 lines
---
 drivers/platform/x86/amd/pmf/cnqf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmf/cnqf.c +3 -2
index 539b186e9027..bc8899e15c91 100644
@@ -8,6 +8,7 @@
  * Author: Shyam Sundar S K <[email protected]>
  */
 
+#include <linux/string_choices.h>
 #include <linux/workqueue.h>
 #include "pmf.h"
 
@@ -399,7 +400,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
 			amd_pmf_set_sps_power_limits(pdev);
 	}
 
-	dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
+	dev_dbg(pdev->dev, "Received CnQF %s\n", str_on_off(input));
 	return count;
 }
 
@@ -409,7 +410,7 @@ static ssize_t cnqf_enable_show(struct device *dev,
 {
 	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
 
-	return sysfs_emit(buf, "%s\n", pdev->cnqf_enabled ? "on" : "off");
+	return sysfs_emit(buf, "%s\n", str_on_off(pdev->cnqf_enabled));
 }
 
 static DEVICE_ATTR_RW(cnqf_enable);
Signature · 2 lines
BR,
Muhammad Usama Anjum
#3 lore raw
In reply to Andy Shevchenko

Hi,

Quoted 4 lines · Andy Shevchenko

We have a common helper to represent a boolean value as "on"/"off" string. Use it for the sake of the unified style.

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 34 lines
---
 drivers/platform/x86/amd/pmf/cnqf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmf/cnqf.c +3 -2
index 539b186e9027..bc8899e15c91 100644
@@ -8,6 +8,7 @@
  * Author: Shyam Sundar S K <[email protected]>
  */
 
+#include <linux/string_choices.h>
 #include <linux/workqueue.h>
 #include "pmf.h"
 
@@ -399,7 +400,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
 			amd_pmf_set_sps_power_limits(pdev);
 	}
 
-	dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
+	dev_dbg(pdev->dev, "Received CnQF %s\n", str_on_off(input));
 	return count;
 }
 
@@ -409,7 +410,7 @@ static ssize_t cnqf_enable_show(struct device *dev,
 {
 	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
 
-	return sysfs_emit(buf, "%s\n", pdev->cnqf_enabled ? "on" : "off");
+	return sysfs_emit(buf, "%s\n", str_on_off(pdev->cnqf_enabled));
 }
 
 static DEVICE_ATTR_RW(cnqf_enable);