@@ -358,9 +358,9 @@ static bool slot_valid(struct nvdimm_drvdata *ndd,
358
358
u64 sum , sum_save ;
359
359
360
360
sum_save = nsl_get_checksum (ndd , nd_label );
361
- nd_label -> checksum = __cpu_to_le64 ( 0 );
361
+ nsl_set_checksum ( ndd , nd_label , 0 );
362
362
sum = nd_fletcher64 (nd_label , sizeof_namespace_label (ndd ), 1 );
363
- nd_label -> checksum = __cpu_to_le64 ( sum_save );
363
+ nsl_set_checksum ( ndd , nd_label , sum_save );
364
364
if (sum != sum_save ) {
365
365
dev_dbg (ndd -> dev , "fail checksum. slot: %d expect: %#llx\n" ,
366
366
slot , sum );
@@ -797,16 +797,15 @@ static int __pmem_label_update(struct nd_region *nd_region,
797
797
nd_label = to_label (ndd , slot );
798
798
memset (nd_label , 0 , sizeof_namespace_label (ndd ));
799
799
memcpy (nd_label -> uuid , nspm -> uuid , NSLABEL_UUID_LEN );
800
- if (nspm -> alt_name )
801
- memcpy (nd_label -> name , nspm -> alt_name , NSLABEL_NAME_LEN );
802
- nd_label -> flags = __cpu_to_le32 (flags );
803
- nd_label -> nlabel = __cpu_to_le16 (nd_region -> ndr_mappings );
804
- nd_label -> position = __cpu_to_le16 (pos );
805
- nd_label -> isetcookie = __cpu_to_le64 (cookie );
806
- nd_label -> rawsize = __cpu_to_le64 (resource_size (res ));
807
- nd_label -> lbasize = __cpu_to_le64 (nspm -> lbasize );
808
- nd_label -> dpa = __cpu_to_le64 (res -> start );
809
- nd_label -> slot = __cpu_to_le32 (slot );
800
+ nsl_set_name (ndd , nd_label , nspm -> alt_name );
801
+ nsl_set_flags (ndd , nd_label , flags );
802
+ nsl_set_nlabel (ndd , nd_label , nd_region -> ndr_mappings );
803
+ nsl_set_position (ndd , nd_label , pos );
804
+ nsl_set_isetcookie (ndd , nd_label , cookie );
805
+ nsl_set_rawsize (ndd , nd_label , resource_size (res ));
806
+ nsl_set_lbasize (ndd , nd_label , nspm -> lbasize );
807
+ nsl_set_dpa (ndd , nd_label , res -> start );
808
+ nsl_set_slot (ndd , nd_label , slot );
810
809
if (namespace_label_has (ndd , type_guid ))
811
810
guid_copy (& nd_label -> type_guid , & nd_set -> type_guid );
812
811
if (namespace_label_has (ndd , abstraction_guid ))
@@ -816,9 +815,9 @@ static int __pmem_label_update(struct nd_region *nd_region,
816
815
if (namespace_label_has (ndd , checksum )) {
817
816
u64 sum ;
818
817
819
- nd_label -> checksum = __cpu_to_le64 ( 0 );
818
+ nsl_set_checksum ( ndd , nd_label , 0 );
820
819
sum = nd_fletcher64 (nd_label , sizeof_namespace_label (ndd ), 1 );
821
- nd_label -> checksum = __cpu_to_le64 ( sum );
820
+ nsl_set_checksum ( ndd , nd_label , sum );
822
821
}
823
822
nd_dbg_dpa (nd_region , ndd , res , "\n" );
824
823
@@ -1017,10 +1016,8 @@ static int __blk_label_update(struct nd_region *nd_region,
1017
1016
nd_label = to_label (ndd , slot );
1018
1017
memset (nd_label , 0 , sizeof_namespace_label (ndd ));
1019
1018
memcpy (nd_label -> uuid , nsblk -> uuid , NSLABEL_UUID_LEN );
1020
- if (nsblk -> alt_name )
1021
- memcpy (nd_label -> name , nsblk -> alt_name ,
1022
- NSLABEL_NAME_LEN );
1023
- nd_label -> flags = __cpu_to_le32 (NSLABEL_FLAG_LOCAL );
1019
+ nsl_set_name (ndd , nd_label , nsblk -> alt_name );
1020
+ nsl_set_flags (ndd , nd_label , NSLABEL_FLAG_LOCAL );
1024
1021
1025
1022
/*
1026
1023
* Use the presence of the type_guid as a flag to
@@ -1029,23 +1026,23 @@ static int __blk_label_update(struct nd_region *nd_region,
1029
1026
*/
1030
1027
if (namespace_label_has (ndd , type_guid )) {
1031
1028
if (i == min_dpa_idx ) {
1032
- nd_label -> nlabel = __cpu_to_le16 ( nsblk -> num_resources );
1033
- nd_label -> position = __cpu_to_le16 ( 0 );
1029
+ nsl_set_nlabel ( ndd , nd_label , nsblk -> num_resources );
1030
+ nsl_set_position ( ndd , nd_label , 0 );
1034
1031
} else {
1035
- nd_label -> nlabel = __cpu_to_le16 ( 0xffff );
1036
- nd_label -> position = __cpu_to_le16 ( 0xffff );
1032
+ nsl_set_nlabel ( ndd , nd_label , 0xffff );
1033
+ nsl_set_position ( ndd , nd_label , 0xffff );
1037
1034
}
1038
- nd_label -> isetcookie = __cpu_to_le64 ( nd_set -> cookie2 );
1035
+ nsl_set_isetcookie ( ndd , nd_label , nd_set -> cookie2 );
1039
1036
} else {
1040
- nd_label -> nlabel = __cpu_to_le16 ( 0 ); /* N/A */
1041
- nd_label -> position = __cpu_to_le16 ( 0 ); /* N/A */
1042
- nd_label -> isetcookie = __cpu_to_le64 ( 0 ); /* N/A */
1037
+ nsl_set_nlabel ( ndd , nd_label , 0 ); /* N/A */
1038
+ nsl_set_position ( ndd , nd_label , 0 ); /* N/A */
1039
+ nsl_set_isetcookie ( ndd , nd_label , 0 ); /* N/A */
1043
1040
}
1044
1041
1045
- nd_label -> dpa = __cpu_to_le64 ( res -> start );
1046
- nd_label -> rawsize = __cpu_to_le64 ( resource_size (res ));
1047
- nd_label -> lbasize = __cpu_to_le64 ( nsblk -> lbasize );
1048
- nd_label -> slot = __cpu_to_le32 ( slot );
1042
+ nsl_set_dpa ( ndd , nd_label , res -> start );
1043
+ nsl_set_rawsize ( ndd , nd_label , resource_size (res ));
1044
+ nsl_set_lbasize ( ndd , nd_label , nsblk -> lbasize );
1045
+ nsl_set_slot ( ndd , nd_label , slot );
1049
1046
if (namespace_label_has (ndd , type_guid ))
1050
1047
guid_copy (& nd_label -> type_guid , & nd_set -> type_guid );
1051
1048
if (namespace_label_has (ndd , abstraction_guid ))
@@ -1056,10 +1053,10 @@ static int __blk_label_update(struct nd_region *nd_region,
1056
1053
if (namespace_label_has (ndd , checksum )) {
1057
1054
u64 sum ;
1058
1055
1059
- nd_label -> checksum = __cpu_to_le64 ( 0 );
1056
+ nsl_set_checksum ( ndd , nd_label , 0 );
1060
1057
sum = nd_fletcher64 (nd_label ,
1061
1058
sizeof_namespace_label (ndd ), 1 );
1062
- nd_label -> checksum = __cpu_to_le64 ( sum );
1059
+ nsl_set_checksum ( ndd , nd_label , sum );
1063
1060
}
1064
1061
1065
1062
/* update label */
0 commit comments