Commit e9c47801 authored by Damien Le Moal's avatar Damien Le Moal Committed by Martin K. Petersen

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/20220301113009.595857-2-damien.lemoal@opensource.wdc.comAcked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 71bb9ab6
...@@ -3167,45 +3167,65 @@ static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec, ...@@ -3167,45 +3167,65 @@ static int prot_verify_read(struct scsi_cmnd *scp, sector_t start_sec,
static inline void static inline void
sdeb_read_lock(struct sdeb_store_info *sip) sdeb_read_lock(struct sdeb_store_info *sip)
{ {
if (sdebug_no_rwlock) if (sdebug_no_rwlock) {
return; if (sip)
if (sip) __acquire(&sip->macc_lck);
read_lock(&sip->macc_lck); else
else __acquire(&sdeb_fake_rw_lck);
read_lock(&sdeb_fake_rw_lck); } else {
if (sip)
read_lock(&sip->macc_lck);
else
read_lock(&sdeb_fake_rw_lck);
}
} }
static inline void static inline void
sdeb_read_unlock(struct sdeb_store_info *sip) sdeb_read_unlock(struct sdeb_store_info *sip)
{ {
if (sdebug_no_rwlock) if (sdebug_no_rwlock) {
return; if (sip)
if (sip) __release(&sip->macc_lck);
read_unlock(&sip->macc_lck); else
else __release(&sdeb_fake_rw_lck);
read_unlock(&sdeb_fake_rw_lck); } else {
if (sip)
read_unlock(&sip->macc_lck);
else
read_unlock(&sdeb_fake_rw_lck);
}
} }
static inline void static inline void
sdeb_write_lock(struct sdeb_store_info *sip) sdeb_write_lock(struct sdeb_store_info *sip)
{ {
if (sdebug_no_rwlock) if (sdebug_no_rwlock) {
return; if (sip)
if (sip) __acquire(&sip->macc_lck);
write_lock(&sip->macc_lck); else
else __acquire(&sdeb_fake_rw_lck);
write_lock(&sdeb_fake_rw_lck); } else {
if (sip)
write_lock(&sip->macc_lck);
else
write_lock(&sdeb_fake_rw_lck);
}
} }
static inline void static inline void
sdeb_write_unlock(struct sdeb_store_info *sip) sdeb_write_unlock(struct sdeb_store_info *sip)
{ {
if (sdebug_no_rwlock) if (sdebug_no_rwlock) {
return; if (sip)
if (sip) __release(&sip->macc_lck);
write_unlock(&sip->macc_lck); else
else __release(&sdeb_fake_rw_lck);
write_unlock(&sdeb_fake_rw_lck); } else {
if (sip)
write_unlock(&sip->macc_lck);
else
write_unlock(&sdeb_fake_rw_lck);
}
} }
static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment