@@ -1317,19 +1317,23 @@ static ssize_t scrub_show(struct device *dev,
1317
1317
struct device_attribute * attr , char * buf )
1318
1318
{
1319
1319
struct nvdimm_bus_descriptor * nd_desc ;
1320
+ struct acpi_nfit_desc * acpi_desc ;
1320
1321
ssize_t rc = - ENXIO ;
1322
+ bool busy ;
1321
1323
1322
1324
device_lock (dev );
1323
1325
nd_desc = dev_get_drvdata (dev );
1324
- if (nd_desc ) {
1325
- struct acpi_nfit_desc * acpi_desc = to_acpi_desc (nd_desc );
1326
-
1327
- mutex_lock (& acpi_desc -> init_mutex );
1328
- rc = sprintf (buf , "%d%s" , acpi_desc -> scrub_count ,
1329
- acpi_desc -> scrub_busy
1330
- && !acpi_desc -> cancel ? "+\n" : "\n" );
1331
- mutex_unlock (& acpi_desc -> init_mutex );
1326
+ if (!nd_desc ) {
1327
+ device_unlock (dev );
1328
+ return rc ;
1332
1329
}
1330
+ acpi_desc = to_acpi_desc (nd_desc );
1331
+
1332
+ mutex_lock (& acpi_desc -> init_mutex );
1333
+ busy = test_bit (ARS_BUSY , & acpi_desc -> scrub_flags )
1334
+ && !test_bit (ARS_CANCEL , & acpi_desc -> scrub_flags );
1335
+ rc = sprintf (buf , "%d%s" , acpi_desc -> scrub_count , busy ? "+\n" : "\n" );
1336
+ mutex_unlock (& acpi_desc -> init_mutex );
1333
1337
device_unlock (dev );
1334
1338
return rc ;
1335
1339
}
@@ -3072,7 +3076,7 @@ static unsigned int __acpi_nfit_scrub(struct acpi_nfit_desc *acpi_desc,
3072
3076
3073
3077
lockdep_assert_held (& acpi_desc -> init_mutex );
3074
3078
3075
- if (acpi_desc -> cancel )
3079
+ if (test_bit ( ARS_CANCEL , & acpi_desc -> scrub_flags ) )
3076
3080
return 0 ;
3077
3081
3078
3082
if (query_rc == - EBUSY ) {
@@ -3146,7 +3150,7 @@ static void __sched_ars(struct acpi_nfit_desc *acpi_desc, unsigned int tmo)
3146
3150
{
3147
3151
lockdep_assert_held (& acpi_desc -> init_mutex );
3148
3152
3149
- acpi_desc -> scrub_busy = 1 ;
3153
+ set_bit ( ARS_BUSY , & acpi_desc -> scrub_flags ) ;
3150
3154
/* note this should only be set from within the workqueue */
3151
3155
if (tmo )
3152
3156
acpi_desc -> scrub_tmo = tmo ;
@@ -3162,7 +3166,7 @@ static void notify_ars_done(struct acpi_nfit_desc *acpi_desc)
3162
3166
{
3163
3167
lockdep_assert_held (& acpi_desc -> init_mutex );
3164
3168
3165
- acpi_desc -> scrub_busy = 0 ;
3169
+ clear_bit ( ARS_BUSY , & acpi_desc -> scrub_flags ) ;
3166
3170
acpi_desc -> scrub_count ++ ;
3167
3171
if (acpi_desc -> scrub_count_state )
3168
3172
sysfs_notify_dirent (acpi_desc -> scrub_count_state );
@@ -3451,7 +3455,7 @@ int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc,
3451
3455
struct nfit_spa * nfit_spa ;
3452
3456
3453
3457
mutex_lock (& acpi_desc -> init_mutex );
3454
- if (acpi_desc -> cancel ) {
3458
+ if (test_bit ( ARS_CANCEL , & acpi_desc -> scrub_flags ) ) {
3455
3459
mutex_unlock (& acpi_desc -> init_mutex );
3456
3460
return 0 ;
3457
3461
}
@@ -3530,7 +3534,7 @@ void acpi_nfit_shutdown(void *data)
3530
3534
mutex_unlock (& acpi_desc_lock );
3531
3535
3532
3536
mutex_lock (& acpi_desc -> init_mutex );
3533
- acpi_desc -> cancel = 1 ;
3537
+ set_bit ( ARS_CANCEL , & acpi_desc -> scrub_flags ) ;
3534
3538
cancel_delayed_work_sync (& acpi_desc -> dwork );
3535
3539
mutex_unlock (& acpi_desc -> init_mutex );
3536
3540
0 commit comments