Commit 0f024379 authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

s390/ipl: cleanup shutdown_action attributes

Use macros wherever applicable and create a shutdown_action attribute
group to simplify the code.
Reviewed-by: default avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 22d557ab
...@@ -1675,9 +1675,7 @@ static ssize_t on_reboot_store(struct kobject *kobj, ...@@ -1675,9 +1675,7 @@ static ssize_t on_reboot_store(struct kobject *kobj,
{ {
return set_trigger(buf, &on_reboot_trigger, len); return set_trigger(buf, &on_reboot_trigger, len);
} }
static struct kobj_attribute on_reboot_attr = __ATTR_RW(on_reboot);
static struct kobj_attribute on_reboot_attr =
__ATTR(on_reboot, 0644, on_reboot_show, on_reboot_store);
static void do_machine_restart(char *__unused) static void do_machine_restart(char *__unused)
{ {
...@@ -1703,9 +1701,7 @@ static ssize_t on_panic_store(struct kobject *kobj, ...@@ -1703,9 +1701,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
{ {
return set_trigger(buf, &on_panic_trigger, len); return set_trigger(buf, &on_panic_trigger, len);
} }
static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
static struct kobj_attribute on_panic_attr =
__ATTR(on_panic, 0644, on_panic_show, on_panic_store);
static void do_panic(void) static void do_panic(void)
{ {
...@@ -1731,9 +1727,7 @@ static ssize_t on_restart_store(struct kobject *kobj, ...@@ -1731,9 +1727,7 @@ static ssize_t on_restart_store(struct kobject *kobj,
{ {
return set_trigger(buf, &on_restart_trigger, len); return set_trigger(buf, &on_restart_trigger, len);
} }
static struct kobj_attribute on_restart_attr = __ATTR_RW(on_restart);
static struct kobj_attribute on_restart_attr =
__ATTR(on_restart, 0644, on_restart_show, on_restart_store);
static void __do_restart(void *ignore) static void __do_restart(void *ignore)
{ {
...@@ -1770,10 +1764,7 @@ static ssize_t on_halt_store(struct kobject *kobj, ...@@ -1770,10 +1764,7 @@ static ssize_t on_halt_store(struct kobject *kobj,
{ {
return set_trigger(buf, &on_halt_trigger, len); return set_trigger(buf, &on_halt_trigger, len);
} }
static struct kobj_attribute on_halt_attr = __ATTR_RW(on_halt);
static struct kobj_attribute on_halt_attr =
__ATTR(on_halt, 0644, on_halt_show, on_halt_store);
static void do_machine_halt(void) static void do_machine_halt(void)
{ {
...@@ -1799,10 +1790,7 @@ static ssize_t on_poff_store(struct kobject *kobj, ...@@ -1799,10 +1790,7 @@ static ssize_t on_poff_store(struct kobject *kobj,
{ {
return set_trigger(buf, &on_poff_trigger, len); return set_trigger(buf, &on_poff_trigger, len);
} }
static struct kobj_attribute on_poff_attr = __ATTR_RW(on_poff);
static struct kobj_attribute on_poff_attr =
__ATTR(on_poff, 0644, on_poff_show, on_poff_store);
static void do_machine_power_off(void) static void do_machine_power_off(void)
{ {
...@@ -1812,26 +1800,27 @@ static void do_machine_power_off(void) ...@@ -1812,26 +1800,27 @@ static void do_machine_power_off(void)
} }
void (*_machine_power_off)(void) = do_machine_power_off; void (*_machine_power_off)(void) = do_machine_power_off;
static struct attribute *shutdown_action_attrs[] = {
&on_restart_attr.attr,
&on_reboot_attr.attr,
&on_panic_attr.attr,
&on_halt_attr.attr,
&on_poff_attr.attr,
NULL,
};
static struct attribute_group shutdown_action_attr_group = {
.attrs = shutdown_action_attrs,
};
static void __init shutdown_triggers_init(void) static void __init shutdown_triggers_init(void)
{ {
shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL, shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL,
firmware_kobj); firmware_kobj);
if (!shutdown_actions_kset) if (!shutdown_actions_kset)
goto fail; goto fail;
if (sysfs_create_file(&shutdown_actions_kset->kobj, if (sysfs_create_group(&shutdown_actions_kset->kobj,
&on_reboot_attr.attr)) &shutdown_action_attr_group))
goto fail;
if (sysfs_create_file(&shutdown_actions_kset->kobj,
&on_panic_attr.attr))
goto fail;
if (sysfs_create_file(&shutdown_actions_kset->kobj,
&on_halt_attr.attr))
goto fail;
if (sysfs_create_file(&shutdown_actions_kset->kobj,
&on_poff_attr.attr))
goto fail;
if (sysfs_create_file(&shutdown_actions_kset->kobj,
&on_restart_attr.attr))
goto fail; goto fail;
return; return;
fail: fail:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment