91
91
92
92
static int self_check_ai (struct ubi_device * ubi , struct ubi_attach_info * ai );
93
93
94
- /* Temporary variables used during scanning */
95
- static struct ubi_ec_hdr * ech ;
96
- static struct ubi_vid_hdr * vidh ;
97
-
98
94
#define AV_FIND BIT(0)
99
95
#define AV_ADD BIT(1)
100
96
#define AV_FIND_OR_ADD (AV_FIND | AV_ADD)
@@ -958,6 +954,8 @@ static bool vol_ignored(int vol_id)
958
954
static int scan_peb (struct ubi_device * ubi , struct ubi_attach_info * ai ,
959
955
int pnum , bool fast )
960
956
{
957
+ struct ubi_ec_hdr * ech = ai -> ech ;
958
+ struct ubi_vid_hdr * vidh = ai -> vidh ;
961
959
long long ec ;
962
960
int err , bitflips = 0 , vol_id = -1 , ec_err = 0 ;
963
961
@@ -1394,12 +1392,12 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai,
1394
1392
1395
1393
err = - ENOMEM ;
1396
1394
1397
- ech = kzalloc (ubi -> ec_hdr_alsize , GFP_KERNEL );
1398
- if (!ech )
1395
+ ai -> ech = kzalloc (ubi -> ec_hdr_alsize , GFP_KERNEL );
1396
+ if (!ai -> ech )
1399
1397
return err ;
1400
1398
1401
- vidh = ubi_zalloc_vid_hdr (ubi , GFP_KERNEL );
1402
- if (!vidh )
1399
+ ai -> vidh = ubi_zalloc_vid_hdr (ubi , GFP_KERNEL );
1400
+ if (!ai -> vidh )
1403
1401
goto out_ech ;
1404
1402
1405
1403
for (pnum = start ; pnum < ubi -> peb_count ; pnum ++ ) {
@@ -1448,15 +1446,15 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai,
1448
1446
if (err )
1449
1447
goto out_vidh ;
1450
1448
1451
- ubi_free_vid_hdr (ubi , vidh );
1452
- kfree (ech );
1449
+ ubi_free_vid_hdr (ubi , ai -> vidh );
1450
+ kfree (ai -> ech );
1453
1451
1454
1452
return 0 ;
1455
1453
1456
1454
out_vidh :
1457
- ubi_free_vid_hdr (ubi , vidh );
1455
+ ubi_free_vid_hdr (ubi , ai -> vidh );
1458
1456
out_ech :
1459
- kfree (ech );
1457
+ kfree (ai -> ech );
1460
1458
return err ;
1461
1459
}
1462
1460
@@ -1508,12 +1506,12 @@ static int scan_fast(struct ubi_device *ubi, struct ubi_attach_info **ai)
1508
1506
if (!scan_ai )
1509
1507
goto out ;
1510
1508
1511
- ech = kzalloc (ubi -> ec_hdr_alsize , GFP_KERNEL );
1512
- if (!ech )
1509
+ scan_ai -> ech = kzalloc (ubi -> ec_hdr_alsize , GFP_KERNEL );
1510
+ if (!scan_ai -> ech )
1513
1511
goto out_ai ;
1514
1512
1515
- vidh = ubi_zalloc_vid_hdr (ubi , GFP_KERNEL );
1516
- if (!vidh )
1513
+ scan_ai -> vidh = ubi_zalloc_vid_hdr (ubi , GFP_KERNEL );
1514
+ if (!scan_ai -> vidh )
1517
1515
goto out_ech ;
1518
1516
1519
1517
for (pnum = 0 ; pnum < UBI_FM_MAX_START ; pnum ++ ) {
@@ -1525,8 +1523,8 @@ static int scan_fast(struct ubi_device *ubi, struct ubi_attach_info **ai)
1525
1523
goto out_vidh ;
1526
1524
}
1527
1525
1528
- ubi_free_vid_hdr (ubi , vidh );
1529
- kfree (ech );
1526
+ ubi_free_vid_hdr (ubi , scan_ai -> vidh );
1527
+ kfree (scan_ai -> ech );
1530
1528
1531
1529
if (scan_ai -> force_full_scan )
1532
1530
err = UBI_NO_FASTMAP ;
@@ -1546,9 +1544,9 @@ static int scan_fast(struct ubi_device *ubi, struct ubi_attach_info **ai)
1546
1544
return err ;
1547
1545
1548
1546
out_vidh :
1549
- ubi_free_vid_hdr (ubi , vidh );
1547
+ ubi_free_vid_hdr (ubi , scan_ai -> vidh );
1550
1548
out_ech :
1551
- kfree (ech );
1549
+ kfree (scan_ai -> ech );
1552
1550
out_ai :
1553
1551
destroy_ai (scan_ai );
1554
1552
out :
@@ -1670,6 +1668,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
1670
1668
*/
1671
1669
static int self_check_ai (struct ubi_device * ubi , struct ubi_attach_info * ai )
1672
1670
{
1671
+ struct ubi_vid_hdr * vidh = ai -> vidh ;
1673
1672
int pnum , err , vols_found = 0 ;
1674
1673
struct rb_node * rb1 , * rb2 ;
1675
1674
struct ubi_ainf_volume * av ;
0 commit comments