diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2015-03-17 05:25:16 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-03-25 06:49:48 -0400 |
commit | 22d557abf75ce39f8b2264c86058b4bcc7a8f9f0 (patch) | |
tree | 1b0a6eb08c8590182f5b8d0dabe8e2c011bf6411 /arch/s390 | |
parent | 9f9d86e1e9ecbb43d0ca41c9c9118f141ab8d93e (diff) |
s390/ipl: cleanup bin attr usage
Use macros wherever applicable and put bin_attributes inside attribute_groups
to simplify/remove some code.
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kernel/ipl.c | 74 |
1 files changed, 18 insertions, 56 deletions
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c index c57951f008c4..31625912cff8 100644 --- a/arch/s390/kernel/ipl.c +++ b/arch/s390/kernel/ipl.c | |||
@@ -415,15 +415,9 @@ static ssize_t ipl_parameter_read(struct file *filp, struct kobject *kobj, | |||
415 | return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START, | 415 | return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START, |
416 | IPL_PARMBLOCK_SIZE); | 416 | IPL_PARMBLOCK_SIZE); |
417 | } | 417 | } |
418 | 418 | static struct bin_attribute ipl_parameter_attr = | |
419 | static struct bin_attribute ipl_parameter_attr = { | 419 | __BIN_ATTR(binary_parameter, S_IRUGO, ipl_parameter_read, NULL, |
420 | .attr = { | 420 | PAGE_SIZE); |
421 | .name = "binary_parameter", | ||
422 | .mode = S_IRUGO, | ||
423 | }, | ||
424 | .size = PAGE_SIZE, | ||
425 | .read = &ipl_parameter_read, | ||
426 | }; | ||
427 | 421 | ||
428 | static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj, | 422 | static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj, |
429 | struct bin_attribute *attr, char *buf, | 423 | struct bin_attribute *attr, char *buf, |
@@ -434,14 +428,13 @@ static ssize_t ipl_scp_data_read(struct file *filp, struct kobject *kobj, | |||
434 | 428 | ||
435 | return memory_read_from_buffer(buf, count, &off, scp_data, size); | 429 | return memory_read_from_buffer(buf, count, &off, scp_data, size); |
436 | } | 430 | } |
431 | static struct bin_attribute ipl_scp_data_attr = | ||
432 | __BIN_ATTR(scp_data, S_IRUGO, ipl_scp_data_read, NULL, PAGE_SIZE); | ||
437 | 433 | ||
438 | static struct bin_attribute ipl_scp_data_attr = { | 434 | static struct bin_attribute *ipl_fcp_bin_attrs[] = { |
439 | .attr = { | 435 | &ipl_parameter_attr, |
440 | .name = "scp_data", | 436 | &ipl_scp_data_attr, |
441 | .mode = S_IRUGO, | 437 | NULL, |
442 | }, | ||
443 | .size = PAGE_SIZE, | ||
444 | .read = ipl_scp_data_read, | ||
445 | }; | 438 | }; |
446 | 439 | ||
447 | /* FCP ipl device attributes */ | 440 | /* FCP ipl device attributes */ |
@@ -484,6 +477,7 @@ static struct attribute *ipl_fcp_attrs[] = { | |||
484 | 477 | ||
485 | static struct attribute_group ipl_fcp_attr_group = { | 478 | static struct attribute_group ipl_fcp_attr_group = { |
486 | .attrs = ipl_fcp_attrs, | 479 | .attrs = ipl_fcp_attrs, |
480 | .bin_attrs = ipl_fcp_bin_attrs, | ||
487 | }; | 481 | }; |
488 | 482 | ||
489 | /* CCW ipl device attributes */ | 483 | /* CCW ipl device attributes */ |
@@ -540,28 +534,6 @@ static struct attribute_group ipl_unknown_attr_group = { | |||
540 | 534 | ||
541 | static struct kset *ipl_kset; | 535 | static struct kset *ipl_kset; |
542 | 536 | ||
543 | static int __init ipl_register_fcp_files(void) | ||
544 | { | ||
545 | int rc; | ||
546 | |||
547 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group); | ||
548 | if (rc) | ||
549 | goto out; | ||
550 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); | ||
551 | if (rc) | ||
552 | goto out_ipl_parm; | ||
553 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_scp_data_attr); | ||
554 | if (!rc) | ||
555 | goto out; | ||
556 | |||
557 | sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); | ||
558 | |||
559 | out_ipl_parm: | ||
560 | sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group); | ||
561 | out: | ||
562 | return rc; | ||
563 | } | ||
564 | |||
565 | static void __ipl_run(void *unused) | 537 | static void __ipl_run(void *unused) |
566 | { | 538 | { |
567 | diag308(DIAG308_IPL, NULL); | 539 | diag308(DIAG308_IPL, NULL); |
@@ -596,7 +568,7 @@ static int __init ipl_init(void) | |||
596 | break; | 568 | break; |
597 | case IPL_TYPE_FCP: | 569 | case IPL_TYPE_FCP: |
598 | case IPL_TYPE_FCP_DUMP: | 570 | case IPL_TYPE_FCP_DUMP: |
599 | rc = ipl_register_fcp_files(); | 571 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group); |
600 | break; | 572 | break; |
601 | case IPL_TYPE_NSS: | 573 | case IPL_TYPE_NSS: |
602 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nss_attr_group); | 574 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nss_attr_group); |
@@ -744,15 +716,13 @@ static ssize_t reipl_fcp_scpdata_write(struct file *filp, struct kobject *kobj, | |||
744 | 716 | ||
745 | return count; | 717 | return count; |
746 | } | 718 | } |
719 | static struct bin_attribute sys_reipl_fcp_scp_data_attr = | ||
720 | __BIN_ATTR(scp_data, (S_IRUGO | S_IWUSR), reipl_fcp_scpdata_read, | ||
721 | reipl_fcp_scpdata_write, PAGE_SIZE); | ||
747 | 722 | ||
748 | static struct bin_attribute sys_reipl_fcp_scp_data_attr = { | 723 | static struct bin_attribute *reipl_fcp_bin_attrs[] = { |
749 | .attr = { | 724 | &sys_reipl_fcp_scp_data_attr, |
750 | .name = "scp_data", | 725 | NULL, |
751 | .mode = S_IRUGO | S_IWUSR, | ||
752 | }, | ||
753 | .size = PAGE_SIZE, | ||
754 | .read = reipl_fcp_scpdata_read, | ||
755 | .write = reipl_fcp_scpdata_write, | ||
756 | }; | 726 | }; |
757 | 727 | ||
758 | DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%llx\n", | 728 | DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%llx\n", |
@@ -841,6 +811,7 @@ static struct attribute *reipl_fcp_attrs[] = { | |||
841 | 811 | ||
842 | static struct attribute_group reipl_fcp_attr_group = { | 812 | static struct attribute_group reipl_fcp_attr_group = { |
843 | .attrs = reipl_fcp_attrs, | 813 | .attrs = reipl_fcp_attrs, |
814 | .bin_attrs = reipl_fcp_bin_attrs, | ||
844 | }; | 815 | }; |
845 | 816 | ||
846 | /* CCW reipl device attributes */ | 817 | /* CCW reipl device attributes */ |
@@ -1261,15 +1232,6 @@ static int __init reipl_fcp_init(void) | |||
1261 | return rc; | 1232 | return rc; |
1262 | } | 1233 | } |
1263 | 1234 | ||
1264 | rc = sysfs_create_bin_file(&reipl_fcp_kset->kobj, | ||
1265 | &sys_reipl_fcp_scp_data_attr); | ||
1266 | if (rc) { | ||
1267 | sysfs_remove_group(&reipl_fcp_kset->kobj, &reipl_fcp_attr_group); | ||
1268 | kset_unregister(reipl_fcp_kset); | ||
1269 | free_page((unsigned long) reipl_block_fcp); | ||
1270 | return rc; | ||
1271 | } | ||
1272 | |||
1273 | if (ipl_info.type == IPL_TYPE_FCP) { | 1235 | if (ipl_info.type == IPL_TYPE_FCP) { |
1274 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); | 1236 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); |
1275 | /* | 1237 | /* |