* [PATCH] greybus: svc: use string choice helpers instead of ternary operator
@ 2025-08-06 6:27 Nai-Chen Cheng
2025-08-07 11:55 ` Alex Elder
0 siblings, 1 reply; 2+ messages in thread
From: Nai-Chen Cheng @ 2025-08-06 6:27 UTC (permalink / raw)
To: Johan Hovold, Alex Elder, Greg Kroah-Hartman
Cc: greybus-dev, linux-kernel, Shuah Khan, linux-kernel-mentees,
Nai-Chen Cheng
Replace ternary operator with str_enabled_disabled() helper to improve
code readability and consistency.
Generated using Coccinelle semantic patch.
Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>
---
drivers/greybus/svc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
index 4256467fcd35..35ea7147dca6 100644
--- a/drivers/greybus/svc.c
+++ b/drivers/greybus/svc.c
@@ -10,6 +10,7 @@
#include <linux/kstrtox.h>
#include <linux/workqueue.h>
#include <linux/greybus.h>
+#include <linux/string_choices.h>
#define SVC_INTF_EJECT_TIMEOUT 9000
#define SVC_INTF_ACTIVATE_TIMEOUT 6000
@@ -73,7 +74,7 @@ static ssize_t watchdog_show(struct device *dev, struct device_attribute *attr,
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "%s\n",
- gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled");
+ str_enabled_disabled(gb_svc_watchdog_enabled(svc)));
}
static ssize_t watchdog_store(struct device *dev,
---
base-commit: 7881cd6886a89eda848192d3f5759ce08672e084
change-id: 20250806-greybus-string-choices-e6d53d2382a6
Best regards,
--
Nai-Chen Cheng <bleach1827@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] greybus: svc: use string choice helpers instead of ternary operator
2025-08-06 6:27 [PATCH] greybus: svc: use string choice helpers instead of ternary operator Nai-Chen Cheng
@ 2025-08-07 11:55 ` Alex Elder
0 siblings, 0 replies; 2+ messages in thread
From: Alex Elder @ 2025-08-07 11:55 UTC (permalink / raw)
To: Nai-Chen Cheng, Johan Hovold, Alex Elder, Greg Kroah-Hartman
Cc: greybus-dev, linux-kernel, Shuah Khan, linux-kernel-mentees
On 8/6/25 1:27 AM, Nai-Chen Cheng wrote:
> Replace ternary operator with str_enabled_disabled() helper to improve
> code readability and consistency.
>
> Generated using Coccinelle semantic patch.
>
> Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>
Looks good to me. Thanks.
Reviewed-by: Alex Elder <elder@riscstar.com>
> ---
> drivers/greybus/svc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
> index 4256467fcd35..35ea7147dca6 100644
> --- a/drivers/greybus/svc.c
> +++ b/drivers/greybus/svc.c
> @@ -10,6 +10,7 @@
> #include <linux/kstrtox.h>
> #include <linux/workqueue.h>
> #include <linux/greybus.h>
> +#include <linux/string_choices.h>
>
> #define SVC_INTF_EJECT_TIMEOUT 9000
> #define SVC_INTF_ACTIVATE_TIMEOUT 6000
> @@ -73,7 +74,7 @@ static ssize_t watchdog_show(struct device *dev, struct device_attribute *attr,
> struct gb_svc *svc = to_gb_svc(dev);
>
> return sprintf(buf, "%s\n",
> - gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled");
> + str_enabled_disabled(gb_svc_watchdog_enabled(svc)));
> }
>
> static ssize_t watchdog_store(struct device *dev,
>
> ---
> base-commit: 7881cd6886a89eda848192d3f5759ce08672e084
> change-id: 20250806-greybus-string-choices-e6d53d2382a6
>
> Best regards,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-07 11:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 6:27 [PATCH] greybus: svc: use string choice helpers instead of ternary operator Nai-Chen Cheng
2025-08-07 11:55 ` Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).