Skip to contentSkip to conversation

drm/tegra: dp: use str_plural in drm_dp_link_train_{full,fast}

PATCH In review Thorsten Blum 2 participants 3 messages May 21 – May 28

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

PATCH 1/2 drm/tegra: dp: use str_plural in drm_dp_link_train_{full,fast}

Replace the manual ternary "s" pluralizations with str_plural() to simplify the code. This also corrects the "0 lanes" case.

---
 drivers/gpu/drm/tegra/dp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/dp.c +4 -2
index 990e744b0923..3cb194f5ce36 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2015 Rob Clark
  */
 
+#include <linux/string_choices.h>
+
 #include <drm/display/drm_dp_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_print.h>
@@ -668,7 +670,7 @@ static int drm_dp_link_train_full(struct drm_dp_link *link)
 
 retry:
 	DRM_DEBUG_KMS("full-training link: %u lane%s at %u MHz\n",
-		      link->lanes, (link->lanes > 1) ? "s" : "",
+		      link->lanes, str_plural(link->lanes),
 		      link->rate / 100);
 
 	err = drm_dp_link_configure(link->aux, link);
@@ -724,7 +726,7 @@ static int drm_dp_link_train_fast(struct drm_dp_link *link)
 	int err;
 
 	DRM_DEBUG_KMS("fast-training link: %u lane%s at %u MHz\n",
-		      link->lanes, (link->lanes > 1) ? "s" : "",
+		      link->lanes, str_plural(link->lanes),
 		      link->rate / 100);
 
 	err = drm_dp_link_configure(link->aux, link);
#1 lore raw

PATCH 2/2 drm/tegra: sor: use str_plural in tegra_sor_dp_link_configure

Replace the manual ternary "s" pluralization with str_plural() to simplify the code.

---
 drivers/gpu/drm/tegra/sor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/tegra/sor.c +2 -1
index de8b2dfc4984..93e5ffd4f206 100644
@@ -13,6 +13,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/reset.h>
+#include <linux/string_choices.h>
 
 #include <soc/tegra/pmc.h>
 
@@ -940,7 +941,7 @@ static int tegra_sor_dp_link_configure(struct drm_dp_link *link)
 	err = tegra_sor_power_up_lanes(sor, lanes);
 	if (err < 0) {
 		dev_err(sor->dev, "failed to power up %u lane%s: %d\n",
-			lanes, (lanes != 1) ? "s" : "", err);
+			lanes, str_plural(lanes), err);
 		return err;
 	}
 
maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

Replace the manual ternary "s" pluralizations with str_plural() to simplify the code. This also corrects the "0 lanes" case.

---
 drivers/gpu/drm/tegra/dp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Both patches applied, thanks.

Thierry