[PATCH v2] iommu/amd: use str_plural() to simplify the code

Xichao Zhao posted 1 patch 1 month, 2 weeks ago
drivers/iommu/amd/iommu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v2] iommu/amd: use str_plural() to simplify the code
Posted by Xichao Zhao 1 month, 2 weeks ago
Use the string choice helper function str_plural() to simplify the code.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 drivers/iommu/amd/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index eb348c63a8d0..fc11a5dab8ec 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -14,6 +14,7 @@
 #include <linux/pci-ats.h>
 #include <linux/bitmap.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/debugfs.h>
 #include <linux/scatterlist.h>
 #include <linux/dma-map-ops.h>
@@ -265,7 +266,7 @@ static inline int get_acpihid_device_id(struct device *dev,
 		return -EINVAL;
 	if (fw_bug)
 		dev_err_once(dev, FW_BUG "No ACPI device matched UID, but %d device%s matched HID.\n",
-			     hid_count, hid_count > 1 ? "s" : "");
+			     hid_count, str_plural(hid_count));
 	if (hid_count > 1)
 		return -EINVAL;
 	if (entry)
-- 
2.34.1
Re: [PATCH v2] iommu/amd: use str_plural() to simplify the code
Posted by Joerg Roedel 4 weeks ago
On Mon, Aug 18, 2025 at 03:05:56PM +0800, Xichao Zhao wrote:
> Use the string choice helper function str_plural() to simplify the code.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>  drivers/iommu/amd/iommu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks.
Re: [PATCH v2] iommu/amd: use str_plural() to simplify the code
Posted by Ankit Soni 1 month, 2 weeks ago
On Mon, Aug 18, 2025 at 03:05:56PM +0800, Xichao Zhao wrote:
> Use the string choice helper function str_plural() to simplify the code.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>

Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>

-Ankit

> ---
>  drivers/iommu/amd/iommu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index eb348c63a8d0..fc11a5dab8ec 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -14,6 +14,7 @@
>  #include <linux/pci-ats.h>
>  #include <linux/bitmap.h>
>  #include <linux/slab.h>
> +#include <linux/string_choices.h>
>  #include <linux/debugfs.h>
>  #include <linux/scatterlist.h>
>  #include <linux/dma-map-ops.h>
> @@ -265,7 +266,7 @@ static inline int get_acpihid_device_id(struct device *dev,
>  		return -EINVAL;
>  	if (fw_bug)
>  		dev_err_once(dev, FW_BUG "No ACPI device matched UID, but %d device%s matched HID.\n",
> -			     hid_count, hid_count > 1 ? "s" : "");
> +			     hid_count, str_plural(hid_count));
>  	if (hid_count > 1)
>  		return -EINVAL;
>  	if (entry)
> -- 
> 2.34.1
>