@@ -1235,7 +1235,7 @@ static int namespace_update_uuid(struct nd_region *nd_region,
1235
1235
if (!nd_label )
1236
1236
continue ;
1237
1237
nd_label_gen_id (& label_id , nd_label -> uuid ,
1238
- __le32_to_cpu ( nd_label -> flags ));
1238
+ nsl_get_flags ( ndd , nd_label ));
1239
1239
if (strcmp (old_label_id .id , label_id .id ) == 0 )
1240
1240
set_bit (ND_LABEL_REAP , & label_ent -> flags );
1241
1241
}
@@ -1851,9 +1851,9 @@ static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid,
1851
1851
1852
1852
if (!nd_label )
1853
1853
continue ;
1854
- isetcookie = __le64_to_cpu ( nd_label -> isetcookie );
1855
- position = __le16_to_cpu ( nd_label -> position );
1856
- nlabel = __le16_to_cpu ( nd_label -> nlabel );
1854
+ isetcookie = nsl_get_isetcookie ( ndd , nd_label );
1855
+ position = nsl_get_position ( ndd , nd_label );
1856
+ nlabel = nsl_get_nlabel ( ndd , nd_label );
1857
1857
1858
1858
if (isetcookie != cookie )
1859
1859
continue ;
@@ -1923,8 +1923,8 @@ static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id)
1923
1923
*/
1924
1924
hw_start = nd_mapping -> start ;
1925
1925
hw_end = hw_start + nd_mapping -> size ;
1926
- pmem_start = __le64_to_cpu ( nd_label -> dpa );
1927
- pmem_end = pmem_start + __le64_to_cpu ( nd_label -> rawsize );
1926
+ pmem_start = nsl_get_dpa ( ndd , nd_label );
1927
+ pmem_end = pmem_start + nsl_get_rawsize ( ndd , nd_label );
1928
1928
if (pmem_start >= hw_start && pmem_start < hw_end
1929
1929
&& pmem_end <= hw_end && pmem_end > hw_start )
1930
1930
/* pass */ ;
@@ -1947,14 +1947,16 @@ static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id)
1947
1947
* @nd_label: target pmem namespace label to evaluate
1948
1948
*/
1949
1949
static struct device * create_namespace_pmem (struct nd_region * nd_region ,
1950
- struct nd_namespace_index * nsindex ,
1951
- struct nd_namespace_label * nd_label )
1950
+ struct nd_mapping * nd_mapping ,
1951
+ struct nd_namespace_label * nd_label )
1952
1952
{
1953
+ struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
1954
+ struct nd_namespace_index * nsindex =
1955
+ to_namespace_index (ndd , ndd -> ns_current );
1953
1956
u64 cookie = nd_region_interleave_set_cookie (nd_region , nsindex );
1954
1957
u64 altcookie = nd_region_interleave_set_altcookie (nd_region );
1955
1958
struct nd_label_ent * label_ent ;
1956
1959
struct nd_namespace_pmem * nspm ;
1957
- struct nd_mapping * nd_mapping ;
1958
1960
resource_size_t size = 0 ;
1959
1961
struct resource * res ;
1960
1962
struct device * dev ;
@@ -1966,10 +1968,10 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
1966
1968
return ERR_PTR (- ENXIO );
1967
1969
}
1968
1970
1969
- if (__le64_to_cpu ( nd_label -> isetcookie ) != cookie ) {
1971
+ if (nsl_get_isetcookie ( ndd , nd_label ) != cookie ) {
1970
1972
dev_dbg (& nd_region -> dev , "invalid cookie in label: %pUb\n" ,
1971
1973
nd_label -> uuid );
1972
- if (__le64_to_cpu ( nd_label -> isetcookie ) != altcookie )
1974
+ if (nsl_get_isetcookie ( ndd , nd_label ) != altcookie )
1973
1975
return ERR_PTR (- EAGAIN );
1974
1976
1975
1977
dev_dbg (& nd_region -> dev , "valid altcookie in label: %pUb\n" ,
@@ -2037,16 +2039,16 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
2037
2039
continue ;
2038
2040
}
2039
2041
2040
- size += __le64_to_cpu (label0 -> rawsize );
2041
- if (__le16_to_cpu (label0 -> position ) != 0 )
2042
+ ndd = to_ndd (nd_mapping );
2043
+ size += nsl_get_rawsize (ndd , label0 );
2044
+ if (nsl_get_position (ndd , label0 ) != 0 )
2042
2045
continue ;
2043
2046
WARN_ON (nspm -> alt_name || nspm -> uuid );
2044
- nspm -> alt_name = kmemdup (( void __force * ) label0 -> name ,
2045
- NSLABEL_NAME_LEN , GFP_KERNEL );
2047
+ nspm -> alt_name = kmemdup (nsl_ref_name ( ndd , label0 ) ,
2048
+ NSLABEL_NAME_LEN , GFP_KERNEL );
2046
2049
nspm -> uuid = kmemdup ((void __force * ) label0 -> uuid ,
2047
2050
NSLABEL_UUID_LEN , GFP_KERNEL );
2048
- nspm -> lbasize = __le64_to_cpu (label0 -> lbasize );
2049
- ndd = to_ndd (nd_mapping );
2051
+ nspm -> lbasize = nsl_get_lbasize (ndd , label0 );
2050
2052
if (namespace_label_has (ndd , abstraction_guid ))
2051
2053
nspm -> nsio .common .claim_class
2052
2054
= to_nvdimm_cclass (& label0 -> abstraction_guid );
@@ -2237,7 +2239,7 @@ static int add_namespace_resource(struct nd_region *nd_region,
2237
2239
if (is_namespace_blk (devs [i ])) {
2238
2240
res = nsblk_add_resource (nd_region , ndd ,
2239
2241
to_nd_namespace_blk (devs [i ]),
2240
- __le64_to_cpu ( nd_label -> dpa ));
2242
+ nsl_get_dpa ( ndd , nd_label ));
2241
2243
if (!res )
2242
2244
return - ENXIO ;
2243
2245
nd_dbg_dpa (nd_region , ndd , res , "%d assign\n" , count );
@@ -2276,7 +2278,7 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
2276
2278
if (nd_label -> isetcookie != __cpu_to_le64 (nd_set -> cookie2 )) {
2277
2279
dev_dbg (ndd -> dev , "expect cookie %#llx got %#llx\n" ,
2278
2280
nd_set -> cookie2 ,
2279
- __le64_to_cpu ( nd_label -> isetcookie ));
2281
+ nsl_get_isetcookie ( ndd , nd_label ));
2280
2282
return ERR_PTR (- EAGAIN );
2281
2283
}
2282
2284
}
@@ -2288,23 +2290,22 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
2288
2290
dev -> type = & namespace_blk_device_type ;
2289
2291
dev -> parent = & nd_region -> dev ;
2290
2292
nsblk -> id = -1 ;
2291
- nsblk -> lbasize = __le64_to_cpu ( nd_label -> lbasize );
2293
+ nsblk -> lbasize = nsl_get_lbasize ( ndd , nd_label );
2292
2294
nsblk -> uuid = kmemdup (nd_label -> uuid , NSLABEL_UUID_LEN ,
2293
2295
GFP_KERNEL );
2294
2296
if (namespace_label_has (ndd , abstraction_guid ))
2295
2297
nsblk -> common .claim_class
2296
2298
= to_nvdimm_cclass (& nd_label -> abstraction_guid );
2297
2299
if (!nsblk -> uuid )
2298
2300
goto blk_err ;
2299
- memcpy ( name , nd_label -> name , NSLABEL_NAME_LEN );
2301
+ nsl_get_name ( ndd , nd_label , name );
2300
2302
if (name [0 ]) {
2301
- nsblk -> alt_name = kmemdup (name , NSLABEL_NAME_LEN ,
2302
- GFP_KERNEL );
2303
+ nsblk -> alt_name = kmemdup (name , NSLABEL_NAME_LEN , GFP_KERNEL );
2303
2304
if (!nsblk -> alt_name )
2304
2305
goto blk_err ;
2305
2306
}
2306
2307
res = nsblk_add_resource (nd_region , ndd , nsblk ,
2307
- __le64_to_cpu ( nd_label -> dpa ));
2308
+ nsl_get_dpa ( ndd , nd_label ));
2308
2309
if (!res )
2309
2310
goto blk_err ;
2310
2311
nd_dbg_dpa (nd_region , ndd , res , "%d: assign\n" , count );
@@ -2345,6 +2346,7 @@ static struct device **scan_labels(struct nd_region *nd_region)
2345
2346
struct device * dev , * * devs = NULL ;
2346
2347
struct nd_label_ent * label_ent , * e ;
2347
2348
struct nd_mapping * nd_mapping = & nd_region -> mapping [0 ];
2349
+ struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
2348
2350
resource_size_t map_end = nd_mapping -> start + nd_mapping -> size - 1 ;
2349
2351
2350
2352
/* "safe" because create_namespace_pmem() might list_move() label_ent */
@@ -2355,17 +2357,17 @@ static struct device **scan_labels(struct nd_region *nd_region)
2355
2357
2356
2358
if (!nd_label )
2357
2359
continue ;
2358
- flags = __le32_to_cpu ( nd_label -> flags );
2360
+ flags = nsl_get_flags ( ndd , nd_label );
2359
2361
if (is_nd_blk (& nd_region -> dev )
2360
2362
== !!(flags & NSLABEL_FLAG_LOCAL ))
2361
2363
/* pass, region matches label type */ ;
2362
2364
else
2363
2365
continue ;
2364
2366
2365
2367
/* skip labels that describe extents outside of the region */
2366
- if (__le64_to_cpu ( nd_label -> dpa ) < nd_mapping -> start ||
2367
- __le64_to_cpu ( nd_label -> dpa ) > map_end )
2368
- continue ;
2368
+ if (nsl_get_dpa ( ndd , nd_label ) < nd_mapping -> start ||
2369
+ nsl_get_dpa ( ndd , nd_label ) > map_end )
2370
+ continue ;
2369
2371
2370
2372
i = add_namespace_resource (nd_region , nd_label , devs , count );
2371
2373
if (i < 0 )
@@ -2381,13 +2383,9 @@ static struct device **scan_labels(struct nd_region *nd_region)
2381
2383
2382
2384
if (is_nd_blk (& nd_region -> dev ))
2383
2385
dev = create_namespace_blk (nd_region , nd_label , count );
2384
- else {
2385
- struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
2386
- struct nd_namespace_index * nsindex ;
2387
-
2388
- nsindex = to_namespace_index (ndd , ndd -> ns_current );
2389
- dev = create_namespace_pmem (nd_region , nsindex , nd_label );
2390
- }
2386
+ else
2387
+ dev = create_namespace_pmem (nd_region , nd_mapping ,
2388
+ nd_label );
2391
2389
2392
2390
if (IS_ERR (dev )) {
2393
2391
switch (PTR_ERR (dev )) {
@@ -2570,7 +2568,7 @@ static int init_active_labels(struct nd_region *nd_region)
2570
2568
break ;
2571
2569
label = nd_label_active (ndd , j );
2572
2570
if (test_bit (NDD_NOBLK , & nvdimm -> flags )) {
2573
- u32 flags = __le32_to_cpu ( label -> flags );
2571
+ u32 flags = nsl_get_flags ( ndd , label );
2574
2572
2575
2573
flags &= ~NSLABEL_FLAG_LOCAL ;
2576
2574
label -> flags = __cpu_to_le32 (flags );
0 commit comments