Skip to contentSkip to conversation

s390/ipl: Improve readability

PATCH Applied Mete Durlu 4 participants 7 messages Jul 21 – Jul 23 s390

lore
Share & tools
lore

Mete Durlu

author
#0 lore raw

cover s390/ipl: Improve readability

Improve readability of s390 ipl code by openly writing static struct definitions, reformatting list definitions and using ARRAY_SIZE() macro in suitable places.

No functional changes, only coding style changes.

---
Mete Durlu (2):
s390/ipl: Use ARRAY_SIZE macro
s390/ipl: Improve readability

 arch/s390/kernel/ipl.c | 58 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 20 deletions(-)

---
base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
change-id: 20260721-ipl_refactor-ef6aa1bafa8a

Best regards,

Signature · 1 line
Mete Durlu <[email protected]>
author
#1 lore raw

PATCH 1/2 s390/ipl: Use ARRAY_SIZE macro

Use ARRAY_SIZE macro instead of reimplementing it.

---
 arch/s390/kernel/ipl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/s390/kernel/ipl.c +2 -3
index 3c346b02ceb9..2e1e37588d0d 100644
@@ -2044,7 +2044,6 @@ static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR,
 static struct shutdown_action *shutdown_actions_list[] = {
 	&ipl_action, &reipl_action, &dump_reipl_action, &dump_action,
 	&vmcmd_action, &stop_action};
-#define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *))
 
 /*
  * Trigger section
@@ -2057,7 +2056,7 @@ static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
 {
 	int i;
 
-	for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
+	for (i = 0; i < ARRAY_SIZE(shutdown_actions_list); i++) {
 		if (sysfs_streq(buf, shutdown_actions_list[i]->name)) {
 			if (shutdown_actions_list[i]->init_rc) {
 				return shutdown_actions_list[i]->init_rc;
@@ -2242,7 +2241,7 @@ static void __init shutdown_actions_init(void)
 {
 	int i;
 
-	for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
+	for (i = 0; i < ARRAY_SIZE(shutdown_actions_list); i++) {
 		if (!shutdown_actions_list[i]->init)
 			continue;
 		shutdown_actions_list[i]->init_rc =
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 1/2] s390/ipl: Use ARRAY_SIZE macro

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines

Use ARRAY_SIZE macro instead of reimplementing it.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author
#3 lore raw

PATCH 2/2 s390/ipl: Improve readability

In reply to Mete Durlu

Use explicit decleration on all shutdown_action/shutdown_trigger declerations and reformat shutdown_actions_list decleration to improve readability. No functional changes.

---
 arch/s390/kernel/ipl.c | 53 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 17 deletions(-)
arch/s390/kernel/ipl.c +36 -17
index 2e1e37588d0d..d74ef30155aa 100644
@@ -2021,8 +2021,11 @@ static int vmcmd_init(void)
 	return sysfs_create_group(&vmcmd_kset->kobj, &vmcmd_attr_group);
 }
 
-static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR,
-					      vmcmd_run, vmcmd_init};
+static struct shutdown_action vmcmd_action = {
+	.name	= SHUTDOWN_ACTION_VMCMD_STR,
+	.fn	= vmcmd_run,
+	.init	= vmcmd_init
+};
 
 /*
  * stop shutdown action: Stop Linux on shutdown.
@@ -2036,14 +2039,21 @@ static void stop_run(struct shutdown_trigger *trigger)
 	smp_stop_cpu();
 }
 
-static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR,
-					     stop_run, NULL};
+static struct shutdown_action stop_action = {
+	.name	= SHUTDOWN_ACTION_STOP_STR,
+	.fn	= stop_run
+};
 
 /* action list */
 
 static struct shutdown_action *shutdown_actions_list[] = {
-	&ipl_action, &reipl_action, &dump_reipl_action, &dump_action,
-	&vmcmd_action, &stop_action};
+	&ipl_action,
+	&reipl_action,
+	&dump_reipl_action,
+	&dump_action,
+	&vmcmd_action,
+	&stop_action
+};
 
 /*
  * Trigger section
@@ -2071,8 +2081,10 @@ static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
 
 /* on reipl */
 
-static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR,
-						    &reipl_action};
+static struct shutdown_trigger on_reboot_trigger = {
+	.name	= ON_REIPL_STR,
+	.action	= &reipl_action
+};
 
 static ssize_t on_reboot_show(struct kobject *kobj,
 			      struct kobj_attribute *attr, char *page)
@@ -2097,8 +2109,10 @@ static void do_machine_restart(char *__unused)
 void (*_machine_restart)(char *command) = do_machine_restart;
 
 /* on panic */
-
-static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action};
+static struct shutdown_trigger on_panic_trigger = {
+	.name	= ON_PANIC_STR,
+	.action	= &stop_action
+};
 
 static ssize_t on_panic_show(struct kobject *kobj,
 			     struct kobj_attribute *attr, char *page)
@@ -2122,9 +2136,10 @@ static void do_panic(void)
 }
 
 /* on restart */
-
-static struct shutdown_trigger on_restart_trigger = {ON_RESTART_STR,
-	&stop_action};
+static struct shutdown_trigger on_restart_trigger = {
+	.name	= ON_RESTART_STR,
+	.action	= &stop_action
+};
 
 static ssize_t on_restart_show(struct kobject *kobj,
 			       struct kobj_attribute *attr, char *page)
@@ -2159,8 +2174,10 @@ void do_restart(void *arg)
 }
 
 /* on halt */
-
-static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action};
+static struct shutdown_trigger on_halt_trigger = {
+	.name	= ON_HALT_STR,
+	.action	= &stop_action
+};
 
 static ssize_t on_halt_show(struct kobject *kobj,
 			    struct kobj_attribute *attr, char *page)
@@ -2185,8 +2202,10 @@ static void do_machine_halt(void)
 void (*_machine_halt)(void) = do_machine_halt;
 
 /* on power off */
-
-static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action};
+static struct shutdown_trigger on_poff_trigger = {
+	.name	= ON_POFF_STR,
+	.action	= &stop_action
+};
 
 static ssize_t on_poff_show(struct kobject *kobj,
 			    struct kobj_attribute *attr, char *page)
Signature · 1 line
2.53.0
#4 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

Use explicit decleration on all shutdown_action/shutdown_trigger declerations and reformat shutdown_actions_list decleration to improve readability. No functional changes.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer Acked-by on the v1 series
#5 lore raw
In reply to Mete Durlu
Quoted 6 lines · Mete Durlu

Improve readability of s390 ipl code by openly writing static struct definitions, reformatting list definitions and using ARRAY_SIZE() macro in suitable places.

No functional changes, only coding style changes.

Quoted 8 lines

---
Mete Durlu (2):
s390/ipl: Use ARRAY_SIZE macro
s390/ipl: Improve readability

 arch/s390/kernel/ipl.c | 58 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 20 deletions(-)
maintainer Applied
#6 lore raw
In reply to Mete Durlu
Quoted 6 lines · Mete Durlu

Improve readability of s390 ipl code by openly writing static struct definitions, reformatting list definitions and using ARRAY_SIZE() macro in suitable places.

No functional changes, only coding style changes.

Quoted 8 lines

---
Mete Durlu (2):
s390/ipl: Use ARRAY_SIZE macro
s390/ipl: Improve readability

 arch/s390/kernel/ipl.c | 58 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 20 deletions(-)

Applied, thank you!