Skip to content

Commit e9c4780

Browse files
Damien Le Moalmartinkpetersen
authored andcommitted
scsi: scsi_debug: Silence unexpected unlock warnings
The return statement inside the sdeb_read_lock(), sdeb_read_unlock(), sdeb_write_lock() and sdeb_write_unlock() confuse sparse, leading to many warnings about unexpected unlocks in the resp_xxx() functions. Modify the lock/unlock functions using the __acquire() and __release() inline annotations for the sdebug_no_rwlock == true case to avoid these warnings. Link: https://lore.kernel.org/r/[email protected] Acked-by: Douglas Gilbert <[email protected]> Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 71bb9ab commit e9c4780

File tree

1 file changed

+44
-24
lines changed

1 file changed

+44
-24
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,45 +3167,65 @@ static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec,
31673167
static inline void
31683168
sdeb_read_lock(struct sdeb_store_info *sip)
31693169
{
3170-
if (sdebug_no_rwlock)
3171-
return;
3172-
if (sip)
3173-
read_lock(&sip->macc_lck);
3174-
else
3175-
read_lock(&sdeb_fake_rw_lck);
3170+
if (sdebug_no_rwlock) {
3171+
if (sip)
3172+
__acquire(&sip->macc_lck);
3173+
else
3174+
__acquire(&sdeb_fake_rw_lck);
3175+
} else {
3176+
if (sip)
3177+
read_lock(&sip->macc_lck);
3178+
else
3179+
read_lock(&sdeb_fake_rw_lck);
3180+
}
31763181
}
31773182

31783183
static inline void
31793184
sdeb_read_unlock(struct sdeb_store_info *sip)
31803185
{
3181-
if (sdebug_no_rwlock)
3182-
return;
3183-
if (sip)
3184-
read_unlock(&sip->macc_lck);
3185-
else
3186-
read_unlock(&sdeb_fake_rw_lck);
3186+
if (sdebug_no_rwlock) {
3187+
if (sip)
3188+
__release(&sip->macc_lck);
3189+
else
3190+
__release(&sdeb_fake_rw_lck);
3191+
} else {
3192+
if (sip)
3193+
read_unlock(&sip->macc_lck);
3194+
else
3195+
read_unlock(&sdeb_fake_rw_lck);
3196+
}
31873197
}
31883198

31893199
static inline void
31903200
sdeb_write_lock(struct sdeb_store_info *sip)
31913201
{
3192-
if (sdebug_no_rwlock)
3193-
return;
3194-
if (sip)
3195-
write_lock(&sip->macc_lck);
3196-
else
3197-
write_lock(&sdeb_fake_rw_lck);
3202+
if (sdebug_no_rwlock) {
3203+
if (sip)
3204+
__acquire(&sip->macc_lck);
3205+
else
3206+
__acquire(&sdeb_fake_rw_lck);
3207+
} else {
3208+
if (sip)
3209+
write_lock(&sip->macc_lck);
3210+
else
3211+
write_lock(&sdeb_fake_rw_lck);
3212+
}
31983213
}
31993214

32003215
static inline void
32013216
sdeb_write_unlock(struct sdeb_store_info *sip)
32023217
{
3203-
if (sdebug_no_rwlock)
3204-
return;
3205-
if (sip)
3206-
write_unlock(&sip->macc_lck);
3207-
else
3208-
write_unlock(&sdeb_fake_rw_lck);
3218+
if (sdebug_no_rwlock) {
3219+
if (sip)
3220+
__release(&sip->macc_lck);
3221+
else
3222+
__release(&sdeb_fake_rw_lck);
3223+
} else {
3224+
if (sip)
3225+
write_unlock(&sip->macc_lck);
3226+
else
3227+
write_unlock(&sdeb_fake_rw_lck);
3228+
}
32093229
}
32103230

32113231
static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)

0 commit comments

Comments
 (0)